Sign

The endpoint plays a pivotal role in the preparation and execution of secure asset swaps on the blockchain. By providing a Quote ID and a destination address, users can initiate the signing process, resulting in the generation of the essential signature and transaction data. This signature and data package, in turn, is integral for ensuring the validity and security of asset transfers within the blockchain network.

Request

Body ParamDescriptionExample

quote_id

String(UUID) - Required The id of the quote returned in quote endpoint

"4c707e45-7019-4b81-b875-c5eb6fe061d6"

destination_address

String - Required It will receive the output token

"0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9"

sender_address

String - Optional it is for DEX aggregator partners that are using their own smart contract to mediate the interaction between users and Clipper. Aggregators should use the address of the account that they will pull tokens from (i.e., the EOA user address) as opposed to the address of their deployed contract. This is an optional value on signing requests - by default, destination_address will be used.

"0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9"

aux_data

String(bit32) - Optional It is for use the calldata swap feature, it can be set to any string and is used for identification purposes in the event logs. By default is 0x436c697070657200000000000000000000000000000000000000000000000000 that is the representation of Clipper

"0x31494e4348000000000000000000000000000000000000000000000000000000"

calldata

Bool - Optional Send this as true if we want to get the bytes representation of the swap in the response. Client can use this to be sent directly to the pool contract for execution. Default is false

true

native_input

Bool - Optional If the input token is native (e.g. raw ETH), this value must be true. This will use the sellEthForToken contract function and will take the msg.value for the input. e.g ETH -> USDC Default is false This field is mutually exclusive with native_output

true

native_output

Bool - Optional If the output token is native (i.e. raw ETH), this value must be true. This will use the sellTokenForEth contract function. e.g USDC -> ETH Default is false This field is mutually exclusive with native_input

true

In case that you want to deal with raw ETH or MATIC for input or output on the swap you should use native_input and native_output params. More details about Native Tokens can be found here.

Response

Sign object

FieldDescription

chain_id

Integer - Represents the ID of the chain

input_asset_address

String - Contract address of the asset you want to provide for the swap

output_asset_address

String - Contract address of the asset you want to receive in the swap

input_amount

String - Amount of assets to be exchanged

output_amount

String - Amount of assets you will receive in the exchange

good_until

String - Number of seconds that quotes live. It can also contained a packed representation of the state

destination_address

String - Address will receive the output token

signature

Object - A EIP 2098 "short signature" representation for the signature from the Clipper Exchange server

clipper_exchange_address

String - Clipper contract address of the pool, is the address used when executing a transaction

calldata

String - Bytes representation of the swap function and parameters to be sent directly to the clipper_exchange_address for execution

Examples

Without calldata

If you want to sign a quote and manually use the values in the response to create the transaction.

Request

curl -X POST "https://api.clipper.exchange/rfq/sign" \
-H "Authorization: Basic <base64 USERNAME:PASSWORD>" \
-H "Content-Type: application/json" \
-d '{
  "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
  "quote_id": "<QUOTE_ID>"
}'

Response

{
    "chain_id": 1,
    "input_asset_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "output_asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "input_amount": "10000000000000000000",
    "output_amount": "5661947917",
    "good_until": "364238673390486983853316167090878487969884185392043445686993915855904",
    "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
    "signature": {
        "v": 28,
        "r": "0xfb8599e4ef2c89b03e1ebc3067f0ba38ecea64517bafa932e5c642318ec923d9",
        "s": "0x1d3c7e38951b23bc459ac91ad668dede2a681bc4c98b915116983f4ae1dcdaa7"
    },
    "clipper_exchange_address": "0xE7b0CE0526fbE3969035a145C9e9691d4d9D216c"
}

With Calldata

  1. If you want to sign a quote and get the bytes representation of the swap to be sent directly to the pool contract for execution.

Request

curl -X POST "https://api.clipper.exchange/rfq/sign" \
-H "Authorization: Basic <base64 USERNAME:PASSWORD>" \
-H "Content-Type: application/json" \
-d '{
  "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
  "quote_id": "<QUOTE_ID>",
  "calldata": true,
  "aux_data": "0x31494e4348000000000000000000000000000000000000000000000000000000",
}'

Response

{
    "chain_id": 1,
    "input_asset_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "output_asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "input_amount": "10000000000000000000",
    "output_amount": "5661947917",
    "good_until": "364266596581665814407146313234570973398742125152679878859837657433201",
    "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
    "signature": {
        "v": 28,
        "r": "0x762ad0475b3a7c42735686d7911f117a2ff6fca1bc3c5c75f4ee43df8da2a61b",
        "s": "0x1eceffea0a50d12566e9fa6b4d9ed826106143d321389654c3c327c648f6f3f6"
    },
    "clipper_exchange_address": "0xE7b0CE0526fbE3969035a145C9e9691d4d9D216c",
    "calldata": "0x2b651a6c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000001517a780d0000000d82eb0b930000000005f7906e00b1a2bc2ec50000006400bc6529c471000000000000000000000000960376b3f62f41e7e66809a05d1c5afdfd60a0e9000000000000000000000000000000000000000000000000000000000000001c762ad0475b3a7c42735686d7911f117a2ff6fca1bc3c5c75f4ee43df8da2a61b1eceffea0a50d12566e9fa6b4d9ed826106143d321389654c3c327c648f6f3f60000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002031494e4348000000000000000000000000000000000000000000000000000000"
}
  1. If you want to sign a quote (using native input token) and get the bytes representation of the swap to be sent directly to the pool contract.

Request

curl -X POST "https://api.clipper.exchange/rfq/sign" \
-H "Authorization: Basic <base64 USERNAME:PASSWORD>" \
-H "Content-Type: application/json" \
-d '{
  "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
  "quote_id": "<QUOTE_ID>",
  "calldata": true,
  "aux_data": "0x31494e4348000000000000000000000000000000000000000000000000000000",
  "native_input": true
}'

Response

{
    "chain_id": 1,
    "input_asset_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "output_asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "input_amount": "10000000000000000000",
    "output_amount": "5661947917",
    "good_until": "364126526759930684504042968316937832960196094624343681678885719229598",
    "destination_address": "0x960376b3F62f41E7e66809a05D1C5afdFD60A0E9",
    "signature": {
        "v": 28,
        "r": "0x1a8fc0856ff121e3ba5a244ee0837cef3d6c6ea96c593decc1b9d074c74c0139",
        "s": "0x60bd1d8700fca625b58cbc4fe84c61b29bf46c9855146eda18da557ab0e079d5"
    },
    "clipper_exchange_address": "0xE7b0CE0526fbE3969035a145C9e9691d4d9D216c",
    "calldata": "0x27a9b424000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000001517a780d0000000d81968de90000000005f7911f00b1a2bc2ec50000006400bc6529c49e000000000000000000000000960376b3f62f41e7e66809a05d1c5afdfd60a0e9000000000000000000000000000000000000000000000000000000000000001c1a8fc0856ff121e3ba5a244ee0837cef3d6c6ea96c593decc1b9d074c74c013960bd1d8700fca625b58cbc4fe84c61b29bf46c9855146eda18da557ab0e079d50000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000002031494e4348000000000000000000000000000000000000000000000000000000"
}

Last updated