ExchangeWithBestRate

Curve Action Plugin - ExchangeWithBestRate

Description

Perform an exchange using the pool that offers the best rate.

Method

exchange_with_best_rate(address, address, uint256, uint256, address)

Input Parameters

No required input parameters

Method Parameters

NameTypeDescription

from

FctAddress

Address of coin being sent.

to

FctAddress

Address of coin being received.

amount

FctValue

Quantity of from being sent.

expected

FctValue

Minimum quantity of to received in order for the transaction to succeed.

receiver

FctValue

Optional address to transfer the received tokens to. If not specified, defaults to the caller.

Returned Values

NamePlugin TypeDescription

amountReceived

FctValue

Amount received in the exchange

Example

Example with initParams

const exchangeWithBestRate = new Curve.actions.ExchangeWithBestRate({
   chainId: 1,
   initParams: {
     methodParams: {
       from: "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT
       to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
       amount: "10000",
       expected: "9999",
       receiver: "0x...",
     }
   }
})

Example without initParams

const exchangeWithBestRate = new Curve.actions.ExchangeWithBestRate({ chainId: 1 })

exchangeWithBestRate.input.set({
    methodParams: {
       from: "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT
       to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
       amount: "10000",
       expected: "9999",
       receiver: "0x...",
    }
})

Learn more

Learn more about Curve exchange here

Last updated