Portals Logo

Documentation
Guides
Get a Quote

Get a Portal Quote

GET v2/portal

This endpoint is for generating a Portal order to transform an inputToken into an outputToken. This endpoint returns an unsigned tx object and an EIP-712 signedOrder, in addition to a context object whose properties describe the Portal order and contain other useful properties.

For more about signedOrder object, see the section on Gasless Transactions.

TIP: The response will not contain a signedOrder object if the inputToken is a Native token or if the gas cost of the Portal transaction is greater than the inputAmount.

Example: Getting Curve Frax (FRAX, 3Pool) LP tokens with USDC

Request

"inputToken": "ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"inputAmount": "28215061",
"outputToken": "ethereum:0x3175df0976dfa876431c2e9ee6bc45b65d3473cc",
"sender": "0x4689cff824d63117f9c4c42f3ec0001676f00d25",

NOTE: Auto slippage will be used if slippageTolerancePercentage is not provided and validate is set to true (default value).

Response

The response includes a tx object which is a valid unsigned Ethereum transaction that can be signed with Ethers (or other Web3 libraries) and submitted to a node (e.g. via Metamask or XDEFI wallet).

The gasLimit property includes a ~10% buffer to ensure that transaction failures due to "out of gas" errors are minimized. Due to this buffer, gas estimates will appear higher than the transaction will actually consume.

The validate flag checks that the sender has granted allowance to the target for inputToken, that they have at least inputAmount, and that they have enough native tokens to pay for the gas (if not using the signedOrder). If you would like to skip these checks, such as when the tx.data object is being consumed in a smart contract that will grant an allowance to target at execution time, set validate to false (keep in mind that auto slippage cannot be used if validate is false).

{
  "tx": {
    "data": "0xa2e42c650000000000000000000000000000000000000000000000000000000000000040000000000000000000000000fbd4c3d8be6b15b7cf428db2838bb44c0054fcd2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000001ae87150000000000000000000000003175df0976dfa876431c2e9ee6bc45b65d3473cc000000000000000000000000000000000000000000000001851a6aec0a8071870000000000000000000000004689cff824d63117f9c4c42f3ec0001676f00d2500000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000080ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000fbd4c3d8be6b15b7cf428db2838bb44c0054fcd20000000000000000000000000000000000000000000000000000000000014aa500000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dcef968d416a41cdac0ed8702fac8128a64241a2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000dcef968d416a41cdac0ed8702fac8128a64241a20000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000640b4c7e4d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003175df0976dfa876431c2e9ee6bc45b65d3473cc0000000000000000000000003175df0976dfa876431c2e9ee6bc45b65d3473cc000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000004689cff824d63117f9c4c42f3ec0001676f00d25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "to": "0xbf5a7f3629fb325e2a8453d595ab103465f75e62",
    "from": "0x4689cff824d63117f9c4c42f3ec0001676f00d25",
    "value": "0",
    "gasLimit": "337306"
  },
  "context": {
    "orderId": "d226938a-e291-4b70-ac46-bef843657887",
    "minOutputAmount": "28037839992169460103",
    "minOutputAmountUsd": 28.03483837887616,
    "minOutputAmountSignedOrder": "18373473875439565006",
    "minOutputAmountUsdSignedOrder": 18.371506888558834,
    "slippageTolerancePercentage": 0.33,
    "gasLimit": "337306",
    "inputAmount": "28215061",
    "inputAmountUsd": 28.211844483046,
    "inputToken": "ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "outputToken": "ethereum:0x3175df0976dfa876431c2e9ee6bc45b65d3473cc",
    "outputAmount": "28108110267839057747",
    "outputAmountUsd": 28.105101131705425,
    "outputAmountSignedOrder": "18444021307341966320",
    "outputAmountUsdSignedOrder": 18.44204676794972,
    "partner": "0xFBD4C3D8bE6B15b7cf428Db2838bb44C0054fCd2",
    "feeToken": "ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "feeAmount": "84645",
    "feeAmountUsd": 0.08463535047000001,
    "feeAmountSignedOrder": "9748801",
    "feeAmountUsdSignedOrder": 9.747689714225704,
    "sender": "0x4689cff824d63117f9c4c42f3ec0001676f00d25",
    "recipient": "0x4689cff824d63117f9c4c42f3ec0001676f00d25",
    "target": "ethereum:0xbf5a7f3629fb325e2a8453d595ab103465f75e62",
    "value": "0",
    "route": ["USDC", "crvFRAX"],
    "steps": [
      "Transfer 0.084645 USDC to fee collector at ethereum:0xFBD4C3D8bE6B15b7cf428Db2838bb44C0054fCd2",
      "Approve USDC to 0xdcef968d416a41cdac0ed8702fac8128a64241a2",
      "Curve add_liquidity from USDC to crvFRAX",
      "Transfer crvFRAX to 0x4689cff824d63117f9c4c42f3ec0001676f00d25"
    ],
    "stepsSignedOrder": [
      "Transfer 9.748801 USDC to fee collector at ethereum:0xFBD4C3D8bE6B15b7cf428Db2838bb44C0054fCd2",
      "Approve USDC to 0xdcef968d416a41cdac0ed8702fac8128a64241a2",
      "Curve add_liquidity from USDC to crvFRAX",
      "Transfer crvFRAX to 0x4689cff824d63117f9c4c42f3ec0001676f00d25"
    ],
    "routeHash": "0xd67340dad900bb9489ec3aabdf9cdbb0309988dc0279f44dc03d3d94bfb4cf3a"
  },
  "signedOrder": {
    "types": {
      "Order": [
        {
          "name": "inputToken",
          "type": "address"
        },
        {
          "name": "inputAmount",
          "type": "uint256"
        },
        {
          "name": "outputToken",
          "type": "address"
        },
        {
          "name": "minOutputAmount",
          "type": "uint256"
        },
        {
          "name": "recipient",
          "type": "address"
        }
      ],
      "SignedOrder": [
        {
          "name": "order",
          "type": "Order"
        },
        {
          "name": "routeHash",
          "type": "bytes32"
        },
        {
          "name": "sender",
          "type": "address"
        },
        {
          "name": "deadline",
          "type": "uint64"
        },
        {
          "name": "nonce",
          "type": "uint64"
        }
      ]
    },
    "domain": {
      "name": "PortalsRouter",
      "version": "1",
      "chainId": 1,
      "verifyingContract": "0xbf5a7f3629fb325e2a8453d595ab103465f75e62"
    },
    "value": {
      "order": {
        "inputToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "outputToken": "0x3175df0976dfa876431c2e9ee6bc45b65d3473cc",
        "inputAmount": "28215061",
        "minOutputAmount": "18373473875439565006",
        "recipient": "0x4689cff824d63117f9c4c42f3ec0001676f00d25"
      },
      "routeHash": "0x47bd3e254ee6bbdfe9053cd260d8073c18c126bcbd91b6d82d663d60bc6ae98b",
      "sender": "0x4689cff824d63117f9c4c42f3ec0001676f00d25",
      "deadline": "1690366882",
      "nonce": "0"
    }
  }
}

Submitting orders with gasless approvals (permit)

If you are making use of gasless approvals via permit (as described here), you can submit the permit signature as part of the request with the permitSignature param. The signature is an EIP-712 secp256k1 signature of bytes type and is defined in EIP-2612.

NOTE: You can use gasless approvals without using gasless transactions (i.e., you can bundle the approval and value transaction together but still submit it yourself and pay the gas).