keeper

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SellNative = iota
	BuyNative
	NoSwap
)
View Source
const (
	ErrorEmptyPool = iota
	ErrorNothingAdded
	NeedMoreY // Need more y token to make Y/X == y/x
	Symmetric // Y/X == y/x
	NeedMoreX // Need more x token to make Y/X == y/x
)
View Source
const MaxPageLimit = 200

Variables

This section is empty.

Functions

func Abs added in v0.14.0

func Abs(a int16) uint16

func ApproxRatSquareRoot added in v1.4.0

func ApproxRatSquareRoot(x *big.Rat) *big.Int

func CalcBlockDistribution added in v0.13.5

func CalcBlockDistribution(period *types.RewardPeriod) sdk.Uint

func CalcDenomChangeMultiplier added in v0.14.0

func CalcDenomChangeMultiplier(decimalsX, decimalsY uint8) big.Rat

Denom change multiplier = 10**decimalsX / 10**decimalsY

func CalcProviderDistributionAmount added in v0.13.4

func CalcProviderDistributionAmount(rowanProviderDistribution sdk.Dec, totalPoolUnits, providerPoolUnits sdk.Uint) sdk.Uint

func CalcRowanSpotPrice added in v0.13.4

func CalcRowanSpotPrice(pool *types.Pool, pmtpCurrentRunningRate sdk.Dec) (sdk.Dec, error)

Calculates spot price of Rowan accounting for PMTP

func CalcRowanValue added in v0.13.4

func CalcRowanValue(rowanAmount sdk.Uint, price sdk.Dec) sdk.Uint

func CalcSpotPriceExternal added in v0.14.0

func CalcSpotPriceExternal(pool *types.Pool, decimalsExternal uint8, pmtpCurrentRunningRate sdk.Dec) (sdk.Dec, error)

func CalcSpotPriceNative added in v0.14.0

func CalcSpotPriceNative(pool *types.Pool, decimalsExternal uint8, pmtpCurrentRunningRate sdk.Dec) (sdk.Dec, error)

func CalcSpotPriceX added in v0.14.0

func CalcSpotPriceX(X, Y sdk.Uint, decimalsX, decimalsY uint8, pmtpCurrentRunningRate sdk.Dec, isXNative bool) (sdk.Dec, error)

Calculates the spot price of asset X in the preferred denominations accounting for PMTP. Since this method applies PMTP adjustment, one of X, Y must be the native asset.

func CalcSwapPmtp added in v0.13.0

func CalcSwapPmtp(toRowan bool, y, pmtpCurrentRunningRate sdk.Dec) sdk.Dec

func CalcSwapResult

func CalcSwapResult(toRowan bool,
	X, x, Y sdk.Uint,
	pmtpCurrentRunningRate, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint)

func CalculateAllAssetsForLP

func CalculateAllAssetsForLP(pool types.Pool, lp types.LiquidityProvider) (sdk.Uint, sdk.Uint, sdk.Uint, sdk.Uint)

func CalculateDiscountedSentAmount added in v1.4.0

func CalculateDiscountedSentAmount(sentAmount sdk.Uint, swapFeeRate sdk.Dec) sdk.Uint

func CalculateExternalSwapAmountAsymmetric added in v1.4.0

func CalculateExternalSwapAmountAsymmetric(R, A, r, a sdk.Uint, f, p *big.Rat) sdk.Uint

Calculates how much external asset to swap for an asymmetric add to become symmetric. R - native asset depth A - external asset depth r - native asset amount a - external asset amount f - swap fee rate p - pmtp (ratio shifting) current running rate

Calculates the amount of external asset to swap, s, such that the ratio of the added assets after the swap equals the ratio of assets in the pool after the swap i.e. calculates s, such that (a+A)/(r+R) = (a−s) / (r + s*R/(s+A)*(1−f)/(1+p)).

Solving for s gives, s = math.Abs((math.Sqrt(R*(-1*(a+A))*(-1*f*f*a*R-f*f*A*R-2*f*p*a*R+4*f*p*A*r+2*f*p*A*R+4*f*A*r+4*f*A*R-p*p*a*R-p*p*A*R-4*p*A*r-4*p*A*R-4*A*r-4*A*R)) + f*a*R + f*A*R + p*a*R - 2*p*A*r - p*A*R - 2*A*r - 2*A*R) / (2 * (p + 1) * (r + R))).

This function should only be used when when more native asset is required in order for an add to be symmetric i.e. when R,A,a > 0 and R/A > r/a. If more external asset is required, then due to ratio shifting the swap formula changes, in which case use CalculateNativeSwapAmountAsymmetric.

func CalculateExternalSwapAmountAsymmetricRat added in v1.4.0

func CalculateExternalSwapAmountAsymmetricRat(Y, X, y, x, f, r *big.Rat) big.Rat

NOTE: this method is only exported to make testing easier

NOTE: this method panics if a negative value is passed to the sqrt It's not clear whether this condition could ever happen given the external constraints on the inputs (e.g. X,Y,x > 0 and Y/X > y/x). It is possible to guard against a panic by ensuring the sqrt argument is positive.

func CalculateNativeSwapAmountAsymmetric added in v1.4.0

func CalculateNativeSwapAmountAsymmetric(R, A, r, a sdk.Uint, f, p *big.Rat) sdk.Uint

This function should only be used when when more external asset is required in order for an add to be symmetric i.e. when R,A,r > 0 and (a==0 or R/A < r/a) If more native asset is required, then due to ratio shifting the swap formula changes, in which case use CalculateExternalSwapAmountAsymmetric.

func CalculateNativeSwapAmountAsymmetricRat added in v1.4.0

func CalculateNativeSwapAmountAsymmetricRat(Y, X, y, x, f, r *big.Rat) big.Rat

NOTE: this method is only exported to make testing easier

NOTE: this method panics if a negative value is passed to the sqrt It's not clear whether this condition could ever happen given the constraints on the inputs (i.e. Y,X,y > 0 and (x==0 or Y/X < y/x). It is possible to guard against a panic by ensuring the sqrt argument is positive.

func CalculatePoolUnits

func CalculatePoolUnits(P, R, A, r, a sdk.Uint, sellNativeSwapFeeRate, buyNativeSwapFeeRate, pmtpCurrentRunningRate sdk.Dec) (sdk.Uint, sdk.Uint, int, sdk.Uint, error)

Calculate pool units taking into account the current pmtpCurrentRunningRate R - native asset depth A - external asset depth r - native asset amount a - external asset amount P - current number of pool units

func CalculatePoolUnitsSymmetric added in v1.4.0

func CalculatePoolUnitsSymmetric(X, x, P sdk.Uint) (sdk.Uint, sdk.Uint)

func CalculateWithdrawal

func CalculateWithdrawal(poolUnits sdk.Uint, nativeAssetDepth string,
	externalAssetDepth string, lpUnits string, wBasisPoints string, asymmetry sdk.Int) (sdk.Uint, sdk.Uint, sdk.Uint, sdk.Uint)

More details on the formula https://github.com/Sifchain/sifnode/blob/develop/docs/1.Liquidity%20Pools%20Architecture.md

func CalculateWithdrawalFromUnits added in v0.13.0

func CalculateWithdrawalFromUnits(poolUnits sdk.Uint, nativeAssetDepth string,
	externalAssetDepth string, lpUnits string, withdrawUnits sdk.Uint) (sdk.Uint, sdk.Uint, sdk.Uint)

More details on the formula https://github.com/Sifchain/sifnode/blob/develop/docs/1.Liquidity%20Pools%20Architecture.md

func CalculateWithdrawalRowanValue added in v1.4.0

func CalculateWithdrawalRowanValue(
	sentAmount sdk.Uint,
	to types.Asset,
	pool types.Pool,
	pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint

func CollectProviderDistribution added in v0.13.4

func CollectProviderDistribution(ctx sdk.Context, pool *types.Pool, poolDepthRowan, blockRate sdk.Dec, poolUnits sdk.Uint, lps []ValidLiquidityProvider, globalLpRowanMap LpRowanMap, globalLpPoolMap LpPoolMap) sdk.Uint

func CollectRewards added in v0.13.4

func CollectRewards(ctx sdk.Context, pool *types.Pool, poolDistribution sdk.Uint, poolUnits sdk.Uint, lps []ValidLiquidityProvider, poolRowanMap PoolRowanMap, lpRowanMap LpRowanMap, lpPoolMap LpPoolMap)

func ConvUnitsToWBasisPoints added in v1.4.0

func ConvUnitsToWBasisPoints(total, units sdk.Uint) sdk.Int

func ConvWBasisPointsToUnits added in v1.4.0

func ConvWBasisPointsToUnits(total sdk.Uint, wbasis sdk.Int) sdk.Uint

func CreateEventBlockHeight added in v0.13.4

func CreateEventBlockHeight(ctx sdk.Context, eventType string, attribute sdk.Attribute) sdk.Event

func CreateEventMsg added in v0.13.4

func CreateEventMsg(signer string) sdk.Event

func DecToRat added in v0.14.0

func DecToRat(d *sdk.Dec) big.Rat

func FindProviderDistributionPeriod added in v0.13.4

func FindProviderDistributionPeriod(currentHeight int64, periods []*types.ProviderDistributionPeriod) *types.ProviderDistributionPeriod

func GetLiquidityAddSymmetryState added in v1.4.0

func GetLiquidityAddSymmetryState(X, x, Y, y sdk.Uint) int

Determines how the amount of assets added to a pool, x, y, compare to the current pool ratio, Y/X

func GetPoolMultiplier added in v0.13.4

func GetPoolMultiplier(asset string, period *types.RewardPeriod) sdk.Dec

func GetSwapFee

func GetSwapFee(sentAmount sdk.Uint,
	to types.Asset,
	pool types.Pool,
	pmtpCurrentRunningRate, swapFeeRate sdk.Dec) sdk.Uint

func Int64ToUint8Safe added in v0.14.0

func Int64ToUint8Safe(x int64) (uint8, error)

func IsAnyZero added in v0.14.0

func IsAnyZero(inputs []sdk.Uint) bool

func IsDistributionBlockPure added in v0.13.4

func IsDistributionBlockPure(blockHeight int64, startHeight, mod uint64) bool

do the thing every mod blocks starting at startHeight

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewQuerier

func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

NewQuerier is the module level router for state queries

func PrintPools added in v0.14.0

func PrintPools(pools []LPPool) string

func RatIntQuo added in v0.14.0

func RatIntQuo(r *big.Rat) *big.Int

func RatToDec added in v0.14.0

func RatToDec(r *big.Rat) (sdk.Dec, error)

func RegisterInvariants added in v1.4.0

func RegisterInvariants(registry sdk.InvariantRegistry, k Keeper)

func SwapOne

func SwapOne(from types.Asset,
	sentAmount sdk.Uint,
	to types.Asset,
	pool types.Pool,
	pmtpCurrentRunningRate sdk.Dec, swapFeeRate sdk.Dec) (sdk.Uint, sdk.Uint, sdk.Uint, types.Pool, error)

Types

type FormattedPool added in v0.13.5

type FormattedPool struct {
	Pool   string   `json:"pool"`
	Amount sdk.Uint `json:"amount"`
}

type Hooks added in v1.4.0

type Hooks struct {
	// contains filtered or unexported fields
}

Hooks wrapper struct for commitments keeper

func (Hooks) AfterEpochEnd added in v1.4.0

func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64)

AfterEpochEnd implements EpochHooks

func (Hooks) BeforeEpochStart added in v1.4.0

func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)

BeforeEpochStart implements EpochHooks

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper of the clp store

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, bankkeeper types.BankKeeper, accountKeeper types.AuthKeeper,
	tokenRegistryKeeper tokenregistrytypes.Keeper, adminKeeper types.AdminKeeper, mintKeeper mintkeeper.Keeper, getMarginKeeper func() margintypes.Keeper, ps paramtypes.Subspace) Keeper

NewKeeper creates a clp keeper

func (Keeper) AddLiquidity

func (k Keeper) AddLiquidity(ctx sdk.Context, msg *types.MsgAddLiquidity, pool types.Pool, newPoolUnits sdk.Uint, lpUnits sdk.Uint) (*types.LiquidityProvider, error)

func (Keeper) AddLiquidityToRewardsBucket added in v1.4.0

func (k Keeper) AddLiquidityToRewardsBucket(ctx sdk.Context, signer string, amounts sdk.Coins) (sdk.Coins, error)

func (Keeper) AddMultipleCoinsToRewardsBuckets added in v1.4.0

func (k Keeper) AddMultipleCoinsToRewardsBuckets(ctx sdk.Context, coins sdk.Coins) (sdk.Coins, error)

AddMultipleCoinsToRewardsBuckets adds multiple coin amounts to their respective RewardsBuckets

func (Keeper) AddRewardAmountToLiquidityPool added in v1.4.0

func (k Keeper) AddRewardAmountToLiquidityPool(ctx sdk.Context, liquidityProvider *types.LiquidityProvider, asset types.Asset, rewardAmount sdk.Int) error

AddRewardAmountToLiquidityPool adds a new reward amount to a liquidity pool

func (Keeper) AddToRewardsBucket added in v1.4.0

func (k Keeper) AddToRewardsBucket(ctx sdk.Context, denom string, amount sdk.Int) error

AddToRewardsBucket adds an amount to a specific RewardsBucket in the store, or creates a new RewardsBucket if one does not already exist for the denom.

func (Keeper) AfterEpochEnd added in v1.4.0

func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ int64)

AfterEpochEnd distributes available rewards from rewards bucket to liquidity providers

func (Keeper) BalanceModuleAccountCheck added in v1.4.0

func (k Keeper) BalanceModuleAccountCheck() sdk.Invariant

func (Keeper) BeforeEpochStart added in v1.4.0

func (k Keeper) BeforeEpochStart(_ sdk.Context, _ string, _ int64)

BeforeEpochStart performs a no-op

func (Keeper) BurnRowan added in v0.13.4

func (k Keeper) BurnRowan(ctx sdk.Context, amount sdk.Int) error

func (Keeper) CLPCalcSwap added in v0.15.0

func (k Keeper) CLPCalcSwap(ctx sdk.Context, sentAmount sdk.Uint, to types.Asset, pool types.Pool, marginEnabled bool) (sdk.Uint, error)

func (Keeper) CalculateRewardAmountForLiquidityProviders added in v1.4.0

func (k Keeper) CalculateRewardAmountForLiquidityProviders(
	ctx sdk.Context,
	rewardShares []sdk.Dec,
	rewardsBucketAmount sdk.Int,
) []sdk.Int

CalculateRewardAmountForLiquidityProviders calculates the reward amount for each liquidity provider

func (Keeper) CalculateRewardShareForLiquidityProviders added in v1.4.0

func (k Keeper) CalculateRewardShareForLiquidityProviders(
	ctx sdk.Context,
	lps []*types.LiquidityProvider,
) []sdk.Dec

calculate the reward share for each liquidity provider

func (Keeper) Codec

func (k Keeper) Codec() codec.BinaryCodec

func (Keeper) CollectProviderDistributions added in v0.13.4

func (k Keeper) CollectProviderDistributions(ctx sdk.Context, pools []*types.Pool, blockRate sdk.Dec) (PoolRowanMap, LpRowanMap, LpPoolMap)

func (Keeper) CreateLiquidityProvider

func (k Keeper) CreateLiquidityProvider(ctx sdk.Context, asset *types.Asset, lpunits sdk.Uint, lpaddress sdk.AccAddress) types.LiquidityProvider

func (Keeper) CreatePool

func (k Keeper) CreatePool(ctx sdk.Context, poolUints sdk.Uint, msg *types.MsgCreatePool) (*types.Pool, error)

func (Keeper) DecommissionPool

func (k Keeper) DecommissionPool(ctx sdk.Context, pool types.Pool) error

func (Keeper) DecrementPmtpBlockCounter added in v0.13.4

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

func (Keeper) DecrementPmtpEpochCounter added in v0.13.4

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

func (Keeper) DequeueRemovalRequest added in v1.4.0

func (k Keeper) DequeueRemovalRequest(ctx sdk.Context, request types.RemovalRequest)

func (Keeper) DestroyLiquidityProvider

func (k Keeper) DestroyLiquidityProvider(ctx sdk.Context, symbol string, lpAddress string)

func (Keeper) DestroyPool

func (k Keeper) DestroyPool(ctx sdk.Context, symbol string) error

func (Keeper) DistributeDepthRewards added in v0.13.0

func (k Keeper) DistributeDepthRewards(ctx sdk.Context, blockDistribution sdk.Uint, period *types.RewardPeriod, pools []*types.Pool) error

func (Keeper) DistributeLiquidityProviderRewards added in v1.4.0

func (k Keeper) DistributeLiquidityProviderRewards(ctx sdk.Context, lp *types.LiquidityProvider, asset string, rewardAmount sdk.Int) error

DistributeLiquidityProviderRewards distributes rewards to a liquidity provider

func (Keeper) Exists

func (k Keeper) Exists(ctx sdk.Context, key []byte) bool

func (Keeper) ExistsClpWhiteList

func (k Keeper) ExistsClpWhiteList(ctx sdk.Context) bool

func (Keeper) ExistsPool

func (k Keeper) ExistsPool(ctx sdk.Context, symbol string) bool

func (Keeper) FinalizeSwap

func (k Keeper) FinalizeSwap(ctx sdk.Context, sentAmount string, finalPool types.Pool, msg types.MsgSwap) error

func (Keeper) GetAllLiquidityProviders added in v0.13.6

func (k Keeper) GetAllLiquidityProviders(ctx sdk.Context) ([]*types.LiquidityProvider, error)

func (Keeper) GetAllLiquidityProvidersForAsset added in v0.13.4

func (k Keeper) GetAllLiquidityProvidersForAsset(ctx sdk.Context, asset types.Asset) ([]*types.LiquidityProvider, error)

func (Keeper) GetAllLiquidityProvidersPaginated

func (k Keeper) GetAllLiquidityProvidersPaginated(ctx sdk.Context,
	pagination *query.PageRequest) ([]*types.LiquidityProvider, *query.PageResponse, error)

func (Keeper) GetAllLiquidityProvidersPartitions added in v0.13.6

func (k Keeper) GetAllLiquidityProvidersPartitions(ctx sdk.Context) (map[types.Asset][]*types.LiquidityProvider, error)

func (Keeper) GetAllRewardsBucket added in v1.4.0

func (k Keeper) GetAllRewardsBucket(ctx sdk.Context) (list []types.RewardsBucket)

GetAllRewardsBucket returns all rewardsBucket

func (Keeper) GetAssetDecimals added in v0.14.0

func (k Keeper) GetAssetDecimals(ctx sdk.Context, asset types.Asset) (uint8, error)

func (Keeper) GetAssetsForLiquidityProviderPaginated

func (k Keeper) GetAssetsForLiquidityProviderPaginated(ctx sdk.Context, lpAddress sdk.AccAddress,
	pagination *query.PageRequest) ([]*types.Asset, *query.PageResponse, error)

func (Keeper) GetAuthKeeper

func (k Keeper) GetAuthKeeper() types.AuthKeeper

func (Keeper) GetBankKeeper

func (k Keeper) GetBankKeeper() types.BankKeeper

func (Keeper) GetBlockDistributionAccu added in v0.13.5

func (k Keeper) GetBlockDistributionAccu(ctx sdk.Context) sdk.Uint

func (Keeper) GetClpWhiteList

func (k Keeper) GetClpWhiteList(ctx sdk.Context) []sdk.AccAddress

func (Keeper) GetCurrentRewardPeriod added in v0.13.0

func (k Keeper) GetCurrentRewardPeriod(ctx sdk.Context, params *types.RewardParams) *types.RewardPeriod

func (Keeper) GetLiquidityProtectionParams added in v0.13.4

func (k Keeper) GetLiquidityProtectionParams(ctx sdk.Context) *types.LiquidityProtectionParams

func (Keeper) GetLiquidityProtectionRateParams added in v0.13.4

func (k Keeper) GetLiquidityProtectionRateParams(ctx sdk.Context) types.LiquidityProtectionRateParams

func (Keeper) GetLiquidityProvider

func (k Keeper) GetLiquidityProvider(ctx sdk.Context, symbol string, lpAddress string) (types.LiquidityProvider, error)

func (Keeper) GetLiquidityProviderIterator

func (k Keeper) GetLiquidityProviderIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) GetLiquidityProvidersForAssetPaginated

func (k Keeper) GetLiquidityProvidersForAssetPaginated(ctx sdk.Context, asset types.Asset,
	pagination *query.PageRequest) ([]*types.LiquidityProvider, *query.PageResponse, error)

func (Keeper) GetMarginKeeper added in v1.4.0

func (k Keeper) GetMarginKeeper() margintypes.Keeper

func (Keeper) GetMinCreatePoolThreshold

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

func (Keeper) GetModuleRowan added in v0.13.4

func (k Keeper) GetModuleRowan(ctx sdk.Context) sdk.Coin

func (Keeper) GetNativePrice added in v1.4.0

func (k Keeper) GetNativePrice(ctx sdk.Context) (sdk.Dec, error)

Currently this calculates the native price on the fly Calculates the price of the native token in MaxRowanLiquidityThresholdAsset

func (Keeper) GetParams

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

func (Keeper) GetPmtpEpoch added in v0.13.0

func (k Keeper) GetPmtpEpoch(ctx sdk.Context) types.PmtpEpoch

func (Keeper) GetPmtpParams added in v0.13.0

func (k Keeper) GetPmtpParams(ctx sdk.Context) *types.PmtpParams

func (Keeper) GetPmtpRateParams added in v0.13.0

func (k Keeper) GetPmtpRateParams(ctx sdk.Context) types.PmtpRateParams

func (Keeper) GetPool

func (k Keeper) GetPool(ctx sdk.Context, symbol string) (types.Pool, error)

func (Keeper) GetPools

func (k Keeper) GetPools(ctx sdk.Context) []*types.Pool

GetPools Use GetPoolsPaginated for RPC queries

func (Keeper) GetPoolsIterator

func (k Keeper) GetPoolsIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) GetPoolsPaginated

func (k Keeper) GetPoolsPaginated(ctx sdk.Context, pagination *query.PageRequest) ([]*types.Pool, *query.PageResponse, error)

func (Keeper) GetProviderDistributionParams added in v0.13.4

func (k Keeper) GetProviderDistributionParams(ctx sdk.Context) *types.ProviderDistributionParams

func (Keeper) GetRemovalQueue added in v1.4.0

func (k Keeper) GetRemovalQueue(ctx sdk.Context, symbol string) types.RemovalQueue

func (Keeper) GetRemovalQueueIterator added in v1.4.0

func (k Keeper) GetRemovalQueueIterator(ctx sdk.Context) sdk.Iterator

func (Keeper) GetRemovalQueueUnitsForLP added in v1.4.0

func (k Keeper) GetRemovalQueueUnitsForLP(ctx sdk.Context, lp types.LiquidityProvider) sdk.Uint

func (Keeper) GetRewardsBucket added in v1.4.0

func (k Keeper) GetRewardsBucket(
	ctx sdk.Context,
	denom string,
) (val types.RewardsBucket, found bool)

GetRewardsBucket returns a rewardsBucket from its index

func (Keeper) GetRewardsEligibleLiquidityProviders added in v1.4.0

func (k Keeper) GetRewardsEligibleLiquidityProviders(ctx sdk.Context) (map[types.Asset][]*types.LiquidityProvider, error)

function that uses GetAllLiquidityProvidersPartitions to get all LPs by asset and filter out the ones that are not eligible for rewards, return a partitioned map of LPs

func (Keeper) GetRewardsParams added in v0.13.0

func (k Keeper) GetRewardsParams(ctx sdk.Context) *types.RewardParams

func (Keeper) GetSwapFeeParams added in v1.4.0

func (k Keeper) GetSwapFeeParams(ctx sdk.Context) types.SwapFeeParams

func (Keeper) GetSwapFeeRate added in v0.17.0

func (k Keeper) GetSwapFeeRate(ctx sdk.Context, asset types.Asset, marginEnabled bool) sdk.Dec

func (Keeper) GetSymmetryRatio added in v0.13.3

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

func (Keeper) GetSymmetryThreshold added in v0.13.1

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

func (Keeper) HasBalance

func (k Keeper) HasBalance(ctx sdk.Context, addr sdk.AccAddress, coin sdk.Coin) bool

func (Keeper) Hooks added in v1.4.0

func (k Keeper) Hooks() Hooks

Return the wrapper struct

func (Keeper) InitiateSwap

func (k Keeper) InitiateSwap(ctx sdk.Context, sentCoin sdk.Coin, swapper sdk.AccAddress) error

func (Keeper) IsBlockedByLiquidityProtection added in v1.4.0

func (k Keeper) IsBlockedByLiquidityProtection(ctx sdk.Context, nativeAmount sdk.Uint, nativePrice sdk.Dec) bool

The nativePrice should be in MaxRowanLiquidityThresholdAsset

func (Keeper) IsDistributionBlock added in v0.13.4

func (k Keeper) IsDistributionBlock(ctx sdk.Context) bool

func (Keeper) IsInsidePmtpWindow added in v0.13.0

func (k Keeper) IsInsidePmtpWindow(ctx sdk.Context) bool

func (Keeper) IsRemovalQueueEnabled added in v0.15.0

func (k Keeper) IsRemovalQueueEnabled(ctx sdk.Context) (enable bool)

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MustUpdateLiquidityProtectionThreshold added in v1.4.0

func (k Keeper) MustUpdateLiquidityProtectionThreshold(ctx sdk.Context, sellNative bool, nativeAmount sdk.Uint, nativePrice sdk.Dec)

This method should only be called if buying or selling native asset. If sellNative is false then this method assumes that buyNative is true. The nativePrice should be in MaxRowanLiquidityThresholdAsset NOTE: this method panics if sellNative is true and the value of the sell amount is greater than the value of currentRowanLiquidityThreshold. Call IsBlockedByLiquidityProtection before if unsure.

func (Keeper) ParseToInt

func (k Keeper) ParseToInt(nu string) (sdk.Int, bool)

Use strings instead of Unit/Int in between conventions

func (Keeper) PolicyCalculations added in v0.13.0

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

func (Keeper) PolicyRun added in v0.13.0

func (k Keeper) PolicyRun(ctx sdk.Context, pmtpCurrentRunningRate sdk.Dec) error

NOTE: the code in this method must not panic otherwise the chain will halt see: https://bytemeta.vip/repo/osmosis-labs/osmosis/issues/1305

func (Keeper) PolicyStart added in v0.13.0

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

func (Keeper) ProcessRemovalQueue added in v1.4.0

func (k Keeper) ProcessRemovalQueue(ctx sdk.Context, msg *types.MsgAddLiquidity, unitsToDistribute sdk.Uint)

func (Keeper) ProcessRemoveLiquidityMsg added in v1.4.0

func (k Keeper) ProcessRemoveLiquidityMsg(ctx sdk.Context, msg *types.MsgRemoveLiquidity) (sdk.Int, sdk.Int, sdk.Uint, error)

func (Keeper) ProviderDistributionPolicyRun added in v0.13.4

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

func (Keeper) PruneUnlockRecords added in v0.13.0

func (k Keeper) PruneUnlockRecords(ctx sdk.Context, lp *types.LiquidityProvider, lockPeriod, cancelPeriod uint64)

func (Keeper) QueueRemoval added in v1.4.0

func (k Keeper) QueueRemoval(ctx sdk.Context, msg *types.MsgRemoveLiquidity, rowanValue sdk.Uint)

func (Keeper) RemoveLiquidity

func (k Keeper) RemoveLiquidity(ctx sdk.Context, pool types.Pool, externalAssetCoin sdk.Coin,
	nativeAssetCoin sdk.Coin, lp types.LiquidityProvider, lpUnitsLeft, poolOriginalEB, poolOriginalNB sdk.Uint) error

func (Keeper) RemoveLiquidityProvider

func (k Keeper) RemoveLiquidityProvider(ctx sdk.Context, coins sdk.Coins, lp types.LiquidityProvider) error

func (Keeper) RemoveRewardsBucket added in v1.4.0

func (k Keeper) RemoveRewardsBucket(
	ctx sdk.Context,
	denom string,
)

RemoveRewardsBucket removes a rewardsBucket from the store

func (Keeper) RemoveRowanFromPool added in v0.13.4

func (k Keeper) RemoveRowanFromPool(ctx sdk.Context, pool *types.Pool, amount sdk.Uint) error

func (Keeper) SendCoins

func (k Keeper) SendCoins(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, coins sdk.Coins) error

func (Keeper) SendRowanFromPool added in v0.13.4

func (k Keeper) SendRowanFromPool(ctx sdk.Context, pool *types.Pool, amount sdk.Uint, recipient sdk.AccAddress) error

func (Keeper) SendRowanFromPoolNoPoolUpdate added in v0.13.4

func (k Keeper) SendRowanFromPoolNoPoolUpdate(ctx sdk.Context, pool *types.Pool, amount sdk.Uint, recipient sdk.AccAddress) error

func (Keeper) SetBlockDistributionAccu added in v0.13.5

func (k Keeper) SetBlockDistributionAccu(ctx sdk.Context, blockDistribution sdk.Uint)

func (Keeper) SetClpWhiteList

func (k Keeper) SetClpWhiteList(ctx sdk.Context, validatorList []sdk.AccAddress)

func (Keeper) SetLiquidityProtectionCurrentRowanLiquidityThreshold added in v0.13.4

func (k Keeper) SetLiquidityProtectionCurrentRowanLiquidityThreshold(ctx sdk.Context, currentRowanLiquidityThreshold sdk.Uint)

func (Keeper) SetLiquidityProtectionParams added in v0.13.4

func (k Keeper) SetLiquidityProtectionParams(ctx sdk.Context, params *types.LiquidityProtectionParams)

func (Keeper) SetLiquidityProtectionRateParams added in v0.13.4

func (k Keeper) SetLiquidityProtectionRateParams(ctx sdk.Context, params types.LiquidityProtectionRateParams)

func (Keeper) SetLiquidityProvider

func (k Keeper) SetLiquidityProvider(ctx sdk.Context, lp *types.LiquidityProvider)

func (Keeper) SetParams

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

set the params

func (Keeper) SetPmtpBlockCounter added in v0.13.4

func (k Keeper) SetPmtpBlockCounter(ctx sdk.Context, epochLength int64)

func (Keeper) SetPmtpBlockRate added in v0.13.0

func (k Keeper) SetPmtpBlockRate(ctx sdk.Context, blockRate sdk.Dec)

func (Keeper) SetPmtpCurrentRunningRate added in v0.13.0

func (k Keeper) SetPmtpCurrentRunningRate(ctx sdk.Context, runningRate sdk.Dec)

func (Keeper) SetPmtpEpoch added in v0.13.0

func (k Keeper) SetPmtpEpoch(ctx sdk.Context, params types.PmtpEpoch)

func (Keeper) SetPmtpInterPolicyRate added in v0.13.0

func (k Keeper) SetPmtpInterPolicyRate(ctx sdk.Context, interPolicyRate sdk.Dec)

func (Keeper) SetPmtpParams added in v0.13.0

func (k Keeper) SetPmtpParams(ctx sdk.Context, params *types.PmtpParams)

func (Keeper) SetPmtpRateParams added in v0.13.0

func (k Keeper) SetPmtpRateParams(ctx sdk.Context, params types.PmtpRateParams)

func (Keeper) SetPool

func (k Keeper) SetPool(ctx sdk.Context, pool *types.Pool) error

func (Keeper) SetProcessedRemovalRequest added in v1.4.0

func (k Keeper) SetProcessedRemovalRequest(ctx sdk.Context, request types.RemovalRequest, pointsProcessed sdk.Int, rowanRemoved sdk.Uint)

func (Keeper) SetProviderDistributionParams added in v0.13.4

func (k Keeper) SetProviderDistributionParams(ctx sdk.Context, params *types.ProviderDistributionParams)

func (Keeper) SetRemovalQueue added in v1.4.0

func (k Keeper) SetRemovalQueue(ctx sdk.Context, queue types.RemovalQueue, symbol string)

func (Keeper) SetRewardParams added in v0.13.0

func (k Keeper) SetRewardParams(ctx sdk.Context, params *types.RewardParams)

func (Keeper) SetRewardsBucket added in v1.4.0

func (k Keeper) SetRewardsBucket(ctx sdk.Context, rewardsBucket types.RewardsBucket)

SetRewardsBucket set a specific rewardsBucket in the store from its index

func (Keeper) SetSwapFeeParams added in v1.4.0

func (k Keeper) SetSwapFeeParams(ctx sdk.Context, params *types.SwapFeeParams)

func (Keeper) SetSymmetryThreshold added in v0.13.1

func (k Keeper) SetSymmetryThreshold(ctx sdk.Context, setThreshold *types.MsgSetSymmetryThreshold)

func (Keeper) ShouldDistributeRewards added in v1.4.0

func (k Keeper) ShouldDistributeRewards(ctx sdk.Context, epochIdentifier string) bool

func (Keeper) ShouldDistributeRewardsToLPWallet added in v1.4.0

func (k Keeper) ShouldDistributeRewardsToLPWallet(ctx sdk.Context) bool

func (Keeper) SingleExternalBalanceModuleAccountCheck added in v1.4.0

func (k Keeper) SingleExternalBalanceModuleAccountCheck(externalAsset string) sdk.Invariant

func (Keeper) SubtractFromRewardsBucket added in v1.4.0

func (k Keeper) SubtractFromRewardsBucket(ctx sdk.Context, denom string, amount sdk.Int) error

SubtractFromRewardsBucket subtracts an amount from a specific RewardsBucket in the store

func (Keeper) TransferProviderDistribution added in v0.13.4

func (k Keeper) TransferProviderDistribution(ctx sdk.Context, poolRowanMap PoolRowanMap, lpRowanMap LpRowanMap, lpPoolMap LpPoolMap)

func (Keeper) TransferProviderDistributionGeneric added in v0.13.4

func (k Keeper) TransferProviderDistributionGeneric(ctx sdk.Context, poolRowanMap PoolRowanMap, lpRowanMap LpRowanMap, lpPoolMap LpPoolMap, typeStr string, successEventType string)

func (Keeper) TransferRewards added in v0.13.4

func (k Keeper) TransferRewards(ctx sdk.Context, poolRowanMap PoolRowanMap, lpRowanMap LpRowanMap, lpPoolMap LpPoolMap)

func (Keeper) UnitsCheck added in v1.4.0

func (k Keeper) UnitsCheck() sdk.Invariant

func (Keeper) UseUnlockedLiquidity added in v0.13.0

func (k Keeper) UseUnlockedLiquidity(ctx sdk.Context, lp types.LiquidityProvider, units sdk.Uint, any bool) error

func (Keeper) ValidateAddress

func (k Keeper) ValidateAddress(ctx sdk.Context, address sdk.AccAddress) bool

func (Keeper) ValidatePool

func (k Keeper) ValidatePool(pool types.Pool) bool

type LPPool added in v0.13.4

type LPPool struct {
	Pool   *types.Pool
	Amount sdk.Uint
}

func PoolRowanMapToLPPools added in v0.14.0

func PoolRowanMapToLPPools(poolRowanMap PoolRowanMap) []LPPool

type LpPoolMap added in v0.13.4

type LpPoolMap map[string][]LPPool

type LpRowanMap added in v0.13.4

type LpRowanMap map[string]sdk.Uint

type Migrator added in v0.13.0

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator added in v0.13.0

func NewMigrator(keeper Keeper) Migrator

func (Migrator) MigrateToVer2 added in v0.13.0

func (m Migrator) MigrateToVer2(ctx sdk.Context) error

func (Migrator) MigrateToVer3 added in v0.13.3

func (m Migrator) MigrateToVer3(ctx sdk.Context) error

func (Migrator) MigrateToVer4 added in v1.4.0

func (m Migrator) MigrateToVer4(ctx sdk.Context) error

func (Migrator) MigrateToVer5 added in v1.4.0

func (m Migrator) MigrateToVer5(ctx sdk.Context) error

type PoolReward added in v0.13.4

type PoolReward struct {
	Pool   *types.Pool
	Reward sdk.Uint
}

func CollectPoolRewardTuples added in v0.13.4

func CollectPoolRewardTuples(pools []*types.Pool, blockDistribution sdk.Uint, totalDepth sdk.Dec, period *types.RewardPeriod) ([]PoolReward, sdk.Uint)

type PoolRowanMap added in v0.13.4

type PoolRowanMap map[*types.Pool]sdk.Uint

type Querier

type Querier struct {
	Keeper Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper

func (Querier) GetAssetList

func (k Querier) GetAssetList(c context.Context, req *types.AssetListReq) (*types.AssetListRes, error)

func (Querier) GetLiquidityProtectionParams added in v0.13.4

func (Querier) GetLiquidityProvider

func (k Querier) GetLiquidityProvider(c context.Context, req *types.LiquidityProviderReq) (*types.LiquidityProviderRes, error)

func (Querier) GetLiquidityProviders

func (k Querier) GetLiquidityProviders(c context.Context, req *types.LiquidityProvidersReq) (*types.LiquidityProvidersRes, error)

func (Querier) GetParams added in v0.13.0

func (k Querier) GetParams(c context.Context, _ *types.ParamsReq) (*types.ParamsRes, error)

func (Querier) GetPmtpParams added in v0.13.0

func (k Querier) GetPmtpParams(c context.Context, _ *types.PmtpParamsReq) (*types.PmtpParamsRes, error)

func (Querier) GetPool

func (k Querier) GetPool(c context.Context, req *types.PoolReq) (*types.PoolRes, error)

func (Querier) GetPoolShareEstimate added in v1.4.0

func (k Querier) GetPoolShareEstimate(c context.Context, req *types.PoolShareEstimateReq) (*types.PoolShareEstimateRes, error)

func (Querier) GetPools

func (k Querier) GetPools(c context.Context, req *types.PoolsReq) (*types.PoolsRes, error)

func (Querier) GetProviderDistributionParams added in v0.13.4

func (Querier) GetRewardParams added in v0.13.0

func (k Querier) GetRewardParams(c context.Context, _ *types.RewardParamsReq) (*types.RewardParamsRes, error)

func (Querier) GetRewardsBucket added in v1.4.0

func (k Querier) GetRewardsBucket(goCtx context.Context, req *types.RewardsBucketReq) (*types.RewardsBucketRes, error)

func (Querier) GetRewardsBucketAll added in v1.4.0

func (k Querier) GetRewardsBucketAll(goCtx context.Context, req *types.AllRewardsBucketReq) (*types.AllRewardsBucketRes, error)

func (Querier) GetSwapFeeParams added in v1.4.0

func (k Querier) GetSwapFeeParams(c context.Context, _ *types.SwapFeeParamsReq) (*types.SwapFeeParamsRes, error)

type ValidLiquidityProvider added in v0.13.4

type ValidLiquidityProvider struct {
	Address sdk.AccAddress
	LP      *types.LiquidityProvider
}

func FilterValidLiquidityProviders added in v0.13.4

func FilterValidLiquidityProviders(ctx sdk.Context, lps []*types.LiquidityProvider) []ValidLiquidityProvider

Jump to

Keyboard shortcuts

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