types

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PowerFunction     = "power_function"
	SigmoidFunction   = "sigmoid_function"
	SwapperFunction   = "swapper_function"
	AugmentedFunction = "augmented_function"

	HatchState  BondState = "HATCH"
	OpenState   BondState = "OPEN"
	SettleState BondState = "SETTLE"
	FailedState BondState = "FAILED"

	DoNotModifyField = "[do-not-modify]"

	AnyNumberOfReserveTokens = -1
)
View Source
const (
	EventTypeCreateBond         = "create_bond"
	EventTypeEditBond           = "edit_bond"
	EventTypeSetNextAlpha       = "set_next_alpha"
	EventTypeEditAlphaSuccess   = "edit_alpha_success"
	EventTypeEditAlphaFailed    = "edit_alpha_failed"
	EventTypeInitSwapper        = "init_swapper"
	EventTypeBuy                = "buy"
	EventTypeSell               = "sell"
	EventTypeSwap               = "swap"
	EventTypeMakeOutcomePayment = "make_outcome_payment"
	EventTypeWithdrawShare      = "withdraw_share"
	EventTypeOrderCancel        = "order_cancel"
	EventTypeOrderFulfill       = "order_fulfill"
	EventTypeStateChange        = "state_change"

	AttributeKeyBondDid                = "bond_did"
	AttributeKeyToken                  = "token"
	AttributeKeyName                   = "name"
	AttributeKeyDescription            = "description"
	AttributeKeyFunctionType           = "function_type"
	AttributeKeyFunctionParameters     = "function_parameters"
	AttributeKeyCreatorDid             = "creator_did"
	AttributeKeyControllerDid          = "controller_did"
	AttributeKeyReserveTokens          = "reserve_tokens"
	AttributeKeyTxFeePercentage        = "tx_fee_percentage"
	AttributeKeyExitFeePercentage      = "exit_fee_percentage"
	AttributeKeyFeeAddress             = "fee_address"
	AttributeKeyMaxSupply              = "max_supply"
	AttributeKeyOrderQuantityLimits    = "order_quantity_limits"
	AttributeKeySanityRate             = "sanity_rate"
	AttributeKeySanityMarginPercentage = "sanity_margin_percentage"
	AttributeKeyAllowSells             = "allow_sells"
	AttributeKeyAlphaBond              = "alpha_bond"
	AttributeKeyBatchBlocks            = "batch_blocks"
	AttributeKeyOutcomePayment         = "outcome_payment"
	AttributeKeyState                  = "state"
	AttributeKeyMaxPrices              = "max_prices"
	AttributeKeySwapFromToken          = "from_token"
	AttributeKeySwapToToken            = "to_token"
	AttributeKeyOrderType              = "order_type"
	AttributeKeyAddress                = "address"
	AttributeKeyCancelReason           = "cancel_reason"
	AttributeKeyTokensMinted           = "tokens_minted"
	AttributeKeyTokensBurned           = "tokens_burned"
	AttributeKeyTokensSwapped          = "tokens_swapped"
	AttributeKeyChargedPrices          = "charged_prices"
	AttributeKeyChargedPricesReserve   = "charged_prices_of_which_reserve"
	AttributeKeyChargedPricesFunding   = "charged_prices_of_which_funding"
	AttributeKeyChargedFees            = "charged_fees"
	AttributeKeyReturnedToAddress      = "returned_to_address"
	AttributeKeyNewBondTokenBalance    = "new_bond_token_balance"
	AttributeKeyOldState               = "old_state"
	AttributeKeyNewState               = "new_state"
	AttributeKeyPublicAlpha            = "public_alpha"
	AttributeKeySystemAlpha            = "system_alpha"

	AttributeValueBuyOrder  = "buy"
	AttributeValueSellOrder = "sell"
	AttributeValueSwapOrder = "swap"
	AttributeValueCategory  = ModuleName
)
View Source
const (
	// ModuleName is the name of this module
	ModuleName = "bonds"

	// StoreKey is the default store key for this module
	StoreKey = ModuleName

	// DefaultParamspace is the default param space for this module
	DefaultParamspace = ModuleName

	// BondsMintBurnAccount the root string for the bonds mint burn account address
	BondsMintBurnAccount = "bonds_mint_burn_account"

	// BatchesIntermediaryAccount the root string for the batches account address
	BatchesIntermediaryAccount = "batches_intermediary_account"

	// BondsReserveAccount the root string for the bonds reserve account address
	BondsReserveAccount = "bonds_reserve_account"

	// QuerierRoute is the querier route for this module's store.
	QuerierRoute = ModuleName

	// RouterKey is the message route for this module
	RouterKey = ModuleName
)
View Source
const (
	TypeMsgCreateBond         = "create_bond"
	TypeMsgEditBond           = "edit_bond"
	TypeMsgSetNextAlpha       = "set_next_alpha"
	TypeMsgUpdateBondState    = "update_bond_state"
	TypeMsgBuy                = "buy"
	TypeMsgSell               = "sell"
	TypeMsgSwap               = "swap"
	TypeMsgMakeOutcomePayment = "make_outcome_payment"
	TypeMsgWithdrawShare      = "withdraw_share"
)
View Source
const (
	DefaultCodespace = ModuleName
)

Variables

View Source
var (
	RequiredParamsForFunctionType = map[string][]string{
		PowerFunction:     {"m", "n", "c"},
		SigmoidFunction:   {"a", "b", "c"},
		SwapperFunction:   nil,
		AugmentedFunction: {"d0", "p0", "theta", "kappa"},
	}

	NoOfReserveTokensForFunctionType = map[string]int{
		PowerFunction:     AnyNumberOfReserveTokens,
		SigmoidFunction:   AnyNumberOfReserveTokens,
		SwapperFunction:   2,
		AugmentedFunction: AnyNumberOfReserveTokens,
	}

	ExtraParameterRestrictions = map[string]FunctionParamRestrictions{
		PowerFunction:     nil,
		SigmoidFunction:   sigmoidParameterRestrictions,
		SwapperFunction:   nil,
		AugmentedFunction: augmentedParameterRestrictions,
	}
)
View Source
var (
	TEN = []sdk.Uint{
		sdk.NewUintFromString("1"),
		sdk.NewUintFromString("10"),
		sdk.NewUintFromString("100"),
		sdk.NewUintFromString("1000"),
		sdk.NewUintFromString("10000"),
		sdk.NewUintFromString("100000"),
		sdk.NewUintFromString("1000000"),
		sdk.NewUintFromString("10000000"),
		sdk.NewUintFromString("100000000"),
		sdk.NewUintFromString("1000000000"),

		sdk.NewUintFromString("10000000000"),
		sdk.NewUintFromString("100000000000"),
		sdk.NewUintFromString("1000000000000"),
		sdk.NewUintFromString("10000000000000"),
		sdk.NewUintFromString("100000000000000"),
		sdk.NewUintFromString("1000000000000000"),
		sdk.NewUintFromString("10000000000000000"),
		sdk.NewUintFromString("100000000000000000"),
		sdk.NewUintFromString("1000000000000000000"),
		sdk.NewUintFromString("10000000000000000000"),

		sdk.NewUintFromString("100000000000000000000"),
		sdk.NewUintFromString("1000000000000000000000"),
		sdk.NewUintFromString("10000000000000000000000"),
		sdk.NewUintFromString("100000000000000000000000"),
		sdk.NewUintFromString("1000000000000000000000000"),
		sdk.NewUintFromString("10000000000000000000000000"),
		sdk.NewUintFromString("100000000000000000000000000"),
		sdk.NewUintFromString("1000000000000000000000000000"),
		sdk.NewUintFromString("10000000000000000000000000000"),
		sdk.NewUintFromString("100000000000000000000000000000"),

		sdk.NewUintFromString("1000000000000000000000000000000"),
		sdk.NewUintFromString("10000000000000000000000000000000"),
		sdk.NewUintFromString("100000000000000000000000000000000"),
		sdk.NewUintFromString("1000000000000000000000000000000000"),
		sdk.NewUintFromString("10000000000000000000000000000000000"),
		sdk.NewUintFromString("100000000000000000000000000000000000"),
		sdk.NewUintFromString("1000000000000000000000000000000000000"),
		sdk.NewUintFromString("10000000000000000000000000000000000000"),
		sdk.NewUintFromString("100000000000000000000000000000000000000"),
		sdk.NewUintFromString("1000000000000000000000000000000000000000"),
	}

	// ln(2) - used in ln(x). 30 DP.
	LN2 = sdk.NewUintFromString("693147180559945309417232121458")

	// 1 / ln(2) - used in exp(x). 30 DP.
	ONE_OVER_LN2 = sdk.NewUintFromString("1442695040888963407359924681002")

	ZeroUint = sdk.ZeroUint()
	OneUint  = sdk.OneUint()
	TwoUint  = sdk.NewUint(2)
	FiveUint = sdk.NewUint(5)
	TenUint  = sdk.NewUint(10)

	// LUT flags
	LUT1_isSet   = false
	LUT2_isSet   = false
	LUT3_1_isSet = false
	LUT3_2_isSet = false
	LUT3_3_isSet = false
	LUT3_4_isSet = false
)
View Source
var (
	ErrArgumentCannotBeEmpty                = sdkerrors.Register(DefaultCodespace, 2, "argument cannot be empty")
	ErrArgumentCannotBeNegative             = sdkerrors.Register(DefaultCodespace, 3, "argument cannot be negative")
	ErrArgumentMustBePositive               = sdkerrors.Register(DefaultCodespace, 4, "argument must be a positive value")
	ErrArgumentMustBeInteger                = sdkerrors.Register(DefaultCodespace, 5, "argument must be an integer value")
	ErrArgumentMustBeBetween                = sdkerrors.Register(DefaultCodespace, 6, "argument must be between")
	ErrFunctionParameterMissingOrNonFloat   = sdkerrors.Register(DefaultCodespace, 7, "parameter is missing or is not a float")
	ErrArgumentMissingOrNonFloat            = sdkerrors.Register(DefaultCodespace, 8, "argument is missing or is not a float")
	ErrArgumentMissingOrNonUInteger         = sdkerrors.Register(DefaultCodespace, 9, "argument is missing or is not an unsigned integer")
	ErrArgumentMissingOrNonBoolean          = sdkerrors.Register(DefaultCodespace, 10, "argument is missing or is not true or false")
	ErrIncorrectNumberOfReserveTokens       = sdkerrors.Register(DefaultCodespace, 11, "incorrect number of reserve tokens")
	ErrIncorrectNumberOfFunctionParameters  = sdkerrors.Register(DefaultCodespace, 12, "incorrect number of function parameters")
	ErrBondDoesNotExist                     = sdkerrors.Register(DefaultCodespace, 13, "bond does not exist")
	ErrBondAlreadyExists                    = sdkerrors.Register(DefaultCodespace, 14, "bond already exists")
	ErrBondTokenIsTaken                     = sdkerrors.Register(DefaultCodespace, 15, "bond token is taken")
	ErrBondDoesNotAllowSelling              = sdkerrors.Register(DefaultCodespace, 16, "bond does not allow selling at the moment")
	ErrDidNotEditAnything                   = sdkerrors.Register(DefaultCodespace, 17, "did not edit any bond field")
	ErrFromAndToCannotBeTheSameToken        = sdkerrors.Register(DefaultCodespace, 18, "from and to tokens cannot be the same token")
	ErrDuplicateReserveToken                = sdkerrors.Register(DefaultCodespace, 19, "cannot have duplicate tokens in reserve tokens")
	ErrInvalidStateForAction                = sdkerrors.Register(DefaultCodespace, 20, "cannot perform that action at the current state")
	ErrUnrecognizedFunctionType             = sdkerrors.Register(DefaultCodespace, 21, "unrecognized function type")
	ErrInvalidFunctionParameter             = sdkerrors.Register(DefaultCodespace, 22, "invalid function parameter")
	ErrFunctionNotAvailableForFunctionType  = sdkerrors.Register(DefaultCodespace, 23, "function is not available for the function type")
	ErrFunctionRequiresNonZeroCurrentSupply = sdkerrors.Register(DefaultCodespace, 24, "function requires the current supply to be non zero")
	ErrTokenIsNotAValidReserveToken         = sdkerrors.Register(DefaultCodespace, 25, "token is not a valid reserve token")
	ErrMaxSupplyDenomDoesNotMatchTokenDenom = sdkerrors.Register(DefaultCodespace, 26, "max supply denom does not match token denom")
	ErrBondTokenCannotAlsoBeReserveToken    = sdkerrors.Register(DefaultCodespace, 27, "token cannot also be a reserve token")
	ErrBondTokenCannotBeStakingToken        = sdkerrors.Register(DefaultCodespace, 28, "bond token cannot be staking token")
	ErrReserveDenomsMismatch                = sdkerrors.Register(DefaultCodespace, 29, "denoms do not match reserve denoms")
	ErrCannotMintMoreThanMaxSupply          = sdkerrors.Register(DefaultCodespace, 30, "cannot mint more tokens than the max supply")
	ErrCannotBurnMoreThanSupply             = sdkerrors.Register(DefaultCodespace, 31, "cannot burn more tokens than the current supply")
	ErrMaxPriceExceeded                     = sdkerrors.Register(DefaultCodespace, 32, "actual prices exceed max prices")
	ErrSwapAmountTooSmallToGiveAnyReturn    = sdkerrors.Register(DefaultCodespace, 33, "swap amount too small to give any return")
	ErrSwapAmountCausesReserveDepletion     = sdkerrors.Register(DefaultCodespace, 34, "swap amount too large and causes reserve to be depleted")
	ErrOrderQuantityLimitExceeded           = sdkerrors.Register(DefaultCodespace, 35, "order quantity limits exceeded")
	ErrValuesViolateSanityRate              = sdkerrors.Register(DefaultCodespace, 36, "values violate sanity rate")
	ErrFeesCannotBeOrExceed100Percent       = sdkerrors.Register(DefaultCodespace, 37, "sum of fees is or exceeds 100 percent")
	ErrNoBondTokensOwned                    = sdkerrors.Register(DefaultCodespace, 38, "no bond tokens of this bond are owned")
	ErrInsufficientReserveToBuy             = sdkerrors.Register(DefaultCodespace, 39, "insufficient reserve was supplied to perform buy order")
	ErrBondTokenDoesNotMatchBond            = sdkerrors.Register(DefaultCodespace, 40, "bond token does not match bond")
	ErrReservedBondToken                    = sdkerrors.Register(DefaultCodespace, 41, "bond token is reserved")
	ErrInvalidAlpha                         = sdkerrors.Register(DefaultCodespace, 42, "alpha value is invalid")
	ErrNumericOverflow                      = sdkerrors.Register(DefaultCodespace, 43, "numeric overflow")
	ErrInvalidStateProgression              = sdkerrors.Register(DefaultCodespace, 44, "invalid state progression requested")
)
View Source
var (
	BondsKeyPrefix       = []byte{0x00} // key for bonds
	BatchesKeyPrefix     = []byte{0x01} // key for batches
	LastBatchesKeyPrefix = []byte{0x02} // key for last batches
	BondDidsKeyPrefix    = []byte{0x03} // key for bond DIDs
)

Bonds and batches are stored as follow:

- Bonds: 0x00<bond_did_bytes> - Batches: 0x01<bond_did_bytes> - Last batches: 0x02<bond_did_bytes> - Bond DIDs: 0x03<bond_token_bytes>

View Source
var (
	KeyReservedBondTokens = []byte("ReservedBondTokens")
)

Parameter store keys

View Source
var ModuleCdc *codec.Codec

ModuleCdc is the codec for the module

View Source
var (
	StartingPublicAlpha = sdk.MustNewDecFromStr("0.5")
)
View Source
var StateTransitions = initStateTransitions()
View Source
var (
	TEN18DEC = sdk.MustNewDecFromStr("1000000000000000000") // 1e18
)

Functions

func AccAddressesToString

func AccAddressesToString(addresses []sdk.AccAddress) (result string)

func AdjustFees

func AdjustFees(fees sdk.Coins, maxFees sdk.Coins) sdk.Coins

func ApproxPower added in v0.14.2

func ApproxPower(d sdk.Dec, power sdk.Dec) (guess sdk.Dec, err error)

ApproxPower returns an approximation of raising a Dec to a positive power

func ApproxRoot added in v0.12.2

func ApproxRoot(d sdk.Dec, root sdk.Dec) (guess sdk.Dec, err error)

ApproxRoot returns an approximation of a Dec's nth root

func CheckCoinDenom

func CheckCoinDenom(denom string) (err error)

func CheckNoOfReserveTokens

func CheckNoOfReserveTokens(resTokens []string, fnType string) error

func CheckReserveTokenNames

func CheckReserveTokenNames(resTokens []string, token string) error

func DivideDecCoinByDec

func DivideDecCoinByDec(dc sdk.DecCoin, scale sdk.Dec) sdk.DecCoin

func DivideDecCoinsByDec

func DivideDecCoinsByDec(dcs sdk.DecCoins, scale sdk.Dec) (scaled sdk.DecCoins)

noinspection GoNilness

func GetBatchKey

func GetBatchKey(bondDid did.Did) []byte

func GetBondDidsKey

func GetBondDidsKey(token string) []byte

func GetBondKey

func GetBondKey(bondDid did.Did) []byte

func GetLastBatchKey

func GetLastBatchKey(bondDid did.Did) []byte

func GetRequiredParamsForFunctionType

func GetRequiredParamsForFunctionType(fnType string) (fnParams []string, err error)

func Invariant added in v0.12.2

func Invariant(R, S sdk.Dec, kappa sdk.Dec) (sdk.Dec, error)

value function for a given state (R,S)

func InvariantI added in v0.14.2

func InvariantI(C sdk.Int, alpha sdk.Dec, R sdk.Int) sdk.Dec

func InvariantIAlt added in v0.14.2

func InvariantIAlt(C sdk.Int, alpha sdk.Dec, kappa sdk.Dec) sdk.Dec

func Kappa added in v0.14.2

func Kappa(I sdk.Dec, C sdk.Int, alpha sdk.Dec) sdk.Dec

func MultiplyDecCoinByDec

func MultiplyDecCoinByDec(dc sdk.DecCoin, scale sdk.Dec) sdk.DecCoin

func MultiplyDecCoinByInt

func MultiplyDecCoinByInt(dc sdk.DecCoin, scale sdk.Int) sdk.DecCoin

func MultiplyDecCoinsByDec

func MultiplyDecCoinsByDec(dcs sdk.DecCoins, scale sdk.Dec) (scaled sdk.DecCoins)

noinspection GoNilness

func MultiplyDecCoinsByInt

func MultiplyDecCoinsByInt(dcs sdk.DecCoins, scale sdk.Int) (scaled sdk.DecCoins)

noinspection GoNilness

func ParamKeyTable added in v0.13.0

func ParamKeyTable() params.KeyTable

ParamTable for bonds module.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

func Reserve added in v0.12.2

func Reserve(S sdk.Dec, kappa sdk.Dec, V0 sdk.Dec) (sdk.Dec, error)

This is the reverse of Supply(...) function

func RoundFee

func RoundFee(f sdk.DecCoin) sdk.Coin

func RoundReservePrice

func RoundReservePrice(p sdk.DecCoin) sdk.Coin

func RoundReservePrices

func RoundReservePrices(ps sdk.DecCoins) (rounded sdk.Coins)

noinspection GoNilness

func RoundReserveReturn

func RoundReserveReturn(r sdk.DecCoin) sdk.Coin

func RoundReserveReturns

func RoundReserveReturns(rs sdk.DecCoins) (rounded sdk.Coins)

noinspection GoNilness

func SpotPrice added in v0.12.2

func SpotPrice(R sdk.Dec, kappa sdk.Dec, V0 sdk.Dec) (sdk.Dec, error)

given a value function (parameterized by kappa) and an invariant coeficient V0 return a spot price P as a function of reserve R

func StringsToString

func StringsToString(strs []string) (result string)

func Supply added in v0.12.2

func Supply(R sdk.Dec, kappa sdk.Dec, V0 sdk.Dec) (sdk.Dec, error)

given a value function (parameterized by kappa) and an invariant coeficient V0 return Supply S as a function of reserve R

func SystemAlpha added in v0.14.2

func SystemAlpha(publicAlpha sdk.Dec, S0, S1, R, C sdk.Int) sdk.Dec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

func ValidateParams added in v0.13.0

func ValidateParams(params Params) error

validate params

Types

type BaseOrder

type BaseOrder struct {
	AccountDid   did.Did  `json:"sender_did" yaml:"sender_did"`
	Amount       sdk.Coin `json:"amount" yaml:"amount"`
	Cancelled    bool     `json:"cancelled" yaml:"cancelled"`
	CancelReason string   `json:"cancel_reason" yaml:"cancel_reason"`
}

func NewBaseOrder

func NewBaseOrder(accountDid did.Did, amount sdk.Coin) BaseOrder

func (BaseOrder) IsCancelled

func (bo BaseOrder) IsCancelled() bool

type Batch

type Batch struct {
	BondDid         did.Did      `json:"bond_did" yaml:"bond_did"`
	BlocksRemaining sdk.Uint     `json:"blocks_remaining" yaml:"blocks_remaining"`
	NextPublicAlpha sdk.Dec      `json:"next_public_alpha" yaml:"next_public_alpha"`
	TotalBuyAmount  sdk.Coin     `json:"total_buy_amount" yaml:"total_buy_amount"`
	TotalSellAmount sdk.Coin     `json:"total_sell_amount" yaml:"total_sell_amount"`
	BuyPrices       sdk.DecCoins `json:"buy_prices" yaml:"buy_prices"`
	SellPrices      sdk.DecCoins `json:"sell_prices" yaml:"sell_prices"`
	Buys            []BuyOrder   `json:"buys" yaml:"buys"`
	Sells           []SellOrder  `json:"sells" yaml:"sells"`
	Swaps           []SwapOrder  `json:"swaps" yaml:"swaps"`
}

func NewBatch

func NewBatch(bondDid did.Did, token string, blocks sdk.Uint) Batch

func (Batch) Empty added in v0.14.2

func (b Batch) Empty() bool

func (Batch) EqualBuysAndSells

func (b Batch) EqualBuysAndSells() bool

func (Batch) HasNextAlpha added in v0.14.2

func (b Batch) HasNextAlpha() bool

func (Batch) MoreBuysThanSells

func (b Batch) MoreBuysThanSells() bool

func (Batch) MoreSellsThanBuys

func (b Batch) MoreSellsThanBuys() bool

type Bond

type Bond struct {
	Token                        string         `json:"token" yaml:"token"`
	Name                         string         `json:"name" yaml:"name"`
	Description                  string         `json:"description" yaml:"description"`
	CreatorDid                   did.Did        `json:"creator_did" yaml:"creator_did"`
	ControllerDid                did.Did        `json:"controller_did" yaml:"controller_did"`
	FunctionType                 string         `json:"function_type" yaml:"function_type"`
	FunctionParameters           FunctionParams `json:"function_parameters" yaml:"function_parameters"`
	ReserveTokens                []string       `json:"reserve_tokens" yaml:"reserve_tokens"`
	TxFeePercentage              sdk.Dec        `json:"tx_fee_percentage" yaml:"tx_fee_percentage"`
	ExitFeePercentage            sdk.Dec        `json:"exit_fee_percentage" yaml:"exit_fee_percentage"`
	FeeAddress                   sdk.AccAddress `json:"fee_address" yaml:"fee_address"`
	MaxSupply                    sdk.Coin       `json:"max_supply" yaml:"max_supply"`
	OrderQuantityLimits          sdk.Coins      `json:"order_quantity_limits" yaml:"order_quantity_limits"`
	SanityRate                   sdk.Dec        `json:"sanity_rate" yaml:"sanity_rate"`
	SanityMarginPercentage       sdk.Dec        `json:"sanity_margin_percentage" yaml:"sanity_margin_percentage"`
	CurrentSupply                sdk.Coin       `json:"current_supply" yaml:"current_supply"`
	CurrentReserve               sdk.Coins      `json:"current_reserve" yaml:"current_reserve"`
	CurrentOutcomePaymentReserve sdk.Coins      `json:"current_outcome_payment_reserve" yaml:"current_outcome_payment_reserve"`
	AllowSells                   bool           `json:"allow_sells" yaml:"allow_sells"`
	AlphaBond                    bool           `json:"alpha_bond" yaml:"alpha_bond"`
	BatchBlocks                  sdk.Uint       `json:"batch_blocks" yaml:"batch_blocks"`
	OutcomePayment               sdk.Int        `json:"outcome_payment" yaml:"outcome_payment"`
	State                        BondState      `json:"state" yaml:"state"`
	BondDid                      did.Did        `json:"bond_did" yaml:"bond_did"`
}

func NewBond

func NewBond(token, name, description string, creatorDid, controllerDid did.Did,
	functionType string, functionParameters FunctionParams, reserveTokens []string,
	txFeePercentage, exitFeePercentage sdk.Dec, feeAddress sdk.AccAddress,
	maxSupply sdk.Coin, orderQuantityLimits sdk.Coins, sanityRate,
	sanityMarginPercentage sdk.Dec, allowSells, alphaBond bool, batchBlocks sdk.Uint,
	outcomePayment sdk.Int, state BondState, bondDid did.Did) Bond

func (Bond) AnyOrderQuantityLimitsExceeded

func (bond Bond) AnyOrderQuantityLimitsExceeded(amounts sdk.Coins) bool

func (Bond) GetCurrentPricesPT

func (bond Bond) GetCurrentPricesPT(reserveBalances sdk.Coins) (sdk.DecCoins, error)

func (Bond) GetExitFee

func (bond Bond) GetExitFee(reserveAmount sdk.DecCoin) sdk.Coin

func (Bond) GetExitFees

func (bond Bond) GetExitFees(reserveAmounts sdk.DecCoins) (fees sdk.Coins)

noinspection GoNilness

func (Bond) GetFee added in v0.12.2

func (bond Bond) GetFee(reserveAmount sdk.DecCoin, percentage sdk.Dec) sdk.Coin

func (Bond) GetFees added in v0.12.2

func (bond Bond) GetFees(reserveAmounts sdk.DecCoins, percentage sdk.Dec) (fees sdk.Coins)

func (Bond) GetNewReserveCoins added in v0.14.2

func (bond Bond) GetNewReserveCoins(amount sdk.Int) (coins sdk.Coins)

func (Bond) GetNewReserveDecCoins

func (bond Bond) GetNewReserveDecCoins(amount sdk.Dec) (coins sdk.DecCoins)

func (Bond) GetPricesAtSupply

func (bond Bond) GetPricesAtSupply(supply sdk.Int) (result sdk.DecCoins, err error)

func (Bond) GetPricesToMint

func (bond Bond) GetPricesToMint(mint sdk.Int, reserveBalances sdk.Coins) (sdk.DecCoins, error)

func (Bond) GetReserveDeltaForLiquidityDelta

func (bond Bond) GetReserveDeltaForLiquidityDelta(mintOrBurn sdk.Int, reserveBalances sdk.Coins) sdk.DecCoins

func (Bond) GetReturnsForBurn

func (bond Bond) GetReturnsForBurn(burn sdk.Int, reserveBalances sdk.Coins) (sdk.DecCoins, error)

func (Bond) GetReturnsForSwap

func (bond Bond) GetReturnsForSwap(from sdk.Coin, toToken string, reserveBalances sdk.Coins) (returns sdk.Coins, txFee sdk.Coin, err error)

func (Bond) GetTxFee

func (bond Bond) GetTxFee(reserveAmount sdk.DecCoin) sdk.Coin

func (Bond) GetTxFees

func (bond Bond) GetTxFees(reserveAmounts sdk.DecCoins) (fees sdk.Coins)

noinspection GoNilness

func (Bond) ReserveAtSupply added in v0.12.2

func (bond Bond) ReserveAtSupply(supply sdk.Int) (result sdk.Dec, err error)

func (Bond) ReserveDenomsEqualTo

func (bond Bond) ReserveDenomsEqualTo(coins sdk.Coins) bool

func (Bond) ReservesViolateSanityRate

func (bond Bond) ReservesViolateSanityRate(newReserves sdk.Coins) bool

type BondDetails added in v0.14.2

type BondDetails struct {
	BondDid   string       `json:"did" yaml:"did"`
	SpotPrice sdk.DecCoins `json:"spot_price" yaml:"spot_price"`
	Supply    sdk.Coin     `json:"supply" yaml:"supply"`
	Reserve   sdk.Coins    `json:"reserve" yaml:"reserve"`
}

type BondState added in v0.14.2

type BondState string

func (BondState) IsValidProgressionFrom added in v0.14.2

func (next BondState) IsValidProgressionFrom(prev BondState) bool

type BondStateTransitionMap added in v0.14.2

type BondStateTransitionMap map[BondState][]BondState

type BuyOrder

type BuyOrder struct {
	BaseOrder
	MaxPrices sdk.Coins `json:"max_prices" yaml:"max_prices"`
}

func NewBuyOrder

func NewBuyOrder(buyerDid did.Did, amount sdk.Coin, maxPrices sdk.Coins) BuyOrder

type FunctionParam

type FunctionParam struct {
	Param string  `json:"param" yaml:"param"`
	Value sdk.Dec `json:"value" yaml:"value"`
}

func NewFunctionParam

func NewFunctionParam(param string, value sdk.Dec) FunctionParam

type FunctionParamRestrictions

type FunctionParamRestrictions func(paramsMap map[string]sdk.Dec) error

func GetExceptionsForFunctionType

func GetExceptionsForFunctionType(fnType string) (restrictions FunctionParamRestrictions, err error)

type FunctionParams

type FunctionParams []FunctionParam

func (FunctionParams) AddParam added in v0.14.2

func (fps FunctionParams) AddParam(param string, value sdk.Dec) FunctionParams

func (FunctionParams) AddParams added in v0.14.2

func (fps FunctionParams) AddParams(newFps FunctionParams) FunctionParams

func (FunctionParams) AsMap

func (fps FunctionParams) AsMap() (paramsMap map[string]sdk.Dec)

func (FunctionParams) ReplaceParam added in v0.14.2

func (fps FunctionParams) ReplaceParam(param string, value sdk.Dec)

func (FunctionParams) String

func (fps FunctionParams) String() (result string)

func (FunctionParams) Validate

func (fps FunctionParams) Validate(functionType string) error

type GenesisState

type GenesisState struct {
	Bonds   []Bond  `json:"bonds" yaml:"bonds"`
	Batches []Batch `json:"batches" yaml:"batches"`
	Params  Params  `json:"params" yaml:"params"`
}

func DefaultGenesisState

func DefaultGenesisState() GenesisState

func NewGenesisState

func NewGenesisState(bonds []Bond, batches []Batch, params Params) GenesisState

type MsgBuy

type MsgBuy struct {
	BuyerDid  did.Did   `json:"buyer_did" yaml:"buyer_did"`
	Amount    sdk.Coin  `json:"amount" yaml:"amount"`
	MaxPrices sdk.Coins `json:"max_prices" yaml:"max_prices"`
	BondDid   did.Did   `json:"bond_did" yaml:"bond_did"`
}

func NewMsgBuy

func NewMsgBuy(buyerDid did.Did, amount sdk.Coin, maxPrices sdk.Coins,
	bondDid did.Did) MsgBuy

func (MsgBuy) GetSignBytes

func (msg MsgBuy) GetSignBytes() []byte

func (MsgBuy) GetSignerDid

func (msg MsgBuy) GetSignerDid() did.Did

func (MsgBuy) GetSigners

func (msg MsgBuy) GetSigners() []sdk.AccAddress

func (MsgBuy) Route

func (msg MsgBuy) Route() string

func (MsgBuy) Type

func (msg MsgBuy) Type() string

func (MsgBuy) ValidateBasic

func (msg MsgBuy) ValidateBasic() error

type MsgCreateBond

type MsgCreateBond struct {
	BondDid                did.Did        `json:"bond_did" yaml:"bond_did"`
	Token                  string         `json:"token" yaml:"token"`
	Name                   string         `json:"name" yaml:"name"`
	Description            string         `json:"description" yaml:"description"`
	FunctionType           string         `json:"function_type" yaml:"function_type"`
	FunctionParameters     FunctionParams `json:"function_parameters" yaml:"function_parameters"`
	CreatorDid             did.Did        `json:"creator_did" yaml:"creator_did"`
	ControllerDid          did.Did        `json:"controller_did" yaml:"controller_did"`
	ReserveTokens          []string       `json:"reserve_tokens" yaml:"reserve_tokens"`
	TxFeePercentage        sdk.Dec        `json:"tx_fee_percentage" yaml:"tx_fee_percentage"`
	ExitFeePercentage      sdk.Dec        `json:"exit_fee_percentage" yaml:"exit_fee_percentage"`
	FeeAddress             sdk.AccAddress `json:"fee_address" yaml:"fee_address"`
	MaxSupply              sdk.Coin       `json:"max_supply" yaml:"max_supply"`
	OrderQuantityLimits    sdk.Coins      `json:"order_quantity_limits" yaml:"order_quantity_limits"`
	SanityRate             sdk.Dec        `json:"sanity_rate" yaml:"sanity_rate"`
	SanityMarginPercentage sdk.Dec        `json:"sanity_margin_percentage" yaml:"sanity_margin_percentage"`
	AllowSells             bool           `json:"allow_sells" yaml:"allow_sells"`
	AlphaBond              bool           `json:"alpha_bond" yaml:"alpha_bond"`
	BatchBlocks            sdk.Uint       `json:"batch_blocks" yaml:"batch_blocks"`
	OutcomePayment         sdk.Int        `json:"outcome_payment" yaml:"outcome_payment"`
}

func NewMsgCreateBond

func NewMsgCreateBond(token, name, description string, creatorDid, controllerDid did.Did,
	functionType string, functionParameters FunctionParams, reserveTokens []string,
	txFeePercentage, exitFeePercentage sdk.Dec, feeAddress sdk.AccAddress, maxSupply sdk.Coin,
	orderQuantityLimits sdk.Coins, sanityRate, sanityMarginPercentage sdk.Dec,
	allowSell, alphaBond bool, batchBlocks sdk.Uint, outcomePayment sdk.Int, bondDid did.Did) MsgCreateBond

func (MsgCreateBond) GetSignBytes

func (msg MsgCreateBond) GetSignBytes() []byte

func (MsgCreateBond) GetSignerDid

func (msg MsgCreateBond) GetSignerDid() did.Did

func (MsgCreateBond) GetSigners

func (msg MsgCreateBond) GetSigners() []sdk.AccAddress

func (MsgCreateBond) Route

func (msg MsgCreateBond) Route() string

func (MsgCreateBond) Type

func (msg MsgCreateBond) Type() string

func (MsgCreateBond) ValidateBasic

func (msg MsgCreateBond) ValidateBasic() error

type MsgEditBond

type MsgEditBond struct {
	BondDid                did.Did `json:"bond_did" yaml:"bond_did"`
	Name                   string  `json:"name" yaml:"name"`
	Description            string  `json:"description" yaml:"description"`
	OrderQuantityLimits    string  `json:"order_quantity_limits" yaml:"order_quantity_limits"`
	SanityRate             string  `json:"sanity_rate" yaml:"sanity_rate"`
	SanityMarginPercentage string  `json:"sanity_margin_percentage" yaml:"sanity_margin_percentage"`
	EditorDid              did.Did `json:"editor_did" yaml:"editor_did"`
}

func NewMsgEditBond

func NewMsgEditBond(name, description, orderQuantityLimits, sanityRate,
	sanityMarginPercentage string, editorDid, bondDid did.Did) MsgEditBond

func (MsgEditBond) GetSignBytes

func (msg MsgEditBond) GetSignBytes() []byte

func (MsgEditBond) GetSignerDid

func (msg MsgEditBond) GetSignerDid() did.Did

func (MsgEditBond) GetSigners

func (msg MsgEditBond) GetSigners() []sdk.AccAddress

func (MsgEditBond) Route

func (msg MsgEditBond) Route() string

func (MsgEditBond) Type

func (msg MsgEditBond) Type() string

func (MsgEditBond) ValidateBasic

func (msg MsgEditBond) ValidateBasic() error

type MsgMakeOutcomePayment added in v0.12.2

type MsgMakeOutcomePayment struct {
	SenderDid did.Did `json:"sender_did" yaml:"sender_did"`
	Amount    sdk.Int `json:"amount" yaml:"amount"`
	BondDid   did.Did `json:"bond_did" yaml:"bond_did"`
}

func NewMsgMakeOutcomePayment added in v0.12.2

func NewMsgMakeOutcomePayment(senderDid did.Did, amount sdk.Int, bondDid did.Did) MsgMakeOutcomePayment

func (MsgMakeOutcomePayment) GetSignBytes added in v0.12.2

func (msg MsgMakeOutcomePayment) GetSignBytes() []byte

func (MsgMakeOutcomePayment) GetSignerDid added in v0.12.2

func (msg MsgMakeOutcomePayment) GetSignerDid() did.Did

func (MsgMakeOutcomePayment) GetSigners added in v0.12.2

func (msg MsgMakeOutcomePayment) GetSigners() []sdk.AccAddress

func (MsgMakeOutcomePayment) Route added in v0.12.2

func (msg MsgMakeOutcomePayment) Route() string

func (MsgMakeOutcomePayment) Type added in v0.12.2

func (msg MsgMakeOutcomePayment) Type() string

func (MsgMakeOutcomePayment) ValidateBasic added in v0.12.2

func (msg MsgMakeOutcomePayment) ValidateBasic() error

type MsgSell

type MsgSell struct {
	SellerDid did.Did  `json:"seller_did" yaml:"seller_did"`
	Amount    sdk.Coin `json:"amount" yaml:"amount"`
	BondDid   did.Did  `json:"bond_did" yaml:"bond_did"`
}

func NewMsgSell

func NewMsgSell(sellerDid did.Did, amount sdk.Coin, bondDid did.Did) MsgSell

func (MsgSell) GetSignBytes

func (msg MsgSell) GetSignBytes() []byte

func (MsgSell) GetSignerDid

func (msg MsgSell) GetSignerDid() did.Did

func (MsgSell) GetSigners

func (msg MsgSell) GetSigners() []sdk.AccAddress

func (MsgSell) Route

func (msg MsgSell) Route() string

func (MsgSell) Type

func (msg MsgSell) Type() string

func (MsgSell) ValidateBasic

func (msg MsgSell) ValidateBasic() error

type MsgSetNextAlpha added in v0.14.2

type MsgSetNextAlpha struct {
	BondDid   did.Did `json:"bond_did" yaml:"bond_did"`
	Alpha     sdk.Dec `json:"alpha" yaml:"alpha"`
	EditorDid did.Did `json:"editor_did" yaml:"editor_did"`
}

func NewMsgSetNextAlpha added in v0.14.2

func NewMsgSetNextAlpha(alpha sdk.Dec, editorDid, bondDid did.Did) MsgSetNextAlpha

func (MsgSetNextAlpha) GetSignBytes added in v0.14.2

func (msg MsgSetNextAlpha) GetSignBytes() []byte

func (MsgSetNextAlpha) GetSignerDid added in v0.14.2

func (msg MsgSetNextAlpha) GetSignerDid() did.Did

func (MsgSetNextAlpha) GetSigners added in v0.14.2

func (msg MsgSetNextAlpha) GetSigners() []sdk.AccAddress

func (MsgSetNextAlpha) Route added in v0.14.2

func (msg MsgSetNextAlpha) Route() string

func (MsgSetNextAlpha) Type added in v0.14.2

func (msg MsgSetNextAlpha) Type() string

func (MsgSetNextAlpha) ValidateBasic added in v0.14.2

func (msg MsgSetNextAlpha) ValidateBasic() error

type MsgSwap

type MsgSwap struct {
	SwapperDid did.Did  `json:"swapper_did" yaml:"swapper_did"`
	BondDid    did.Did  `json:"bond_did" yaml:"bond_did"`
	From       sdk.Coin `json:"from" yaml:"from"`
	ToToken    string   `json:"to_token" yaml:"to_token"`
}

func NewMsgSwap

func NewMsgSwap(swapperDid did.Did, from sdk.Coin, toToken string,
	bondDid did.Did) MsgSwap

func (MsgSwap) GetSignBytes

func (msg MsgSwap) GetSignBytes() []byte

func (MsgSwap) GetSignerDid

func (msg MsgSwap) GetSignerDid() did.Did

func (MsgSwap) GetSigners

func (msg MsgSwap) GetSigners() []sdk.AccAddress

func (MsgSwap) Route

func (msg MsgSwap) Route() string

func (MsgSwap) Type

func (msg MsgSwap) Type() string

func (MsgSwap) ValidateBasic

func (msg MsgSwap) ValidateBasic() error

type MsgUpdateBondState added in v0.14.2

type MsgUpdateBondState struct {
	BondDid   did.Did   `json:"bond_did" yaml:"bond_did"`
	State     BondState `json:"state" yaml:"state"`
	EditorDid did.Did   `json:"editor_did" yaml:"editor_did"`
}

func NewMsgUpdateBondState added in v0.14.2

func NewMsgUpdateBondState(state BondState, editorDid, bondDid did.Did) MsgUpdateBondState

func (MsgUpdateBondState) GetSignBytes added in v0.14.2

func (msg MsgUpdateBondState) GetSignBytes() []byte

func (MsgUpdateBondState) GetSignerDid added in v0.14.2

func (msg MsgUpdateBondState) GetSignerDid() did.Did

func (MsgUpdateBondState) GetSigners added in v0.14.2

func (msg MsgUpdateBondState) GetSigners() []sdk.AccAddress

func (MsgUpdateBondState) Route added in v0.14.2

func (msg MsgUpdateBondState) Route() string

func (MsgUpdateBondState) Type added in v0.14.2

func (msg MsgUpdateBondState) Type() string

func (MsgUpdateBondState) ValidateBasic added in v0.14.2

func (msg MsgUpdateBondState) ValidateBasic() error

type MsgWithdrawShare added in v0.12.2

type MsgWithdrawShare struct {
	RecipientDid did.Did `json:"recipient_did" yaml:"recipient_did"`
	BondDid      did.Did `json:"bond_did" yaml:"bond_did"`
}

func NewMsgWithdrawShare added in v0.12.2

func NewMsgWithdrawShare(recipientDid, bondDid did.Did) MsgWithdrawShare

func (MsgWithdrawShare) GetSignBytes added in v0.12.2

func (msg MsgWithdrawShare) GetSignBytes() []byte

func (MsgWithdrawShare) GetSignerDid added in v0.12.2

func (msg MsgWithdrawShare) GetSignerDid() did.Did

func (MsgWithdrawShare) GetSigners added in v0.12.2

func (msg MsgWithdrawShare) GetSigners() []sdk.AccAddress

func (MsgWithdrawShare) Route added in v0.12.2

func (msg MsgWithdrawShare) Route() string

func (MsgWithdrawShare) Type added in v0.12.2

func (msg MsgWithdrawShare) Type() string

func (MsgWithdrawShare) ValidateBasic added in v0.12.2

func (msg MsgWithdrawShare) ValidateBasic() error

type Params added in v0.13.0

type Params struct {
	ReservedBondTokens []string `json:"reserved_bond_tokens" yaml:"reserved_bond_tokens"`
}

bonds parameters

func DefaultParams added in v0.13.0

func DefaultParams() Params

default bonds module parameters

func NewParams added in v0.13.0

func NewParams(reservedBondTokens []string) Params

func (*Params) ParamSetPairs added in v0.13.0

func (p *Params) ParamSetPairs() params.ParamSetPairs

Implements params.ParamSet

func (Params) String added in v0.13.0

func (p Params) String() string

type QueryAlphaMaximums added in v0.14.2

type QueryAlphaMaximums struct {
	MaxSystemAlphaIncrease sdk.Dec `json:"max_system_alpha_increase" yaml:"max_system_alpha_increase"`
	MaxSystemAlpha         sdk.Dec `json:"max_system_alpha" yaml:"max_system_alpha"`
}

type QueryBonds

type QueryBonds []string

func (QueryBonds) String

func (b QueryBonds) String() string

type QueryBondsDetailed added in v0.14.2

type QueryBondsDetailed []BondDetails

type QueryBuyPrice

type QueryBuyPrice struct {
	AdjustedSupply sdk.Coin  `json:"adjusted_supply" yaml:"asdjusted_supply"`
	Prices         sdk.Coins `json:"prices" yaml:"prices"`
	TxFees         sdk.Coins `json:"tx_fees" yaml:"tx_fees"`
	TotalPrices    sdk.Coins `json:"total_prices" yaml:"total_prices"`
	TotalFees      sdk.Coins `json:"total_fees" yaml:"total_fees"`
}

type QuerySellReturn

type QuerySellReturn struct {
	AdjustedSupply sdk.Coin  `json:"adjusted_supply" yaml:"asdjusted_supply"`
	Returns        sdk.Coins `json:"returns" yaml:"returns"`
	TxFees         sdk.Coins `json:"tx_fees" yaml:"tx_fees"`
	ExitFees       sdk.Coins `json:"exit_fees" yaml:"exit_fees"`
	TotalReturns   sdk.Coins `json:"total_returns" yaml:"total_returns"`
	TotalFees      sdk.Coins `json:"total_fees" yaml:"total_fees"`
}

type QuerySwapReturn

type QuerySwapReturn struct {
	TotalReturns sdk.Coins `json:"total_returns" yaml:"total_returns"`
	TotalFees    sdk.Coins `json:"total_fees" yaml:"total_fees"`
}

type SellOrder

type SellOrder struct {
	BaseOrder
}

func NewSellOrder

func NewSellOrder(sellerDid did.Did, amount sdk.Coin) SellOrder

type SwapOrder

type SwapOrder struct {
	BaseOrder
	ToToken string `json:"to_token" yaml:"to_token"`
}

func NewSwapOrder

func NewSwapOrder(swapperDid did.Did, from sdk.Coin, toToken string) SwapOrder

Jump to

Keyboard shortcuts

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