Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

swapExactAmountIn

Submit an instant swap with an exact input amount and an optional minimum output for slippage control.

Signature

function swapExactAmountIn(
  client: Client<Signer>,
  parameters: {
    sender: Address
    route: SwapRoute
    input: Coin
    minimumOutput?: string
  },
): Promise<{ hash: Uint8Array } & TxData>

Example

import { createSignerClient, createTransport, testnet, PrivateKeySigner } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createSignerClient({
  chain: testnet,
  transport: createTransport(),
  signer: PrivateKeySigner.fromMnemonic(process.env.DANGO_MNEMONIC!),
})
const sender: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
await client.swapExactAmountIn({
  sender,
  input: { denom: "dango", amount: "1000000000" },
  route: [{ baseDenom: "dango", quoteDenom: "bridge/usdc" }],
  minimumOutput: "490000000",
})

Parameters

senderAddress. The trader.

routeSwapRoute. Array of PairId hops.

inputCoin. Exact input { denom, amount } in base units. The denom must be the base or quote of the first pair.

minimumOutputstring, optional. Minimum output amount in base units. The swap reverts if the realized output is below this.

Returns

{ hash: Uint8Array } & TxData — see broadcastTxSync.

See also