Repository navigation
Add moon.cx memepad, CPMM and CLMM Tolk ABI - #509
Open
cellunderflow wants to merge 1 commit into
Open
cellunderflow wants to merge 1 commit into
cellunderflow wants to merge 1 commit into
Conversation
Author
|
Работай мой родненький |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theJettonTransferNotification<T>wrapper, following the ffVault pattern.Notes
Op names follow
mooncx_<product>_<contract>_<message>, for examplemooncx_cpmm_pool_swap,mooncx_clmm_range_deposit_liquidityormooncx_memepad_curve_buy.Some messages are sent by several contracts with the same layout, so their names leave out the contract:
mooncx_swap_fulfillandmooncx_swap_reject(with their_payloadforms) are sent by CPMM pools and CLMM ranges;mooncx_cpmm_excessis sent by the CPMM pool, LP account and LP position;mooncx_clmm_excessis 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+getLockedfor the CPMM LP position;getPool+getRangesfor the CLMM pool;getRangefor 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'sgetPositionis 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.gohas 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 fromabi.InternalMessageDecoderorabi.JettonPayload; most are also re-encoded to the same cell. Getter stacks are also decoded throughKnownGetMethodsDecoder.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.
abi/tolk_*_generated.goandabi/tolk_jetton_msg_types.goare produced bygo generate ./.... If another schema lands first, re-run it.Deployed contracts (mainnet)
Example transactions (messages of other protocols in these traces, such as TEP-89 wallet address queries or other DEXes, are outside this PR)