Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABI support for BCL contracts (Ton.Fun) #327

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tontradingbot-dev
Copy link

@tontradingbot-dev tontradingbot-dev commented Dec 16, 2024

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant