POST
/
v0
/
uniswap
/
swap
/
buy_exactly
import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.uniswapV3.swapBuyExactly({
    tokenIn: "FXS",
    tokenOut: "ETHx",
    fee: "0.01",
    amount: 1.5,
    maxSlippagePercent: 0.5,
    wrapEth: true,
    chain: "ethereum:mainnet",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();
{
  "chainId": 123,
  "data": "<string>",
  "from": "<string>",
  "gas": 123,
  "to": "<string>",
  "value": 123,
  "nonce": 123,
  "maxFeePerGas": 123,
  "maxPriorityFeePerGas": 123,
  "authorizationList": []
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json

Request model for buying an exact amount of tokens.

Response

200
application/json

Successful Response

The response is of type object.