termdeposit

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package termdeposit implements an intrest-bearing contracts. Anyone can sign a contract by depositing funds.

This is a minimal implementation of term deposit functionality. Each deposit interest is computed offchain and transferred inteprendetly from this extension.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCodec   = fmt.Errorf("proto: integer overflow")
)

Functions

func NewDepositBucket

func NewDepositBucket() orm.ModelBucket

func NewDepositContractBucket

func NewDepositContractBucket() orm.ModelBucket

func RegisterQuery

func RegisterQuery(qr weave.QueryRouter)

func RegisterRoutes

func RegisterRoutes(r weave.Registry, auth x.Authenticator, cashctrl cash.Controller)

Types

type Configuration

type Configuration struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Owner is present to implement gconf.OwnedConfig interface. Owner is
	// allowed to update the configuration.
	Owner github_com_iov_one_weave.Address `protobuf:"bytes,2,opt,name=owner,proto3,casttype=github.com/iov-one/weave.Address" json:"owner,omitempty"`
	// Admin is an address that is able to create deposit contracts.
	Admin github_com_iov_one_weave.Address `protobuf:"bytes,3,opt,name=admin,proto3,casttype=github.com/iov-one/weave.Address" json:"admin,omitempty"`
	// A list of bonus values applied to each created Deposit instance.
	Bonuses []DepositBonus `protobuf:"bytes,4,rep,name=bonuses,proto3" json:"bonuses"`
	// Base rates defines a list of addresses that have their q-score value fixed.
	BaseRates []CustomRate `protobuf:"bytes,5,rep,name=base_rates,json=baseRates,proto3" json:"base_rates"`
}

Configuration is a dynamic configuration used by this extension, managed by the functionality provided by gconf package.

func (*Configuration) Descriptor

func (*Configuration) Descriptor() ([]byte, []int)

func (*Configuration) GetAdmin

func (*Configuration) GetBaseRates

func (m *Configuration) GetBaseRates() []CustomRate

func (*Configuration) GetBonuses

func (m *Configuration) GetBonuses() []DepositBonus

func (*Configuration) GetMetadata

func (m *Configuration) GetMetadata() *weave.Metadata

func (*Configuration) GetOwner

func (*Configuration) Marshal

func (m *Configuration) Marshal() (dAtA []byte, err error)

func (*Configuration) MarshalTo

func (m *Configuration) MarshalTo(dAtA []byte) (int, error)

func (*Configuration) ProtoMessage

func (*Configuration) ProtoMessage()

func (*Configuration) Reset

func (m *Configuration) Reset()

func (*Configuration) Size

func (m *Configuration) Size() (n int)

func (*Configuration) String

func (m *Configuration) String() string

func (*Configuration) Unmarshal

func (m *Configuration) Unmarshal(dAtA []byte) error

func (*Configuration) Validate

func (c *Configuration) Validate() error

func (*Configuration) XXX_DiscardUnknown

func (m *Configuration) XXX_DiscardUnknown()

func (*Configuration) XXX_Marshal

func (m *Configuration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Configuration) XXX_Merge

func (m *Configuration) XXX_Merge(src proto.Message)

func (*Configuration) XXX_Size

func (m *Configuration) XXX_Size() int

func (*Configuration) XXX_Unmarshal

func (m *Configuration) XXX_Unmarshal(b []byte) error

type CreateDepositContractMsg

type CreateDepositContractMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// An activation date for the newly created deposit contract.
	ValidSince github_com_iov_one_weave.UnixTime `` /* 135-byte string literal not displayed */
	// An expiration date for the newly created deposit contract.
	ValidUntil github_com_iov_one_weave.UnixTime `` /* 135-byte string literal not displayed */
}

CreateDepositContractMsg creates a new DepositContract entity. This message must be signed by the admin as configured via the Configuration entity.

func (*CreateDepositContractMsg) Descriptor

func (*CreateDepositContractMsg) Descriptor() ([]byte, []int)

func (*CreateDepositContractMsg) GetMetadata

func (m *CreateDepositContractMsg) GetMetadata() *weave.Metadata

func (*CreateDepositContractMsg) GetValidSince

func (*CreateDepositContractMsg) GetValidUntil

func (*CreateDepositContractMsg) Marshal

func (m *CreateDepositContractMsg) Marshal() (dAtA []byte, err error)

func (*CreateDepositContractMsg) MarshalTo

func (m *CreateDepositContractMsg) MarshalTo(dAtA []byte) (int, error)

func (CreateDepositContractMsg) Path

func (*CreateDepositContractMsg) ProtoMessage

func (*CreateDepositContractMsg) ProtoMessage()

func (*CreateDepositContractMsg) Reset

func (m *CreateDepositContractMsg) Reset()

func (*CreateDepositContractMsg) Size

func (m *CreateDepositContractMsg) Size() (n int)

func (*CreateDepositContractMsg) String

func (m *CreateDepositContractMsg) String() string

func (*CreateDepositContractMsg) Unmarshal

func (m *CreateDepositContractMsg) Unmarshal(dAtA []byte) error

func (*CreateDepositContractMsg) Validate

func (m *CreateDepositContractMsg) Validate() error

func (*CreateDepositContractMsg) XXX_DiscardUnknown

func (m *CreateDepositContractMsg) XXX_DiscardUnknown()

func (*CreateDepositContractMsg) XXX_Marshal

func (m *CreateDepositContractMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateDepositContractMsg) XXX_Merge

func (m *CreateDepositContractMsg) XXX_Merge(src proto.Message)

func (*CreateDepositContractMsg) XXX_Size

func (m *CreateDepositContractMsg) XXX_Size() int

func (*CreateDepositContractMsg) XXX_Unmarshal

func (m *CreateDepositContractMsg) XXX_Unmarshal(b []byte) error

type CustomRate

type CustomRate struct {
	Address github_com_iov_one_weave.Address `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/iov-one/weave.Address" json:"address,omitempty"`
	Rate    weave.Fraction                   `protobuf:"bytes,2,opt,name=rate,proto3" json:"rate"`
}

Custom Rate allows to declare a fixed rate value for an address.

func (*CustomRate) Descriptor

func (*CustomRate) Descriptor() ([]byte, []int)

func (*CustomRate) GetAddress

func (*CustomRate) GetRate

func (m *CustomRate) GetRate() weave.Fraction

func (*CustomRate) Marshal

func (m *CustomRate) Marshal() (dAtA []byte, err error)

func (*CustomRate) MarshalTo

func (m *CustomRate) MarshalTo(dAtA []byte) (int, error)

func (*CustomRate) ProtoMessage

func (*CustomRate) ProtoMessage()

func (*CustomRate) Reset

func (m *CustomRate) Reset()

func (*CustomRate) Size

func (m *CustomRate) Size() (n int)

func (*CustomRate) String

func (m *CustomRate) String() string

func (*CustomRate) Unmarshal

func (m *CustomRate) Unmarshal(dAtA []byte) error

func (*CustomRate) XXX_DiscardUnknown

func (m *CustomRate) XXX_DiscardUnknown()

func (*CustomRate) XXX_Marshal

func (m *CustomRate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CustomRate) XXX_Merge

func (m *CustomRate) XXX_Merge(src proto.Message)

func (*CustomRate) XXX_Size

func (m *CustomRate) XXX_Size() int

func (*CustomRate) XXX_Unmarshal

func (m *CustomRate) XXX_Unmarshal(b []byte) error

type Deposit

type Deposit struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Deposit contract ID that this funds allocation was made with.
	DepositContractID []byte `protobuf:"bytes,2,opt,name=deposit_contract_id,json=depositContractId,proto3" json:"deposit_contract_id,omitempty"`
	// Total amount that was deposited within a contract. Must be IOV tokens.
	// This information is used when computing each depositor reward. It is used
	// instead of looking at the actual wallet state, so that it is not possible
	// to increase the value of a deposit wallet only shortly before the
	// computation.
	Amount coin.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"`
	// Pro-rated interest rate as detailed in the Confluence spec.
	Rate weave.Fraction `protobuf:"bytes,4,opt,name=rate,proto3" json:"rate"`
	// Payback is an address that locked funds and interest are send back to once
	// the contract expires.
	Depositor github_com_iov_one_weave.Address `protobuf:"bytes,5,opt,name=depositor,proto3,casttype=github.com/iov-one/weave.Address" json:"depositor,omitempty"`
	// Released flag is used to determin whether the funds locked by this deposit
	// were already released or not.
	Released bool `protobuf:"varint,6,opt,name=released,proto3" json:"released,omitempty"`
	// CreatedAt is set to the wall clock value at the deposit creation time.
	CreatedAt github_com_iov_one_weave.UnixTime `` /* 132-byte string literal not displayed */
}

Deposit represents a single fund deposition. Deposited funds are locked until the contract expiration.

func (*Deposit) Descriptor

func (*Deposit) Descriptor() ([]byte, []int)

func (*Deposit) GetAmount

func (m *Deposit) GetAmount() coin.Coin

func (*Deposit) GetCreatedAt

func (m *Deposit) GetCreatedAt() github_com_iov_one_weave.UnixTime

func (*Deposit) GetDepositContractID

func (m *Deposit) GetDepositContractID() []byte

func (*Deposit) GetDepositor

func (m *Deposit) GetDepositor() github_com_iov_one_weave.Address

func (*Deposit) GetMetadata

func (m *Deposit) GetMetadata() *weave.Metadata

func (*Deposit) GetRate

func (m *Deposit) GetRate() weave.Fraction

func (*Deposit) GetReleased

func (m *Deposit) GetReleased() bool

func (*Deposit) Marshal

func (m *Deposit) Marshal() (dAtA []byte, err error)

func (*Deposit) MarshalTo

func (m *Deposit) MarshalTo(dAtA []byte) (int, error)

func (*Deposit) ProtoMessage

func (*Deposit) ProtoMessage()

func (*Deposit) Reset

func (m *Deposit) Reset()

func (*Deposit) Size

func (m *Deposit) Size() (n int)

func (*Deposit) String

func (m *Deposit) String() string

func (*Deposit) Unmarshal

func (m *Deposit) Unmarshal(dAtA []byte) error

func (*Deposit) Validate

func (m *Deposit) Validate() error

func (*Deposit) XXX_DiscardUnknown

func (m *Deposit) XXX_DiscardUnknown()

func (*Deposit) XXX_Marshal

func (m *Deposit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Deposit) XXX_Merge

func (m *Deposit) XXX_Merge(src proto.Message)

func (*Deposit) XXX_Size

func (m *Deposit) XXX_Size() int

func (*Deposit) XXX_Unmarshal

func (m *Deposit) XXX_Unmarshal(b []byte) error

type DepositBonus

type DepositBonus struct {
	// Deposit minimal lockin period required to use this bonus.
	LockinPeriod github_com_iov_one_weave.UnixDuration `` /* 145-byte string literal not displayed */
	// Bonus rate for given range.
	Bonus weave.Fraction `protobuf:"bytes,2,opt,name=bonus,proto3" json:"bonus"`
}

DepositBonus defines a bonus value used to calculate deposit rate. The longer the deposit period, the higher the deposit bonus should be.

func (*DepositBonus) Descriptor

func (*DepositBonus) Descriptor() ([]byte, []int)

func (*DepositBonus) GetBonus

func (m *DepositBonus) GetBonus() weave.Fraction

func (*DepositBonus) GetLockinPeriod

func (m *DepositBonus) GetLockinPeriod() github_com_iov_one_weave.UnixDuration

func (*DepositBonus) Marshal

func (m *DepositBonus) Marshal() (dAtA []byte, err error)

func (*DepositBonus) MarshalTo

func (m *DepositBonus) MarshalTo(dAtA []byte) (int, error)

func (*DepositBonus) ProtoMessage

func (*DepositBonus) ProtoMessage()

func (*DepositBonus) Reset

func (m *DepositBonus) Reset()

func (*DepositBonus) Size

func (m *DepositBonus) Size() (n int)

func (*DepositBonus) String

func (m *DepositBonus) String() string

func (*DepositBonus) Unmarshal

func (m *DepositBonus) Unmarshal(dAtA []byte) error

func (*DepositBonus) XXX_DiscardUnknown

func (m *DepositBonus) XXX_DiscardUnknown()

func (*DepositBonus) XXX_Marshal

func (m *DepositBonus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DepositBonus) XXX_Merge

func (m *DepositBonus) XXX_Merge(src proto.Message)

func (*DepositBonus) XXX_Size

func (m *DepositBonus) XXX_Size() int

func (*DepositBonus) XXX_Unmarshal

func (m *DepositBonus) XXX_Unmarshal(b []byte) error

type DepositContract

type DepositContract struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Valid since defines the beginning of when the contract is active.
	ValidSince github_com_iov_one_weave.UnixTime `` /* 135-byte string literal not displayed */
	// An expiration date for this deposit contract. After this deadline, all
	// depositor funds are released and deposit contract is no longer active.
	ValidUntil github_com_iov_one_weave.UnixTime `` /* 135-byte string literal not displayed */
}

DepositContract is an entity created in order to allow investment deposits. Anyone can deposit funds and therefore sign a deposit contract in order to lock funds and receive appropriate interest after the contract expires.

func (*DepositContract) Descriptor

func (*DepositContract) Descriptor() ([]byte, []int)

func (*DepositContract) GetMetadata

func (m *DepositContract) GetMetadata() *weave.Metadata

func (*DepositContract) GetValidSince

func (*DepositContract) GetValidUntil

func (*DepositContract) Marshal

func (m *DepositContract) Marshal() (dAtA []byte, err error)

func (*DepositContract) MarshalTo

func (m *DepositContract) MarshalTo(dAtA []byte) (int, error)

func (*DepositContract) ProtoMessage

func (*DepositContract) ProtoMessage()

func (*DepositContract) Reset

func (m *DepositContract) Reset()

func (*DepositContract) Size

func (m *DepositContract) Size() (n int)

func (*DepositContract) String

func (m *DepositContract) String() string

func (*DepositContract) Unmarshal

func (m *DepositContract) Unmarshal(dAtA []byte) error

func (*DepositContract) Validate

func (m *DepositContract) Validate() error

func (*DepositContract) XXX_DiscardUnknown

func (m *DepositContract) XXX_DiscardUnknown()

func (*DepositContract) XXX_Marshal

func (m *DepositContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DepositContract) XXX_Merge

func (m *DepositContract) XXX_Merge(src proto.Message)

func (*DepositContract) XXX_Size

func (m *DepositContract) XXX_Size() int

func (*DepositContract) XXX_Unmarshal

func (m *DepositContract) XXX_Unmarshal(b []byte) error

type DepositMsg

type DepositMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Deposit contract ID that this funds allocation was made with. Contract
	// must not be expired.
	DepositContractID []byte `protobuf:"bytes,2,opt,name=deposit_contract_id,json=depositContractId,proto3" json:"deposit_contract_id,omitempty"`
	// Total amount that was deposited within a contract. Must be IOV tokens.
	Amount coin.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"`
	// Payback is an address that locked funds and interest are send back to once
	// the contract expires.
	Depositor github_com_iov_one_weave.Address `protobuf:"bytes,4,opt,name=depositor,proto3,casttype=github.com/iov-one/weave.Address" json:"depositor,omitempty"`
}

DepositMsg can be send by anyone to deposit funds within a non expired contract. Funds will stay locked until that contract expiration date.

func (*DepositMsg) Descriptor

func (*DepositMsg) Descriptor() ([]byte, []int)

func (*DepositMsg) GetAmount

func (m *DepositMsg) GetAmount() coin.Coin

func (*DepositMsg) GetDepositContractID

func (m *DepositMsg) GetDepositContractID() []byte

func (*DepositMsg) GetDepositor

func (m *DepositMsg) GetDepositor() github_com_iov_one_weave.Address

func (*DepositMsg) GetMetadata

func (m *DepositMsg) GetMetadata() *weave.Metadata

func (*DepositMsg) Marshal

func (m *DepositMsg) Marshal() (dAtA []byte, err error)

func (*DepositMsg) MarshalTo

func (m *DepositMsg) MarshalTo(dAtA []byte) (int, error)

func (DepositMsg) Path

func (DepositMsg) Path() string

func (*DepositMsg) ProtoMessage

func (*DepositMsg) ProtoMessage()

func (*DepositMsg) Reset

func (m *DepositMsg) Reset()

func (*DepositMsg) Size

func (m *DepositMsg) Size() (n int)

func (*DepositMsg) String

func (m *DepositMsg) String() string

func (*DepositMsg) Unmarshal

func (m *DepositMsg) Unmarshal(dAtA []byte) error

func (*DepositMsg) Validate

func (m *DepositMsg) Validate() error

func (*DepositMsg) XXX_DiscardUnknown

func (m *DepositMsg) XXX_DiscardUnknown()

func (*DepositMsg) XXX_Marshal

func (m *DepositMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DepositMsg) XXX_Merge

func (m *DepositMsg) XXX_Merge(src proto.Message)

func (*DepositMsg) XXX_Size

func (m *DepositMsg) XXX_Size() int

func (*DepositMsg) XXX_Unmarshal

func (m *DepositMsg) XXX_Unmarshal(b []byte) error

type Initializer

type Initializer struct{}

Initializer fulfils the Initializer interface to load data from the genesis file

func (*Initializer) FromGenesis

func (*Initializer) FromGenesis(opts weave.Options, params weave.GenesisParams, db weave.KVStore) error

FromGenesis will parse initial account info from genesis and save it to the database

type ReleaseDepositMsg

type ReleaseDepositMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// ID of the deposit that is to be released.
	DepositID []byte `protobuf:"bytes,2,opt,name=deposit_id,json=depositId,proto3" json:"deposit_id,omitempty"`
}

ReleaseDepositMsg cause releasing of all funds allocated within given deposit. Related contract must be expired. Anyone can submit this message.

func (*ReleaseDepositMsg) Descriptor

func (*ReleaseDepositMsg) Descriptor() ([]byte, []int)

func (*ReleaseDepositMsg) GetDepositID

func (m *ReleaseDepositMsg) GetDepositID() []byte

func (*ReleaseDepositMsg) GetMetadata

func (m *ReleaseDepositMsg) GetMetadata() *weave.Metadata

func (*ReleaseDepositMsg) Marshal

func (m *ReleaseDepositMsg) Marshal() (dAtA []byte, err error)

func (*ReleaseDepositMsg) MarshalTo

func (m *ReleaseDepositMsg) MarshalTo(dAtA []byte) (int, error)

func (ReleaseDepositMsg) Path

func (ReleaseDepositMsg) Path() string

func (*ReleaseDepositMsg) ProtoMessage

func (*ReleaseDepositMsg) ProtoMessage()

func (*ReleaseDepositMsg) Reset

func (m *ReleaseDepositMsg) Reset()

func (*ReleaseDepositMsg) Size

func (m *ReleaseDepositMsg) Size() (n int)

func (*ReleaseDepositMsg) String

func (m *ReleaseDepositMsg) String() string

func (*ReleaseDepositMsg) Unmarshal

func (m *ReleaseDepositMsg) Unmarshal(dAtA []byte) error

func (*ReleaseDepositMsg) Validate

func (m *ReleaseDepositMsg) Validate() error

func (*ReleaseDepositMsg) XXX_DiscardUnknown

func (m *ReleaseDepositMsg) XXX_DiscardUnknown()

func (*ReleaseDepositMsg) XXX_Marshal

func (m *ReleaseDepositMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ReleaseDepositMsg) XXX_Merge

func (m *ReleaseDepositMsg) XXX_Merge(src proto.Message)

func (*ReleaseDepositMsg) XXX_Size

func (m *ReleaseDepositMsg) XXX_Size() int

func (*ReleaseDepositMsg) XXX_Unmarshal

func (m *ReleaseDepositMsg) XXX_Unmarshal(b []byte) error

type UpdateConfigurationMsg

type UpdateConfigurationMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	Patch    *Configuration  `protobuf:"bytes,2,opt,name=patch,proto3" json:"patch,omitempty"`
}

func (*UpdateConfigurationMsg) Descriptor

func (*UpdateConfigurationMsg) Descriptor() ([]byte, []int)

func (*UpdateConfigurationMsg) GetMetadata

func (m *UpdateConfigurationMsg) GetMetadata() *weave.Metadata

func (*UpdateConfigurationMsg) GetPatch

func (m *UpdateConfigurationMsg) GetPatch() *Configuration

func (*UpdateConfigurationMsg) Marshal

func (m *UpdateConfigurationMsg) Marshal() (dAtA []byte, err error)

func (*UpdateConfigurationMsg) MarshalTo

func (m *UpdateConfigurationMsg) MarshalTo(dAtA []byte) (int, error)

func (UpdateConfigurationMsg) Path

func (*UpdateConfigurationMsg) ProtoMessage

func (*UpdateConfigurationMsg) ProtoMessage()

func (*UpdateConfigurationMsg) Reset

func (m *UpdateConfigurationMsg) Reset()

func (*UpdateConfigurationMsg) Size

func (m *UpdateConfigurationMsg) Size() (n int)

func (*UpdateConfigurationMsg) String

func (m *UpdateConfigurationMsg) String() string

func (*UpdateConfigurationMsg) Unmarshal

func (m *UpdateConfigurationMsg) Unmarshal(dAtA []byte) error

func (*UpdateConfigurationMsg) Validate

func (m *UpdateConfigurationMsg) Validate() error

func (*UpdateConfigurationMsg) XXX_DiscardUnknown

func (m *UpdateConfigurationMsg) XXX_DiscardUnknown()

func (*UpdateConfigurationMsg) XXX_Marshal

func (m *UpdateConfigurationMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateConfigurationMsg) XXX_Merge

func (m *UpdateConfigurationMsg) XXX_Merge(src proto.Message)

func (*UpdateConfigurationMsg) XXX_Size

func (m *UpdateConfigurationMsg) XXX_Size() int

func (*UpdateConfigurationMsg) XXX_Unmarshal

func (m *UpdateConfigurationMsg) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL