@floorlaunchpad/sdk 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/LICENSE +201 -60
- package/README.md +45 -24
- package/dist/abi/evm-event-names.js +12 -0
- package/dist/abi/evm.gen.js +130 -0
- package/dist/abi/functions.gen.js +144 -0
- package/dist/abi/index.js +17 -0
- package/dist/abi/solana.gen.js +128 -0
- package/dist/burn.js +21 -0
- package/dist/client/evm/index.js +191 -0
- package/dist/client/index.js +19 -0
- package/dist/client/solana/index.js +259 -0
- package/dist/client/types.js +5 -0
- package/dist/codec.js +77 -0
- package/dist/config/codeHash.js +9 -0
- package/dist/config/generated.js +746 -0
- package/dist/config/index.js +49 -0
- package/dist/config/registry.gen.js +118 -0
- package/dist/config/solana-genesis.js +7 -0
- package/dist/ed25519.js +31 -0
- package/dist/errors.js +249 -0
- package/dist/events/index.js +40 -0
- package/dist/events/types.gen.js +3 -0
- package/dist/evm/abi.js +283 -0
- package/dist/evm/balances.js +26 -0
- package/dist/evm/chains.js +144 -0
- package/dist/evm/floor/abi.gen.js +195 -0
- package/dist/evm/floor/calls.js +230 -0
- package/dist/evm/floor/create.js +49 -0
- package/dist/evm/floor/events.js +41 -0
- package/dist/evm/floor/iface.js +44 -0
- package/dist/evm/items.js +209 -0
- package/dist/evm/keccak.js +118 -0
- package/dist/evm/multicall.js +30 -0
- package/dist/evm/router.js +184 -0
- package/dist/evm/zap.js +128 -0
- package/dist/fixtures.js +53 -0
- package/dist/generated/index.js +28 -0
- package/dist/generated/interface.gen.js +146 -0
- package/dist/handle.js +22 -0
- package/dist/index.js +91 -7
- package/dist/indexer/bodies.js +473 -0
- package/dist/indexer/client.js +104 -0
- package/dist/indexer/contract.js +349 -0
- package/dist/indexer/decode.js +97 -0
- package/dist/indexer/partners.js +100 -0
- package/dist/indexer/paths.js +127 -0
- package/dist/indexer/read.js +109 -0
- package/dist/indexer/stream.js +71 -0
- package/dist/lock.js +16 -0
- package/dist/math/fixed.js +154 -0
- package/dist/math/genesis.js +39 -0
- package/dist/math/index.js +20 -0
- package/dist/math/u256.js +49 -0
- package/dist/math/v2/ask.js +162 -0
- package/dist/math/v2/book.js +607 -0
- package/dist/math/v2/circulating.js +62 -0
- package/dist/math/v2/create.js +122 -0
- package/dist/math/v2/display.js +208 -0
- package/dist/math/v2/error.js +17 -0
- package/dist/math/v2/feasibility.js +174 -0
- package/dist/math/v2/fees.js +121 -0
- package/dist/math/v2/holders.js +105 -0
- package/dist/math/v2/milestones.js +40 -0
- package/dist/math/v2/pow.js +69 -0
- package/dist/math/v2/preset.js +151 -0
- package/dist/math/v2/receipt.js +108 -0
- package/dist/math/v2/relay.js +217 -0
- package/dist/math/v2/rows.js +365 -0
- package/dist/math/v2/split.js +111 -0
- package/dist/math/v2/sqrt.js +84 -0
- package/dist/math/v2/supply.js +21 -0
- package/dist/math/v2/team.js +75 -0
- package/dist/math/v2/trade.js +126 -0
- package/dist/math/v2/wide.js +51 -0
- package/dist/quote.js +6 -0
- package/dist/registryPrice.js +23 -0
- package/dist/route/edge-jupiter.js +42 -0
- package/dist/route/edge.js +11 -0
- package/dist/route/graph.js +51 -0
- package/dist/route/path.js +75 -0
- package/dist/route/quote.js +15 -0
- package/dist/route-jupiter.js +35 -0
- package/dist/route.js +8 -0
- package/dist/sha256.js +61 -0
- package/dist/solana/alt.js +18 -0
- package/dist/solana/floor/accounts.js +390 -0
- package/dist/solana/floor/borsh.js +66 -0
- package/dist/solana/floor/create.js +65 -0
- package/dist/solana/floor/events.js +140 -0
- package/dist/solana/floor/genesis.js +91 -0
- package/dist/solana/floor/genesisList.js +68 -0
- package/dist/solana/floor/instructions.js +435 -0
- package/dist/solana/floor/metadata.js +198 -0
- package/dist/solana/floor/mint.js +206 -0
- package/dist/solana/floor/program.js +64 -0
- package/dist/solana/floor/registry.js +83 -0
- package/dist/solana/instruction.js +49 -0
- package/dist/solana/pda.js +88 -0
- package/dist/solana/tx.js +138 -0
- package/dist/v2/burnPreview.js +35 -0
- package/dist/v2/circulating.js +11 -0
- package/dist/v2/claimAllEvm.js +70 -0
- package/dist/v2/claims-evm.js +120 -0
- package/dist/v2/claims.js +218 -0
- package/dist/v2/dead.js +21 -0
- package/dist/v2/devbuy.js +37 -0
- package/dist/v2/events.js +115 -0
- package/dist/v2/evm.js +299 -0
- package/dist/v2/evmReads.js +76 -0
- package/dist/v2/genesis.js +76 -0
- package/dist/v2/layouts.js +217 -0
- package/dist/v2/market-evm.js +74 -0
- package/dist/v2/presetRowEvm.js +45 -0
- package/dist/v2/press.js +106 -0
- package/dist/v2/quoteMint.js +52 -0
- package/dist/v2/receipt-tx.js +149 -0
- package/dist/v2/route-alt.js +114 -0
- package/dist/v2/route.js +389 -0
- package/dist/v2/solana.js +391 -0
- package/dist/v2/solanaSettle.js +97 -0
- package/dist/v2/tx/evm.js +126 -0
- package/dist/v2/tx/genesis.js +47 -0
- package/dist/v2/tx/index.js +5 -0
- package/dist/v2/tx/solana.js +118 -0
- package/dist/v2/types.js +13 -0
- package/docs/aggregator.md +61 -0
- package/docs/bot.md +50 -0
- package/docs/frontend.md +29 -0
- package/docs/wallet.md +54 -0
- package/package.json +428 -32
- package/src/abi/evm-event-names.ts +12 -0
- package/src/abi/evm.gen.ts +139 -0
- package/src/abi/functions.gen.ts +154 -0
- package/src/abi/index.ts +30 -0
- package/src/abi/solana.gen.ts +138 -0
- package/src/burn.ts +37 -0
- package/src/client/evm/index.ts +199 -0
- package/src/client/index.ts +23 -0
- package/src/client/solana/index.ts +260 -0
- package/src/client/types.ts +162 -0
- package/src/codec.ts +77 -0
- package/src/config/codeHash.ts +9 -0
- package/src/config/generated.ts +746 -0
- package/src/config/index.ts +91 -0
- package/src/config/registry.gen.ts +118 -0
- package/src/config/solana-genesis.ts +7 -0
- package/src/ed25519.ts +31 -0
- package/src/errors.ts +270 -0
- package/src/events/index.ts +44 -0
- package/src/events/types.gen.ts +831 -0
- package/src/evm/abi.ts +292 -0
- package/src/evm/balances.ts +26 -0
- package/src/evm/chains.ts +167 -0
- package/src/evm/floor/abi.gen.ts +195 -0
- package/src/evm/floor/calls.ts +247 -0
- package/src/evm/floor/create.ts +68 -0
- package/src/evm/floor/events.ts +51 -0
- package/src/evm/floor/iface.ts +45 -0
- package/src/evm/items.ts +252 -0
- package/src/evm/keccak.ts +118 -0
- package/src/evm/multicall.ts +43 -0
- package/src/evm/router.ts +209 -0
- package/src/evm/zap.ts +152 -0
- package/src/fixtures.ts +53 -0
- package/src/generated/index.ts +29 -0
- package/src/generated/interface.gen.ts +153 -0
- package/src/handle.ts +22 -0
- package/src/index.ts +91 -6
- package/src/indexer/bodies.ts +528 -0
- package/src/indexer/client.ts +178 -0
- package/src/indexer/contract.ts +410 -0
- package/src/indexer/decode.ts +109 -0
- package/src/indexer/partners.ts +109 -0
- package/src/indexer/paths.ts +190 -0
- package/src/indexer/read.ts +119 -0
- package/src/indexer/stream.ts +83 -0
- package/src/lock.ts +16 -0
- package/src/math/fixed.ts +154 -0
- package/src/math/genesis.ts +39 -0
- package/src/math/index.ts +24 -0
- package/src/math/u256.ts +49 -0
- package/src/math/v2/ask.ts +218 -0
- package/src/math/v2/book.ts +660 -0
- package/src/math/v2/circulating.ts +69 -0
- package/src/math/v2/create.ts +139 -0
- package/src/math/v2/display.ts +250 -0
- package/src/math/v2/error.ts +19 -0
- package/src/math/v2/feasibility.ts +200 -0
- package/src/math/v2/fees.ts +121 -0
- package/src/math/v2/holders.ts +124 -0
- package/src/math/v2/milestones.ts +51 -0
- package/src/math/v2/pow.ts +71 -0
- package/src/math/v2/preset.ts +189 -0
- package/src/math/v2/receipt.ts +162 -0
- package/src/math/v2/relay.ts +235 -0
- package/src/math/v2/rows.ts +412 -0
- package/src/math/v2/split.ts +160 -0
- package/src/math/v2/sqrt.ts +86 -0
- package/src/math/v2/supply.ts +27 -0
- package/src/math/v2/team.ts +75 -0
- package/src/math/v2/trade.ts +145 -0
- package/src/math/v2/wide.ts +52 -0
- package/src/quote.ts +6 -0
- package/src/registryPrice.ts +28 -0
- package/src/route/edge-jupiter.ts +71 -0
- package/src/route/edge.ts +22 -0
- package/src/route/graph.ts +77 -0
- package/src/route/path.ts +84 -0
- package/src/route/quote.ts +46 -0
- package/src/route-jupiter.ts +36 -0
- package/src/route.ts +8 -0
- package/src/sha256.ts +61 -0
- package/src/solana/alt.ts +25 -0
- package/src/solana/floor/accounts.ts +393 -0
- package/src/solana/floor/borsh.ts +66 -0
- package/src/solana/floor/create.ts +89 -0
- package/src/solana/floor/events.ts +147 -0
- package/src/solana/floor/genesis.ts +111 -0
- package/src/solana/floor/genesisList.ts +75 -0
- package/src/solana/floor/instructions.ts +491 -0
- package/src/solana/floor/metadata.ts +246 -0
- package/src/solana/floor/mint.ts +242 -0
- package/src/solana/floor/program.ts +64 -0
- package/src/solana/floor/registry.ts +96 -0
- package/src/solana/instruction.ts +61 -0
- package/src/solana/pda.ts +91 -0
- package/src/solana/tx.ts +143 -0
- package/src/v2/burnPreview.ts +52 -0
- package/src/v2/circulating.ts +22 -0
- package/src/v2/claimAllEvm.ts +97 -0
- package/src/v2/claims-evm.ts +179 -0
- package/src/v2/claims.ts +288 -0
- package/src/v2/dead.ts +21 -0
- package/src/v2/devbuy.ts +55 -0
- package/src/v2/events.ts +131 -0
- package/src/v2/evm.ts +349 -0
- package/src/v2/evmReads.ts +121 -0
- package/src/v2/genesis.ts +80 -0
- package/src/v2/layouts.ts +219 -0
- package/src/v2/market-evm.ts +95 -0
- package/src/v2/presetRowEvm.ts +54 -0
- package/src/v2/press.ts +124 -0
- package/src/v2/quoteMint.ts +63 -0
- package/src/v2/receipt-tx.ts +251 -0
- package/src/v2/route-alt.ts +114 -0
- package/src/v2/route.ts +494 -0
- package/src/v2/solana.ts +439 -0
- package/src/v2/solanaSettle.ts +117 -0
- package/src/v2/tx/evm.ts +152 -0
- package/src/v2/tx/genesis.ts +66 -0
- package/src/v2/tx/index.ts +5 -0
- package/src/v2/tx/solana.ts +140 -0
- package/src/v2/types.ts +284 -0
- package/dist/adapter.d.ts +0 -28
- package/dist/adapter.d.ts.map +0 -1
- package/dist/adapter.js +0 -2
- package/dist/adapter.js.map +0 -1
- package/dist/chain.d.ts +0 -23
- package/dist/chain.d.ts.map +0 -1
- package/dist/chain.js +0 -25
- package/dist/chain.js.map +0 -1
- package/dist/client.d.ts +0 -26
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -43
- package/dist/client.js.map +0 -1
- package/dist/dex-adapter.d.ts +0 -228
- package/dist/dex-adapter.d.ts.map +0 -1
- package/dist/dex-adapter.js +0 -407
- package/dist/dex-adapter.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/quotes.d.ts +0 -12
- package/dist/quotes.d.ts.map +0 -1
- package/dist/quotes.gen.d.ts +0 -8
- package/dist/quotes.gen.d.ts.map +0 -1
- package/dist/quotes.gen.js +0 -2170
- package/dist/quotes.gen.js.map +0 -1
- package/dist/quotes.js +0 -24
- package/dist/quotes.js.map +0 -1
- package/dist/types.d.ts +0 -111
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/adapter.ts +0 -20
- package/src/chain.ts +0 -39
- package/src/client.ts +0 -41
- package/src/dex-adapter.ts +0 -477
- package/src/quotes.gen.ts +0 -2170
- package/src/quotes.ts +0 -29
- package/src/types.ts +0 -115
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export const SOLANA_EVENT_SCHEMAS = [
|
|
4
|
+
{ name: "LaunchCreated", discriminator: "3b26bee621225914", source: "v1", fields: [["launch","pubkey"],["mint","pubkey"],["quoteMint","pubkey"],["creator","pubkey"],["id","u64"],["presetId","u8"],["presetVersion","u32"],["presetHash","bytes:32"],["p0X64","u128"],["raise","u64"],["windowTokens","u64"],["creatorBuyTokens","u64"],["createFee","u64"],["name","bytes:32"],["symbol","bytes:10"],["slot","u64"],["ts","i64"],["listed","bool"],["quoteUsdCentsX64","u128"],["nativeCreateFee","u64"]] },
|
|
5
|
+
{ name: "Graduated", discriminator: "33f142328cf59cc0", source: "v1", fields: [["launch","pubkey"],["priceX64","u128"],["windowRaised","u64"],["windowTokens","u64"],["slot","u64"],["ts","i64"]] },
|
|
6
|
+
{ name: "PotsSwept", discriminator: "33480c25b092b903", source: "v1", fields: [["launch","pubkey"],["amount","u64"],["reason","u8"]] },
|
|
7
|
+
{ name: "Claimed", discriminator: "d9c07b486c96f821", source: "v1", fields: [["wallet","pubkey"],["sender","pubkey"],["launch","pubkey"],["quoteMint","pubkey"],["types","u8"],["creator","u64"],["creatorRef","u64"],["teamSlot","u64"],["traderRef","u64"],["extra","u64"],["amount","u64"],["teamBuy","u64?"],["shareBought","u64?"],["typesHi","u8?"]] },
|
|
8
|
+
{ name: "TeamShareBought", discriminator: "40e04bbcf76ac766", source: "v1", fields: [["launch","pubkey"],["member","pubkey"],["place","u8"],["spent","u64"],["refund","u64"],["tokens","u64"],["shareLeft","u64"],["boughtOwed","u64"],["day","u64"],["firstToday","bool"],["ts","i64"]] },
|
|
9
|
+
{ name: "PlatformWithdrawn", discriminator: "b043dc238ac4c5d9", source: "v1", fields: [["launch","pubkey"],["quoteMint","pubkey"],["destination","pubkey"],["amount","u64"],["owedAfter","u64"]] },
|
|
10
|
+
{ name: "HolderWithdrawn", discriminator: "c0451de603775eb7", source: "v1", fields: [["launch","pubkey"],["quoteMint","pubkey"],["destination","pubkey"],["amount","u64"],["owedAfter","u64"]] },
|
|
11
|
+
{ name: "PresetWritten", discriminator: "530e30dce6faf60c", source: "v1", fields: [["id","u8"],["rowVersion","u32"],["enabled","bool"],["deleted","bool"]] },
|
|
12
|
+
{ name: "QuoteWritten", discriminator: "4fa3daf6a35e7d00", source: "v1", fields: [["mint","pubkey"],["enabled","bool"],["createFee","u64"],["usdCentsX64","u128"],["admittedCaps","u32"]] },
|
|
13
|
+
{ name: "ConfigWritten", discriminator: "0c5130359b91585d", source: "v1", fields: [["authority","pubkey"],["pendingAuthority","pubkey"],["timelock","pubkey"],["referralAuthority","pubkey"],["createPaused","bool"],["holderDest","pubkey"],["nativeCreateFee","u64"],["treasury","pubkey?"],["priceUpdater","pubkey?"]] },
|
|
14
|
+
{ name: "MetadataBaseSet", discriminator: "cc5e538ba5e2ee12", source: "v1", fields: [["base","bytes:72"],["len","u8"]] },
|
|
15
|
+
{ name: "TeamSlotOpened", discriminator: "d05e3fd292216e2c", source: "v1", fields: [["launch","pubkey"],["rateBps","u16"],["price","u64"]] },
|
|
16
|
+
{ name: "TeamSlotMember", discriminator: "f4986f7946c5d0bc", source: "v1", fields: [["launch","pubkey"],["index","u8"],["key","bytes:32"],["kind","u8"],["state","u8"],["paid","u64"],["requested","u64"],["bought","u64"],["boughtPpm","u32"]] },
|
|
17
|
+
{ name: "TraderRefOpened", discriminator: "b19ede398fd84173", source: "v1", fields: [["trader","pubkey"],["quoteMint","pubkey"],["tiers","pubkey[3]"]] },
|
|
18
|
+
{ name: "TraderLinkOpened", discriminator: "ce3cf7987530744b", source: "v1", fields: [["trader","pubkey"],["tiers","pubkey[3]"]] },
|
|
19
|
+
{ name: "TraderRefCleared", discriminator: "2248a8735d5891ac", source: "v1", fields: [["trader","pubkey"],["records","u16"]] },
|
|
20
|
+
{ name: "CreatorBuyUnlocked", discriminator: "2a091cbbe392c8fc", source: "v1", fields: [["launch","pubkey"],["creator","pubkey"],["tokens","u64"],["members","u64[10]?"],["paid","u64?"]] },
|
|
21
|
+
{ name: "RefOwedOpened", discriminator: "c6738dc0a56e6a77", source: "v1", fields: [["referrer","pubkey"],["quoteMint","pubkey"]] },
|
|
22
|
+
{ name: "RefsRolled", discriminator: "65150ff9ec7a53ab", source: "v1", fields: [["quoteMint","pubkey"],["traderRefs","u16"],["amount","u64"]] },
|
|
23
|
+
{ name: "GenesisAccepted", discriminator: "9703fe606786835f", source: "v1", fields: [["oldSale","pubkey"],["count","u16"],["totalMigrated","u64"],["donation","u64"]] },
|
|
24
|
+
{ name: "HandleBound", discriminator: "7974f392419d329c", source: "v1", fields: [["launch","pubkey"],["index","u8"],["handle","bytes:32"],["wallet","pubkey"]] },
|
|
25
|
+
{ name: "QuoteShort", discriminator: "70fe20aec353fefc", source: "v1", fields: [["launch","pubkey"],["quoteVault","u64"],["quoteBooked","u64"],["short","u64"],["slot","u64"]] },
|
|
26
|
+
{ name: "BackingCredited", discriminator: "d417c481f9107bb7", source: "v1", fields: [["launch","pubkey"],["donor","pubkey"],["amount","u64"],["fAfter","u64"],["slot","u64"]] },
|
|
27
|
+
{ name: "CutWithdrawn", discriminator: "17e29a6f64b021d2", source: "v1", fields: [["launch","pubkey"],["amount","u64"],["cutOwedAfter","u64"]] },
|
|
28
|
+
{ name: "RoleRegistered", discriminator: "3486a2c763b07a80", source: "v1", fields: [["wallet","pubkey"],["page","u16"],["launch","pubkey"],["roles","u8"]] },
|
|
29
|
+
{ name: "ClaimsLutSet", discriminator: "27cdea513b27179d", source: "v1", fields: [["wallet","pubkey"],["lookupTable","pubkey"]] },
|
|
30
|
+
{ name: "NativeFeesWithdrawn", discriminator: "07c7006947b8a690", source: "v1", fields: [["destination","pubkey"],["amount","u64"],["owedAfter","u64"]] },
|
|
31
|
+
{ name: "GenesisContributed", discriminator: "c7919c94f1a5125c", source: "v1", fields: [["wallet","pubkey"],["amount","u64"],["walletTotal","u64"],["liveTotal","u64"]] },
|
|
32
|
+
{ name: "GenesisMigratedRefunded", discriminator: "695a3b686fa8ad30", source: "v1", fields: [["wallet","pubkey"],["amount","u64"],["liveTotal","u64"]] },
|
|
33
|
+
{ name: "GenesisOpened", discriminator: "9973ecd9e7cc9e65", source: "v1", fields: [["launch","pubkey"],["mint","pubkey"],["raised","u64"],["tokens","u64"],["donation","u64"],["p0X64","u128"],["weightTotal","u64"],["slotRateBps","u16"],["quoteMint","pubkey?"],["floorUsdcIn","u64?"],["refund","u64?"],["usdcExcess","u64?"],["solConverted","u64?"],["usdcConverted","u64?"],["solUnconverted","u64?"],["usdcRefund","u64?"]] },
|
|
34
|
+
{ name: "GenesisClaimed", discriminator: "ce3a49c18407ddc6", source: "v1", fields: [["wallet","pubkey"],["migratedCredit","u64"],["phase3Credit","u64"],["tokens","u64"],["refund","u64?"],["listedCredit","u64?"],["usdcRefund","u64?"]] },
|
|
35
|
+
{ name: "GenesisRefundOwed", discriminator: "e4573825740c25a4", source: "v1", fields: [["wallet","pubkey"],["amount","u64"],["usdc","u64?"]] },
|
|
36
|
+
{ name: "GenesisRefundPaid", discriminator: "a1ae6974371dc3ee", source: "v1", fields: [["wallet","pubkey"],["to","pubkey"],["amount","u64"],["usdc","u64?"],["usdcTo","pubkey?"]] },
|
|
37
|
+
{ name: "GenesisDustSwept", discriminator: "8b66b64a34f81b41", source: "v1", fields: [["launch","pubkey"],["amount","u64"],["usdc","u64?"]] },
|
|
38
|
+
{ name: "GenesisSolConverted", discriminator: "22a613c2b37d5a67", source: "v1", fields: [["caller","pubkey"],["lamports","u64"],["usdc","u64"],["solUsdCentsX64","u128"],["usdcUsdCentsX64","u128"],["discountBps","u16"],["solConverted","u64"],["usdcConverted","u64"],["usdcCaps","u64"]] },
|
|
39
|
+
{ name: "GenesisWagmiBought", discriminator: "e500e15ae1f7f064", source: "v1", fields: [["floorLaunch","pubkey"],["usdcIn","u64"],["floorOut","u64"]] },
|
|
40
|
+
{ name: "GenesisWagmiOpened", discriminator: "904723978db3cef1", source: "v1", fields: [["launch","pubkey"],["mint","pubkey"],["floorIn","u64"],["tokens","u64"],["floorRefund","u64"],["p0X64","u128"],["quoteUsdCentsX64","u128?"],["capTokens","u64?"],["overCapFloor","u64?"],["overCapTokens","u64?"]] },
|
|
41
|
+
{ name: "GenesisWagmiClaimed", discriminator: "e6009dc3235f5294", source: "v1", fields: [["wallet","pubkey"],["tokens","u64"],["floorBack","u64"]] },
|
|
42
|
+
{ name: "GenesisWagmiDustSwept", discriminator: "7bd06e76b0edb06e", source: "v1", fields: [["launch","pubkey"],["floor","u64"]] },
|
|
43
|
+
{ name: "GenesisListedContributed", discriminator: "7ecf2ca585f10140", source: "v1", fields: [["wallet","pubkey"],["amount","u64"],["walletListed","u64"],["allowanceLeft","u64"],["liveTotal","u64"]] },
|
|
44
|
+
{ name: "GenesisListRootSet", discriminator: "85037264ea1a3265", source: "v1", fields: [["signer","pubkey"],["oldRoot","bytes:32"],["newRoot","bytes:32"]] },
|
|
45
|
+
{ name: "BurnsSynced", discriminator: "cfb2d288fed64590", source: "v1", fields: [["launch","pubkey"],["incinerated","u64"],["supply","u64"],["sOut","u64"],["floorAfterX64","u128"],["slot","u64"]] },
|
|
46
|
+
{ name: "TokensBurned", discriminator: "e6ff2271e235e309", source: "v1", fields: [["launch","pubkey"],["wallet","pubkey"],["role","u8"],["place","u8"],["fromTeamBuy","u64"],["fromWallet","u64"],["balanceBefore","u64"],["owedAfter","u64"],["split","u64[10]"],["supply","u64"],["sOut","u64"],["floorAfterX64","u128"],["slot","u64"],["fromShareBought","u64?"]] },
|
|
47
|
+
{ name: "LaunchCreatedV2", discriminator: "4c0e9eb9ef6b568e", source: "v2", fields: [["launch","pubkey"],["mint","pubkey"],["quoteMint","pubkey"],["creator","pubkey"],["id","u64"],["presetId","u8"],["presetVersion","u32"],["presetHash","bytes:32"],["p0X64","u128"],["raise","u64"],["windowTokens","u64"],["creatorBuyTokens","u64"],["createFee","u64"],["name","bytes:32"],["symbol","bytes:10"],["slot","u64"],["ts","i64"],["listed","bool"],["quoteUsdCentsX64","u128"],["nativeCreateFee","u64"],["rowVersion","u8"],["sqrtP0","u128"]] },
|
|
48
|
+
{ name: "Trade", discriminator: "18feda98fd2b1251", source: "v2", fields: [["launch","pubkey"],["trader","pubkey"],["isBuy","bool"],["quoteGross","u64"],["quoteNet","u64"],["refund","u64"],["tokens","u64"],["fees","u64[5]"],["traderRef","u64"],["fromResale","u64"],["fromFirst","u64"],["unfilled","u64"],["sqrtBefore","u128"],["sqrtAfter","u128"],["sqrtF","u128"],["floor","u64"],["cushion","u64"],["sCirc","u64"],["steps","u8"],["budgetHit","bool"],["slot","u64"],["ts","i64"],["kind","u8"],["creatorRef","u64"],["recipient","pubkey"],["bidMoney","u64"],["msPaid","u64[4]"]] },
|
|
49
|
+
{ name: "HolderPositionOpened", discriminator: "86a0f22128a8ddac", source: "v2", fields: [["launch","pubkey"],["owner","pubkey"],["amount","u64"]] },
|
|
50
|
+
{ name: "HolderPositionClosed", discriminator: "a5451f6d7c8dab3c", source: "v2", fields: [["launch","pubkey"],["owner","pubkey"],["amount","u64"],["paid","u64"]] },
|
|
51
|
+
{ name: "HolderIndexRolled", discriminator: "5c857c0e16a9a203", source: "v2", fields: [["launch","pubkey"],["index","u128"],["wMatured","u64"],["wPending","u64"],["carry","u64"]] },
|
|
52
|
+
{ name: "DeadSynced", discriminator: "29e5a9cda4b90d32", source: "v2", fields: [["launch","pubkey"],["added","u64"],["deadTokens","u64"],["sCirc","u64"]] },
|
|
53
|
+
{ name: "GenesisRaiseBought", discriminator: "81c072c6908a578b", source: "v2", fields: [["launch","pubkey"],["trader","pubkey"],["isBuy","bool"],["quoteGross","u64"],["quoteNet","u64"],["refund","u64"],["tokens","u64"],["fees","u64[5]"],["traderRef","u64"],["fromResale","u64"],["fromFirst","u64"],["unfilled","u64"],["sqrtBefore","u128"],["sqrtAfter","u128"],["sqrtF","u128"],["floor","u64"],["cushion","u64"],["sCirc","u64"],["steps","u8"],["budgetHit","bool"],["slot","u64"],["ts","i64"],["kind","u8"],["creatorRef","u64"],["recipient","pubkey"],["bidMoney","u64"],["msPaid","u64[4]"]] },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
export const SOLANA_ERRORS = [
|
|
57
|
+
{ chain: "solana", name: "NotAuthority", message: "signer is not the authority this instruction needs", code: 6000, selector: null, signature: null },
|
|
58
|
+
{ chain: "solana", name: "NotUpgradeAuthority", message: "signer is not the program's upgrade authority", code: 6001, selector: null, signature: null },
|
|
59
|
+
{ chain: "solana", name: "PresetInvalid", message: "the preset row fails spec_ok", code: 6002, selector: null, signature: null },
|
|
60
|
+
{ chain: "solana", name: "PresetIdNotNext", message: "the preset id is not the next one (ids are append-only; 0 is reserved)", code: 6003, selector: null, signature: null },
|
|
61
|
+
{ chain: "solana", name: "PresetDeleted", message: "the preset is deleted", code: 6004, selector: null, signature: null },
|
|
62
|
+
{ chain: "solana", name: "PresetDisabled", message: "the preset is disabled", code: 6005, selector: null, signature: null },
|
|
63
|
+
{ chain: "solana", name: "QuoteNotListed", message: "the quote mint is not listed or is disabled", code: 6006, selector: null, signature: null },
|
|
64
|
+
{ chain: "solana", name: "CreatesPaused", message: "creates are paused (governance's switch; trading is never paused)", code: 6007, selector: null, signature: null },
|
|
65
|
+
{ chain: "solana", name: "CreatorBuyTooLarge", message: "the Team Buy is over the preset's share of the window", code: 6008, selector: null, signature: null },
|
|
66
|
+
{ chain: "solana", name: "SlippageExceeded", message: "fewer tokens out than the minimum", code: 6009, selector: null, signature: null },
|
|
67
|
+
{ chain: "solana", name: "NothingToDo", message: "nothing to do", code: 6010, selector: null, signature: null },
|
|
68
|
+
{ chain: "solana", name: "Overflow", message: "arithmetic overflow", code: 6011, selector: null, signature: null },
|
|
69
|
+
{ chain: "solana", name: "MathFailed", message: "the math refused (floor-math)", code: 6012, selector: null, signature: null },
|
|
70
|
+
{ chain: "solana", name: "BadAccount", message: "an account does not match the launch", code: 6013, selector: null, signature: null },
|
|
71
|
+
{ chain: "solana", name: "ClaimsShort", message: "a booked claim is not held by the vault", code: 6014, selector: null, signature: null },
|
|
72
|
+
{ chain: "solana", name: "Locked", message: "the Team Buy is still locked", code: 6015, selector: null, signature: null },
|
|
73
|
+
{ chain: "solana", name: "OverOwed", message: "an amount over what is owed", code: 6016, selector: null, signature: null },
|
|
74
|
+
{ chain: "solana", name: "UnknownClaimType", message: "an unknown claim type bit", code: 6017, selector: null, signature: null },
|
|
75
|
+
{ chain: "solana", name: "TeamSlotRateOverMax", message: "the Team Slot rate is over the preset's maximum", code: 6018, selector: null, signature: null },
|
|
76
|
+
{ chain: "solana", name: "TeamSlotFull", message: "the Team Slot is full (10 members)", code: 6019, selector: null, signature: null },
|
|
77
|
+
{ chain: "solana", name: "TeamSlotPaid", message: "a paid Team Slot member can never be removed", code: 6020, selector: null, signature: null },
|
|
78
|
+
{ chain: "solana", name: "TeamSlotExists", message: "the Team Slot already exists or the member is already in it", code: 6021, selector: null, signature: null },
|
|
79
|
+
{ chain: "solana", name: "TeamSlotNoRequest", message: "no such Team Slot request", code: 6022, selector: null, signature: null },
|
|
80
|
+
{ chain: "solana", name: "SellTooLarge", message: "a sell of more tokens than are outside", code: 6023, selector: null, signature: null },
|
|
81
|
+
{ chain: "solana", name: "TraderRefMismatch", message: "the trader reference is already open with other tiers", code: 6024, selector: null, signature: null },
|
|
82
|
+
{ chain: "solana", name: "BadArgument", message: "invalid argument", code: 6025, selector: null, signature: null },
|
|
83
|
+
{ chain: "solana", name: "BadDecimals", message: "the decimals are not the program's", code: 6026, selector: null, signature: null },
|
|
84
|
+
{ chain: "solana", name: "GenesisMismatch", message: "the migrated amount does not match the copied credits", code: 6027, selector: null, signature: null },
|
|
85
|
+
{ chain: "solana", name: "NotPendingHandle", message: "the Team Slot member is not a pending handle with this id", code: 6028, selector: null, signature: null },
|
|
86
|
+
{ chain: "solana", name: "NobodyBacked", message: "credit_backing needs tokens outside (S_out > 0)", code: 6029, selector: null, signature: null },
|
|
87
|
+
{ chain: "solana", name: "PageFull", message: "the claims page is full; take the next page", code: 6030, selector: null, signature: null },
|
|
88
|
+
{ chain: "solana", name: "RoleNotHeld", message: "the wallet does not hold this role on the subject", code: 6031, selector: null, signature: null },
|
|
89
|
+
{ chain: "solana", name: "GenesisWrongState", message: "the genesis raise is not in the state this needs", code: 6032, selector: null, signature: null },
|
|
90
|
+
{ chain: "solana", name: "GenesisNotMigrated", message: "the old floor_launch raise is not marked migrated, or is graduated", code: 6033, selector: null, signature: null },
|
|
91
|
+
{ chain: "solana", name: "GenesisBadRecord", message: "an old genesis account is not the live program's (owner, address or layout)", code: 6034, selector: null, signature: null },
|
|
92
|
+
{ chain: "solana", name: "GenesisRaiseEnded", message: "the genesis raise has ended", code: 6035, selector: null, signature: null },
|
|
93
|
+
{ chain: "solana", name: "GenesisRaiseNotEnded", message: "the genesis raise has not ended", code: 6036, selector: null, signature: null },
|
|
94
|
+
{ chain: "solana", name: "GenesisNotMigratedWallet", message: "the wallet has no migrated credit to refund", code: 6037, selector: null, signature: null },
|
|
95
|
+
{ chain: "solana", name: "GenesisBadPreset", message: "the preset has no window", code: 6038, selector: null, signature: null },
|
|
96
|
+
{ chain: "solana", name: "GenesisOpenFailed", message: "the raise did not buy the whole window", code: 6039, selector: null, signature: null },
|
|
97
|
+
{ chain: "solana", name: "GenesisVaultShort", message: "the genesis vault holds less than the raise", code: 6040, selector: null, signature: null },
|
|
98
|
+
{ chain: "solana", name: "MetadataBaseUnset", message: "no metadata host is set (set_metadata_base); creates wait for it, since the metadata is immutable", code: 6041, selector: null, signature: null },
|
|
99
|
+
{ chain: "solana", name: "MetadataBaseInvalid", message: "the metadata host must be https:// ipfs:// or ar://, printable ASCII with no space, no trailing slash, at most 72 bytes", code: 6042, selector: null, signature: null },
|
|
100
|
+
{ chain: "solana", name: "TreasuryNotSet", message: "no treasury is set: the platform bucket withdraws only to Config.treasury (S6)", code: 6043, selector: null, signature: null },
|
|
101
|
+
{ chain: "solana", name: "NotPriceUpdater", message: "only Config.price_updater writes a quote's price (none set = nobody; governance and the timelock included)", code: 6044, selector: null, signature: null },
|
|
102
|
+
{ chain: "solana", name: "BadMember", message: "a Team Slot member cannot be the zero key (its share would be paid to nobody)", code: 6045, selector: null, signature: null },
|
|
103
|
+
{ chain: "solana", name: "GenesisNotListed", message: "the wallet is not on the genesis list (a bad or over-long proof, or no list)", code: 6046, selector: null, signature: null },
|
|
104
|
+
{ chain: "solana", name: "GenesisListedAllowanceUsed", message: "the wallet's listed allowance is used up", code: 6047, selector: null, signature: null },
|
|
105
|
+
{ chain: "solana", name: "QuoteRowCannotOpen", message: "a launch of this preset cannot open on this quote (its declared price and decimals; floor-math Launch::quote_opens)", code: 6048, selector: null, signature: null },
|
|
106
|
+
{ chain: "solana", name: "QuoteTransferShort", message: "nothing of the quote arrived in the vault (a transfer fee took all of it)", code: 6049, selector: null, signature: null },
|
|
107
|
+
{ chain: "solana", name: "PresetUnchecked", message: "the preset row has not passed every listing step (check_preset)", code: 6050, selector: null, signature: null },
|
|
108
|
+
{ chain: "solana", name: "GenesisRefundUnderRent", message: "the refund would leave the receiving account under rent; it stays owed (name a funded account)", code: 6051, selector: null, signature: null },
|
|
109
|
+
{ chain: "solana", name: "GenesisDustNotYet", message: "the genesis refund dust is known only once every live credit has claimed", code: 6052, selector: null, signature: null },
|
|
110
|
+
{ chain: "solana", name: "GenesisConvertCapped", message: "the conversion reached $FLOOR's cap + $WAGMI's (USDC): no more SOL is converted, the rest is refunded", code: 6053, selector: null, signature: null },
|
|
111
|
+
{ chain: "solana", name: "GenesisPriceStale", message: "the SOL quote's registry price is older than GENESIS_PRICE_MAX_AGE_SECS (the price updater refreshes it)", code: 6054, selector: null, signature: null },
|
|
112
|
+
{ chain: "solana", name: "GenesisConvertSlippage", message: "the conversion would cost more USDC than max_usdc", code: 6055, selector: null, signature: null },
|
|
113
|
+
{ chain: "solana", name: "GenesisSolNotConverted", message: "the genesis raise's SOL is not converted up to the caps yet (convert_genesis_sol)", code: 6056, selector: null, signature: null },
|
|
114
|
+
{ chain: "solana", name: "GenesisWagmiWrongState", message: "$WAGMI's genesis is not in that state (pin before the open; open once, after $FLOOR's open; claim after it)", code: 6057, selector: null, signature: null },
|
|
115
|
+
{ chain: "solana", name: "GenesisWagmiNoPreset", message: "no $WAGMI row is pinned (set_genesis_wagmi_preset)", code: 6058, selector: null, signature: null },
|
|
116
|
+
{ chain: "solana", name: "GenesisWagmiQuoteNotListed", message: "$FLOOR is not a listed, enabled Token-2022 quote (governance add_quote after the open)", code: 6059, selector: null, signature: null },
|
|
117
|
+
{ chain: "solana", name: "HolderDestNotSet", message: "no holder destination is set: the holder bucket withdraws only to Config.holder_dest (set_holder_dest)", code: 6060, selector: null, signature: null },
|
|
118
|
+
{ chain: "solana", name: "NotTeamMember", message: "only a Team Slot member that is IN (a wallet) spends its Team Share on this launch", code: 6061, selector: null, signature: null },
|
|
119
|
+
{ chain: "solana", name: "BurnTooLarge", message: "the burn is more than this place's Team Buy", code: 6062, selector: null, signature: null },
|
|
120
|
+
{ chain: "solana", name: "NothingToSettle", message: "nothing to settle: cover_pending is 0", code: 6063, selector: null, signature: null },
|
|
121
|
+
{ chain: "solana", name: "HolderPositionExists", message: "the holder position already exists", code: 6064, selector: null, signature: null },
|
|
122
|
+
{ chain: "solana", name: "HolderPositionNotEmpty", message: "the holder position's owner still holds tokens", code: 6065, selector: null, signature: null },
|
|
123
|
+
{ chain: "solana", name: "HolderBookMismatch", message: "the holder book does not belong to this launch", code: 6066, selector: null, signature: null },
|
|
124
|
+
{ chain: "solana", name: "DeadAccountNotDead", message: "the token account is not owned by the incinerator or the System Program, or is not this launch's mint", code: 6067, selector: null, signature: null },
|
|
125
|
+
{ chain: "solana", name: "HookAccountsMissing", message: "the transfer-hook accounts are missing", code: 6068, selector: null, signature: null },
|
|
126
|
+
{ chain: "solana", name: "RowTooManyRanges", message: "the row has too many ranges", code: 6069, selector: null, signature: null },
|
|
127
|
+
{ chain: "solana", name: "RowNotFeasible", message: "the row fails the feasibility check", code: 6070, selector: null, signature: null },
|
|
128
|
+
];
|
package/dist/burn.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export const BURN_SCENE_BPS = 5_000n;
|
|
4
|
+
|
|
5
|
+
export const BURN_SCENE_MIN_SUPPLY_BPS = 10n;
|
|
6
|
+
|
|
7
|
+
export const BURN_SCENE_COOLDOWN_SECS = 3_600;
|
|
8
|
+
|
|
9
|
+
export function burnPlaysScene(b ) {
|
|
10
|
+
if (b.role === 0 || b.burned <= 0n || b.balanceBefore <= 0n || b.sOutBefore <= 0n) return false;
|
|
11
|
+
if (b.burned * 10_000n <= b.balanceBefore * BURN_SCENE_BPS) return false;
|
|
12
|
+
if (b.burned * 10_000n < b.sOutBefore * BURN_SCENE_MIN_SUPPLY_BPS) return false;
|
|
13
|
+
return b.lastSceneAt == null || b.now - b.lastSceneAt >= BURN_SCENE_COOLDOWN_SECS;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function planBurn(amount , teamBuyPart , wallet ) {
|
|
17
|
+
if (amount <= 0n) throw new Error("planBurn: amount must be > 0");
|
|
18
|
+
if (amount > teamBuyPart + wallet) throw new Error("planBurn: more than the balance");
|
|
19
|
+
const fromTeamBuy = amount < teamBuyPart ? amount : teamBuyPart;
|
|
20
|
+
return { fromTeamBuy, fromWallet: amount - fromTeamBuy };
|
|
21
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { approveCall, buyCall, sellCall } from "../../evm/floor/calls.js";
|
|
4
|
+
import { NATIVE_QUOTE } from "../../evm/floor/iface.js";
|
|
5
|
+
import { checkFloorHops } from "../../evm/router.js";
|
|
6
|
+
import { FLOOR_ERROR_CODES, FloorError, decodeEvmProgramError, errorCodeOf } from "../../errors.js";
|
|
7
|
+
|
|
8
|
+
import { FloorMathError } from "../../math/index.js";
|
|
9
|
+
import { nextBuyPriceX64 } from "../../math/v2/display.js";
|
|
10
|
+
import { feeTotal } from "../../math/v2/fees.js";
|
|
11
|
+
import { priceImpactV2, quoteSellImpactV2 } from "../../math/v2/receipt.js";
|
|
12
|
+
import { sCirc } from "../../math/v2/supply.js";
|
|
13
|
+
|
|
14
|
+
import { claimV2Call, evmSettleInputsV2, quoteBuyEvmV2 } from "../../v2/evm.js";
|
|
15
|
+
import { buyMinTokens } from "../../math/v2/trade.js";
|
|
16
|
+
|
|
17
|
+
import { decodeLaunchStateV2, launchStateCallV2 } from "../../v2/evmReads.js";
|
|
18
|
+
|
|
19
|
+
import { EVM_TOKEN_SCALE, readLaunchV2 } from "../../v2/market-evm.js";
|
|
20
|
+
|
|
21
|
+
import { fillsNothing } from "../../v2/route.js";
|
|
22
|
+
import { MAX_SLIPPAGE_BPS, minOutAt } from "../../v2/press.js";
|
|
23
|
+
import { DEFAULT_SLIPPAGE_BPS } from "../types.js";
|
|
24
|
+
|
|
25
|
+
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
26
|
+
const CODES = new Set(FLOOR_ERROR_CODES);
|
|
27
|
+
|
|
28
|
+
const bad = (message ) => new FloorError("BadArgument", message, { source: "sdk" });
|
|
29
|
+
const legs = (f ) => ({ backing: f[0], team: f[1], platform: f[2], floor: f[3], holder: f[4], total: feeTotal(f) });
|
|
30
|
+
const bps = (ppm ) => (ppm === null ? null : Number(ppm / 100n));
|
|
31
|
+
|
|
32
|
+
function slippageOf(s ) {
|
|
33
|
+
const v = s ?? DEFAULT_SLIPPAGE_BPS;
|
|
34
|
+
if (!Number.isInteger(v) || v < 0 || v > MAX_SLIPPAGE_BPS) throw bad(`slippageBps in 0..=${MAX_SLIPPAGE_BPS}`);
|
|
35
|
+
return v;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function asFloorError(e ) {
|
|
39
|
+
if (e instanceof FloorError) return e;
|
|
40
|
+
if (e instanceof FloorMathError) {
|
|
41
|
+
const code = CODES.has(e.code) ? (e.code ) : errorCodeOf(e.code) === "Unknown" ? "MathFailed" : errorCodeOf(e.code);
|
|
42
|
+
return new FloorError(code, e.message, { source: "sdk", name: e.code, mathError: e.code, cause: e });
|
|
43
|
+
}
|
|
44
|
+
if (e instanceof RangeError || e instanceof TypeError) return new FloorError("BadArgument", e.message, { source: "sdk", cause: e });
|
|
45
|
+
return new FloorError("Unknown", e instanceof Error ? e.message : String(e), { source: "sdk", cause: e });
|
|
46
|
+
}
|
|
47
|
+
async function guard (f ) {
|
|
48
|
+
try {
|
|
49
|
+
return await f();
|
|
50
|
+
} catch (e) {
|
|
51
|
+
throw asFloorError(e);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createEvmClient(opts ) {
|
|
56
|
+
const chain = opts?.chain;
|
|
57
|
+
if (chain?.family !== "evm") throw bad("createEvmClient takes an EVM chain (family \"evm\")");
|
|
58
|
+
const { chainId, floorAmm } = chain;
|
|
59
|
+
try {
|
|
60
|
+
checkFloorHops(chainId, 1);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
throw asFloorError(e);
|
|
63
|
+
}
|
|
64
|
+
if (typeof floorAmm !== "string" || !ADDRESS.test(floorAmm)) throw bad(`floorAmm ${String(floorAmm)}: a 20-byte 0x address`);
|
|
65
|
+
const transport = opts.transport;
|
|
66
|
+
if (typeof transport?.rpc?.call !== "function") throw bad("transport.rpc.call: the caller's eth_call");
|
|
67
|
+
|
|
68
|
+
const call = async (c ) => {
|
|
69
|
+
try {
|
|
70
|
+
return await transport.rpc.call(c);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
throw decodeEvmProgramError(e) ?? new FloorError("Transport", `eth_call to ${c.to} failed`, { source: "sdk", cause: e });
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const tx = (calls ) => ({ family: "evm", chainId, calls });
|
|
76
|
+
const launchIdOf = (launch ) => {
|
|
77
|
+
if (typeof launch !== "bigint" || launch <= 0n) throw bad("launch: an EVM launch is its launchId, a bigint > 0");
|
|
78
|
+
return launch;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const caps = new Map ();
|
|
82
|
+
const rows = new Map ();
|
|
83
|
+
const readLaunch = (launchId , o = {}) => {
|
|
84
|
+
if (o.msCapPpm) caps.set(launchId, o.msCapPpm);
|
|
85
|
+
if (o.row) rows.set(launchId, o.row);
|
|
86
|
+
const msCapPpm = o.msCapPpm ?? caps.get(launchId);
|
|
87
|
+
const row = o.row ?? rows.get(launchId);
|
|
88
|
+
return readLaunchV2(call, floorAmm, launchId, { ...(chain.multicall !== undefined ? { multicall: chain.multicall } : {}), ...(msCapPpm ? { msCapPpm } : {}), ...(row ? { row } : {}) });
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const mathOf = (launch , launchId ) => {
|
|
92
|
+
if (launch.math) return launch.math;
|
|
93
|
+
if (!rows.has(launchId)) throw bad(`launch ${launchId}: no split row (no EVM view returns it): readLaunch(launchId, { row }) first`);
|
|
94
|
+
throw new FloorError("Transport", `launch ${launchId}: circulatingOf failed (the dead count)`, { source: "sdk" });
|
|
95
|
+
};
|
|
96
|
+
const states = new Map ();
|
|
97
|
+
const launchState = (launchId ) => {
|
|
98
|
+
let s = states.get(launchId);
|
|
99
|
+
if (!s) {
|
|
100
|
+
s = call({ to: floorAmm, data: launchStateCallV2(launchId), value: 0n }).then(decodeLaunchStateV2);
|
|
101
|
+
s.catch(() => states.delete(launchId));
|
|
102
|
+
states.set(launchId, s);
|
|
103
|
+
}
|
|
104
|
+
return s;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
family: "evm",
|
|
109
|
+
chain,
|
|
110
|
+
readLaunch: (launchId, o) => guard(() => readLaunch(launchIdOf(launchId), o)),
|
|
111
|
+
launchState: (launchId) => guard(() => launchState(launchIdOf(launchId))),
|
|
112
|
+
|
|
113
|
+
quoteBuy: (p) => guard(async () => {
|
|
114
|
+
const launchId = launchIdOf(p.launch);
|
|
115
|
+
const slippageBps = slippageOf(p.slippageBps);
|
|
116
|
+
if (p.amountIn <= 0n) throw bad("amountIn must be > 0");
|
|
117
|
+
const launch = await readLaunch(launchId);
|
|
118
|
+
const math = mathOf(launch, launchId);
|
|
119
|
+
const msCapPpm = caps.get(launchId);
|
|
120
|
+
const v = { book: launch.book, row: math.row, sup: math.sup };
|
|
121
|
+
const o = { curve: launch.curve, ...(msCapPpm ? { msCapPpm } : {}) };
|
|
122
|
+
const r = quoteBuyEvmV2(v, p.amountIn, o);
|
|
123
|
+
|
|
124
|
+
let minTokens = 0n;
|
|
125
|
+
try {
|
|
126
|
+
const s = evmSettleInputsV2(v.book, v.row, v.sup, o.msCapPpm, o.curve);
|
|
127
|
+
minTokens = buyMinTokens(s.book, s.row, s.sup, p.amountIn, slippageBps);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
if (!fillsNothing(e)) throw e;
|
|
130
|
+
}
|
|
131
|
+
const impact = priceImpactV2(nextBuyPriceX64(math.book), r.buy.net, r.buy.tokens, "buy");
|
|
132
|
+
const q = {
|
|
133
|
+
family: "evm", chainId, side: "buy", launch: launchId.toString(), amountIn: p.amountIn, amountOut: r.buy.tokens * EVM_TOKEN_SCALE,
|
|
134
|
+
minOut: minTokens > 0n ? minTokens * EVM_TOKEN_SCALE : 1n, slippageBps, fees: legs(r.buy.fees), priceImpactBps: bps(impact.ppm),
|
|
135
|
+
refund: r.buy.refund, graduates: r.buy.graduatedNow,
|
|
136
|
+
};
|
|
137
|
+
return q;
|
|
138
|
+
}),
|
|
139
|
+
|
|
140
|
+
quoteSell: (p) => guard(async () => {
|
|
141
|
+
const launchId = launchIdOf(p.launch);
|
|
142
|
+
const slippageBps = slippageOf(p.slippageBps);
|
|
143
|
+
if (p.tokensIn <= 0n) throw bad("tokensIn must be > 0");
|
|
144
|
+
const tokens = p.tokensIn / EVM_TOKEN_SCALE;
|
|
145
|
+
if (tokens === 0n) throw bad("tokensIn must be at least one TOKEN_SCALE (10^12)");
|
|
146
|
+
const launch = await readLaunch(launchId);
|
|
147
|
+
const { book, sup } = mathOf(launch, launchId);
|
|
148
|
+
const { quote: s, impact } = quoteSellImpactV2(book, tokens, sCirc(book, sup));
|
|
149
|
+
const less = s.out > 0n ? minOutAt(s.out, slippageBps) : 0n;
|
|
150
|
+
const q = {
|
|
151
|
+
family: "evm", chainId, side: "sell", launch: launchId.toString(), amountIn: tokens * EVM_TOKEN_SCALE, amountOut: s.out,
|
|
152
|
+
minOut: less > 0n ? less : 1n, slippageBps, fees: legs(s.fees), priceImpactBps: bps(impact.ppm),
|
|
153
|
+
refund: s.unfilled * EVM_TOKEN_SCALE, graduates: false,
|
|
154
|
+
};
|
|
155
|
+
return q;
|
|
156
|
+
}),
|
|
157
|
+
|
|
158
|
+
buildBuy: (p) => guard(async () => {
|
|
159
|
+
const launchId = launchIdOf(p.launch);
|
|
160
|
+
const { quote } = await launchState(launchId);
|
|
161
|
+
const buy = buyCall({ floorAmm, quote, launchId, amountIn: p.amountIn, minTokensOut: p.minOut, to: p.recipient ?? p.trader, ...(p.deadline !== undefined ? { deadline: p.deadline } : {}) });
|
|
162
|
+
return tx(quote.toLowerCase() === NATIVE_QUOTE ? [buy] : [approveCall(quote, floorAmm, p.amountIn), buy]);
|
|
163
|
+
}),
|
|
164
|
+
|
|
165
|
+
buildSell: (p) => guard(async () => {
|
|
166
|
+
const launchId = launchIdOf(p.launch);
|
|
167
|
+
const sell = sellCall({ floorAmm, launchId, tokensIn: p.tokensIn, minQuoteOut: p.minOut, to: p.recipient ?? p.trader, ...(p.deadline !== undefined ? { deadline: p.deadline } : {}) });
|
|
168
|
+
const { token } = await launchState(launchId);
|
|
169
|
+
return tx([approveCall(token, floorAmm, p.tokensIn), sell]);
|
|
170
|
+
}),
|
|
171
|
+
|
|
172
|
+
claim: (p) => guard(async () => tx([claimV2Call({ floorAmm, wallet: p.wallet, types: p.types, quotes: [p.quote], launchIds: p.launches.map(launchIdOf) })])),
|
|
173
|
+
|
|
174
|
+
send: (t) => guard(async () => {
|
|
175
|
+
const send = transport.send;
|
|
176
|
+
if (!send) throw new FloorError("NoSend", "transport.send: none given (the SDK never signs)", { source: "sdk" });
|
|
177
|
+
if (t?.family !== "evm" || t.chainId !== chainId) throw bad(`send: a tx for chain ${chainId}`);
|
|
178
|
+
const hashes = [];
|
|
179
|
+
for (const c of t.calls) {
|
|
180
|
+
try {
|
|
181
|
+
hashes.push(await send(c));
|
|
182
|
+
} catch (e) {
|
|
183
|
+
throw decodeEvmProgramError(e) ?? new FloorError("Transport", `send to ${c.to} failed`, { source: "sdk", cause: e });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return hashes;
|
|
187
|
+
}),
|
|
188
|
+
|
|
189
|
+
decodeError: decodeEvmProgramError,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { FloorError } from "../errors.js";
|
|
4
|
+
import { createEvmClient } from "./evm/index.js";
|
|
5
|
+
import { createSolanaClient } from "./solana/index.js";
|
|
6
|
+
|
|
7
|
+
export { DEFAULT_SLIPPAGE_BPS } from "./types.js";
|
|
8
|
+
|
|
9
|
+
export { createEvmClient } from "./evm/index.js";
|
|
10
|
+
|
|
11
|
+
export { createSolanaClient } from "./solana/index.js";
|
|
12
|
+
|
|
13
|
+
export function createFloorClient (opts ) {
|
|
14
|
+
const family = opts.chain?.family;
|
|
15
|
+
if (!opts.transport?.rpc) throw new FloorError("BadArgument", "createFloorClient: transport.rpc is required", { source: "sdk" });
|
|
16
|
+
if (family === "solana") return createSolanaClient(opts ) ;
|
|
17
|
+
if (family === "evm") return createEvmClient(opts ) ;
|
|
18
|
+
throw new FloorError("BadArgument", `createFloorClient: chain.family ${String(family)}`, { source: "sdk" });
|
|
19
|
+
}
|