Documentation ¶
Index ¶
- Constants
- Variables
- type ActionType
- type ContextKey
- type Market
- type MarketStatus
- type PayInput
- func RequestBorrow(ctx context.Context, followID string, assetID string, ...) (*PayInput, error)
- func RequestLiquidate(ctx context.Context, followID string, userAddress string, ...) (*PayInput, error)
- func RequestPayURL(ctx context.Context, payRequest *PayRequest) (*PayInput, error)
- func RequestPledge(ctx context.Context, followID string, ctokenAssetID string, ...) (*PayInput, error)
- func RequestQuickBorrow(ctx context.Context, followID string, supplyAssetID string, ...) (*PayInput, error)
- func RequestQuickPledge(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (*PayInput, error)
- func RequestQuickRedeem(ctx context.Context, followID string, ctokenAssetID string, ...) (*PayInput, error)
- func RequestRedeem(ctx context.Context, followID string, ctokenAssetID string, ...) (*PayInput, error)
- func RequestRepay(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (*PayInput, error)
- func RequestSupply(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (*PayInput, error)
- func RequestUnpledge(ctx context.Context, followID string, ctokenAssetID string, ...) (*PayInput, error)
- type PayRequest
- type Transaction
- type TransactionExtraData
Constants ¶
const ( // TransactionKeyService key service type :string TransactionKeyService = "service" // TransactionKeyBlock block index :int64 TransactionKeyBlock = "block" // TransactionKeySymbol symbol key :string TransactionKeySymbol = "symbol" // TransactionKeyPrice price :decimal TransactionKeyPrice = "price" // TransactionKeyBorrowRate borrow rate :decimal TransactionKeyBorrowRate = "borrow_rate" // TransactionKeySupplyRate supply rate : decimal TransactionKeySupplyRate = "supply_rate" // TransactionKeyAmount amount TransactionKeyAmount = "amount" // TransactionKeyCToken ctokens TransactionKeyCToken = "ctoken" // TransactionKeyInterest interest TransactionKeyInterest = "interest" // TransactionKeyStatus status TransactionKeyStatus = "status" // TransactionKeyUser user TransactionKeyUser = "user" // TransactionKeyErrorCode error code TransactionKeyErrorCode = "error_code" // TransactionKeyReferTrace refer trace TransactionKeyReferTrace = "refer_trace" // TransactionKeyAssetID asset id TransactionKeyAssetID = "asset_id" // TransactionKeyTotalCash total cash TransactionKeyTotalCash = "total_cash" // TransactionKeyTotalBorrows total borrows TransactionKeyTotalBorrows = "total_borrows" // TransactionKeyReserves reserves TransactionKeyReserves = "reserves" // TransactionKeyCTokens ctokens TransactionKeyCTokens = "ctokens" // TransactionKeyCTokenAssetID ctoken asset id TransactionKeyCTokenAssetID = "ctoken_asset_id" // TransactionKeyOrigin origin TransactionKeyOrigin = "origin" // TransactionKeySupply supply TransactionKeySupply = "supply" // TransactionKeyBorrow borrow TransactionKeyBorrow = "borrow" // TransactionKeyMarket market TransactionKeyMarket = "market" )
Variables ¶
var (
BlocksPerYear = decimal.NewFromInt(2102400)
)
var Endpoint string
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType int
ActionType compound action type
const ( // ActionTypeDefault default ActionTypeDefault ActionType = iota // ActionTypeSupply supply action ActionTypeSupply // ActionTypeBorrow borrow action ActionTypeBorrow // ActionTypeRedeem redeem action ActionTypeRedeem // ActionTypeRepay repay action ActionTypeRepay // ActionTypeMint mint ctoken action ActionTypeMint // ActionTypePledge pledge action ActionTypePledge // ActionTypeUnpledge unpledge action ActionTypeUnpledge // ActionTypeLiquidate liquidation action ActionTypeLiquidate // ActionTypeRedeemTransfer redeem transfer action ActionTypeRedeemTransfer // ActionTypeUnpledgeTransfer unpledge transfer action ActionTypeUnpledgeTransfer // ActionTypeBorrowTransfer borrow transfer action ActionTypeBorrowTransfer // ActionTypeLiquidateTransfer liquidation transfer action ActionTypeLiquidateTransfer // ActionTypeRefundTransfer refund action ActionTypeRefundTransfer // ActionTypeRepayRefundTransfer repay refund action ActionTypeRepayRefundTransfer // ActionTypeLiquidateRefundTransfer seize refund action ActionTypeLiquidateRefundTransfer // ActionTypeProposalUpsertMarket add market proposal action ActionTypeProposalUpsertMarket // ActionTypeProposalUpdateMarket update market proposal action ActionTypeProposalUpdateMarket // ActionTypeProposalWithdrawReserves withdraw reserves proposal action ActionTypeProposalWithdrawReserves // ActionTypeProposalProvidePrice provide price action ActionTypeProposalProvidePrice // ActionTypeProposalVote vote action ActionTypeProposalVote // ActionTypeProposalInjectCTokenForMint inject token action ActionTypeProposalInjectCTokenForMint // ActionTypeProposalUpdateMarketAdvance update market advance parameters action ActionTypeProposalUpdateMarketAdvance // ActionTypeProposalTransfer proposal transfer action ActionTypeProposalTransfer // ActionTypeProposalCloseMarket proposal close market action ActionTypeProposalCloseMarket // ActionTypeProposalOpenMarket proposal open market action ActionTypeProposalOpenMarket // ActionTypeProposalAddScope proposal add allowlist scope action ActionTypeProposalAddScope // ActionTypeProposalRemoveScope proposal remove allowlist scope action ActionTypeProposalRemoveScope // ActionTypeProposalAddAllowList proposal add to allowlist action ActionTypeProposalAddAllowList // ActionTypeProposalRemoveAllowList proposal remove from allowlist action ActionTypeProposalRemoveAllowList // ActionTypeUpdateMarket update market ActionTypeUpdateMarket // ActionTypeQuickPledge supply -> pledge ActionTypeQuickPledge // ActionTypeQuickBorrow supply -> pledge -> borrow ActionTypeQuickBorrow // ActionTypeQuickBorrowTransfer quick borrow transfer ActionTypeQuickBorrowTransfer // ActionTypeQuickRedeem unpledge -> redeem ActionTypeQuickRedeem // ActionTypeQuickRedeem quick redeem transfer ActionTypeQuickRedeemTransfer // ActionTypeProposalAddOracleSigner add oracle signer proposal action ActionTypeProposalAddOracleSigner // ActionTypeProposalRemoveOracleSigner remove oracle signer proposal action ActionTypeProposalRemoveOracleSigner // ActionTypeProposalSetProperty proposal to set property value ActionTypeProposalSetProperty ActionTypeProposalMake ActionTypeProposalShout )
func (ActionType) IsTransfer ¶
func (a ActionType) IsTransfer() bool
IsTransfer check where it is transfer to user or not
func (ActionType) IsValidAction ¶
func (a ActionType) IsValidAction() bool
func (ActionType) MarshalBinary ¶ added in v0.3.1
func (i ActionType) MarshalBinary() (data []byte, err error)
func (ActionType) String ¶ added in v0.3.1
func (i ActionType) String() string
func (*ActionType) UnmarshalBinary ¶ added in v0.3.1
func (i *ActionType) UnmarshalBinary(data []byte) error
type Market ¶
type Market struct { AssetID string `json:"asset_id"` Symbol string `json:"symbol"` CTokenAssetID string `json:"ctoken_asset_id"` TotalCash decimal.Decimal `json:"total_cash"` TotalBorrows decimal.Decimal `json:"total_borrows"` MaxPledge decimal.Decimal `json:"max_pledge"` // 保留金 Reserves decimal.Decimal `json:"reserves"` // CToken 累计铸造出来的币的数量 CTokens decimal.Decimal `json:"ctokens"` // 初始兑换率 InitExchangeRate decimal.Decimal `json:"init_exchange_rate"` // 平台保留金率 (0, 1), 默认为 0.10 ReserveFactor decimal.Decimal `json:"reserve_factor"` // 清算激励因子 (0, 1), 一般为0.1 LiquidationIncentive decimal.Decimal `json:"liquidation_incentive"` // 资金池的最小资金量 BorrowCap decimal.Decimal `json:"borrow_cap"` //抵押因子 = 可借贷价值 / 抵押资产价值,目前compound设置为0.75. 稳定币(USDT)的抵押率是0,即不可抵押 CollateralFactor decimal.Decimal `json:"collateral_factor"` //触发清算因子 [0.05, 0.9] 清算人最大可清算的资产比例 CloseFactor decimal.Decimal `json:"close_factor"` //基础利率 per year, 0.025 BaseRate decimal.Decimal `json:"base_rate"` // The multiplier of utilization rate that gives the slope of the interest rate. per year Multiplier decimal.Decimal `json:"multiplier"` // The multiplierPerBlock after hitting a specified utilization point. per year JumpMultiplier decimal.Decimal `json:"jump_multiplier"` // Kink Kink decimal.Decimal `json:"kink"` //当前区块高度 BlockNumber int64 `json:"block_number"` UtilizationRate decimal.Decimal `json:"utilization_rate"` ExchangeRate decimal.Decimal `json:"exchange_rate"` SupplyRatePerBlock decimal.Decimal `json:"supply_rate_per_block"` BorrowRatePerBlock decimal.Decimal `json:"borrow_rate_per_block"` Price decimal.Decimal `json:"price"` PriceUpdatedAt time.Time `json:"price_updated_at"` BorrowIndex decimal.Decimal `json:"borrow_index"` Status MarketStatus `json:"status"` SupplyApy decimal.Decimal `json:"supply_apy,omitempty"` BorrowApy decimal.Decimal `json:"borrow_apy,omitempty"` Suppliers int64 `json:"suppliers,omitempty"` Borrowers int64 `json:"borrowers,omitempty"` }
type MarketStatus ¶
type MarketStatus int
MarketStatus market status
const ( // MarketStatusOpen open MarketStatusOpen MarketStatus // MarketStatusClose close MarketStatusClose )
type PayInput ¶ added in v0.3.0
type PayInput struct { URL string `json:"url"` TransferInput *mixin.TransferInput `json:"transfer_input"` }
func RequestBorrow ¶
func RequestBorrow(ctx context.Context, followID string, assetID string, borrowAmount decimal.Decimal) (*PayInput, error)
RequestBorrow request borrow action url
func RequestLiquidate ¶
func RequestLiquidate(ctx context.Context, followID string, userAddress string, supplyCTokenAssetID string, borrowAssetID string, repayAmount decimal.Decimal) (*PayInput, error)
RequestLiquidate request liquidate action url
func RequestPayURL ¶
func RequestPayURL(ctx context.Context, payRequest *PayRequest) (*PayInput, error)
RequestPayURL
func RequestPledge ¶
func RequestPledge(ctx context.Context, followID string, ctokenAssetID string, amount decimal.Decimal) (*PayInput, error)
RequestPledge request pledge action url
func RequestQuickBorrow ¶
func RequestQuickBorrow(ctx context.Context, followID string, supplyAssetID string, supplyAmount decimal.Decimal, borrowAssetID string, borrowAmount decimal.Decimal) (*PayInput, error)
RequestQuickBorrow request quick_borrow action url
func RequestQuickPledge ¶
func RequestQuickPledge(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (*PayInput, error)
RequestQuickPledge request quick_pledge action url
func RequestQuickRedeem ¶
func RequestQuickRedeem(ctx context.Context, followID string, ctokenAssetID string, redeemAmount decimal.Decimal) (*PayInput, error)
RequestQuickRedeem request quick_redeem action url
func RequestRedeem ¶
func RequestRedeem(ctx context.Context, followID string, ctokenAssetID string, redeemAmount decimal.Decimal) (*PayInput, error)
RequestRedeem request redeem action url
func RequestRepay ¶
func RequestRepay(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (*PayInput, error)
RequestRepay request repay action url
type PayRequest ¶
type PayRequest struct { MemoBase64 string `json:"memo_base64,omitempty"` AssetID string `json:"asset_id,omitempty"` Amount decimal.Decimal `json:"amount,omitempty"` TraceID string `json:"trace_id,omitempty"` FollowID string `json:"follow_id,omitempty"` WithGas bool `json:"with_gas,omitempty"` }
func (*PayRequest) Validate ¶
func (p *PayRequest) Validate() error
type Transaction ¶
type Transaction struct { ID int64 `json:"id,omitempty"` Action ActionType `json:"action,omitempty"` TraceID string `json:"trace_id,omitempty"` UserID string `json:"user_id,omitempty"` FollowID string `json:"follow_id,omitempty"` SnapshotTraceID string `json:"snapshot_trace_id,omitempty"` AssetID string `json:"asset_id,omitempty"` Amount decimal.Decimal `json:"amount,omitempty"` Data types.JSONText `json:"data,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` }
func RequestTransactions ¶
RequestTransactions pull compound transactions
#limit: page limit #offset: transaction start time
type TransactionExtraData ¶
type TransactionExtraData map[string]interface{}
TransactionExtraData extra data
func NewTransactionExtra ¶
func NewTransactionExtra() TransactionExtraData
NewTransactionExtra new transaction extra instance
func (TransactionExtraData) Format ¶
func (t TransactionExtraData) Format() []byte
Format format as []byte by default
func (TransactionExtraData) Put ¶
func (t TransactionExtraData) Put(key string, value string)
Put put data