Ondefy Docs
  • Getting Started
    • Introduction to Ondefy
    • FAQ
    • Supported chains and exchanges
  • Ondefy Solutions
    • Ondefy Superapp
    • Ondefy Widget
      • Smart Ramp
      • Swap
      • Developer guides
        • Integrate with iframe
        • integrate with web component
          • Installation
          • Usage
          • Launch in fullscreen
          • Typescript notes
  • Smart Contracts
    • Router & Adapters
      • Ethereum
      • Arbitrum
      • Polygon
  • Socials & Support
    • Website
    • X
    • Discord
    • Telegram
    • Medium
  • About Us
    • Company and Team
    • Brand Assets
Powered by GitBook
On this page
  • Contract flow
  • Deployments
  1. Smart Contracts

Router & Adapters

Previousintegrate with web componentNextEthereum

Last updated 1 year ago

In order to eliminate the necessity for an approval transaction and to apply a service fee to our orders, we've implemented a system comprising a central Router contract, in conjunction with adapters tailored to each of our partner swap protocols.

Contract flow

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.

Deployments

Ethereum
Arbitrum
Polygon
Smart Ramp