Sobes.tech
Junior — Middle+

Determining the optimal token pair for exchange in a crypto wallet

livecode

Task condition

It is necessary to implement a function that selects an appropriate pair of tokens for a swap in a user's wallet.

  1. The function takes one parameter – the wallet address (for example, walletAddress).
  2. The function returns two token symbols: the token from which the swap will be made and the token to which it will be directed.
  3. The token from which the swap is performed is chosen as the one with the largest balance.
  4. Supported exchange pairs are: ETH ↔ USDC and USDT ↔ USDC.
  5. The exchange rate is fixed: 1 ETH = 2000 USDC (or USDT).