0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEto represent ETH. It is suggested that developers identify the transaction source for attribution by setting the
auxiliaryBytesin the contract call to a unique string since these bytes are emitted by the Clipper exchange in the swap event. For instance, our Clipper Router contract uses the encoded version of ClipperRouter.
nTokens()-1, and returns the address of the ERC20 token contract) on the Pool contract. Note that ETH is always available in the Pool and is not considered to be a "token".
chain_idset to the appropriate (integer) chain ID. Polygon is 137. The JSON response will include the pool's address and list of contract addresses on that chain. Example response:
num_assetswill be an integer value with the number of assets in the pool.
assetskey at the top level is a list of length
num_assetsdescribing the pool assets. The
addressof each asset are the most important fields.
https://api.clipper.exchange/rfq/quoteendpoint a JSON body with the following keys.
output_amountshould be specified, and that value should be a string.
time_in_secondsrefers 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.
output_asset_symbolshould correspond to the asset
namereturned from the
/rfq/poolcall 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_byis 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
https://api.clipper.exchange/rfq/signendpoint with the following JSON body:
quote_idshould be set to the ID field of the quote requested above
destination_addresswill receive the output token.
externalfunctions for interacting with the Clipper exchange onchain, depending on your use case. In all of these functions,
Signatureis a struct defined by:
auxiliaryDatawhich can be set to any string and is used for identification purposes in the event logs.
transmitAndSwapstarts by transferring
msg.senderto the exchange, while
swapassumes 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.
inputTokenhas already been sent, while the second pulls that input token directly from
msg.sender. Observe further that:
outputTokenargument is not present (since it will be native currency)
Ethregardless of chain
msg.valueor by transferring that native currency to the exchange contract prior to the function call.