Skip to content

Swap

In the SAI Wallet application, token exchange is presented as a single screen, but the actual execution route depends on the type of assets being exchanged and whether the operation includes cross-chain transfer. This approach allows using different liquidity sources and different fee calculation schemes within a single user scenario.

Stablecoin Exchange via Cross-Chain Route

Stablecoin exchange in SAI Wallet is oriented toward scenarios where the user transfers value between networks and expects the result as a stablecoin in the target network. Technically, such an exchange is considered as a route of steps:

  1. preparation and estimation (quota), including fee estimation by steps;
  2. actions in the source network (e.g., approval/transfer);
  3. cross-chain step (delivery/transfer);
  4. execution in the destination network (receiving/issuing the result).

In this class of operations, route cost accounts for:

  • network fees for transactions ($F_{gas}$);
  • cross-chain step costs ($F_{infra}$);
  • exchange and liquidity losses, if the route includes a swap ($F_{swap}$);
  • SAI Wallet fee, if it applies to this route ($F_{app}$).

The SAI Wallet fee is accounted for as a separate route cost component (see Economics) and may be charged at the smart contract level of the route.

Exchange of Other Tokens via External Platform

For tokens that are not in the supported set of stablecoins or do not require cross-chain transfer, SAI Wallet uses an exchange module based on an external platform/liquidity aggregator.

This page uses a template, as the specific platform may be specified:

  • Provider: (to be selected)
  • Documentation/link: (to be added)

In this scheme, SAI Wallet forms exchange parameters, receives a quote from the provider, and executes the exchange through a transaction in the corresponding network. Route costs in this case consist of network fees ($F_{gas}$), swap losses ($F_{swap}$), and possible SAI Wallet fee ($F_{app}$), if it applies to the operation.

Single Screen and Exchange Mechanism Selection

At the UI level, exchange is presented as a single screen. At the execution level, SAI Wallet selects the exchange mechanism by operation parameters:

  • type of input and output asset (stablecoin/non-stablecoin);
  • source and destination networks (intra-network operation or cross-chain);
  • route availability and aggregate cost estimation.

Below is a simplified decision route (logic is illustrative; specific rules depend on supported networks and assets):

Swap mechanism

Exchange mechanism selection is described as an engineering rule for minimizing route costs and dependency on external services: for some scenarios, a route relying on cross-chain infrastructure and own contracts is preferable, while for others - an external exchange module.

Exchange operations are used as steps in most workflows (entry/exit from positions, asset conversion, rebalancing). When calculating net results, slippage and exchange fees are accounted for along with gas costs and cross-chain costs (see Economics).