@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,491 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { R, RS, W, WS, instructionDiscriminator } from "../instruction.ts";
|
|
4
|
+
import type { AccountMeta, Instruction } from "../instruction.ts";
|
|
5
|
+
import { SYSTEM_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, WSOL_MINT, associatedTokenAddress } from "../pda.ts";
|
|
6
|
+
import {
|
|
7
|
+
FLOOR_AMM_PROGRAM_ID, GENESIS_USDC_MINT, INSTRUCTIONS_SYSVAR_ID, METADATA_PROGRAM_ID, configPda, floorEventAuthorityPda, genesisAllocPda, genesisConvertBandPda, genesisMigrationVaultPda, genesisRaisePda, genesisRaiseTokenVault,
|
|
8
|
+
genesisVaultFloor, genesisVaultUsdc, launchPda, metadataPda, presetPda, quoteEntryPda, teamSlotPda, traderLinkPda,
|
|
9
|
+
} from "./program.ts";
|
|
10
|
+
import { Writer } from "./borsh.ts";
|
|
11
|
+
import { CLAIM_BITS, CLAIM_KNOWN_MASKS, CLAIM_RESERVED, CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, CLAIM_RESERVED_HOLDER, CLAIM_EXTRA, CLAIM_TEAM_BUY, CLAIM_SHARE_BOUGHT } from "../../generated/index.ts";
|
|
12
|
+
import { launchMintPda } from "./mint.ts";
|
|
13
|
+
|
|
14
|
+
export type { Ctx } from "../../v2/solana.ts";
|
|
15
|
+
import type { Ctx } from "../../v2/solana.ts";
|
|
16
|
+
|
|
17
|
+
const pid = (c?: Ctx): string => c?.programId ?? FLOOR_AMM_PROGRAM_ID;
|
|
18
|
+
const evPair = (c?: Ctx): AccountMeta[] => [R(floorEventAuthorityPda(pid(c))[0]), R(pid(c))];
|
|
19
|
+
function ix(name: string, accounts: AccountMeta[], args: (w: Writer) => Writer, c?: Ctx): Instruction {
|
|
20
|
+
const w = new Writer().bytes(instructionDiscriminator(name));
|
|
21
|
+
return { programAddress: pid(c), accounts: [...accounts, ...evPair(c)], data: args(w).done() };
|
|
22
|
+
}
|
|
23
|
+
const none = (w: Writer): Writer => w;
|
|
24
|
+
|
|
25
|
+
const withRest = (i: Instruction, rest: AccountMeta[]): Instruction => (rest.length ? { ...i, accounts: [...i.accounts, ...rest] } : i);
|
|
26
|
+
|
|
27
|
+
export function initializeConfigInstruction(p: { upgradeAuthority: string; config: string; programData: string; authority: string; timelock: string; referralAuthority: string } & Ctx): Instruction {
|
|
28
|
+
return ix("initialize_config", [WS(p.upgradeAuthority), W(p.config), R(p.programData), R(SYSTEM_PROGRAM_ID)], (w) => w.pubkey(p.authority).pubkey(p.timelock).pubkey(p.referralAuthority), p);
|
|
29
|
+
}
|
|
30
|
+
export function transferAuthorityInstruction(p: { authority: string; config: string; newAuthority: string } & Ctx): Instruction {
|
|
31
|
+
return ix("transfer_authority", [RS(p.authority), W(p.config)], (w) => w.pubkey(p.newAuthority), p);
|
|
32
|
+
}
|
|
33
|
+
export function acceptAuthorityInstruction(p: { signer: string; config: string } & Ctx): Instruction {
|
|
34
|
+
return ix("accept_authority", [RS(p.signer), W(p.config)], none, p);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function setTreasuryInstruction(p: { signer: string; config: string; treasury: string } & Ctx): Instruction {
|
|
38
|
+
return ix("set_treasury", [RS(p.signer), W(p.config)], (w) => w.pubkey(p.treasury), p);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function setPriceUpdaterInstruction(p: { authority: string; config: string; priceUpdater: string } & Ctx): Instruction {
|
|
42
|
+
return ix("set_price_updater", [RS(p.authority), W(p.config)], (w) => w.pubkey(p.priceUpdater), p);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function setQuotePriceInstruction(p: { priceUpdater: string; config: string; quoteMint: string; quote?: string; usdCentsX64: bigint } & Ctx): Instruction {
|
|
46
|
+
if (p.usdCentsX64 <= 0n || p.usdCentsX64 >= 1n << 128n) throw new RangeError("usdCentsX64 is in (0, 2^128 - 1] (BadArgument)");
|
|
47
|
+
const quote = p.quote ?? quoteEntryPda(p.quoteMint, pid(p))[0];
|
|
48
|
+
return ix("set_quote_price", [RS(p.priceUpdater), R(p.config), R(p.quoteMint), W(quote)], (w) => w.u128(p.usdCentsX64), p);
|
|
49
|
+
}
|
|
50
|
+
export function setTimelockInstruction(p: { signer: string; config: string; timelock: string } & Ctx): Instruction {
|
|
51
|
+
return ix("set_timelock", [RS(p.signer), W(p.config)], (w) => w.pubkey(p.timelock), p);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function setCreatePausedInstruction(p: { authority: string; config: string; paused: boolean } & Ctx): Instruction {
|
|
55
|
+
return ix("set_create_paused", [RS(p.authority), W(p.config)], (w) => w.bool(p.paused), p);
|
|
56
|
+
}
|
|
57
|
+
export function setReferralAuthorityInstruction(p: { authority: string; config: string; referralAuthority: string } & Ctx): Instruction {
|
|
58
|
+
return ix("set_referral_authority", [RS(p.authority), W(p.config)], (w) => w.pubkey(p.referralAuthority), p);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function setHolderDestInstruction(p: { authority: string; config: string; holderDest: string } & Ctx): Instruction {
|
|
62
|
+
return ix("set_holder_dest", [RS(p.authority), W(p.config)], (w) => w.pubkey(p.holderDest), p);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function withdrawHolderInstruction(p: { authority: string; config: string; launch: string; quoteMint: string; quoteVault: string; destination: string; quoteTokenProgram: string; amount: bigint } & Ctx): Instruction {
|
|
66
|
+
return ix("withdraw_holder", [RS(p.authority), R(p.config), W(p.launch), R(p.quoteMint), W(p.quoteVault), W(p.destination), R(p.quoteTokenProgram)], (w) => w.u64(p.amount), p);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function withdrawHolderManyInstruction(p: { authority: string; config: string; quoteMint: string; destination: string; quoteTokenProgram: string; launches: readonly { launch: string; quoteVault: string }[] } & Ctx): Instruction {
|
|
70
|
+
if (p.launches.length === 0) throw new RangeError("withdraw_holder_many: no launch");
|
|
71
|
+
const base = ix("withdraw_holder_many", [RS(p.authority), R(p.config), R(p.quoteMint), W(p.destination), R(p.quoteTokenProgram)], (w) => w.u8(p.launches.length), p);
|
|
72
|
+
return { ...base, accounts: [...base.accounts, ...p.launches.flatMap((l) => [W(l.launch), W(l.quoteVault)])] };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function clearTraderRefInstruction(p: { authority: string; config: string; trader: string; traderLink?: string; traderRefs?: string[] } & Ctx): Instruction {
|
|
76
|
+
const i = ix("clear_trader_ref", [RS(p.authority), R(p.config), W(p.traderLink ?? traderLinkPda(p.trader, p.programId)[0])], none, p);
|
|
77
|
+
return withRest(i, (p.traderRefs ?? []).map((r) => W(r)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function withdrawPlatformInstruction(p: { authority: string; config: string; launch: string; quoteMint: string; quoteVault: string; destination: string; quoteTokenProgram: string; amount: bigint } & Ctx): Instruction {
|
|
81
|
+
return ix("withdraw_platform", [RS(p.authority), R(p.config), W(p.launch), R(p.quoteMint), W(p.quoteVault), W(p.destination), R(p.quoteTokenProgram)], (w) => w.u64(p.amount), p);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function checkPresetInstruction(p: { authority: string; config: string; preset: string; id: number } & Ctx): Instruction {
|
|
85
|
+
return ix("check_preset", [RS(p.authority), R(p.config), W(p.preset)], (w) => w.u8(p.id), p);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function setPresetEnabledInstruction(p: { authority: string; config: string; preset: string; id: number; enabled: boolean } & Ctx): Instruction {
|
|
89
|
+
return ix("set_preset_enabled", [RS(p.authority), R(p.config), W(p.preset)], (w) => w.u8(p.id).bool(p.enabled), p);
|
|
90
|
+
}
|
|
91
|
+
export function deletePresetInstruction(p: { authority: string; config: string; preset: string; id: number } & Ctx): Instruction {
|
|
92
|
+
return ix("delete_preset", [RS(p.authority), R(p.config), W(p.preset)], (w) => w.u8(p.id), p);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function addQuoteInstruction(p: { authority: string; config: string; mint: string; quote: string; createFee: bigint; usdCentsX64: bigint; admittedCaps?: number } & Ctx): Instruction {
|
|
96
|
+
return ix("add_quote", [WS(p.authority), R(p.config), R(p.mint), W(p.quote), R(SYSTEM_PROGRAM_ID)], (w) => w.u64(p.createFee).u128(p.usdCentsX64).u32(p.admittedCaps ?? 0), p);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function setQuoteCapsInstruction(p: { authority: string; config: string; quote: string; admittedCaps: number } & Ctx): Instruction {
|
|
100
|
+
return ix("set_quote_caps", [RS(p.authority), R(p.config), W(p.quote)], (w) => w.u32(p.admittedCaps), p);
|
|
101
|
+
}
|
|
102
|
+
export function updateQuoteInstruction(p: { authority: string; config: string; quote: string; enabled: boolean; createFee: bigint; usdCentsX64: bigint } & Ctx): Instruction {
|
|
103
|
+
return ix("update_quote", [RS(p.authority), R(p.config), W(p.quote)], (w) => w.bool(p.enabled).u64(p.createFee).u128(p.usdCentsX64), p);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const MAX_NAME_LEN = 32;
|
|
107
|
+
export const MAX_SYMBOL_LEN = 10;
|
|
108
|
+
export const MAX_URI_LEN = 200;
|
|
109
|
+
|
|
110
|
+
export const MAX_METADATA_BASE_LEN = 72;
|
|
111
|
+
export const METADATA_BASE_SCHEMES = ["https://", "ipfs://", "ar://"] as const;
|
|
112
|
+
|
|
113
|
+
export function metadataBaseOk(base: string): boolean {
|
|
114
|
+
if (base === "") return true;
|
|
115
|
+
return (
|
|
116
|
+
base.length <= MAX_METADATA_BASE_LEN &&
|
|
117
|
+
METADATA_BASE_SCHEMES.some((s) => base.startsWith(s) && base.length > s.length) &&
|
|
118
|
+
/^[\x21-\x7e]+$/.test(base) &&
|
|
119
|
+
!base.endsWith("/")
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const metadataUri = (base: string, baseMint: string): string => `${base}/${baseMint}.json`;
|
|
124
|
+
|
|
125
|
+
export function setMetadataBaseInstruction(p: { authority: string; config: string; base: string } & Ctx): Instruction {
|
|
126
|
+
if (!metadataBaseOk(p.base)) throw new RangeError("the metadata base is \"\" or https:// · ipfs:// · ar://, printable ASCII, no space, no trailing slash, ≤ 72 bytes");
|
|
127
|
+
return ix("set_metadata_base", [RS(p.authority), W(p.config)], (w) => w.string(p.base), p);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface CreateMintAccounts {
|
|
131
|
+
mintNonce: bigint;
|
|
132
|
+
baseMint: string;
|
|
133
|
+
launch: string;
|
|
134
|
+
tokenVault: string;
|
|
135
|
+
quoteVault: string;
|
|
136
|
+
metadata: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function createMintAccounts(p: { creator: string; quoteMint: string; quoteTokenProgram: string; baseMint?: string; launch?: string; tokenVault?: string; quoteVault?: string; metadata?: string; args: { mintNonce: bigint } } & Ctx): CreateMintAccounts {
|
|
140
|
+
const nonce = p.args.mintNonce;
|
|
141
|
+
if (typeof nonce !== "bigint") throw new RangeError("args.mintNonce (a u64 bigint) is required: the mint is the PDA [\"mint\", creator, mintNonce LE]");
|
|
142
|
+
const baseMint = launchMintPda(p.creator, nonce, pid(p))[0];
|
|
143
|
+
if (p.baseMint !== undefined && p.baseMint !== baseMint) throw new RangeError(`baseMint ${p.baseMint} is not the creator's mint PDA for nonce ${nonce} (${baseMint})`);
|
|
144
|
+
const launch = p.launch ?? launchPda(baseMint, pid(p))[0];
|
|
145
|
+
return {
|
|
146
|
+
mintNonce: nonce,
|
|
147
|
+
baseMint,
|
|
148
|
+
launch,
|
|
149
|
+
tokenVault: p.tokenVault ?? associatedTokenAddress(launch, baseMint, TOKEN_2022_PROGRAM_ID),
|
|
150
|
+
quoteVault: p.quoteVault ?? associatedTokenAddress(launch, p.quoteMint, p.quoteTokenProgram),
|
|
151
|
+
metadata: p.metadata ?? metadataPda(baseMint)[0],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface TradeAccounts {
|
|
156
|
+
trader: string;
|
|
157
|
+
launch: string;
|
|
158
|
+
baseMint: string;
|
|
159
|
+
quoteMint: string;
|
|
160
|
+
tokenVault: string;
|
|
161
|
+
quoteVault: string;
|
|
162
|
+
traderBase: string;
|
|
163
|
+
traderQuote: string;
|
|
164
|
+
quoteTokenProgram: string;
|
|
165
|
+
traderRef?: string | null;
|
|
166
|
+
escrow?: string | null;
|
|
167
|
+
|
|
168
|
+
user?: string | null;
|
|
169
|
+
|
|
170
|
+
linkWallet?: string | null;
|
|
171
|
+
|
|
172
|
+
recipient?: string | null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function initTeamSlotInstruction(p: { creator: string; launch: string; quote: string; teamSlot: string; rateBps: number } & Ctx): Instruction {
|
|
176
|
+
return ix("init_team_slot", [WS(p.creator), W(p.launch), R(p.quote), W(p.teamSlot), R(SYSTEM_PROGRAM_ID)], (w) => w.u16(p.rateBps), p);
|
|
177
|
+
}
|
|
178
|
+
interface TeamSlotPayment {
|
|
179
|
+
payer: string;
|
|
180
|
+
launch: string;
|
|
181
|
+
teamSlot: string;
|
|
182
|
+
quoteMint: string;
|
|
183
|
+
payerQuote: string;
|
|
184
|
+
quoteVault: string;
|
|
185
|
+
quoteTokenProgram: string;
|
|
186
|
+
|
|
187
|
+
baseMint: string;
|
|
188
|
+
}
|
|
189
|
+
const slotPay = (a: TeamSlotPayment): AccountMeta[] => [WS(a.payer), W(a.launch), W(a.teamSlot), R(a.quoteMint), W(a.payerQuote), W(a.quoteVault), R(a.quoteTokenProgram), R(a.baseMint)];
|
|
190
|
+
export const TEAM_SLOT_WALLET = 0;
|
|
191
|
+
export const TEAM_SLOT_PENDING_HANDLE = 1;
|
|
192
|
+
export function teamSlotAddInstruction(p: TeamSlotPayment & { key: string; kind: number; amount: bigint; payNow: boolean } & Ctx): Instruction {
|
|
193
|
+
return ix("team_slot_add", slotPay(p), (w) => w.pubkey(p.key).u8(p.kind).u64(p.amount).bool(p.payNow), p);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function bindHandleInstruction(p: { referralAuthority: string; config: string; launch: string; teamSlot: string; index: number; handle: Uint8Array; wallet: string } & Ctx): Instruction {
|
|
197
|
+
if (p.handle.length !== 32) throw new RangeError("a handle is 32 bytes");
|
|
198
|
+
|
|
199
|
+
return ix("bind_handle", [RS(p.referralAuthority), R(p.config), R(p.launch), W(p.teamSlot), RS(p.wallet)], (w) => w.u8(p.index).bytes(p.handle).pubkey(p.wallet), p);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function openTraderRefInstruction(p: { payer: string; referralAuthority: string; config: string; quoteMint: string; traderRef: string; escrow: string; quoteTokenProgram: string; trader: string; tiers: [string, string, string]; withLink?: boolean } & Ctx): Instruction {
|
|
203
|
+
return withRest(
|
|
204
|
+
ix(
|
|
205
|
+
"open_trader_ref",
|
|
206
|
+
[WS(p.payer), RS(p.referralAuthority), R(p.config), R(p.quoteMint), W(p.traderRef), W(p.escrow), R(p.quoteTokenProgram), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID), RS(p.trader)],
|
|
207
|
+
(w) => w.pubkey(p.trader).pubkey(p.tiers[0]).pubkey(p.tiers[1]).pubkey(p.tiers[2]),
|
|
208
|
+
p,
|
|
209
|
+
),
|
|
210
|
+
[W(traderLinkPda(p.trader, p.programId)[0])],
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function openTraderLinkInstruction(p: { payer: string; referralAuthority: string; config: string; traderLink?: string; trader: string; tiers: [string, string, string] } & Ctx): Instruction {
|
|
215
|
+
return ix(
|
|
216
|
+
"open_trader_link",
|
|
217
|
+
[WS(p.payer), RS(p.referralAuthority), R(p.config), W(p.traderLink ?? traderLinkPda(p.trader, p.programId)[0]), R(SYSTEM_PROGRAM_ID), RS(p.trader)],
|
|
218
|
+
(w) => w.pubkey(p.trader).pubkey(p.tiers[0]).pubkey(p.tiers[1]).pubkey(p.tiers[2]),
|
|
219
|
+
p,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function openRefOwedInstruction(p: { payer: string; quoteMint: string; refOwed: string; vault: string; quoteTokenProgram: string; referrer: string } & Ctx): Instruction {
|
|
224
|
+
return ix("open_ref_owed", [WS(p.payer), R(p.quoteMint), W(p.refOwed), W(p.vault), R(p.quoteTokenProgram), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID)], (w) => w.pubkey(p.referrer), p);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function rollUpRefsInstruction(p: { quoteMint: string; quoteTokenProgram: string; traderRefs: readonly { traderRef: string; escrow: string }[]; refOwed: readonly { refOwed: string; vault: string }[] } & Ctx): Instruction {
|
|
228
|
+
if (p.traderRefs.length > 255) throw new RangeError("at most 255 links a roll-up");
|
|
229
|
+
const base = ix("roll_up_refs", [R(p.quoteMint), R(p.quoteTokenProgram)], (w) => w.u8(p.traderRefs.length), p);
|
|
230
|
+
const rest: AccountMeta[] = [];
|
|
231
|
+
for (const t of p.traderRefs) rest.push(W(t.traderRef), W(t.escrow));
|
|
232
|
+
for (const r of p.refOwed) rest.push(W(r.refOwed), W(r.vault));
|
|
233
|
+
return { ...base, accounts: [...base.accounts, ...rest] };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, CLAIM_RESERVED_HOLDER, CLAIM_EXTRA, CLAIM_TEAM_BUY, CLAIM_SHARE_BOUGHT };
|
|
237
|
+
|
|
238
|
+
export const CLAIM_RESERVED_PAYOUT = CLAIM_RESERVED.solana.payout;
|
|
239
|
+
|
|
240
|
+
export const CLAIM_KNOWN = CLAIM_KNOWN_MASKS.solana.claim;
|
|
241
|
+
|
|
242
|
+
export const CLAIM_KNOWN_WIDE = CLAIM_KNOWN_MASKS.solana.claimWideV1;
|
|
243
|
+
|
|
244
|
+
export interface ClaimLaunch {
|
|
245
|
+
launch: string;
|
|
246
|
+
quoteVault: string;
|
|
247
|
+
teamSlot: string | null;
|
|
248
|
+
|
|
249
|
+
teamBuy?: { baseMint: string; tokenVault: string; walletBase: string };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function setNativeCreateFeeInstruction(p: { authority: string; config: string; lamports: bigint } & Ctx): Instruction {
|
|
253
|
+
return ix("set_native_create_fee", [RS(p.authority), W(p.config)], (w) => w.u64(p.lamports), p);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function withdrawPlatformManyInstruction(p: { authority: string; config: string; quoteMint: string; destination: string; quoteTokenProgram: string; launches: readonly { launch: string; quoteVault: string }[]; nativeTo?: string; quoteHook?: readonly AccountMeta[] } & Ctx): Instruction {
|
|
257
|
+
if (p.launches.length === 0 && !p.nativeTo) throw new RangeError("withdraw_platform_many: no launch and no native fees");
|
|
258
|
+
|
|
259
|
+
if (p.quoteHook?.length && p.launches.length === 0) throw new RangeError("withdraw_platform_many: a quote hook block needs a launch");
|
|
260
|
+
const base = ix("withdraw_platform_many", [RS(p.authority), p.nativeTo ? W(p.config) : R(p.config), R(p.quoteMint), W(p.destination), R(p.quoteTokenProgram)], (w) => w.u8(p.launches.length), p);
|
|
261
|
+
return { ...base, accounts: [...base.accounts, ...p.launches.flatMap((l) => [W(l.launch), W(l.quoteVault)]), ...(p.quoteHook ?? []), ...(p.nativeTo ? [W(p.nativeTo)] : [])] };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export const INCINERATOR = "1nc1nerator11111111111111111111111111111111";
|
|
265
|
+
|
|
266
|
+
export function syncBurnsInstruction(p: { launch: string; baseMint: string; incineratorAta?: string; extra?: readonly string[] } & Ctx): Instruction {
|
|
267
|
+
const base = ix("sync_burns", [W(p.launch), R(p.baseMint), R(p.incineratorAta ?? associatedTokenAddress(INCINERATOR, p.baseMint, TOKEN_2022_PROGRAM_ID))], none, p);
|
|
268
|
+
return { ...base, accounts: [...base.accounts, ...(p.extra ?? []).map((a) => R(a))] };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function contributeGenesisInstruction(p: { contributor: string; genesisRaise: string; migrationVault: string; allocation: string; amount: bigint } & Ctx): Instruction {
|
|
272
|
+
return ix("contribute_genesis", [WS(p.contributor), W(p.genesisRaise), W(p.migrationVault), W(p.allocation), R(SYSTEM_PROGRAM_ID)], (w) => w.u64(p.amount), p);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function contributeGenesisListedInstruction(p: { contributor: string; genesisRaise: string; migrationVault: string; allocation: string; amount: bigint; proof: readonly Uint8Array[] } & Ctx): Instruction {
|
|
276
|
+
for (const s of p.proof) if (s.length !== 32) throw new RangeError("contributeGenesisListedInstruction: a proof sibling is 32 bytes");
|
|
277
|
+
return ix(
|
|
278
|
+
"contribute_genesis_listed",
|
|
279
|
+
[WS(p.contributor), W(p.genesisRaise), W(p.migrationVault), W(p.allocation), R(SYSTEM_PROGRAM_ID)],
|
|
280
|
+
(w) => p.proof.reduce((x, s) => x.bytes(s), w.u64(p.amount).u32(p.proof.length)),
|
|
281
|
+
p,
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function refundGenesisMigratedInstruction(p: { wallet: string; genesisRaise: string; migrationVault: string; allocation: string } & Ctx): Instruction {
|
|
286
|
+
return ix("refund_genesis_migrated", [WS(p.wallet), W(p.genesisRaise), W(p.migrationVault), W(p.allocation), R(SYSTEM_PROGRAM_ID)], none, p);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function setGenesisCreatorInstruction(p: { authority: string; config: string; genesisRaise: string; creator: string } & Ctx): Instruction {
|
|
290
|
+
return ix("set_genesis_creator", [RS(p.authority), R(p.config), W(p.genesisRaise)], (w) => w.pubkey(p.creator), p);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function setGenesisListRootInstruction(p: { authority: string; config: string; genesisRaise: string; listRoot: Uint8Array } & Ctx): Instruction {
|
|
294
|
+
if (p.listRoot.length !== 32) throw new RangeError("setGenesisListRootInstruction: the root is 32 bytes");
|
|
295
|
+
return ix("set_genesis_list_root", [RS(p.authority), R(p.config), W(p.genesisRaise)], (w) => w.bytes(p.listRoot), p);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function setGenesisPresetInstruction(p: { authority: string; config: string; genesisRaise: string; preset: string; presetId: number } & Ctx): Instruction {
|
|
299
|
+
return ix("set_genesis_preset", [RS(p.authority), R(p.config), W(p.genesisRaise), R(p.preset)], (w) => w.u8(p.presetId), p);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function setGenesisWagmiPresetInstruction(p: { authority: string; presetId: number; config?: string; genesisRaise?: string; preset?: string } & Ctx): Instruction {
|
|
303
|
+
const g = pid(p);
|
|
304
|
+
const preset = p.preset ?? (p.presetId === 0 ? g : presetPda(p.presetId, g)[0]);
|
|
305
|
+
return ix("set_genesis_wagmi_preset", [RS(p.authority), R(p.config ?? configPda(g)[0]), W(p.genesisRaise ?? genesisRaisePda(g)[0]), R(preset)], (w) => w.u8(p.presetId), p);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function setGenesisWagmiCapInstruction(p: { authority: string; capTokens: bigint; config?: string; genesisRaise?: string } & Ctx): Instruction {
|
|
309
|
+
if (p.capTokens < 0n || p.capTokens >> 64n !== 0n) throw new RangeError("set_genesis_wagmi_cap: cap_tokens is a u64");
|
|
310
|
+
const g = pid(p);
|
|
311
|
+
return ix("set_genesis_wagmi_cap", [RS(p.authority), R(p.config ?? configPda(g)[0]), W(p.genesisRaise ?? genesisRaisePda(g)[0])], (w) => w.u64(p.capTokens), p);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export function convertGenesisSolInstruction(p: {
|
|
315
|
+
caller: string; lamports: bigint; maxUsdc: bigint; preset: string; wagmiPreset?: string;
|
|
316
|
+
callerUsdc?: string; genesisRaise?: string; migrationVault?: string; solQuote?: string; usdcQuote?: string; vaultUsdc?: string; usdcMint?: string;
|
|
317
|
+
|
|
318
|
+
convertBand?: string | true;
|
|
319
|
+
} & Ctx): Instruction {
|
|
320
|
+
if (p.lamports <= 0n) throw new RangeError("convert_genesis_sol: the lamports must be > 0");
|
|
321
|
+
const g = pid(p);
|
|
322
|
+
const usdc = p.usdcMint ?? GENESIS_USDC_MINT;
|
|
323
|
+
return ix(
|
|
324
|
+
"convert_genesis_sol",
|
|
325
|
+
[
|
|
326
|
+
WS(p.caller), W(p.genesisRaise ?? genesisRaisePda(g)[0]), W(p.migrationVault ?? genesisMigrationVaultPda(g)[0]), R(p.solQuote ?? quoteEntryPda(WSOL_MINT, g)[0]), R(p.usdcQuote ?? quoteEntryPda(usdc, g)[0]), R(usdc),
|
|
327
|
+
W(p.callerUsdc ?? associatedTokenAddress(p.caller, usdc, TOKEN_PROGRAM_ID)), W(p.vaultUsdc ?? genesisVaultUsdc(g, usdc)), R(p.preset), R(p.wagmiPreset ?? g),
|
|
328
|
+
R(TOKEN_PROGRAM_ID), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID),
|
|
329
|
+
R(typeof p.convertBand === "string" ? p.convertBand : genesisConvertBandPda(g)[0]),
|
|
330
|
+
],
|
|
331
|
+
(w) => w.u64(p.lamports).u64(p.maxUsdc),
|
|
332
|
+
p,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function openGenesisLaunchInstruction(p: {
|
|
337
|
+
authority: string; config: string; genesisRaise: string; migrationVault: string; deployer: string; preset: string; quote: string; quoteMint: string; baseMint: string;
|
|
338
|
+
launch: string; tokenVault: string; quoteVault: string; raiseTokenVault: string; teamSlot: string; metadata: string; metadataProgram?: string;
|
|
339
|
+
vaultUsdc?: string; vaultFloor?: string; wagmiPreset?: string; wagmiPresetId?: number; solQuote?: string;
|
|
340
|
+
args: { name: string; symbol: string; uri?: string };
|
|
341
|
+
} & Ctx): Instruction {
|
|
342
|
+
const g = pid(p);
|
|
343
|
+
const wagmiPreset = p.wagmiPreset ?? (p.wagmiPresetId ? presetPda(p.wagmiPresetId, g)[0] : g);
|
|
344
|
+
return ix(
|
|
345
|
+
"open_genesis_launch",
|
|
346
|
+
[
|
|
347
|
+
WS(p.authority), W(p.config), W(p.genesisRaise), W(p.migrationVault), W(p.deployer), R(p.preset), W(p.quote), R(p.quoteMint), WS(p.baseMint), W(p.launch), W(p.tokenVault), W(p.quoteVault),
|
|
348
|
+
W(p.raiseTokenVault), W(p.teamSlot), W(p.metadata), R(p.metadataProgram ?? METADATA_PROGRAM_ID), R(TOKEN_2022_PROGRAM_ID), R(TOKEN_PROGRAM_ID), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID), R(INSTRUCTIONS_SYSVAR_ID),
|
|
349
|
+
W(p.vaultUsdc ?? genesisVaultUsdc(g, p.quoteMint)), W(p.vaultFloor ?? genesisVaultFloor(p.baseMint, g)), R(wagmiPreset), R(p.solQuote ?? quoteEntryPda(WSOL_MINT, g)[0]),
|
|
350
|
+
],
|
|
351
|
+
(w) => w.string(p.args.name).string(p.args.symbol).string(p.args.uri ?? ""),
|
|
352
|
+
p,
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export function openGenesisLaunchDefaults(p: { authority: string; deployer: string; baseMint: string; presetId: number; wagmiPresetId?: number; usdcMint?: string } & Ctx): Omit<Parameters<typeof openGenesisLaunchInstruction>[0], "args"> {
|
|
357
|
+
const g = pid(p);
|
|
358
|
+
const usdc = p.usdcMint ?? GENESIS_USDC_MINT;
|
|
359
|
+
const launch = launchPda(p.baseMint, g)[0];
|
|
360
|
+
return {
|
|
361
|
+
programId: g, authority: p.authority, config: configPda(g)[0], genesisRaise: genesisRaisePda(g)[0], migrationVault: genesisMigrationVaultPda(g)[0], deployer: p.deployer,
|
|
362
|
+
preset: presetPda(p.presetId, g)[0], quote: quoteEntryPda(usdc, g)[0], quoteMint: usdc, baseMint: p.baseMint, launch,
|
|
363
|
+
tokenVault: associatedTokenAddress(launch, p.baseMint, TOKEN_2022_PROGRAM_ID), quoteVault: associatedTokenAddress(launch, usdc, TOKEN_PROGRAM_ID),
|
|
364
|
+
raiseTokenVault: genesisRaiseTokenVault(p.baseMint, g), teamSlot: teamSlotPda(launch, g)[0], metadata: metadataPda(p.baseMint)[0],
|
|
365
|
+
vaultUsdc: genesisVaultUsdc(g, usdc), vaultFloor: genesisVaultFloor(p.baseMint, g), wagmiPresetId: p.wagmiPresetId ?? 0,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export function openGenesisWagmiInstruction(p: {
|
|
370
|
+
authority: string; config: string; genesisRaise: string; preset: string; quote: string; quoteMint: string; baseMint: string; launch: string; tokenVault: string;
|
|
371
|
+
quoteVault: string; raiseTokenVault: string; teamSlot: string; vault: string; vaultFloor: string; metadata: string; metadataProgram?: string;
|
|
372
|
+
floorLaunch?: string; usdcQuote?: string;
|
|
373
|
+
args: { name: string; symbol: string; uri?: string };
|
|
374
|
+
} & Ctx): Instruction {
|
|
375
|
+
const g = pid(p);
|
|
376
|
+
return ix(
|
|
377
|
+
"open_genesis_wagmi",
|
|
378
|
+
[
|
|
379
|
+
WS(p.authority), W(p.config), W(p.genesisRaise), R(p.preset), W(p.quote), R(p.quoteMint), WS(p.baseMint), W(p.launch), W(p.tokenVault), W(p.quoteVault), W(p.raiseTokenVault),
|
|
380
|
+
W(p.teamSlot), R(p.vault), W(p.vaultFloor), W(p.metadata), R(p.metadataProgram ?? METADATA_PROGRAM_ID), R(TOKEN_2022_PROGRAM_ID), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID), R(INSTRUCTIONS_SYSVAR_ID),
|
|
381
|
+
R(p.floorLaunch ?? launchPda(p.quoteMint, g)[0]), R(p.usdcQuote ?? quoteEntryPda(GENESIS_USDC_MINT, g)[0]),
|
|
382
|
+
],
|
|
383
|
+
(w) => w.string(p.args.name).string(p.args.symbol).string(p.args.uri ?? ""),
|
|
384
|
+
p,
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export function openGenesisWagmiDefaults(p: { authority: string; floorMint: string; baseMint: string; wagmiPresetId: number; usdcMint?: string } & Ctx): Omit<Parameters<typeof openGenesisWagmiInstruction>[0], "args"> {
|
|
389
|
+
const g = pid(p);
|
|
390
|
+
const launch = launchPda(p.baseMint, g)[0];
|
|
391
|
+
return {
|
|
392
|
+
programId: g, authority: p.authority, config: configPda(g)[0], genesisRaise: genesisRaisePda(g)[0], preset: presetPda(p.wagmiPresetId, g)[0],
|
|
393
|
+
quote: quoteEntryPda(p.floorMint, g)[0], quoteMint: p.floorMint, baseMint: p.baseMint, launch,
|
|
394
|
+
tokenVault: associatedTokenAddress(launch, p.baseMint, TOKEN_2022_PROGRAM_ID), quoteVault: associatedTokenAddress(launch, p.floorMint, TOKEN_2022_PROGRAM_ID),
|
|
395
|
+
raiseTokenVault: genesisRaiseTokenVault(p.baseMint, g), teamSlot: teamSlotPda(launch, g)[0], vault: genesisMigrationVaultPda(g)[0], vaultFloor: genesisVaultFloor(p.floorMint, g),
|
|
396
|
+
metadata: metadataPda(p.baseMint)[0], floorLaunch: launchPda(p.floorMint, g)[0], usdcQuote: quoteEntryPda(p.usdcMint ?? GENESIS_USDC_MINT, g)[0],
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export function claimGenesisInstruction(p: { sender: string; wallet: string; genesisRaise: string; allocation: string; baseMint: string; raiseTokenVault: string; destination: string; migrationVault?: string; usdcMint?: string; vaultUsdc?: string; usdcDestination?: string } & Ctx): Instruction {
|
|
401
|
+
const usdc = p.usdcMint ?? GENESIS_USDC_MINT;
|
|
402
|
+
return ix(
|
|
403
|
+
"claim_genesis",
|
|
404
|
+
[
|
|
405
|
+
WS(p.sender), W(p.wallet), W(p.genesisRaise), W(p.allocation), R(p.baseMint), W(p.raiseTokenVault), W(p.destination), R(TOKEN_2022_PROGRAM_ID), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID), W(p.migrationVault ?? genesisMigrationVaultPda(pid(p))[0]),
|
|
406
|
+
R(usdc), W(p.vaultUsdc ?? genesisVaultUsdc(pid(p), usdc)), W(p.usdcDestination ?? associatedTokenAddress(p.wallet, usdc, TOKEN_PROGRAM_ID)), R(TOKEN_PROGRAM_ID),
|
|
407
|
+
],
|
|
408
|
+
(w) => w.pubkey(p.wallet),
|
|
409
|
+
p,
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export function claimGenesisRefundInstruction(p: { claimer: string; wallet: string; to?: string; genesisRaise?: string; allocation?: string; migrationVault?: string; vaultUsdc?: string; usdcMint?: string; usdcTo?: string } & Ctx): Instruction {
|
|
414
|
+
const g = pid(p);
|
|
415
|
+
const usdc = p.usdcMint ?? GENESIS_USDC_MINT;
|
|
416
|
+
return ix(
|
|
417
|
+
"claim_genesis_refund",
|
|
418
|
+
[
|
|
419
|
+
RS(p.claimer), W(p.genesisRaise ?? genesisRaisePda(g)[0]), W(p.allocation ?? genesisAllocPda(p.wallet, g)[0]), W(p.to ?? p.wallet), W(p.migrationVault ?? genesisMigrationVaultPda(g)[0]), R(SYSTEM_PROGRAM_ID),
|
|
420
|
+
W(p.vaultUsdc ?? genesisVaultUsdc(g, usdc)), R(usdc), W(p.usdcTo ?? associatedTokenAddress(p.wallet, usdc, TOKEN_PROGRAM_ID)), R(TOKEN_PROGRAM_ID),
|
|
421
|
+
],
|
|
422
|
+
(w) => w.pubkey(p.wallet),
|
|
423
|
+
p,
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export function sweepGenesisDustInstruction(p: { launch: string; quoteVault: string; genesisRaise?: string; migrationVault?: string; config?: string; vaultUsdc?: string; usdcMint?: string } & Ctx): Instruction {
|
|
428
|
+
const g = pid(p);
|
|
429
|
+
const usdc = p.usdcMint ?? GENESIS_USDC_MINT;
|
|
430
|
+
return ix(
|
|
431
|
+
"sweep_genesis_dust",
|
|
432
|
+
[
|
|
433
|
+
W(p.genesisRaise ?? genesisRaisePda(g)[0]), W(p.launch), W(p.quoteVault), W(p.migrationVault ?? genesisMigrationVaultPda(g)[0]), R(TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID),
|
|
434
|
+
W(p.config ?? configPda(g)[0]), W(p.vaultUsdc ?? genesisVaultUsdc(g, usdc)), R(usdc),
|
|
435
|
+
],
|
|
436
|
+
none,
|
|
437
|
+
p,
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export function claimGenesisWagmiInstruction(p: {
|
|
442
|
+
sender: string; wallet: string; wagmiMint: string; floorMint: string;
|
|
443
|
+
genesisRaise?: string; allocation?: string; raiseWagmiVault?: string; wagmiDestination?: string; migrationVault?: string; vaultFloor?: string; floorDestination?: string;
|
|
444
|
+
} & Ctx): Instruction {
|
|
445
|
+
const g = pid(p);
|
|
446
|
+
return ix(
|
|
447
|
+
"claim_genesis_wagmi",
|
|
448
|
+
[
|
|
449
|
+
WS(p.sender), R(p.wallet), W(p.genesisRaise ?? genesisRaisePda(g)[0]), W(p.allocation ?? genesisAllocPda(p.wallet, g)[0]),
|
|
450
|
+
R(p.wagmiMint), W(p.raiseWagmiVault ?? genesisRaiseTokenVault(p.wagmiMint, g)), W(p.wagmiDestination ?? associatedTokenAddress(p.wallet, p.wagmiMint, TOKEN_2022_PROGRAM_ID)),
|
|
451
|
+
R(p.floorMint), R(p.migrationVault ?? genesisMigrationVaultPda(g)[0]), W(p.vaultFloor ?? genesisVaultFloor(p.floorMint, g)), W(p.floorDestination ?? associatedTokenAddress(p.wallet, p.floorMint, TOKEN_2022_PROGRAM_ID)),
|
|
452
|
+
R(TOKEN_2022_PROGRAM_ID), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID),
|
|
453
|
+
],
|
|
454
|
+
(w) => w.pubkey(p.wallet),
|
|
455
|
+
p,
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export function sweepGenesisWagmiDustInstruction(p: { launch: string; floorMint: string; quoteVault?: string; genesisRaise?: string; vault?: string; vaultFloor?: string } & Ctx): Instruction {
|
|
460
|
+
const g = pid(p);
|
|
461
|
+
return ix(
|
|
462
|
+
"sweep_genesis_wagmi_dust",
|
|
463
|
+
[
|
|
464
|
+
W(p.genesisRaise ?? genesisRaisePda(g)[0]), W(p.launch), W(p.quoteVault ?? associatedTokenAddress(p.launch, p.floorMint, TOKEN_2022_PROGRAM_ID)), R(p.floorMint),
|
|
465
|
+
R(p.vault ?? genesisMigrationVaultPda(g)[0]), W(p.vaultFloor ?? genesisVaultFloor(p.floorMint, g)), R(TOKEN_2022_PROGRAM_ID),
|
|
466
|
+
],
|
|
467
|
+
none,
|
|
468
|
+
p,
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export function acceptGenesisMigrationInstruction(p: {
|
|
473
|
+
authority: string;
|
|
474
|
+
config: string;
|
|
475
|
+
genesisRaise: string;
|
|
476
|
+
migrationVault: string;
|
|
477
|
+
oldSale: string;
|
|
478
|
+
contributors: readonly { contribution: string; allocation: string }[];
|
|
479
|
+
expectedTotal: bigint;
|
|
480
|
+
} & Ctx): Instruction {
|
|
481
|
+
const base = ix("accept_genesis_migration", [WS(p.authority), R(p.config), W(p.genesisRaise), W(p.migrationVault), R(p.oldSale), R(SYSTEM_PROGRAM_ID)], (w) => w.u16(p.contributors.length).u64(p.expectedTotal), p);
|
|
482
|
+
return { ...base, accounts: [...base.accounts, ...p.contributors.flatMap((c) => [R(c.contribution), W(c.allocation)])] };
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export function tokenBurnCheckedInstruction(p: { owner: string; account: string; mint: string; amount: bigint; decimals: number }): Instruction {
|
|
486
|
+
const data = new Uint8Array(10);
|
|
487
|
+
data[0] = 15;
|
|
488
|
+
new DataView(data.buffer).setBigUint64(1, p.amount, true);
|
|
489
|
+
data[9] = p.decimals;
|
|
490
|
+
return { programAddress: TOKEN_2022_PROGRAM_ID, accounts: [W(p.account), W(p.mint), RS(p.owner)], data };
|
|
491
|
+
}
|