keeper

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

nolint:deadcode unused noalias

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)
	InitCoins  = sdk.NewCoins(sdk.NewCoin(core.MicroLunaDenom, InitTokens))
)

Functions

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func QuerySwap added in v0.4.0

func QuerySwap(ctx sdk.Context, params types.QuerySwapParams, keeper Keeper) (sdk.Coin, error)

QuerySwap interface for simulate swap

Types

type Keeper

type Keeper struct {
	SupplyKeeper types.SupplyKeeper
	// contains filtered or unexported fields
}

Keeper of the oracle store

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey,
	paramspace params.Subspace, oracleKeeper types.OracleKeeper,
	supplyKeeper types.SupplyKeeper) 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 Terra 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 added in v0.4.0

func (k Keeper) GetMarketAccount(ctx sdk.Context) supplyexported.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) (delta sdk.Dec)

GetTerraPoolDelta returns the gap between the TerraPool and the BasePool

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MinStabilitySpread added in v0.4.0

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 int64)

PoolRecoveryPeriod is the period required to recover Terra&Luna Pools to the BasePool

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.Codec
	Acckeeper    auth.AccountKeeper
	OracleKeeper oracle.Keeper
	SupplyKeeper supply.Keeper
	MarketKeeper Keeper
}

TestInput nolint

func CreateTestInput

func CreateTestInput(t *testing.T) TestInput

CreateTestInput nolint

Jump to

Keyboard shortcuts

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