tongo icon indicating copy to clipboard operation
tongo copied to clipboard

ABI support for BCL contracts (Ton.Fun)

Open tontradingbot-dev opened this issue 10 months ago • 1 comments

Ton.Fun is a software interface to a public blockchain protocol, enabling easy creation, collection, and trading of memes or vanity coins (tokens) in a peer-to-peer (P2P) manner. (source)

Recently launched on the TON Blockchain, Ton.Fun has quickly become a popular memepad. At its core, Ton.Fun utilizes BCL contracts, which consist of:

  • BCL Master: Responsible for deploying new BCL Jetton contracts
  • BCL Jetton: A modified TON Jetton contract that adheres to the standard Jetton specification and adds extra functions. Its goal is to add ability to trade tokens on bonding curve without using DEX's and safely list token on DEX after all coins are sold.
  • BCL Wallet: Similar to standard Jetton Wallets, but with the added ability to sell coins directly back to the Jetton master contract. All wallets are locked by default, meaning no wallet-to-wallet transfers are allowed. Once the trading phase concludes and liquidity is sent to a DEX, the wallet can be unlocked by sending a special message to the Jetton master. If a wallet receives a transfer from another wallet, it unlocks automatically.

This PR adds three mentioned contracts (interfaces), along with the TLB of most of their messages and get methods. Most changes in this PR were auto-generated, and the only file added is abi/schemas/bcl.xml.

All changes in this PR were also thoroughly tested in the production environment at TonTradingBot.

Note: There are a few irregular types in the TL-B schema: BclReferralData, BclBuyerAddress, and BclDeployOptions.

ref_v1#f7ecea4c address:MsgAddress = BclReferralData;
ref_none#_ = BclReferralData;

addr_std$100 workchain_id:int8 address:bits256 = BclBuyerAddress;
addr_none#_ = BclBuyerAddress;

deploy_buy#af750d34 query_id:uint64 min_receive:(VarUInteger 16) referral:(Maybe ^BclReferralData) buyer_address:BclBuyerAddress = BclDeployOptions;
deploy_top_up#d372158c query_id:uint64 = BclDeployOptions;
deploy_none#_ = BclDeployOptions;

As they are serialized and deserialized optionally without an indicator bit (Maybe), we were unsure whether this was the correct way to define their schema. Example from ton-bcl-sdk:

let buyMessage = beginCell()
    .storeUint(crc32str("op::buy"), 32)
    .storeUint(opts.queryId ?? 0, 64)
    .storeCoins(opts.minReceive)
    .storeMaybeRef(opts.referral)

if (opts.buyerAddress) {
    buyMessage.storeAddress(opts.buyerAddress)
}

Resources:

  • https://tonfun-1.gitbook.io/tonfun
  • https://github.com/ton-fun-tech/ton-bcl-sdk/tree/main

tontradingbot-dev avatar Dec 16 '24 14:12 tontradingbot-dev