keeper

package
v0.0.0-...-891b8cb Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

NewMsgServerImpl creates and returns a new types.MsgServer, fulfilling the ibcstaking Msg service interface

func NewQuerier

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

NewQuerier returns a new sdk.Keeper instance.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers the gal module invariants

Types

type DepositState

type DepositState int64
const (
	DEPOSIT_REQUEST DepositState = iota + 1
	DEPOSIT_SUCCESS
	DELEGATE_REQUEST
	DELEGATE_SUCCESS
)

type Hooks

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

Hooks wrapper struct for gal keeper

func (Hooks) AfterAutoStakingEnd

func (h Hooks) AfterAutoStakingEnd()

func (Hooks) AfterDelegateEnd

func (h Hooks) AfterDelegateEnd(ctx sdk.Context, delegateMsg stakingtypes.MsgDelegate)

delegateAddr(controllerAddr), validatorAddr, delegateAmt

func (Hooks) AfterTransferEnd

func (h Hooks) AfterTransferEnd(ctx sdk.Context, data transfertypes.FungibleTokenPacketData, baseDenom string)

AfterTransferEnd coins user deposit information. It will be used in share token minting process.

func (Hooks) AfterUndelegateEnd

func (h Hooks) AfterUndelegateEnd(ctx sdk.Context, undelegateMsg stakingtypes.MsgUndelegate, msg *stakingtypes.MsgUndelegateResponse)

AfterUndelegateEnd is executed when ICA undelegation request finished. 1. It removes undelegation history in store. 2. It saves undelegation finish time to store.

func (Hooks) AfterWithdrawEnd

func (h Hooks) AfterWithdrawEnd(ctx sdk.Context, transferMsg transfertypes.MsgTransfer)

ica transfer

func (Hooks) BeforeUndelegateStart

func (h Hooks) BeforeUndelegateStart(ctx sdk.Context, zoneId string)

type Keeper

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

Keeper defines a module interface that facilitates the transfer of coins between accounts.

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec,
	key sdk.StoreKey,
	paramSpace paramtypes.Subspace,
	bankKeeper types.BankKeeper,
	accountKeeper types.AccountKeeper,
	ibcstakingKeeper ibcstakingKeeper.Keeper,
	ibcTransferKeeper transfer.Keeper,
	oracleKeeper oraclekeeper.Keeper) Keeper

func (Keeper) BurnShareTokens

func (k Keeper) BurnShareTokens(ctx sdk.Context, burner sdk.Address, amt sdk.Coin) error

BurnShareTokens burns share token.

func (Keeper) CalculateDepositAlpha

func (k Keeper) CalculateDepositAlpha(userDepositAmt, totalShareTokenSupply, totalStakedAmount *big.Int) *big.Int

CalculateDepositAlpha calculates alpha value. Alpha = userDepositAmount / totalStakedAmount Delta = Alpha * totalShareTokenSupply

func (Keeper) CalculateWithdrawAlpha

func (k Keeper) CalculateWithdrawAlpha(burnedStTokenAmt, totalShareTokenSupply, totalStakedAmount *big.Int) *big.Int

CalculateWithdrawAlpha calculates lambda value. Lambda = userWithdrawAmount / totalStakedAmount Delta = Lambda * totalShareTokenSupply

func (Keeper) ChangeDepositState

func (k Keeper) ChangeDepositState(ctx sdk.Context, zoneId string, preState, postState DepositState)

func (Keeper) ChangeUndelegateState

func (k Keeper) ChangeUndelegateState(ctx sdk.Context, zoneId string, state UndelegatedState)

ChangeUndelegateState changes undelegate record. UNDELEGATE_REQUEST_USER : Just requested undelegate by user. It is not in undelegate period. UNDELEGATE_REQUEST_ICA : Requested by ICA, It is in undelegate period.

func (Keeper) ChangeWithdrawState

func (k Keeper) ChangeWithdrawState(ctx sdk.Context, zoneId string, preState, postState WithdrawRegisterType)

func (Keeper) ClaimAndMintShareToken

func (k Keeper) ClaimAndMintShareToken(ctx sdk.Context, claimer sdk.AccAddress, asset sdk.Coin, transferPortId, transferChanId string) (sdk.Coin, error)

ClaimAndMintShareToken is used when user want to claim their share token. It calculates user's share and the amount of claimable share token.

func (Keeper) ClaimWithdrawAsset

func (k Keeper) ClaimWithdrawAsset(ctx sdk.Context, from sdk.AccAddress, withdrawer sdk.AccAddress, amt sdk.Coin) error

ClaimWithdrawAsset is used when user want to claim their asset which is after undeleagted.

func (Keeper) ClearRecordedDepositAmt

func (k Keeper) ClearRecordedDepositAmt(ctx sdk.Context, zoneId string, depositor sdk.AccAddress) error

ClearRecordedDepositAmt remove all data in "DepositRecord". It must be removed after staking in host chain.

func (Keeper) DeleteRecordedDepositItem

func (k Keeper) DeleteRecordedDepositItem(ctx sdk.Context, zoneId string, depositor sdk.AccAddress, state DepositState) error

func (Keeper) DeleteUndelegateRecords

func (k Keeper) DeleteUndelegateRecords(ctx sdk.Context, zoneId string, state UndelegatedState)

DeleteUndelegateRecords removes undelegate record.

func (Keeper) DeleteWithdrawRecord

func (k Keeper) DeleteWithdrawRecord(ctx sdk.Context, withdraw types.WithdrawRecord)

DeleteWithdrawRecord removes withdraw record.

func (Keeper) GetAllAmountNotMintShareToken

func (k Keeper) GetAllAmountNotMintShareToken(ctx sdk.Context, zoneId, transferPortId, transferChanId string) (sdk.Coin, error)

func (Keeper) GetAllUndelegateRecord

func (k Keeper) GetAllUndelegateRecord(ctx sdk.Context, zoneId string) []types.UndelegateRecord

GetAllUndelegateRecord returns all undelegate record.

func (Keeper) GetParams

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

GetParams returns total set of gal parameters.

func (Keeper) GetRecordedDepositAmt

func (k Keeper) GetRecordedDepositAmt(ctx sdk.Context, zoneId string, depositor sdk.AccAddress) (*types.DepositRecord, error)

GetRecordedDepositAmt returns the amount of coin user deposit by address.

func (Keeper) GetTotalDepositAmtForZoneId

func (k Keeper) GetTotalDepositAmtForZoneId(ctx sdk.Context, zoneId, denom string, state DepositState) sdk.Coin

GetTotalDepositAmtForZoneId : delegate를 위한 TotlaDepositAmt로, 해당 zone에서 deposit 완료된 금액을 받아서 반환하는 함수

func (Keeper) GetTotalStakedForLazyMinting

func (k Keeper) GetTotalStakedForLazyMinting(ctx sdk.Context, denom, transferPortId, transferChanId string) (sdk.Coin, error)

func (Keeper) GetTotalWithdrawAmountForZoneId

func (k Keeper) GetTotalWithdrawAmountForZoneId(ctx sdk.Context, zoneId string, blockTime time.Time) sdk.Coin

func (Keeper) GetUndelegateAmount

func (k Keeper) GetUndelegateAmount(ctx sdk.Context, denom string, zoneId string, state UndelegatedState) sdk.Coin

GetUndelegateAmount returns the amount of undelegated coin.

func (Keeper) GetUndelegateRecord

func (k Keeper) GetUndelegateRecord(ctx sdk.Context, key string) (types.UndelegateRecord, bool)

GetUndelegateRecord returns undelegate record by key.

func (Keeper) GetUndelegateRecordsForZoneId

func (k Keeper) GetUndelegateRecordsForZoneId(ctx sdk.Context, zoneId string, state UndelegatedState) []types.UndelegateRecord

GetUndelegateRecordsForZoneId returns undelegate coins by zone-id.

func (Keeper) GetWithdrawAmt

func (k Keeper) GetWithdrawAmt(ctx sdk.Context, amt sdk.Coin) (sdk.Coin, error)

GetWithdrawAmt is used for calculating the amount of coin user can withdraw after un-delegate. This function is executed when ICA un-delegate call executed, and calculate using the balance of user's share coin.

func (Keeper) GetWithdrawRecord

func (k Keeper) GetWithdrawRecord(ctx sdk.Context, zoneId, withdrawer string) (*types.WithdrawRecord, error)

GetWithdrawRecord returns withdraw record item by key.

func (Keeper) GetsnDenomForIBCDenom

func (k Keeper) GetsnDenomForIBCDenom(ctx sdk.Context, ibcDenom string) (string, error)

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

func (Keeper) IsAbleToWithdraw

func (k Keeper) IsAbleToWithdraw(ctx sdk.Context, from sdk.AccAddress, amt sdk.Coin) bool

IsAbleToWithdraw returns if user can withdraw their asset. It refers nova ICA account. If ICA account's balance is greater than user withdraw request amount, this function returns true.

func (Keeper) IterateDepositRecord

func (k Keeper) IterateDepositRecord(ctx sdk.Context, fn func(index int64, depositRecord types.DepositRecord) (stop bool))

func (Keeper) IterateUndelegatedRecords

func (k Keeper) IterateUndelegatedRecords(ctx sdk.Context, fn func(index int64, undelegateInfo types.UndelegateRecord) (stop bool))

IterateUndelegatedRecords iterate through zones

func (Keeper) IterateWithdrawRecords

func (k Keeper) IterateWithdrawRecords(ctx sdk.Context, fn func(index int64, withdrawInfo types.WithdrawRecord) (stop bool))

IterateWithdrawRecords iterate

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MintShareTokens

func (k Keeper) MintShareTokens(ctx sdk.Context, depositor sdk.AccAddress, amt sdk.Coin) error

MintShareTokens mints st-token(share token) regard with deposited token.

func (Keeper) SetBlockHeight

func (k Keeper) SetBlockHeight(ctx sdk.Context, zoneId string, state DepositState, blockHeight int64)

func (Keeper) SetDepositAmt

func (k Keeper) SetDepositAmt(ctx sdk.Context, msg *types.DepositRecord)

SetDepositAmt write the amount of coin user deposit to the "DepositRecord" store.

func (Keeper) SetParams

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

SetParams sets the total set of gal parameters.

func (Keeper) SetUndelegateRecord

func (k Keeper) SetUndelegateRecord(ctx sdk.Context, record types.UndelegateRecord)

SetUndelegateRecord write undelegate record.

func (Keeper) SetWithdrawRecord

func (k Keeper) SetWithdrawRecord(ctx sdk.Context, record types.WithdrawRecord)

SetWithdrawRecord writes withdraw record.

func (Keeper) SetWithdrawRecords

func (k Keeper) SetWithdrawRecords(ctx sdk.Context, zoneId string, state UndelegatedState)

SetWithdrawRecords write multiple withdraw record.

func (Keeper) SetWithdrawTime

func (k Keeper) SetWithdrawTime(ctx sdk.Context, zoneId string, state WithdrawRegisterType, time time.Time)

SetWithdrawTime writes the time undelegate finish.

func (Keeper) TransferToTargetZone

func (k Keeper) TransferToTargetZone(ctx sdk.Context,
	sourcePort, sourceChannel, depositor, icaController string, amt sdk.Coin) error

TransferToTargetZone transfers user's asset to target zone(Host chain) using IBC transfer.

type UndelegatedState

type UndelegatedState int64
const (
	UNDELEGATE_REQUEST_USER UndelegatedState = iota + 1
	UNDELEGATE_REQUEST_ICA
)

type WithdrawRegisterType

type WithdrawRegisterType int
const (
	WITHDRAW_REGISTER WithdrawRegisterType = iota + 1
	TRANSFER_SUCCESS
)

Jump to

Keyboard shortcuts

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