Router & Adapters
Last updated
Last updated
In order to eliminate the necessity for an approval transaction and to apply a service fee to our Smart Ramp orders, we've implemented a system comprising a central Router contract, in conjunction with adapters tailored to each of our partner swap protocols.
For Smart Ramp orders requiring a swap, after the optimal route for the swap and corresponding calldata is computed off-chain, the swap transaction goes as follow, through the execution of Router
's ftatSwapWithPermit
function :
Calldata intended for the swap protocol contract is passed to our Router
contract along with a signed permit. This permit grants Router
permission to spend input tokens for the swap.
Subsequently, the permit undergoes validation, and the approval is executed.
Router
transfers the requisite tokens from user's wallet to the relevant adapter. The calldata is also transmitted alongside, trough a call to adapter's callAction
function.
In turn, the adapter engages directly with the swap protocol through the provided calldata, using Solidity's call
function.
If execution is successful, Router
emits a Swap
event.