rings

package module
Version: v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 15 Imported by: 0

README

Pando Rings SDK

Installing

go get github.com/fox-one/pando-rings-sdk-go

Using

  • Initialize endpoint
rings.Endpoint = "https://compound-test-api.fox.one"
  • Request supply action url
rings.RequestSupply(...)
  • Request borrow action url
rings.RequestBorrow(...)
  • Request Liquidate action url
rings.RequestLiquidate(...)

More details of the API using, please read the example

LICENSE

Documentation

Index

Constants

View Source
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

View Source
var (
	BlocksPerYear = decimal.NewFromInt(2102400)
)
View Source
var Endpoint string

Functions

func NewBasicMemoValues

func NewBasicMemoValues(actionType ActionType, followID string) (string, []interface{}, error)

func NewUserAddress

func NewUserAddress(mixinUserID string) string

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
	// ActionTypeProposalAddMarket add market proposal action
	ActionTypeProposalAddMarket
	// 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
)

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

type ContextKey

type ContextKey int
const (
	ContextKeyRequestID ContextKey = iota
)

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"`
	// 保留金
	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"`
}

func RequestAllMarkets

func RequestAllMarkets(ctx context.Context) ([]*Market, error)

RequestAllMarkets response all markets' data

type MarketStatus

type MarketStatus int

MarketStatus market status

const (

	// MarketStatusOpen open
	MarketStatusOpen MarketStatus
	// MarketStatusClose close
	MarketStatusClose
)

func (MarketStatus) IsValid

func (s MarketStatus) IsValid() bool

IsValid is valid status

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) (string, *PayInput, error)

RequestBorrow request borrow action url

func RequestLiquidate

func RequestLiquidate(ctx context.Context, followID string, supplyUserID string, supplyCTokenAssetID string, borrowAssetID string, repayAmount decimal.Decimal) (string, *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) (string, *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) (string, *PayInput, error)

RequestQuickBorrow request quick_borrow action url

func RequestQuickPledge

func RequestQuickPledge(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (string, *PayInput, error)

RequestQuickPledge request quick_pledge action url

func RequestQuickRedeem

func RequestQuickRedeem(ctx context.Context, followID string, ctokenAssetID string, redeemAmount decimal.Decimal) (string, *PayInput, error)

RequestQuickRedeem request quick_redeem action url

func RequestRedeem

func RequestRedeem(ctx context.Context, followID string, ctokenAssetID string, redeemAmount decimal.Decimal) (string, *PayInput, error)

RequestRedeem request redeem action url

func RequestRepay

func RequestRepay(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (string, *PayInput, error)

RequestRepay request repay action url

func RequestSupply

func RequestSupply(ctx context.Context, followID string, assetID string, amount decimal.Decimal) (string, *PayInput, error)

RequestSupply request supply action url

func RequestUnpledge

func RequestUnpledge(ctx context.Context, followID string, ctokenAssetID string, ctokenAmount decimal.Decimal) (string, *PayInput, error)

RequestUnpledge request unpledge 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

func RequestTransactions(ctx context.Context, limit int, offset time.Time) ([]*Transaction, error)

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL