Class: WardenBestRate
Warden Best Rate for getting quote and swapping.
Constructors
constructor
▸ new WardenBestRate(provider
, networkName
, options?
)
Create new instance of WardenBestRate
Parameters
Name | Type | Description |
---|---|---|
|
| ethersjs' Provider instance |
|
| Chain name (supported by WardenSwap), |
|
| Options |
Methods
approve
▸ approve(signer
, src
, allowedAmount?
, overrides?
): Promise
<ContractTransaction
>
Set Allowance of a token to be spendable by WardenSwap contract
Parameters
Name | Type | Default value | Description |
---|---|---|---|
|
|
| ethers' Signer |
|
|
| Token to be approved |
|
|
| Allowed amount to be spendable by WardenSwap contract |
|
|
| ethers' overrides |
Returns
Promise
<ContractTransaction
>
ethers' contract transaction (no wait)
getDepositAddresses
▸ getDepositAddresses(srcDestRouteTuples
, dexManager?
): string
[]
Get deposit addresses indicating the first hop to be used for starting the trade. This information is required by Wardenswap contract
Parameters
Name | Type | Description |
---|---|---|
| { | tuples of src, dest, and routeAddress |
|
| - |
Returns
string
[]
a list of deposit addresses with the same order as the input
getQuote
▸ getQuote(src
, dest
, amountIn
, gasPrice
, opts?
): Promise
<QuoteResult
>
Get the best rate of a token pair with given amount
Parameters
Name | Type | Description |
---|---|---|
|
| Address of src asset |
|
| Address of dest asset |
|
| Amount of src asset to be traded |
|
| Amount of gas price per unit in native currency (18 decimals) e.g. BSC = BNB, Polygon = MATIC, Ethereum = ETH. For L2 chains, this is Ethereum (L1) gas price. |
|
| Options for getting quote |
Returns
Promise
<QuoteResult
>
Trading routes which provide the best rate
swap
▸ swap(signer
, src
, dest
, amountIn
, minDestAmount
, quoteResult
, partnerId?
, metaData?
, receiver?
, overrides?
): Promise
<ContractTransaction
>
Send a swap transaction to WardenSwap based on given quote
Parameters
Name | Type | Default value | Description |
---|---|---|---|
|
|
| ethers' Signer |
|
|
| Source token |
|
|
| Destination token |
|
|
| Amount of source token |
|
|
| Minimum amount of destination token |
|
|
| Best rate quote got from |
|
|
| Warden's partner ID |
|
|
| MetaWarden ID |
|
|
| Wallet to receive destination token, default to tx sender |
|
|
| ethers' transaction overrides |
Returns
Promise
<ContractTransaction
>
ethers' contract transaction (no wait)
Last updated