keeper

package
v3.0.1-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PubKeys = []crypto.PubKey{
		secp256k1.GenPrivKey().PubKey(),
		secp256k1.GenPrivKey().PubKey(),
		secp256k1.GenPrivKey().PubKey(),
	}

	Addrs = []sdk.AccAddress{
		sdk.AccAddress(PubKeys[0].Address()),
		sdk.AccAddress(PubKeys[1].Address()),
		sdk.AccAddress(PubKeys[2].Address()),
	}

	ValAddrs = []sdk.ValAddress{
		sdk.ValAddress(PubKeys[0].Address()),
		sdk.ValAddress(PubKeys[1].Address()),
		sdk.ValAddress(PubKeys[2].Address()),
	}

	InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
	InitCoins  = sdk.NewCoins(sdk.NewCoin(core.MicroLunaDenom, InitTokens))
)

Test Account

Functions

func FundAccount

func FundAccount(input TestInput, addr sdk.AccAddress, amounts sdk.Coins) error

FundAccount is a utility function that funds an account by minting and sending the coins to the address. This should be used for testing purposes only!

func MakeEncodingConfig

func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig

MakeEncodingConfig

func MakeTestCodec

func MakeTestCodec(t *testing.T) codec.Codec

MakeTestCodec

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the market MsgServer interface for the provided Keeper.

func NewQuerier

func NewQuerier(keeper Keeper) types.QueryServer

NewQuerier returns an implementation of the market QueryServer interface for the provided Keeper.

Types

type Keeper

type Keeper struct {
	AccountKeeper types.AccountKeeper
	BankKeeper    types.BankKeeper
	OracleKeeper  types.OracleKeeper
	// contains filtered or unexported fields
}

Keeper of the market store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey storetypes.StoreKey,
	paramstore paramstypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	oracleKeeper types.OracleKeeper,
) Keeper

NewKeeper constructs a new keeper for oracle

func (Keeper) ApplySwapToPool

func (k Keeper) ApplySwapToPool(ctx sdk.Context, offerCoin sdk.Coin, askCoin sdk.DecCoin) error

ApplySwapToPool updates each pool with offerCoin and askCoin taken from swap operation, OfferPool = OfferPool + offerAmt (Fills the swap pool with offerAmt) AskPool = AskPool - askAmt (Uses askAmt from the swap pool)

func (Keeper) BasePool

func (k Keeper) BasePool(ctx sdk.Context) (res sdk.Dec)

BasePool is liquidity pool(usdr unit) which will be made available per PoolRecoveryPeriod

func (Keeper) ComputeInternalSwap

func (k Keeper) ComputeInternalSwap(ctx sdk.Context, offerCoin sdk.DecCoin, askDenom string) (sdk.DecCoin, error)

ComputeInternalSwap returns the amount of asked DecCoin should be returned for a given offerCoin at the effective exchange rate registered with the oracle. Different from ComputeSwap, ComputeInternalSwap does not charge a spread as its use is system internal.

func (Keeper) ComputeSwap

func (k Keeper) ComputeSwap(ctx sdk.Context, offerCoin sdk.Coin, askDenom string) (retDecCoin sdk.DecCoin, spread sdk.Dec, err error)

ComputeSwap returns the amount of asked coins should be returned for a given offerCoin at the effective exchange rate registered with the oracle. Returns an Error if the swap is recursive, or the coins to be traded are unknown by the oracle, or the amount to trade is too small.

func (Keeper) GetMarketAccount

func (k Keeper) GetMarketAccount(ctx sdk.Context) authtypes.ModuleAccountI

GetMarketAccount returns market ModuleAccount

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams returns the total set of market parameters.

func (Keeper) GetTerraPoolDelta

func (k Keeper) GetTerraPoolDelta(ctx sdk.Context) sdk.Dec

GetTerraPoolDelta returns the gap between the TerraPool and the TerraBasePool

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MinStabilitySpread

func (k Keeper) MinStabilitySpread(ctx sdk.Context) (res sdk.Dec)

MinStabilitySpread is the minimum spread applied to swaps to / from Luna. Intended to prevent swing trades exploiting oracle period delays

func (Keeper) PoolRecoveryPeriod

func (k Keeper) PoolRecoveryPeriod(ctx sdk.Context) (res uint64)

PoolRecoveryPeriod is the period required to recover Terra&Luna Pools to the MintBasePool & BurnBasePool

func (Keeper) ReplenishPools

func (k Keeper) ReplenishPools(ctx sdk.Context)

ReplenishPools replenishes each pool(Terra,Luna) to BasePool

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the total set of market parameters.

func (Keeper) SetTerraPoolDelta

func (k Keeper) SetTerraPoolDelta(ctx sdk.Context, delta sdk.Dec)

SetTerraPoolDelta updates TerraPoolDelta which is gap between the TerraPool and the BasePool

type TestInput

type TestInput struct {
	Ctx           sdk.Context
	Cdc           *codec.LegacyAmino
	AccountKeeper authkeeper.AccountKeeper
	BankKeeper    bankkeeper.Keeper
	OracleKeeper  types.OracleKeeper
	MarketKeeper  Keeper
}

func CreateTestInput

func CreateTestInput(t *testing.T) TestInput

Jump to

Keyboard shortcuts

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