Router & Adapters
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 grantsRouter
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'scallAction
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 aSwap
event.

Last modified 1mo ago