Exchange

Curve Action Plugin - Exchange

Description

Perform a token exchange using a specific pool.

Method

exchange(address, address, address, uint256, uint256, address)

Input Parameters

No required input parameters

Method Parameters

NameTypeDescription

pool

FctAddress

Address of the pool to use for the swap.

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 exchange = new Curve.actions.Exchange({
   chainId: 1,
   initParams: {
     methodParams: {
       pool: "0x...",
       from: "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT
       to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
       amount: "10000",
       expected: "9999",
       receiver: "0x...",
     }
   }
})

Example without initParams

const exchange = new Curve.actions.Exchange({ chainId: 1 })

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

Learn more

Learn more about Curve exchange here

Last updated