deposit

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InterestRateDenominator uint64 = 1_000_000 * interestRateBase
	OfferMinDepositAmount   uint64 = 1 * units.MilliAvax
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Deposit

type Deposit struct {
	DepositOfferID      ids.ID   `serialize:"true"` // ID of deposit offer that was used to create this deposit
	UnlockedAmount      uint64   `serialize:"true"` // How many tokens have already been unlocked from this deposit
	ClaimedRewardAmount uint64   `serialize:"true"` // How many reward tokens have already been claimed for this deposit
	Start               uint64   `serialize:"true"` // Timestamp of time, when this deposit was created
	Duration            uint32   `serialize:"true"` // Duration of this deposit in seconds
	Amount              uint64   `serialize:"true"` // How many tokens were locked with this deposit
	RewardOwner         fx.Owner `serialize:"true"` // The owner who has right to claim rewards for this deposit
}

func (*Deposit) ClaimableReward

func (deposit *Deposit) ClaimableReward(offer *Offer, claimTime uint64) uint64

Returns amount of tokens that can be claimed as reward for deposit at [claimetime] (seconds).

Precondition: all args are valid in conjunction.

func (*Deposit) EndTime

func (deposit *Deposit) EndTime() time.Time

func (*Deposit) IsExpired

func (deposit *Deposit) IsExpired(timestamp uint64) bool

func (*Deposit) StartTime

func (deposit *Deposit) StartTime() time.Time

func (*Deposit) TotalReward

func (deposit *Deposit) TotalReward(offer *Offer) uint64

Returns amount of tokens that can be claimed as reward for [depositAmount].

Precondition: all args are valid in conjunction.

func (*Deposit) UnlockableAmount

func (deposit *Deposit) UnlockableAmount(offer *Offer, unlockTime uint64) uint64

Returns amount of tokens that can be unlocked from deposit at [unlockTime] (seconds).

Precondition: all args are valid in conjunction.

type Offer

type Offer struct {
	UpgradeVersionID codec.UpgradeVersionID
	ID               ids.ID

	InterestRateNominator   uint64              `serialize:"true" json:"interestRateNominator"`                   // deposit.Amount * (interestRateNominator / interestRateDenominator) == reward for deposit with 1 year duration
	Start                   uint64              `serialize:"true" json:"start"`                                   // Unix time in seconds, when this offer becomes active (can be used to create new deposits)
	End                     uint64              `serialize:"true" json:"end"`                                     // Unix time in seconds, when this offer becomes inactive (can't be used to create new deposits)
	MinAmount               uint64              `serialize:"true" json:"minAmount"`                               // Minimum amount that can be deposited with this offer
	TotalMaxAmount          uint64              `serialize:"true" json:"totalMaxAmount"`                          // Maximum amount that can be deposited with this offer in total (across all deposits)
	DepositedAmount         uint64              `serialize:"true" json:"depositedAmount"`                         // Amount that was already deposited with this offer
	MinDuration             uint32              `serialize:"true" json:"minDuration"`                             // Minimum duration of deposit created with this offer
	MaxDuration             uint32              `serialize:"true" json:"maxDuration"`                             // Maximum duration of deposit created with this offer
	UnlockPeriodDuration    uint32              `serialize:"true" json:"unlockPeriodDuration"`                    // Duration of period during which tokens deposited with this offer will be unlocked. The unlock period starts at the end of deposit minus unlockPeriodDuration
	NoRewardsPeriodDuration uint32              `serialize:"true" json:"noRewardsPeriodDuration"`                 // Duration of period during which rewards won't be accumulated. No rewards period starts at the end of deposit minus unlockPeriodDuration
	Memo                    types.JSONByteSlice `serialize:"true" json:"memo"`                                    // Arbitrary offer memo
	Flags                   OfferFlag           `serialize:"true" json:"flags"`                                   // Bitfield with flags
	TotalMaxRewardAmount    uint64              `serialize:"true" json:"totalMaxRewardAmount" upgradeVersion:"1"` // Maximum amount that can be rewarded for all deposits created with this offer in total
	RewardedAmount          uint64              `serialize:"true" json:"rewardedAmount"       upgradeVersion:"1"` // Amount that was already rewarded (including potential rewards) for deposits created with this offer
	OwnerAddress            ids.ShortID         `serialize:"true" json:"ownerAddress"         upgradeVersion:"1"` // Address that can sign deposit-creator permission
}

func (*Offer) EndTime

func (o *Offer) EndTime() time.Time

Time when this offer becomes inactive

func (*Offer) InterestRateFloat64

func (o *Offer) InterestRateFloat64() float64

func (*Offer) IsActiveAt

func (o *Offer) IsActiveAt(timestamp uint64) bool

func (*Offer) MaxRemainingAmountByReward

func (o *Offer) MaxRemainingAmountByReward() uint64

Returns maximum possible amount that could be deposited with this offer. Return 0 if o.TotalMaxRewardAmount is 0.

func (*Offer) MaxRemainingRewardByTotalMaxAmount

func (o *Offer) MaxRemainingRewardByTotalMaxAmount() uint64

Calculates max remaining reward amount by using offer max duration. Return 0 if o.TotalMaxAmount is 0.

func (*Offer) PermissionMsg

func (o *Offer) PermissionMsg(depositCreatorAddres ids.ShortID) []byte

func (*Offer) RemainingAmount

func (o *Offer) RemainingAmount() uint64

Return 0 if o.TotalMaxAmount is 0.

func (*Offer) RemainingReward

func (o *Offer) RemainingReward() uint64

Return 0 if o.TotalMaxRewardAmount is 0.

func (*Offer) StartTime

func (o *Offer) StartTime() time.Time

Time when this offer becomes active

func (*Offer) Verify

func (o *Offer) Verify() error

type OfferFlag

type OfferFlag uint64
const (
	OfferFlagNone   OfferFlag = 0
	OfferFlagLocked OfferFlag = 0b1
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳