Skip to content

Add moon.cx memepad, CPMM and CLMM Tolk ABI - #509

Open
cellunderflow wants to merge 1 commit into
tonkeeper:masterfrom
cellunderflow:mooncx-memepad-abi
Open

cellunderflow wants to merge 1 commit into
tonkeeper:masterfrom
cellunderflow:mooncx-memepad-abi

Conversation

@cellunderflow

Copy link
Copy Markdown

Adds Tolk ABI stubs for the moon.cx (https://moon.cx) contracts on mainnet, so that TonAPI / Tonviewer can decode their messages: the memepad (bonding curve launchpad), the CPMM DEX and the CLMM DEX.

Files in abi-tolk/schemas/mooncx/:

  • memepadFactory.tolk, memepadCurve.tolk: the memepad factory and its bonding curves. Each curve is also the jetton master of its token.
  • cpmmFactory.tolk, cpmmPool.tolk, cpmmAccount.tolk, cpmmPosition.tolk: the CPMM factory, pools, LP accounts and LP positions.
  • clmmFactory.tolk, clmmPool.tolk, clmmRange.tolk, clmmAccount.tolk, clmmPosition.tolk: the CLMM factory, pools, ranges, LP accounts and LP positions. A CLMM pool keeps its liquidity in three ranges, and swaps are sent to a range.

They declare 96 structs with an opcode (not counting the generic JettonTransferNotification<T> wrapper, declared in three files), plus helper structs for nested fields and getter results. These cover the incoming messages, the op + query_id payouts, refunds and excesses the contracts send, 7 jetton forward payloads (swap, liquidity deposit, boost and the swap results) and the memepad sell payload (the custom_payload of a jetton burn). The payloads are registered through the JettonTransferNotification<T> wrapper, following the ffVault pattern.

Notes

  • Op names follow mooncx_<product>_<contract>_<message>, for example mooncx_cpmm_pool_swap, mooncx_clmm_range_deposit_liquidity or mooncx_memepad_curve_buy.

  • Some messages are sent by several contracts with the same layout, so their names leave out the contract:

    • mooncx_swap_fulfill and mooncx_swap_reject (with their _payload forms) are sent by CPMM pools and CLMM ranges;
    • mooncx_cpmm_excess is sent by the CPMM pool, LP account and LP position;
    • mooncx_clmm_excess is sent by the CLMM range and LP account.
  • Seven opcodes are both an internal message and a jetton forward payload, for example 0xfa45056b (swap). Each payload is named <Message>Payload, so the message decoder comes first. The tests check that real internal bodies resolve to the message name.

  • A memepad sell is a TEP-74 jetton burn whose custom_payload is the sell order 0xb97a94b7 (mooncx_memepad_curve_sell_payload, with the minimum GRAM out). tongo decodes that field through the same jetton payload table, so the burn shows the sell order; the burn_notification the jetton wallet sends to the curve still decodes as the standard one.

  • Get methods are declared only where they identify our contracts:

    • getPosition + getLocked for the CPMM LP position;
    • getPool + getRanges for the CLMM pool;
    • getRange for the CLMM range.

    These names exist in no other schema. None of the STON.fi, DeDust, TONCO and Tonstakers contracts we checked has these method ids. The memepad and CPMM factories, CPMM pools and LP accounts have no getters, and the CLMM factory has only getPoolAddress, which takes arguments, so they are not detected; memepad curves have only generic jetton getters, so they show as plain jetton masters. Their messages still decode through the opcode table. The CLMM LP position's getPosition is left out, because its generated Go name would clash with the CPMM one in the same package.

  • Standard TEP-74 jetton messages and the TVM rich bounce (0xfffffffe) are not redeclared. None of the opcodes collides with an existing tongo message, including abi/schemas/mooncx.xml, which describes earlier, unrelated moon_* contracts.

  • Compiled with acton 1.1.0 (Tolk 1.4.1), like the other schemas. go generate ./... reproduces the generated files byte for byte.

  • abiGenerated/mooncx/*_test.go has 17 test functions with 105 subtests on real mainnet message bodies and getter stacks. Every moon.cx body and payload sample is checked for leftover bits and refs, for field values against the chain and for the expected name from abi.InternalMessageDecoder or abi.JettonPayload; most are also re-encoded to the same cell. Getter stacks are also decoded through KnownGetMethodsDecoder.

    • A few admin, boost and cancel paths have only been used by earlier moon.cx deployments with the same layout. Those samples are marked in the tests.
    • The remaining messages have no sample and are declared from the contract sources; some were never sent on mainnet, others only by earlier moon.cx deployments.
  • Bulk check outside the PR: about 14,000 mainnet messages on moon.cx CPMM and CLMM accounts were decoded, about 13,500 of them with moon.cx opcodes, plus about 9,700 memepad messages with moon.cx opcodes.

    • The roughly 5,500 CPMM and CLMM messages from the current and legacy factories decode with no errors and no leftovers, and so do all of those memepad messages.
    • No message that tongo already decoded changed its name.
    • Early test deployments, from before the legacy factories, reused some opcodes with other layouts: about 800 of their roughly 8,000 historical messages may show raw, with wrong fields, or under the payload name of the same opcode.
  • abi/tolk_*_generated.go and abi/tolk_jetton_msg_types.go are produced by go generate ./.... If another schema lands first, re-run it.

Deployed contracts (mainnet)

  • Memepad factory: EQDOEt2Hvs6nOFA22KHUEa3BEbS7Hy2ed-9yllPy5nk8Hjhs
  • CPMM factory: EQCAYGE5-ogaKfvlFb-TO_GYKQsuiVOOLbKSDvAKJ9jkvP5W (legacy, same messages: EQCTBiBa_B4UknFdYaeCh_zMHLjStrdzIZ357cygQFmP0xhv)
  • CLMM factory: EQD4uiDMK7T3KMVlcfIfp_LCe9eHtm6BIHCcHJ4stNQtb4R9 (legacy, same messages: EQDugULuWQbVGoa2ChPgWiJSRPwr0DkU04NfcXacgmCOGbWR)
  • A graduated memepad curve (MOONI): EQCw6ChrZFkZqytP07H6h1VdhLLUsHkI1kqNTMinQaxmooni, and its CPMM pool EQDYaknWzA_oe_c2okEJmEf_7WWXZO6pKhoXuRoXFgPbD0HM
  • A CLMM pool (GRAM/USDT): EQDOAVaKQsb1CY_CT2RvalUlntZjrIF3cjpVFwG-VzjliWZ2, and its range 0 EQCEDqD6beyufWkmtCEnkW490ZcOZVrpkqRF7fkqn9OZyLOs

Example transactions (messages of other protocols in these traces, such as TEP-89 wallet address queries or other DEXes, are outside this PR)

@cellunderflow

Copy link
Copy Markdown
Author

Работай мой родненький
чат джбт

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