Documentation
¶
Index ¶
- func InitCalculator(source ratesSource) *calculator
- type Asset
- type ExecutionResult
- type Invariant
- type LpAsset
- type Market
- type Mock
- func (m *Mock) GetCurrentMarketsTonPrice() ([]Market, error)
- func (m *Mock) GetCurrentRates() (map[string]float64, error)
- func (m Mock) GetMarketsTonPrice() ([]Market, error)
- func (m Mock) GetRates(date int64) (map[string]float64, error)
- func (m Mock) GetRatesChart(token string, currency string, pointsCount int, startDate *int64, ...) ([]Point, error)
- type Point
- type Pool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitCalculator ¶
func InitCalculator(source ratesSource) *calculator
Types ¶
type ExecutionResult ¶
type ExecutionResult struct {
Success bool `json:"success"`
ExitCode int `json:"exit_code"`
Stack []struct {
Type string `json:"type"`
Cell string `json:"cell"`
Slice string `json:"slice"`
Num string `json:"num"`
} `json:"stack"`
}
ExecutionResult represents a result from a smart contract call
type LpAsset ¶
type LpAsset struct {
Account ton.AccountID
Decimals int
TotalSupply *big.Int // The total supply of the liquidity provider asset
Assets []Asset // A slice of Asset included in the liquidity pool
}
LpAsset represents a liquidity provider asset that holds a collection of assets in a pool
type Market ¶
type Market struct {
ID int64
Name string // Name of the service used for price calculation
UsdPrice float64
URL string
// Converter for calculating the TON to USD price
TonPriceConverter func(respBody []byte) (float64, error)
// Converter for calculating fiat prices
FiatPriceConverter func(respBody []byte) (map[string]float64, error)
// Converter for calculating jetton prices within pools
PoolResponseConverter func(respBody []byte) ([]Pool, []LpAsset, error)
DateUpdate time.Time
}
type Mock ¶
type Mock struct {
// TonApiToken the token for TonApi to increase HTTP limits is obtained from https://tonconsole.com/tonapi
TonApiToken string
// URL to the CSV file from the analytics service https://tonconsole.com/analytics (data is sourced from the TonApi analytics database)
StonFiV1ResultUrl, StonFiV2ResultUrl, StonFiV2StableSwapResultUrl string
// URL to the CSV file from the analytics service https://tonconsole.com/analytics (data is sourced from the TonApi analytics database)
DedustResultUrl string
}
func (*Mock) GetCurrentMarketsTonPrice ¶
GetCurrentMarketsTonPrice shows the TON to USD price on different markets
func (*Mock) GetCurrentRates ¶
GetCurrentRates fetches current jetton and fiat rates
func (Mock) GetMarketsTonPrice ¶
func (Mock) GetRates ¶
GetRates cannot request data for a specific date in the open source version It will always return data for the current day
func (Mock) GetRatesChart ¶
func (m Mock) GetRatesChart(token string, currency string, pointsCount int, startDate *int64, endDate *int64) ([]Point, error)
GetRatesChart cannot be used to request charts for jettons in the open source version To use this method, you must save today's data from GetRates and then override the method
type Pool ¶
type Pool struct {
Assets []Asset
Invariant Invariant // Pool's invariant (x*y, x^3*y + x*y^3 etc.)
Amp float64 // Additional parameter for stable swap (iterative) pool invariant
Weight float64 // Additional parameter for weighted pools invariants
Rate float64 // Additional parameter for wighted stable swap pool invariant
}
Pool represents a collection of assets in a pool
Click to show internal directories.
Click to hide internal directories.