Documentation ¶
Index ¶
- Constants
- Variables
- func ApproveSharesEmitEvents(ctx sdk.Context, validator sdk.ValAddress, owner, spender sdk.AccAddress, ...)
- func DelegateEmitEvents(ctx sdk.Context, delegator sdk.AccAddress, validator sdk.ValAddress, ...)
- func GetABI() abi.ABI
- func GetAddress() common.Address
- func TransferSharesEmitEvents(ctx sdk.Context, validator sdk.ValAddress, from, recipient sdk.AccAddress, ...)
- func Undelegate(ctx sdk.Context, sk StakingKeeper, bk BankKeeper, delAddr sdk.AccAddress, ...) (sdkmath.Int, time.Time, error)
- func UndelegateEmitEvents(ctx sdk.Context, delegator sdk.AccAddress, validator sdk.ValAddress, ...)
- func WithdrawEmitEvents(ctx sdk.Context, delegator sdk.AccAddress, amount sdk.Coins)
- type AllowanceSharesArgs
- type ApproveSharesArgs
- type BankKeeper
- type Contract
- func (c *Contract) AddLog(evm *vm.EVM, event abi.Event, topics []common.Hash, args ...interface{}) error
- func (c *Contract) Address() common.Address
- func (c *Contract) AllowanceShares(ctx sdk.Context, _ *vm.EVM, contract *vm.Contract, _ bool) ([]byte, error)
- func (c *Contract) ApproveShares(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) Delegate(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) Delegation(ctx sdk.Context, _ *vm.EVM, contract *vm.Contract, _ bool) ([]byte, error)
- func (c *Contract) DelegationRewards(ctx sdk.Context, _ *vm.EVM, contract *vm.Contract, _ bool) ([]byte, error)
- func (c *Contract) IsStateful() bool
- func (c *Contract) RequiredGas(input []byte) uint64
- func (c *Contract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) (ret []byte, err error)
- func (c *Contract) TransferFromShares(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) TransferShares(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) Undelegate(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) Withdraw(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- type DelegateArgs
- type DelegationArgs
- type DelegationRewardsArgs
- type DistrKeeper
- type EvmKeeper
- type StakingKeeper
- type TransferFromSharesArgs
- type TransferSharesArgs
- type UndelegateArgs
- type WithdrawArgs
Constants ¶
const ( DelegateGas = 40_000 // 98000 - 160000 // 165000 UndelegateGas = 45_000 // 94000 - 163000 // 172000 WithdrawGas = 30_000 // 94000 // 120000 DelegationGas = 30_000 // 98000 DelegationRewardsGas = 30_000 // 94000 DelegateMethodName = "delegate" UndelegateMethodName = "undelegate" WithdrawMethodName = "withdraw" DelegationMethodName = "delegation" DelegationRewardsMethodName = "delegationRewards" DelegateEventName = "Delegate" UndelegateEventName = "Undelegate" WithdrawEventName = "Withdraw" )
Variables ¶
var ( ApproveSharesEventName, ApproveSharesEventName, false, abi.Arguments{ abi.Argument{Name: "owner", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "spender", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "validator", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "shares", Type: types.TypeUint256, Indexed: false}, }, ) DelegateEvent = abi.NewEvent( DelegateEventName, DelegateEventName, false, abi.Arguments{ abi.Argument{Name: "delegator", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "validator", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "amount", Type: types.TypeUint256, Indexed: false}, abi.Argument{Name: "shares", Type: types.TypeUint256, Indexed: false}, }, ) TransferSharesEventName, TransferSharesEventName, false, abi.Arguments{ abi.Argument{Name: "from", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "to", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "validator", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "shares", Type: types.TypeUint256, Indexed: false}, abi.Argument{Name: "token", Type: types.TypeUint256, Indexed: false}, }, ) UndelegateEvent = abi.NewEvent( UndelegateEventName, UndelegateEventName, false, abi.Arguments{ abi.Argument{Name: "sender", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "validator", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "shares", Type: types.TypeUint256, Indexed: false}, abi.Argument{Name: "amount", Type: types.TypeUint256, Indexed: false}, abi.Argument{Name: "completionTime", Type: types.TypeUint256, Indexed: false}, }, ) WithdrawEvent = abi.NewEvent( WithdrawEventName, WithdrawEventName, false, abi.Arguments{ abi.Argument{Name: "sender", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "validator", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "reward", Type: types.TypeUint256, Indexed: false}, }, ) )
var ( abi.NewMethod( AllowanceSharesMethodName, AllowanceSharesMethodName, abi.Function, "view", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, abi.Argument{Name: "_owner", Type: types.TypeAddress}, abi.Argument{Name: "_spender", Type: types.TypeAddress}, }, abi.Arguments{ abi.Argument{Name: "_shares", Type: types.TypeUint256}, }, ) // DelegationMethod Query the amount of shares in val. DelegationMethod = abi.NewMethod( DelegationMethodName, DelegationMethodName, abi.Function, "view", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, abi.Argument{Name: "_del", Type: types.TypeAddress}, }, abi.Arguments{ abi.Argument{Name: "_shares", Type: types.TypeUint256}, abi.Argument{Name: "_delegateAmount", Type: types.TypeUint256}, }, ) // DelegationRewardsMethod Query the amount of rewards in val. DelegationRewardsMethod = abi.NewMethod( DelegationRewardsMethodName, DelegationRewardsMethodName, abi.Function, "view", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, abi.Argument{Name: "_del", Type: types.TypeAddress}, }, abi.Arguments{ abi.Argument{Name: "_reward", Type: types.TypeUint256}, }, ) )AllowanceSharesMethod =
var ( abi.NewMethod( ApproveSharesMethodName, ApproveSharesMethodName, abi.Function, "nonpayable", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, abi.Argument{Name: "_spender", Type: types.TypeAddress}, abi.Argument{Name: "_shares", Type: types.TypeUint256}, }, abi.Arguments{ abi.Argument{Name: "_result", Type: types.TypeBool}, }, ) // DelegateMethod Delegate token to a validator. DelegateMethod = abi.NewMethod( DelegateMethodName, DelegateMethodName, abi.Function, "payable", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, }, abi.Arguments{ abi.Argument{Name: "_shares", Type: types.TypeUint256}, abi.Argument{Name: "_reward", Type: types.TypeUint256}, }, ) TransferSharesMethod = abi.NewMethod( TransferSharesMethodName, TransferSharesMethodName, abi.Function, "nonpayable", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, abi.Argument{Name: "_to", Type: types.TypeAddress}, abi.Argument{Name: "_shares", Type: types.TypeUint256}, }, abi.Arguments{ abi.Argument{Name: "_token", Type: types.TypeUint256}, abi.Argument{Name: "_reward", Type: types.TypeUint256}, }, ) TransferFromSharesMethod = abi.NewMethod( TransferFromSharesMethodName, TransferFromSharesMethodName, abi.Function, "nonpayable", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, abi.Argument{Name: "_from", Type: types.TypeAddress}, abi.Argument{Name: "_to", Type: types.TypeAddress}, abi.Argument{Name: "_shares", Type: types.TypeUint256}, }, abi.Arguments{ abi.Argument{Name: "_token", Type: types.TypeUint256}, abi.Argument{Name: "_reward", Type: types.TypeUint256}, }, ) // UndelegateMethod Undelegate shares from a validator. UndelegateMethod = abi.NewMethod( UndelegateMethodName, UndelegateMethodName, abi.Function, "nonpayable", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, abi.Argument{Name: "_shares", Type: types.TypeUint256}, }, abi.Arguments{ abi.Argument{Name: "_amount", Type: types.TypeUint256}, abi.Argument{Name: "_reward", Type: types.TypeUint256}, abi.Argument{Name: "_completionTime", Type: types.TypeUint256}, }, ) // WithdrawMethod Withdraw rewards from a validator. WithdrawMethod = abi.NewMethod( WithdrawMethodName, WithdrawMethodName, abi.Function, "nonpayable", false, false, abi.Arguments{ abi.Argument{Name: "_val", Type: types.TypeString}, }, abi.Arguments{ abi.Argument{Name: "_reward", Type: types.TypeUint256}, }, ) )ApproveSharesMethod =
Functions ¶
func ApproveSharesEmitEvents ¶
func ApproveSharesEmitEvents(ctx sdk.Context, validator sdk.ValAddress, owner, spender sdk.AccAddress, shares sdkmath.Int)
func DelegateEmitEvents ¶
func DelegateEmitEvents(ctx sdk.Context, delegator sdk.AccAddress, validator sdk.ValAddress, amount *big.Int, newShares sdk.Dec)
func GetAddress ¶
func TransferSharesEmitEvents ¶
func TransferSharesEmitEvents(ctx sdk.Context, validator sdk.ValAddress, from, recipient sdk.AccAddress, shares, token sdkmath.Int)
func Undelegate ¶
func Undelegate(ctx sdk.Context, sk StakingKeeper, bk BankKeeper, delAddr sdk.AccAddress, valAddr sdk.ValAddress, shares sdk.Dec, bondDenom string, ) (sdkmath.Int, time.Time, error)
func UndelegateEmitEvents ¶
func UndelegateEmitEvents(ctx sdk.Context, delegator sdk.AccAddress, validator sdk.ValAddress, amount sdkmath.Int, completionTime time.Time)
func WithdrawEmitEvents ¶
Types ¶
type AllowanceSharesArgs ¶
type AllowanceSharesArgs struct {}
func (*AllowanceSharesArgs) GetValidator ¶
func (args *AllowanceSharesArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*AllowanceSharesArgs) Validate ¶
func (args *AllowanceSharesArgs) Validate() error
Validate validates the args
type ApproveSharesArgs ¶
type ApproveSharesArgs struct {}
func (*ApproveSharesArgs) GetValidator ¶
func (args *ApproveSharesArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*ApproveSharesArgs) Validate ¶
func (args *ApproveSharesArgs) Validate() error
Validate validates the args
type BankKeeper ¶
type BankKeeper interface { MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error }
type Contract ¶
type Contract struct {
// contains filtered or unexported fields
}
func NewPrecompiledContract ¶
func NewPrecompiledContract( ctx sdk.Context, bankKeeper BankKeeper, stakingKeeper StakingKeeper, distrKeeper DistrKeeper, evmKeeper EvmKeeper, ) *Contract
func (*Contract) AllowanceShares ¶
func (*Contract) ApproveShares ¶
func (*Contract) Delegation ¶
func (*Contract) DelegationRewards ¶
func (*Contract) IsStateful ¶
func (*Contract) RequiredGas ¶
func (*Contract) TransferFromShares ¶
func (*Contract) TransferShares ¶
func (*Contract) Undelegate ¶
type DelegateArgs ¶
type DelegateArgs struct {
Validator string `abi:"_val"`
}
func (*DelegateArgs) GetValidator ¶
func (args *DelegateArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*DelegateArgs) Validate ¶
func (args *DelegateArgs) Validate() error
Validate validates the args
type DelegationArgs ¶
func (*DelegationArgs) GetValidator ¶
func (args *DelegationArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*DelegationArgs) Validate ¶
func (args *DelegationArgs) Validate() error
Validate validates the args
type DelegationRewardsArgs ¶
type DelegationRewardsArgs struct { Validator string `abi:"_val"` Delegator common.Address `abi:"_del"` }
func (*DelegationRewardsArgs) GetValidator ¶
func (args *DelegationRewardsArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*DelegationRewardsArgs) Validate ¶
func (args *DelegationRewardsArgs) Validate() error
Validate validates the args
type DistrKeeper ¶
type DistrKeeper interface { WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) GetDelegatorWithdrawAddr(ctx sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.ValidatorI) uint64 CalculateDelegationRewards(ctx sdk.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) GetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) (period distrtypes.DelegatorStartingInfo) SetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress, period distrtypes.DelegatorStartingInfo) DeleteDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) GetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress) (rewards distrtypes.ValidatorCurrentRewards) GetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64) (rewards distrtypes.ValidatorHistoricalRewards) SetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64, rewards distrtypes.ValidatorHistoricalRewards) DeleteValidatorHistoricalReward(ctx sdk.Context, val sdk.ValAddress, period uint64) }
type StakingKeeper ¶
type StakingKeeper interface { GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) SetDelegation(ctx sdk.Context, delegation stakingtypes.Delegation) RemoveDelegation(ctx sdk.Context, delegation stakingtypes.Delegation) error GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdkmath.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares sdk.Dec, err error) HasMaxUnbondingDelegationEntries(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool Unbond(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, shares sdk.Dec) (amount sdkmath.Int, err error) UnbondingTime(ctx sdk.Context) (res time.Duration) SetUnbondingDelegationEntry(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, creationHeight int64, minTime time.Time, balance sdkmath.Int) stakingtypes.UnbondingDelegation InsertUBDQueue(ctx sdk.Context, ubd stakingtypes.UnbondingDelegation, completionTime time.Time) GetAllowance(ctx sdk.Context, valAddr sdk.ValAddress, owner, spender sdk.AccAddress) *big.Int SetAllowance(ctx sdk.Context, valAddr sdk.ValAddress, owner, spender sdk.AccAddress, shares *big.Int) HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool }
type TransferFromSharesArgs ¶
type TransferFromSharesArgs struct {}
func (*TransferFromSharesArgs) GetValidator ¶
func (args *TransferFromSharesArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*TransferFromSharesArgs) Validate ¶
func (args *TransferFromSharesArgs) Validate() error
Validate validates the args
type TransferSharesArgs ¶
type TransferSharesArgs struct {}
func (*TransferSharesArgs) GetValidator ¶
func (args *TransferSharesArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*TransferSharesArgs) Validate ¶
func (args *TransferSharesArgs) Validate() error
Validate validates the args
type UndelegateArgs ¶
type UndelegateArgs struct { Validator string `abi:"_val"` }
func (*UndelegateArgs) GetValidator ¶
func (args *UndelegateArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*UndelegateArgs) Validate ¶
func (args *UndelegateArgs) Validate() error
Validate validates the args
type WithdrawArgs ¶
type WithdrawArgs struct {
Validator string `abi:"_val"`
}
func (*WithdrawArgs) GetValidator ¶
func (args *WithdrawArgs) GetValidator() sdk.ValAddress
GetValidator returns the validator address, caller must ensure the validator address is valid
func (*WithdrawArgs) Validate ¶
func (args *WithdrawArgs) Validate() error
Validate validates the args