Skip to Content

SDK Params

fillOrKillParams

The fillOrKillParams object sets two different types of slippage protection when initiating a swap.

  1. minimum accepted price This protects the swapper against price changes between a quote and the execution of a swap by setting a minimum accepted price. If the minimum price cannot be met with the available liquidity during the specified number of blocks, deposited assets will be refunded to the specified refund address.
  2. live price protection This protects the swapper from getting an execution price that significantly deviates from the global index price of the asset (as determined by an oracle) ensuring the LPs are offering competitive pricing. Similar to other slippage settings, the execution of the swap will be paused until an LP offers a price that is within the specified deviation or the swap deadline is reached - in which case the swap will be refunded. This setting is especially useful during longer DCA swaps where the price of the asset is moving in favor of the swapper. i.e the slippage tolerance will “follow” the global price of the asset. In case the price moves against the swapper, it will still execute as long as the execution price is above the minimum accepted price.
type FillOrKillParams = { refundAddress: string; livePriceSlippageTolerancePercent?: string | number; refundCcmMetadata?: CcmParams | null; } & ( | { minPrice: string; retryDurationBlocks: number } | { minPrice: string; retryDurationMinutes: number } | { slippageTolerancePercent: string | number; retryDurationBlocks: number } | { slippageTolerancePercent: string | number; retryDurationMinutes: number } );
ParamDescriptionData type
refundAddressAddress on the source chain to which the refund will be sent, if the minimum price cannot be met.string
slippageTolerancePercentThe percent of slippage that is acceptable for the swap. The estimatedPrice field from the quote is used to calculate the minimum price for the channel. This field must be left out when specifying a minPrice.string | number
minPriceMinimum accepted price for swaps triggered through the deposit channel. This field must be left out when specifying a slippageTolerancePercent.string
retryDurationBlocksNumber of State Chain blocks after which a deposit is refunded, if the minimum price cannot be met. One State Chain block corresponds to 6 seconds. This field must be left out when specifying a retryDurationMinutes.number
retryDurationMinutesNumber of minutes after which a deposit is refunded, if the minimum price cannot be met. Converted to State Chain blocks by the SDK. Pass the recommendedRetryDurationMinutes field from the quote to use the recommended value. This field must be left out when specifying a retryDurationBlocks.number
livePriceSlippageTolerancePercent (optional)The percentage deviation from the global index price that is acceptable for the swap to execute. If the deviation exceeds, the swap will be refunded to the specified refund address. If not set, the recommendedLivePriceSlippageTolerancePercent from the quote is applied. (if available for the asset pair)string | number
refundCcmMetadata (optional)ccmParams to attach to the refund transaction, so a message is passed to a receiver contract/program on the source chain when the swap is refunded.CcmParams | null

Exactly one of minPrice / slippageTolerancePercent and exactly one of retryDurationBlocks / retryDurationMinutes must be provided. Both tolerance values must be between 0 and 100 inclusive. Passing a livePriceSlippageTolerancePercent for an asset pair that does not support live price protection throws an error.

Slippage tolerance is applied relative to the quoted price unlike live price slippage which is applied relative to the global index price. Prices are checked on the AMM level and do not include deposit or broadcast fees.

Live price slippage protection is only available for asset pairs that have a recommendedLivePriceSlippageTolerancePercent in the quote and this execution does NOT need to account for protocol or broker fees.

Example

const fillOrKillParams = { refundAddress: "0xa56A6be23b6Cf39D9448FF6e897C29c41c8fbDFF", // address to which assets are refunded retryDurationBlocks: 100, // 100 blocks * 6 seconds = 10 minutes before deposits are refunded slippageTolerancePercent: quote.recommendedSlippageTolerancePercent, // use recommended slippage tolerance from quote livePriceSlippageTolerancePercent: quote.recommendedLivePriceSlippageTolerancePercent, // use recommended live price slippage tolerance from quote };

Using the recommended retry duration from the quote instead of a fixed number of blocks:

const fillOrKillParams = { refundAddress: "0xa56A6be23b6Cf39D9448FF6e897C29c41c8fbDFF", retryDurationMinutes: quote.recommendedRetryDurationMinutes, // use recommended retry duration from quote slippageTolerancePercent: quote.recommendedSlippageTolerancePercent, livePriceSlippageTolerancePercent: quote.recommendedLivePriceSlippageTolerancePercent, };

ccmParams

The Cross-Chain Messaging optional ccmParams object enables to pass a Cross-Chain Message to a receiver contract/program on the destination chain.

type CcmParams = { gasBudget: string; message: string; ccmAdditionalData?: string; };
ParamDescriptionData type
message (required)Message (bytes) that is passed to the destination address on the destination chain. Hex-encoded, up to 15,000 bytes.string
gasBudget (required)Gas budget for the call on the destination chain. This amount is the amount of gas or compute units required by the user logic on the destination chain. Passed as a decimal or hex-encoded string.string
ccmAdditionalData (optional)Additional bytes required for the CCM call on the destination chain. This is required for Solana to pass the accounts that are required for the call. Hex-encoded, up to 3,000 bytes. Defaults to 0x.string

The presence of ccmParams must match between the quote and the swap request. Passing ccmParams to requestDepositAddressV2, encodeVaultSwapData or encodeCfParameters throws unless the quote was requested with ccmParams, and vice versa.

Example

const ccmParams = { message: "0xdeadc0de", gasBudget: "250000", };
Last updated on