Documentation
¶
Index ¶
- type ApproveAllowanceRes
- type ApproveSpenderRes
- type ApproveTransactionOpts
- type ApproveTransactionRes
- type Client
- func (c *Client) ApproveAllowance(ctx context.Context, network Network, tokenAddress, walletAddress string) (*ApproveAllowanceRes, int, error)
- func (c *Client) ApproveSpender(ctx context.Context, network Network) (*ApproveSpenderRes, int, error)
- func (c *Client) ApproveTransaction(ctx context.Context, network Network, tokenAddress string, ...) (*ApproveTransactionRes, int, error)
- func (c *Client) Healthcheck(ctx context.Context, network Network) (*HealthcheckRes, int, error)
- func (c *Client) LiquiditySouces(ctx context.Context, network Network) (*LiquiditySoucesRes, int, error)
- func (c *Client) Quote(ctx context.Context, network Network, ...) (*QuoteRes, int, error)
- func (c *Client) Swap(ctx context.Context, network Network, ...) (*SwapRes, int, error)
- func (c *Client) Tokens(ctx context.Context, network Network) (*TokensRes, int, error)
- type HealthcheckRes
- type LiquiditySoucesRes
- type Network
- type Protocol
- type Protocols
- type QuoteOpts
- type QuoteRes
- type SwapOpts
- type SwapRes
- type Token
- type TokensRes
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApproveAllowanceRes ¶ added in v0.0.7
type ApproveAllowanceRes struct { // address of 1inch contract Allowance string `json:"allowance"` }
type ApproveSpenderRes ¶
type ApproveSpenderRes struct { // address of 1inch contract Address string `json:"address"` }
type ApproveTransactionOpts ¶ added in v0.0.7
type ApproveTransactionOpts struct { // Amount of tokens to be approved: // 0 — set approval to zero (lock a token) // >0 — approve exact amount of tokens. // if not set use infinity approve Amount string }
type ApproveTransactionRes ¶ added in v0.0.7
type Client ¶
func (*Client) ApproveAllowance ¶ added in v0.0.7
func (c *Client) ApproveAllowance(ctx context.Context, network Network, tokenAddress, walletAddress string) (*ApproveAllowanceRes, int, error)
ApproveAllowance gets the number of tokens that the 1inch router is allowed to spend
func (*Client) ApproveSpender ¶
func (c *Client) ApproveSpender(ctx context.Context, network Network) (*ApproveSpenderRes, int, error)
ApproveSpender gets the address to which you need to approve before the swap transaction
func (*Client) ApproveTransaction ¶ added in v0.0.7
func (c *Client) ApproveTransaction(ctx context.Context, network Network, tokenAddress string, opts *ApproveTransactionOpts) (*ApproveTransactionRes, int, error)
ApproveTransaction gets calldata for approve transaction and spender address Do not combine amount parameter with infinity parameter, only one must be sent. infinity will overwrite amount amount is set in minimal divisible units: for example, to unlock 1 DAI, amount should be 1000000000000000000, to unlock 1.03 USDC, amount should be 1030000.
func (*Client) Healthcheck ¶
Healthcheck checks if service is able to handle requests
func (*Client) LiquiditySouces ¶ added in v0.0.7
func (c *Client) LiquiditySouces(ctx context.Context, network Network) (*LiquiditySoucesRes, int, error)
ProtocolsImages gets names and images of all supported protocols
func (*Client) Quote ¶
func (c *Client) Quote(ctx context.Context, network Network, fromTokenAddress, toTokenAddress, amount string, opts *QuoteOpts) (*QuoteRes, int, error)
Quote gets quote for an aggregated swap which can be used with a web3 provider to send the transaction
type HealthcheckRes ¶
type HealthcheckRes struct {
Status string `json:"status"`
}
type LiquiditySoucesRes ¶ added in v0.0.7
type LiquiditySoucesRes struct {
Protocols []Protocols `json:"protocols"`
}
type QuoteOpts ¶ added in v0.0.5
type QuoteOpts struct { // referrer's fee in percentage // Ethereum: min: 0; max: 3; Binance: min: 0; max: 3; default: 0; !should be the same for quote and swap! Fee string // liquidity protocols that can be used in a swap Protocols string // gas price // default: fast from network GasPrice string // how many connectorTokens can be used // min: 0; max: 3; default: 2; !should be the same for quote and swap! ComplexityLevel string // contract addresses of connector tokens // max: 5; !should be the same for quote and swap! ConnectorTokens string // maximum amount of gas for a swap GasLimit string // virtual split parts. default: 50; max: 500; !should be the same for quote and swap! VirtualParts string // maximum number of parts each main route part can be split into // split parts. default: Ethereum: 50; Binance: 40 max: Ethereum: 100; Binance: 100; !should be the same for quote and swap! Parts string // maximum number of main route parts // default: Ethereum: 10, Binance: 10; max: Ethereum: 50, Binance: 50 !should be the same for quote and swap! MainRouteParts string }
type QuoteRes ¶
type QuoteRes struct { // parameters of a token to sell FromToken Token `json:"fromToken"` // parameters of a token to buy ToToken Token `json:"ToToken"` // input amount of fromToken in minimal divisible units ToTokenAmount string `json:"toTokenAmount"` // result amount of toToken in minimal divisible units FromTokenAmount string `json:"fromTokenAmount"` // route of the trade Protocols []Protocol `json:"protocols"` // rough estimated amount of the gas limit for used protocols; // do not use estimatedGas from the quote method as the gas limit of a transaction EstimatedGas int64 `json:"estimatedGas"` }
type SwapOpts ¶ added in v0.0.5
type SwapOpts struct { // protocols that can be used in a swap Protocols string // address that will receive a purchased token // Receiver of destination currency. default: fromAddress DestReceiver string // referrer's address ReferrerAddress string // referrer's fee in percentage // Ethereum: min: 0; max: 3; Binance: min: 0; max: 3; default: 0; !should be the same for quote and swap! Fee string // gas price // default: fast from network GasPrice string // if true, CHI will be burned from fromAddress to compensate gas // default: false; Suggest to check user's balance and allowance before set this flag; CHI should be approved to spender address BurnChi bool // how many connectorTokens can be used // min: 0; max: 3; default: 2; !should be the same for quote and swap! ComplexityLevel string // contract addresses of connector tokens // max: 5; !should be the same for quote and swap! ConnectorTokens string // if true, accept the partial order execution AllowPartialFill bool // if true, checks of the required quantities are disabled DisableEstimate bool // maximum amount of gas for a swap GasLimit string // virtual split parts. default: 50; max: 500; !should be the same for quote and swap! VirtualParts string // maximum number of parts each main route part can be split into // split parts. default: Ethereum: 50; Binance: 40 max: Ethereum: 100; Binance: 100; !should be the same for quote and swap! Parts string // maximum number of main route parts // default: Ethereum: 10, Binance: 10; max: Ethereum: 50, Binance: 50 !should be the same for quote and swap! MainRouteParts string }
type SwapRes ¶
type SwapRes struct { // parameters of a token to sell FromToken Token `json:"fromToken"` // parameters of a token to buy ToToken Token `json:"ToToken"` // input amount of fromToken in minimal divisible units ToTokenAmount string `json:"toTokenAmount"` // result amount of toToken in minimal divisible units FromTokenAmount string `json:"fromTokenAmount"` // route of the trade Protocols []Protocol `json:"protocols"` // transaction data Tx Tx `json:"tx"` }
type Tx ¶
type Tx struct { // transactions will be sent from this address From string `json:"from"` // transactions will be sent to our contract address To string `json:"to"` // call data Data string `json:"data"` // amount of ETH (in wei) will be sent to the contract address Value string `json:"value"` // gas price in wei GasPrice string `json:"gasPrice"` // estimated amount of the gas limit, increase this value by 25% Gas int64 `json:"gas"` }