Options for OnboardingBridgeSDK.fundCAddressWithSwap.

The bridge contract will:

  1. Pull sourceAmount of sourceAsset from source.
  2. Route it through swapRoute (an ordered list of DEX pool addresses).
  3. Deduct the protocol fee in targetAsset.
  4. Credit the net targetAsset amount to target.
const result = await sdk.fundCAddressWithSwap(
{
source: keypair.publicKey(),
target: 'CC...',
sourceAsset: 'CD...usdc',
targetAsset: 'CD...xlm',
sourceAmount: '10000000', // 1 USDC
minTargetAmount: '9000000', // 0.9 XLM minimum (10% slippage tolerance)
swapRoute: ['CD...xlm_usdc_pool'],
},
keypair,
);
interface FundCAddressWithSwapOptions {
    minTargetAmount: string;
    source: string;
    sourceAmount: string;
    sourceAsset: string;
    swapRoute: string[];
    target: string;
    targetAsset: string;
}

Properties

minTargetAmount: string

Minimum acceptable targetAsset amount after the swap. The transaction reverts with SlippageExceeded if the DEX returns less. Set this to protect against price manipulation or large slippage.

source: string

Source G-address providing sourceAsset. Must sign the transaction.

sourceAmount: string

Gross amount of sourceAsset to swap and bridge, in its smallest unit.

sourceAsset: string

Contract address of the token the source holds and wants to swap.

swapRoute: string[]

Ordered list of DEX pool contract addresses through which the swap is routed. Each pool must implement swap(min_amount_out: i128, to: Address) → i128.

target: string

Destination C-address that will receive targetAsset.

targetAsset: string

Contract address of the token the target should receive after the swap.