Megaton Finance
English
English
  • GETTING STARTED
    • Megaton Finance
    • TON Network
    • Participants
    • FAQ
  • products
    • WTON Gateway
    • Swap
    • Yield Farm
    • T@connect
      • T@connect Terms of Use
      • T@connect User Guide
      • T@connect Integration Guide
    • MEGA Staking
      • Overview
      • Staking
      • Membership Benefits
      • Unstaking
      • Early Termination
      • NFT Trading
  • TOKENOMICS
    • MEGA
      • Tokenomics (-August 31st 2023 03:00 UTC)
      • Tokenomics (Current)
      • Allocation (-August 31st 2023 03:00 UTC)
      • Allocation (Current)
  • Guides
    • Create a Wallet
    • How to deposit assets
    • How to convert TON to WTON through the WTON Gateway
    • How to get cross-chain assets on Orbit Bridge
    • Deposit LP (Yield Farm)
  • DEVELOPERS
    • Contract
      • MEGA
      • Router/Factory
      • Exchange
  • MORE
    • Risk & Security
    • Contract & Audit
    • Support & Team
  • OFFICIAL LINKS
    • Megaton Finance
    • WTON Gateway
    • Orbit Bridge
    • Discord
Powered by GitBook
On this page
  • Code
  • Functions
  • Exchange Minter
  • Exchange Wallet
  1. DEVELOPERS
  2. Contract

Exchange

This is a smart contract to expand Jetton that is created with every liquidity pair. The Router deploys this as new pool creation is requested. Although the Router actually stores the two tokens of a pair and swapping takes place through it, the Exchange Contract must be called for liquidity to be provided or taken.

Code

Github Link: (to be updated)

Functions

Exchange Minter

get_jetton_data

(int, int, slice, cell, cell) get_jetton_data() method_id
  • int totalSupply

  • int mintable

  • slice admin_address

  • cell exchange_content

  • cell exchange_wallet_code

get_lp_swap_data

(int, int, slice, slice, slice, int, int, slice, slice, int, int) get_lp_swap_data() method_id
  • int swap_fee

  • int min_amount

  • slice router_address

  • slice jettonA_address

  • slice jettonA_wallet_address

  • int jettonA_balance

  • int jettonA_pending_balance

  • slice jettonB_address

  • slice jettonB_wallet_address

  • int jettonB_balance

  • int jettonB_pending_balance

get_lp_mining_data

(int, int, int, int, int, int, cell) get_lp_mining_data() method_id
  • int mining_amount

  • int datetime_amount

  • int minable_time

  • int half_life

  • int last_index

  • int last_mined

  • cell mining_rate_cell

get_lp_user_info_dict

(cell) get_lp_user_info_dict() method_id
  • cell ( dict ) total_user_info_dict

get_lp_user_info

(int, int, int, int) get_lp_user_info(slice user_address) method_id
  • int find

  • int balance

  • int user_reward_sum

  • int last_user_index

get_wallet_address

slice get_wallet_address(slice owner_address) method_id
  • slice user_wallet_address

How to build transaction

  • Add Liquidity

// TL-B schema
// transfer query_id:uint64 amount:VarUInteger 16 destination:MsgAddress response_destination:MsgAddress custom_payload:Maybe ^Cell forward_ton_amount:VarUInteger 16 forward_payload:Either Cell ^Cell = InternalMsgBody

// 1. add liquidity tokenA
await sendInternalMessageWithWallet({
    walletContract,
    secretKey,
    to: userJettonAWalletAddress,
    value: toNano(0.7),
    body: beginCell()
        .storeUint(0xf8a7ea5, 32)
        .storeUint(query_id, 64)
        .storeCoins(jettonAAmount)
        .storeAddress(lpAddress)
        .storeAddress(responseAddress)
        .storeDict(beginCell().endCell())
        .storeCoins(toNano(0.5))
        .storeDict(beginCell()
            .storeCoins(minAmountForJettonA)
            .storeCoins(minAmountForJettonB)
        .endCell())
    .endCell()
});

// 2. add liquidity tokenB
await sendInternalMessageWithWallet({
    walletContract,
    secretKey,
    to: userJettonBWalletAddress,
    value: toNano(0.7),
    body: beginCell()
        .storeUint(0xf8a7ea5, 32)
        .storeUint(query_id, 64)
        .storeCoins(jettonBAmount)
        .storeAddress(lpAddress)
        .storeAddress(responseAddress)
        .storeDict(beginCell().endCell())
        .storeCoins(toNano(0.5))
        .storeDict(beginCell()
            .storeCoins(minAmountForJettonA)
            .storeCoins(minAmountForJettonB)
        .endCell())
    .endCell()
});
  • Remove Liquidity

// TL-B schema
// burn query_id:uint64 amount:VarUInteger 16 response_destination:MsgAddress custom_payload:Maybe ^Cell = InternalMsgBody

await sendInternalMessageWithWallet({
    walletContract,
    secretKey,
    to: lpAddress,
    value: toNano(0.35),
    body: beginCell()
        .storeUint(0x595f07bc, 32)
        .storeUint(query_id, 64)
        .storeCoins(lpAmount)
        .storeDict(beginCell()
            .storeCoins(minAmountForJettonA)
            .storeCoins(minAmountForJettonB)
        .endCell())
    .endCell()
});
  • Claim

// TL-B schema
// claim query_id:uint64 = InternalMsgBody

await sendInternalMessageWithWallet({
    walletContract,
    secretKey,
    to: lpAddress,
    value: toNano(0.15),
    body: beginCell()
        .storeUint(0x6b14cfe1, 32)
        .storeUint(query_id, 64)
    .endCell()
});

Exchange Wallet

get_wallet_data

(int, slice, slice, cell) get_wallet_data() method_id
  • int balance

  • slice owner_address

  • slice lp_minter_address

  • cell lp_wallet_code

get_wallet_extra_data

(int, int, slice, slice) get_wallet_extra_data() method_id
  • int jettonA_pending_balance

  • int jettonB_pending_balance

  • slice jettonA_address

  • slice jettonB_address

PreviousRouter/FactoryNextRisk & Security

Last updated 1 year ago