TAYA
  • about taya
    • Introduction
    • Features
    • Liquidity Pools
      • Dynamic LP
      • Concentrated LP
    • Swap
  • Dapp as a service
    • D-A-A-S
    • Component
    • SDK/API
  • Tokenomic
    • Taya Toknomic
  • further information
    • Roadmap
    • Audit
    • Media Kit
    • Links
Powered by GitBook
On this page
  1. about taya

Swap

SwapCraft Function

Taya is an automated market maker (AMM), a decentralized exchange (DEX) that allows users to trade assets directly without the need for a traditional order book to match buyers and sellers.

SwapCraft Function

At the heart of SwapCraft lies the "swapTokens" function, a powerful mechanism that facilitates token exchanges with ease. Let's delve into its core components:

function swapTokens(
    TokenSwap tokenSwapRequest,
    AssetManagement assetRouting,
    uint256 tradeThreshold,
    uint256 swapExpiry
) returns (uint256 tradeResults[In/Out])
  • poolIdentifier: Identifies the pool designated for the swap.

  • tradeType: Precisely defines the type of trade, allowing for either "Out Given Exact In" or "In Given Exact Out" swaps.

  • inputAsset: Refers to the asset intended to be swapped into the pool.

  • outputAsset: Signals the asset to be acquired in exchange.

  • tradeAmount: Its meaning seamlessly adjusts according to the selected "tradeType":

    1. GIVEN_IN: Signifies the amount of assets being dispatched.

    2. GIVEN_OUT: Designates the target amount of assets to be received.

  • userSpecificData: This field serves as a conduit for any supplementary information necessary for the pool to execute the swap, thus facilitating future enhancements in the swapping protocol.

TokenSwap Structure

A vital cog in the SwapCraft machinery is the "TokenSwap" structure, meticulously outlined as follows:

enum ExchangeType { GIVEN_IN, GIVEN_OUT }

struct TokenSwap {
   bytes32 poolIdentifier;
   ExchangeType tradeType;
   IAsset inputAsset;
   IAsset outputAsset;
   uint256 tradeAmount;
   bytes userSpecificData;
}

AssetManagement Structure

The "AssetManagement" structure plays a pivotal role in determining the flow of input and output assets. It takes the following form:

struct AssetManagement {
    address senderAddress;
    bool sourceFromInternalStorage;
    address payable receiverAddress;
    bool sendToInternalStorage;
}
  • senderAddress: Specifies the address from which assets will be sourced for the swap.

  • sourceFromInternalStorage: Dictates whether the assets should be drawn from the sender's pre-existing holdings within the Vault.

  • Taya's bespoke swap function tailored to our unique pool types, fortified with the robust technology inherited from the Balancer swap module.

Last updated 6 months ago

Tayaswap's bespoke swap function tailored to our unique pool types, fortified with the robust technology inherited from the swap module.

Balancer