https://api.clipper.exchange/rfq/pool?chain_id=....
with the chain_id
set to the appropriate (integer) chain ID. The JSON response will include the pool's address and list of contract addresses on that chain. Example response:num_assets
will be an integer value with the number of assets in the pool.assets
key at the top level is a list of length num_assets
describing the pool assets. The name
and address
of each asset are the most important fields.https://api.clipper.exchange/rfq/quote
endpoint a JSON body with the following keys.input_amount
or output_amount
should be specified, and that value should be a string.time_in_seconds
refers to the amount of time between accepting a quote and receiving the quote on the blockchain. A good suggestion for Polygon is 30 seconds. As this value increases, the quote will get worse for the user.input_asset_symbol
and output_asset_symbol
should correspond to the asset name
returned from the /rfq/pool
call above. Observe that "ETH" and "MATIC" are both assets, but that the Clipper exchange uses the wrapped version of these assets, a distinction made clear and unambiguous by the inclusion of the contract addresses in the response.must_accept_by
is a human-readable UTC timestamp by which you must accept the quote and should be expected to be a short duration. If this time has passed already, request a new quote - the server will not sign a quote after must_accept_by
has passed.https://api.clipper.exchange/rfq/sign
endpoint with the following JSON body:quote_id
should be set to the ID field of the quote requested abovedestination_address
will receive the output token.external
functions for interacting with the Clipper exchange onchain, depending on your use case. In all of these functions, Signature
is a struct defined by:auxiliaryData
which can be set to any string and is used for identification purposes in the event logs.swap
and transmitAndSwap
is that transmitAndSwap
starts by transferring inputAmount
of the inputToken
from msg.sender
to the exchange, while swap
assumes that the appropriate amount of the input token has already been transmitted. Which function you should use depends on if and how you are connecting the Clipper swap to other operations.inputAmount
of inputToken
has already been sent, while the second pulls that input token directly from msg.sender
. Observe further that:outputToken
argument is not present (since it will be native currency)Eth
regardless of chainmsg.value
or by transferring that native currency to the exchange contract prior to the function call.0x0000000000000000000000000000000000000802
.calldata
APIcalldata
in order to lower transactions costs. These functions are:packedTransmitAndSwap
to transmit the token from msg.sender
and use packedSwap
if tokens have already been transmitted.address(0)
. uint256
value. The packed format puts the address as the (first, lowest order) 160 bits (= 40 hex values = 20 bytes) and the amount as the (second, highest order) 96 bits (= 24 hex values = 12 bytes). To created a packed value, leftshift the integer amount by 160 bits and add it to the binary representation of the contract address. The three packed arguments into this function, and the values they encode, are:packedInput
: input amount and contract addresspackedOutput
: output amount and contract addresspackedDestination
: destination address and good until