defi

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AddressTypeContract = tezos.AddressTypeContract
	ParseAddress        = tezos.ParseAddress
	NewAddress          = tezos.NewAddress
)

Functions

This section is empty.

Types

type Address

type Address = tezos.Address

type Dex

type Dex struct {
	Id              uint64    `json:"id"`
	Contract        string    `json:"contract"`
	PairId          int       `json:"pair_id"`
	Creator         string    `json:"creator"`
	Name            string    `json:"name"`
	Entity          string    `json:"entity"`
	Pair            string    `json:"pair"`
	NumTokens       int       `json:"num_tokens"`
	TokenA          *Token    `json:"token_a"`
	TokenB          *Token    `json:"token_b"`
	TokenLP         *Token    `json:"token_lp"`
	FirstBlock      int64     `json:"first_block"`
	FirstTime       time.Time `json:"first_time"`
	Tags            []string  `json:"tags"`
	SupplyA         Z         `json:"supply_a"`
	SupplyB         Z         `json:"supply_b"`
	SupplyLP        Z         `json:"supply_lp"`
	LastChangeBlock int64     `json:"last_change_block"`
	LastChangeTime  time.Time `json:"last_change_time"`
	LastTradeTime   time.Time `json:"last_trade_time"`
	NumTrades       int       `json:"num_trades"`
	FeesBps         float64   `json:"fees_bps,string"`
	Price           float64   `json:"price,string"`
	PriceUSD        float64   `json:"price_usd,string"`
	LiquidityUSD    float64   `json:"liquidity_usd,string"`
	NumCurrentLPs   int       `json:"num_lps"`
	NumTotalLPs     int       `json:"num_total_lps"`
	NumTotalUsers   int       `json:"num_total_users"`
}

func (Dex) Address

func (p Dex) Address() PoolAddress

type DexAPI

type DexAPI interface {
	GetDex(context.Context, PoolAddress) (*Dex, error)
	GetTicker(context.Context, PoolAddress) (*DexTicker, error)
	ListPoolEvents(context.Context, PoolAddress, Query) ([]*DexEvent, error)
	ListPoolTrades(context.Context, PoolAddress, Query) ([]*DexTrade, error)
	ListPoolPositions(context.Context, PoolAddress, Query) ([]*DexPosition, error)

	// firehose
	ListDex(context.Context, Query) ([]*Dex, error)
	ListTickers(context.Context, Query) ([]*DexTicker, error)
	ListEvents(context.Context, Query) ([]*DexEvent, error)
	ListTrades(context.Context, Query) ([]*DexTrade, error)
	ListPositions(context.Context, Query) ([]*DexPosition, error)
}

func NewDexAPI

func NewDexAPI(c *client.Client) DexAPI

type DexEvent

type DexEvent struct {
	Id         uint64    `json:"id"`
	Contract   Address   `json:"contract"`
	PairId     int       `json:"pair_id"`
	Name       string    `json:"name"`
	Entity     string    `json:"entity"`
	Pair       string    `json:"pair"`
	Type       string    `json:"event_type"`
	VolumeA    Z         `json:"volume_a"`
	VolumeB    Z         `json:"volume_b"`
	VolumeLP   Z         `json:"volume_lp"`
	DecimalsA  int       `json:"decimals_a"`
	DecimalsB  int       `json:"decimals_b"`
	DecimalsLP int       `json:"decimals_lp"`
	SupplyA    Z         `json:"supply_a"`
	SupplyB    Z         `json:"supply_b"`
	SupplyLP   Z         `json:"supply_lp"`
	ValueUSD   float64   `json:"value_usd,string"`
	Signer     Address   `json:"signer"`
	Sender     Address   `json:"sender"`
	Receiver   Address   `json:"receiver"`
	Router     Address   `json:"router"`
	TxHash     OpHash    `json:"tx_hash"`
	TxFee      int64     `json:"tx_fee,string"`
	Block      int64     `json:"block"`
	Time       time.Time `json:"time"`
}

type DexPosition

type DexPosition struct {
	Id               uint64     `json:"id"`
	Contract         Address    `json:"contract"`
	PairId           int        `json:"pair_id"`
	Name             string     `json:"name"`
	Entity           string     `json:"entity"`
	Pair             string     `json:"pair"`
	Owner            Address    `json:"owner"`
	DecimalsA        int        `json:"decimals_a"`
	DecimalsB        int        `json:"decimals_b"`
	DecimalsLP       int        `json:"decimals_lp"`
	TotalShares      Z          `json:"total_shares"`
	Shares           Z          `json:"shares"`
	ValueA           Z          `json:"value_a"`
	ValueB           Z          `json:"value_b"`
	SharesMinted     Z          `json:"shares_minted"`
	SharesBurned     Z          `json:"shares_burned"`
	SharesSent       Z          `json:"shares_sent"`
	SharesReceived   Z          `json:"shares_received"`
	DepositedA       Z          `json:"deposited_a"`
	DepositedB       Z          `json:"deposited_b"`
	WithdrawnA       Z          `json:"withdrawn_a"`
	WithdrawnB       Z          `json:"withdrawn_b"`
	IsClosed         bool       `json:"is_closed"`
	OpenBlock        int64      `json:"open_block"`
	OpenTime         time.Time  `json:"open_time"`
	CloseBlock       int64      `json:"close_block,omitempty"`
	CloseTime        *time.Time `json:"close_time,omitempty"`
	PositionValueUSD float64    `json:"position_value_usd,string"`
	ShareValueUSD    float64    `json:"share_value_usd,string"`
	OpenValueUSD     float64    `json:"open_value_usd,string"`
	CloseValueUSD    float64    `json:"close_value_usd,string"`
	FeeIncomeUSD     float64    `json:"fee_income_usd,string"`
	FeeIncomeBps     float64    `json:"fee_income_bps,string"`
	ProfitLossUSD    float64    `json:"pnl_usd,string"`
	ProfitLossBps    float64    `json:"pnl_bps,string"`
}

type DexTicker

type DexTicker struct {
	Id               uint64      `json:"id"`
	Pair             string      `json:"pair"`
	Pool             PoolAddress `json:"pool"`
	Name             string      `json:"name"`
	Entity           string      `json:"entity"`
	PriceChange      float64     `json:"price_change,string"`
	PriceChangeBps   float64     `json:"price_change_bps,string"`
	AskPrice         float64     `json:"ask_price,string"`
	WeightedAvgPrice float64     `json:"weighted_avg_price,string"`
	LastPrice        float64     `json:"last_price,string"`
	LastQty          float64     `json:"last_qty,string"`
	LastTradeTime    time.Time   `json:"last_trade_time"`
	BaseVolume       float64     `json:"base_volume,string"`
	QuoteVolume      float64     `json:"quote_volume,string"`
	OpenPrice        float64     `json:"open_price,string"`
	HighPrice        float64     `json:"high_price,string"`
	LowPrice         float64     `json:"low_price,string"`
	OpenTime         time.Time   `json:"open_time"`
	CloseTime        time.Time   `json:"close_time"`
	NumTrades        int         `json:"num_trades"`
	LiquidityUSD     string      `json:"liquidity_usd"`
	PriceUSD         string      `json:"price_usd"`
}

type DexTrade

type DexTrade struct {
	Id             uint64    `json:"id"`
	Contract       Address   `json:"contract"`
	PairId         int       `json:"pair_id"`
	Name           string    `json:"name"`
	Entity         string    `json:"entity"`
	Pair           string    `json:"pair"`
	Counter        int64     `json:"counter"`
	Side           string    `json:"side"`
	BaseVolume     Z         `json:"base_volume"`
	BaseSymbol     string    `json:"base_symbol"`
	BaseDecimals   int       `json:"base_decimals"`
	QuoteVolume    Z         `json:"quote_volume"`
	QuoteSymbol    string    `json:"quote_symbol"`
	QuoteDecimals  int       `json:"quote_decimals"`
	LpFee          Z         `json:"lp_fee"`
	LpFeeBps       float64   `json:"lp_fee_bps,string"`
	LpFeeSymbol    string    `json:"lp_fee_symbol"`
	LpFeeDecimals  int       `json:"lp_fee_decimals"`
	DevFee         Z         `json:"dev_fee"`
	DevFeeBps      float64   `json:"dev_fee_bps,string"`
	DevFeeSymbol   string    `json:"dev_fee_symbol"`
	DevFeeDecimals int       `json:"dev_fee_decimals"`
	RefFee         Z         `json:"referral_fee"`
	RefFeeBps      float64   `json:"referral_fee_bps,string"`
	RefFeeSymbol   string    `json:"referral_fee_symbol"`
	RefFeeDecimals int       `json:"referral_fee_decimals"`
	IncFee         Z         `json:"incentive_fee"`
	IncFeeBps      float64   `json:"incentive_fee_bps,string"`
	IncFeeSymbol   string    `json:"incentive_fee_symbol"`
	IncFeeDecimals int       `json:"incentive_fee_decimals"`
	Burn           Z         `json:"burn"`
	BurnBps        float64   `json:"burn_bps,string"`
	BurnSymbol     string    `json:"burn_symbol"`
	BurnDecimals   int       `json:"burn_decimals"`
	PriceSymbol    string    `json:"price_symbol"`
	PriceDecimals  int       `json:"price_decimals"`
	PriceNet       float64   `json:"price_net,string"`        // including fees
	PriceGross     float64   `json:"price_gross,string"`      // excluding fees
	PriceBefore    float64   `json:"price_before,string"`     // marginal price before execution
	PriceAfter     float64   `json:"price_after,string"`      // marginal price after execution
	Delta          float64   `json:"price_delta_bps,string"`  // price delta (in basispoints) between mid price and execution price
	Impact         float64   `json:"price_impact_bps,string"` // price impact (in basispoints) between mid price and next mid price
	Signer         string    `json:"signer"`
	Sender         string    `json:"sender"`
	Receiver       string    `json:"receiver"`
	Router         string    `json:"router"`
	IsWash         bool      `json:"is_wash_trade"`
	TxHash         string    `json:"tx_hash"`
	TxFee          int64     `json:"tx_fee,string"`
	TxFeeSymbol    string    `json:"tx_fee_symbol"`
	TxFeeDecimals  int       `json:"tx_fee_decimals"`
	Block          int64     `json:"block"`
	Time           time.Time `json:"time"`
	PriceUSD       float64   `json:"price_usd,string"`
	FeesUSD        float64   `json:"fees_usd,string"`
	VolumeUSD      float64   `json:"volume_usd,string"`
}

type Farm

type Farm struct {
	Id               uint64     `json:"id"`
	Contract         Address    `json:"contract"`
	PoolId           int        `json:"pool_id"`
	Creator          Address    `json:"creator"`
	Name             string     `json:"name"`
	Entity           string     `json:"entity"`
	StakeToken       *Token     `json:"stake_token"`
	RewardToken      *Token     `json:"reward_token"`
	FirstBlock       int64      `json:"first_block"`
	FirstTime        time.Time  `json:"first_time"`
	Tags             []string   `json:"tags"`
	TotalStake       Z          `json:"total_stake"`
	RemainingRewards Z          `json:"remaining_rewards"`
	NumPositions     int        `json:"num_positions"`
	StartTime        *time.Time `json:"start_time,omitempty"`
	EndTime          *time.Time `json:"end_time,omitempty"`
	StakeValueUSD    float64    `json:"stake_value_usd,string"`
	RewardsValueUSD  float64    `json:"rewards_value_usd,string"`
}

func (Farm) Address

func (p Farm) Address() PoolAddress

type FarmAPI

type FarmAPI interface {
	GetFarm(context.Context, PoolAddress) (*Farm, error)
	ListPoolEvents(context.Context, PoolAddress, Query) ([]*FarmEvent, error)
	ListFarmPoolPositions(context.Context, PoolAddress, Query) ([]*FarmPosition, error)

	// firehose
	ListFarms(context.Context, Query) ([]*Farm, error)
	ListEvents(context.Context, Query) ([]*FarmEvent, error)
	ListPositions(context.Context, Query) ([]*FarmPosition, error)
}

func NewFarmAPI

func NewFarmAPI(c *client.Client) FarmAPI

type FarmEvent

type FarmEvent struct {
	Id             uint64       `json:"id"`
	Contract       Address      `json:"contract"`
	PoolId         int          `json:"pool_id"`
	Name           string       `json:"name"`
	Entity         string       `json:"entity"`
	Type           string       `json:"event_type"`
	StakeToken     TokenAddress `json:"stake_token"`
	RewardToken    TokenAddress `json:"reward_token"`
	StakeSymbol    string       `json:"stake_symbol"`
	RewardSymbol   string       `json:"reward_symbol"`
	StakeDecimals  int          `json:"stake_decimals"`
	RewardDecimals int          `json:"reward_decimals"`
	Volume         Z            `json:"volume"`
	Reward         Z            `json:"reward"`
	Fee            Z            `json:"fee"`
	FeeBps         float64      `json:"fee_bps,string"`
	StakeId        int64        `json:"stake_id"`
	StakeSupply    Z            `json:"stake_supply"`
	RewardSupply   Z            `json:"reward_supply"`
	Signer         Address      `json:"signer"`
	Sender         Address      `json:"sender"`
	Receiver       Address      `json:"receiver"`
	TxHash         OpHash       `json:"tx_hash"`
	TxFee          int64        `json:"tx_fee,string"`
	Block          int64        `json:"block"`
	Time           time.Time    `json:"time"`
}

type FarmPosition

type FarmPosition struct {
	Id             uint64       `json:"id"`
	Contract       Address      `json:"contract"`
	PoolId         int          `json:"pool_id"`
	Name           string       `json:"name"`
	Entity         string       `json:"entity"`
	Owner          Address      `json:"owner"`
	StakeToken     TokenAddress `json:"stake_token"`
	RewardToken    TokenAddress `json:"reward_token"`
	StakeSymbol    string       `json:"stake_symbol"`
	RewardSymbol   string       `json:"reward_symbol"`
	StakeDecimals  int          `json:"stake_decimals"`
	RewardDecimals int          `json:"reward_decimals"`
	TotalStake     Z            `json:"total_stake"`
	StakeId        int64        `json:"stake_id"`
	Stake          Z            `json:"stake_balance"`
	Deposited      Z            `json:"stake_deposited"`
	Withdrawn      Z            `json:"stake_withdrawn"`
	Claimed        Z            `json:"rewards_claimed"`
	Pending        Z            `json:"rewards_pending"`
	IsClosed       bool         `json:"is_closed"`
	OpenBlock      int64        `json:"open_block"`
	OpenTime       time.Time    `json:"open_time"`
	CloseBlock     int64        `json:"close_block,omitempty"`
	CloseTime      *time.Time   `json:"close_time,omitempty"`
	ValueUSD       float64      `json:"value_usd,string"`
	PendingUSD     float64      `json:"pending_usd,string"`
	ClaimedUSD     float64      `json:"claimed_usd,string"`
}

type LendingAPI

type LendingAPI interface {
	GetPool(context.Context, PoolAddress) (*LendingPool, error)
	ListPoolEvents(context.Context, PoolAddress, Query) ([]*LendingEvent, error)
	ListPoolPositions(context.Context, PoolAddress, Query) ([]*LendingPosition, error)

	// firehose
	ListPools(context.Context, Query) ([]*LendingPool, error)
	ListEvents(context.Context, Query) ([]*LendingEvent, error)
	ListPositions(context.Context, Query) ([]*LendingPosition, error)
}

func NewLendingAPI

func NewLendingAPI(c *client.Client) LendingAPI

type LendingEvent

type LendingEvent struct {
	Id                 uint64       `json:"id"`
	Contract           Address      `json:"contract"`
	PoolId             int          `json:"pool_id"`
	Name               string       `json:"name"`
	Entity             string       `json:"entity"`
	Type               string       `json:"event_type"`
	DebtToken          TokenAddress `json:"debt_token"`
	CollateralToken    TokenAddress `json:"collateral_token"`
	DebtDecimals       int          `json:"debt_decimals"`
	CollateralDecimals int          `json:"collateral_decimals"`
	DebtSymbol         string       `json:"debt_symbol"`
	CollateralSymbol   string       `json:"collateral_symbol"`
	Owner              Address      `json:"owner"`
	StakeId            int64        `json:"stake_id"`
	Volume             Z            `json:"volume"`
	Debt               Z            `json:"debt"`
	Collateral         Z            `json:"collateral"`
	Fee                Z            `json:"fee"`
	Interest           Z            `json:"interest"`
	Signer             Address      `json:"signer"`
	Sender             Address      `json:"sender"`
	Receiver           Address      `json:"receiver"`
	TxHash             OpHash       `json:"tx_hash"`
	TxFee              int64        `json:"tx_fee,string"`
	Block              int64        `json:"block"`
	Time               time.Time    `json:"time"`
}

type LendingPool

type LendingPool struct {
	Id                 uint64    `json:"id"`
	Contract           Address   `json:"contract"`
	PoolId             int       `json:"pool_id"`
	Creator            Address   `json:"creator"`
	Name               string    `json:"name"`
	Entity             string    `json:"entity"`
	DebtToken          *Token    `json:"debt_token"`
	CollateralToken    *Token    `json:"collateral_token"`
	FirstBlock         int64     `json:"first_block"`
	FirstTime          time.Time `json:"first_time"`
	Tags               []string  `json:"tags"`
	TotalCollateral    Z         `json:"total_collateral"`
	TotalDebt          Z         `json:"total_debt"`
	NumDeposits        int       `json:"num_deposits"`
	NumBorrows         int       `json:"num_borrows"`
	CollateralValueUSD float64   `json:"collateral_value_usd,string"`
	DebtValueUSD       float64   `json:"debt_value_usd,string"`
}

func (LendingPool) Address

func (p LendingPool) Address() PoolAddress

type LendingPosition

type LendingPosition struct {
	Id                 uint64       `json:"id"`
	Contract           Address      `json:"contract"`
	PoolId             int          `json:"pool_id"`
	Name               string       `json:"name"`
	Entity             string       `json:"entity"`
	Owner              Address      `json:"owner"`
	StakeId            int64        `json:"stake_id"`
	DebtToken          TokenAddress `json:"debt_token"`
	CollateralToken    TokenAddress `json:"collateral_token"`
	DebtDecimals       int          `json:"debt_decimals"`
	CollateralDecimals int          `json:"collateral_decimals"`
	DebtSymbol         string       `json:"debt_symbol"`
	CollateralSymbol   string       `json:"collateral_symbol"`
	Balance            Z            `json:"balance"`
	Deposited          Z            `json:"deposited"`
	Withdrawn          Z            `json:"withdrawn"`
	Borrowed           Z            `json:"borrowed"`
	Repaid             Z            `json:"repaid"`
	Liquidated         Z            `json:"liquidated"`
	Sent               Z            `json:"sent"`
	Received           Z            `json:"received"`
	InterestEarned     Z            `json:"interest_earned"`
	InterestPaid       Z            `json:"interest_paid"`
	InterestPending    Z            `json:"interest_pending"`
	IsClosed           bool         `json:"is_closed"`
	OpenBlock          int64        `json:"open_block"`
	OpenTime           time.Time    `json:"open_time"`
	CloseBlock         int64        `json:"close_block,omitempty"`
	CloseTime          *time.Time   `json:"close_time,omitempty"`
	PositionUSD        float64      `json:"position_value_usd,string"`
	InterestUSD        float64      `json:"interest_pending_usd,string"`
}

type OpHash

type OpHash = tezos.OpHash

type PoolAddress

type PoolAddress struct {
	Hash [20]byte // type is always KT1
	Id   int
}

PoolAddress represents a specialized address that consists of a smart contract KT1 address and a numeric pool id.

func MustParsePoolAddress

func MustParsePoolAddress(s string) PoolAddress

func NewPoolAddress

func NewPoolAddress(contract Address, id int) (a PoolAddress)

func ParsePoolAddress

func ParsePoolAddress(s string) (PoolAddress, error)

func (PoolAddress) Clone

func (a PoolAddress) Clone() PoolAddress

func (PoolAddress) Contract

func (a PoolAddress) Contract() Address

func (PoolAddress) Equal

func (a PoolAddress) Equal(b PoolAddress) bool

func (PoolAddress) PoolId

func (a PoolAddress) PoolId() int

func (PoolAddress) String

func (a PoolAddress) String() string

func (*PoolAddress) UnmarshalText

func (a *PoolAddress) UnmarshalText(data []byte) error

type Query

type Query = client.Query

type Token

type Token = token.Token

type TokenAddress added in v0.17.3

type TokenAddress = tezos.Token

type Z

type Z = tezos.Z

Jump to

Keyboard shortcuts

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