Swap tokenIn for tokenOut at market price
Market swaps use a Uniswap V3 TWAP value to determine the price of tokenIn
relative to tokenOut
.
Schema
Property | Required | Description |
---|---|---|
type | Yes | "marketSwap" |
owner | Yes | Address that will release input token and require output token. This also needs to be the address that sets approval allowance to the signer's account |
tokenIn | Yes | Address of the input token |
tokenOut | Yes | Address of the output token |
tokenInAmount | Yes | Amount of tokenIn allowed to be sent from the signer to the solver |
fee | Yes | The fee that the signer is willing to pay for the swap, as a percentage of the total swap value. Expects a number from 0 to 100. The fee can be subtracted from the market output in order to determine the amount of tokenOut that the signer requires. For example, for a 10 WETH to DAI market swap with a 0.5% fee, if the TWAP reports a WETH/DAI price of 1,500 then the solver would be required to pay the signer 14,925 DAI (15,000 DAI - 75 DAI). |
twapInterval | No | The TWAP interval to use in seconds. Default is 1000. |
twapFeePool | No | The TWAP fee pool to use. Expects a Uniswap FeeAmount. Default is 3000. |
Example
{
type: 'marketSwap',
owner: '0xD12598bc2260f803a157a970486cE5e711B8CB3B', // address that holds USDC and receives WETH
tokenIn: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
tokenOut: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
tokenInAmount: 7500_000000,
fee: 1.5
}