@floorlaunchpad/sdk 0.7.0 → 0.8.1

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/README.md +12 -1
  3. package/dist/abi/evm.gen.js +75 -2
  4. package/dist/abi/functions.gen.js +87 -1
  5. package/dist/abi/solana.gen.js +59 -0
  6. package/dist/client/solana/index.js +25 -6
  7. package/dist/config/generated.js +803 -26374
  8. package/dist/errors.js +20 -1
  9. package/dist/events/types.gen.js +1 -1
  10. package/dist/evm/chains.js +49 -0
  11. package/dist/evm/floor/abi.gen.js +115 -0
  12. package/dist/evm/squid.js +21 -5
  13. package/dist/evm/venues.js +302 -0
  14. package/dist/generated/interface.gen.js +45 -1
  15. package/dist/index.js +7 -0
  16. package/dist/indexer/bodies.js +154 -2
  17. package/dist/indexer/client.js +8 -1
  18. package/dist/indexer/contract.js +78 -11
  19. package/dist/indexer/paths.js +46 -0
  20. package/dist/indexer/read.js +14 -1
  21. package/dist/math/v2/book.js +24 -7
  22. package/dist/math/v2/create.js +1 -1
  23. package/dist/math/v2/escrow.js +205 -0
  24. package/dist/math/v2/office.js +110 -0
  25. package/dist/math/v2/relay.js +263 -96
  26. package/dist/math/v2/team.js +28 -0
  27. package/dist/math/v2/trade.js +3 -1
  28. package/dist/reprice.js +88 -0
  29. package/dist/route/quote.js +16 -0
  30. package/dist/scaledUi.js +113 -0
  31. package/dist/solana/floor/accounts.js +8 -2
  32. package/dist/solana/floor/events.js +56 -1
  33. package/dist/solana/floor/instructions.js +16 -0
  34. package/dist/stockRefresh.js +99 -0
  35. package/dist/ton/consts.generated.js +2 -2
  36. package/dist/ton/gas.js +3 -3
  37. package/dist/v2/claims.js +28 -5
  38. package/dist/v2/devbuy.js +28 -3
  39. package/dist/v2/evm.js +178 -5
  40. package/dist/v2/layouts.js +100 -2
  41. package/dist/v2/office-events.js +127 -0
  42. package/dist/v2/office-evm.js +68 -0
  43. package/dist/v2/office-read.js +182 -0
  44. package/dist/v2/office-solana.js +134 -0
  45. package/dist/v2/office-trade.js +73 -0
  46. package/dist/v2/route-alt.js +1 -0
  47. package/dist/v2/route.js +1 -1
  48. package/dist/v2/solana.js +224 -5
  49. package/dist/v2/solanaSettle.js +2 -0
  50. package/dist/v2/tx/evm.js +51 -1
  51. package/dist/v2/tx/solana.js +3 -3
  52. package/dist/v2/types.js +4 -0
  53. package/docs/aggregator.md +19 -0
  54. package/examples/floor-line.html +1 -1
  55. package/package.json +26 -1
  56. package/src/abi/evm.gen.ts +75 -2
  57. package/src/abi/functions.gen.ts +87 -1
  58. package/src/abi/solana.gen.ts +59 -0
  59. package/src/client/solana/index.ts +25 -6
  60. package/src/config/generated.ts +803 -26374
  61. package/src/errors.ts +20 -1
  62. package/src/events/types.gen.ts +402 -1
  63. package/src/evm/chains.ts +58 -0
  64. package/src/evm/floor/abi.gen.ts +115 -0
  65. package/src/evm/squid.ts +22 -6
  66. package/src/evm/venues.ts +340 -0
  67. package/src/generated/interface.gen.ts +45 -1
  68. package/src/index.ts +7 -0
  69. package/src/indexer/bodies.ts +167 -2
  70. package/src/indexer/client.ts +16 -2
  71. package/src/indexer/contract.ts +84 -12
  72. package/src/indexer/paths.ts +77 -0
  73. package/src/indexer/read.ts +16 -3
  74. package/src/math/v2/book.ts +23 -7
  75. package/src/math/v2/create.ts +1 -1
  76. package/src/math/v2/escrow.ts +213 -0
  77. package/src/math/v2/office.ts +114 -0
  78. package/src/math/v2/relay.ts +269 -96
  79. package/src/math/v2/team.ts +28 -0
  80. package/src/math/v2/trade.ts +3 -1
  81. package/src/reprice.ts +121 -0
  82. package/src/route/quote.ts +16 -0
  83. package/src/scaledUi.ts +123 -0
  84. package/src/solana/floor/accounts.ts +8 -2
  85. package/src/solana/floor/events.ts +57 -2
  86. package/src/solana/floor/instructions.ts +16 -0
  87. package/src/stockRefresh.ts +131 -0
  88. package/src/ton/consts.generated.ts +2 -2
  89. package/src/ton/gas.ts +3 -3
  90. package/src/v2/claims.ts +34 -5
  91. package/src/v2/devbuy.ts +38 -3
  92. package/src/v2/evm.ts +204 -5
  93. package/src/v2/layouts.ts +100 -2
  94. package/src/v2/office-events.ts +133 -0
  95. package/src/v2/office-evm.ts +76 -0
  96. package/src/v2/office-read.ts +264 -0
  97. package/src/v2/office-solana.ts +159 -0
  98. package/src/v2/office-trade.ts +96 -0
  99. package/src/v2/route-alt.ts +1 -0
  100. package/src/v2/route.ts +1 -1
  101. package/src/v2/solana.ts +235 -5
  102. package/src/v2/solanaSettle.ts +2 -0
  103. package/src/v2/tx/evm.ts +51 -1
  104. package/src/v2/tx/solana.ts +5 -3
  105. package/src/v2/types.ts +66 -1
package/src/v2/solana.ts CHANGED
@@ -6,7 +6,7 @@ import { R, RS, W, WS, instructionDiscriminator } from "../solana/instruction.ts
6
6
  import type { AccountMeta, Instruction } from "../solana/instruction.ts";
7
7
  import { ASSOCIATED_TOKEN_PROGRAM_ID, SYSTEM_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, WSOL_MINT, associatedTokenAddress, findProgramAddress } from "../solana/pda.ts";
8
8
  import type { Pda } from "../solana/pda.ts";
9
- import { FLOOR_AMM_ERRORS, FLOOR_AMM_PROGRAM_ID, INSTRUCTIONS_SYSVAR_ID, METADATA_PROGRAM_ID, configPda, floorEventAuthorityPda, genesisConvertBandPda, genesisRaisePda, launchPda, teamSlotPda, traderLinkPda, traderRefPda, unwrapPda } from "../solana/floor/program.ts";
9
+ import { FLOOR_AMM_ERRORS, FLOOR_AMM_PROGRAM_ID, INSTRUCTIONS_SYSVAR_ID, METADATA_PROGRAM_ID, configPda, floorEventAuthorityPda, genesisConvertBandPda, genesisRaisePda, launchPda, refOwedPda, teamSlotPda, traderLinkPda, traderRefPda, unwrapPda } from "../solana/floor/program.ts";
10
10
  import { Writer } from "../solana/floor/borsh.ts";
11
11
  import { CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_EXTRA, CLAIM_KNOWN_WIDE, CLAIM_TEAM_BUY, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, CLAIM_SHARE_BOUGHT, MAX_NAME_LEN, MAX_SYMBOL_LEN, createMintAccounts, withdrawPlatformManyInstruction } from "../solana/floor/instructions.ts";
12
12
  import type { ClaimLaunch, TradeAccounts } from "../solana/floor/instructions.ts";
@@ -14,6 +14,7 @@ import { MEMBERS_MAX, ROW_LEN } from "./layouts.ts";
14
14
  import { freshRegistryPrice } from "../registryPrice.ts";
15
15
  import type { RegistryPrice } from "../registryPrice.ts";
16
16
  import { CLAIM_BITS, CLAIM_KNOWN_MASKS, PROGRAM_IDS } from "../generated/index.ts";
17
+ import { DEAL_ESCROW_STEPS_MAX, STEP_VOLUME } from "../math/v2/escrow.ts";
17
18
 
18
19
  export const FLOOR_HOOK_PROGRAM_ID: string = PROGRAM_IDS.floorHook;
19
20
 
@@ -38,7 +39,14 @@ export const extraAccountMetasPda = (baseMint: string, hook = FLOOR_HOOK_PROGRAM
38
39
 
39
40
  const V2_ERROR_NAMES = [
40
41
  "NothingToSettle", "HolderPositionExists", "HolderPositionNotEmpty", "HolderBookMismatch", "DeadAccountNotDead",
41
- "HookAccountsMissing", "RowTooManyRanges", "RowNotFeasible", "OgFull",
42
+ "HookAccountsMissing", "RowTooManyRanges", "RowNotFeasible", "OgFull", "DealFeeOverCap", "DealFeeFixed",
43
+ "DealEscrowSteps", "DealEscrowExpiry", "DealEscrowTarget", "DealEscrowNotArmed", "DealEscrowTooSoon", "DealEscrowDone", "DealEscrowExpired", "DealEscrowNotExpired", "DealEscrowFunding", "DealEscrowNotParty",
44
+
45
+ "DealEscrowAgency", "DealEscrowProofNotRequired", "DealEscrowProofState", "DealEscrowWindowClosed", "DealEscrowNoObjectionLeft", "DealEscrowNotProven", "DealEscrowVersion",
46
+
47
+ "RefVolumeBookFull",
48
+
49
+ "OfficeNotMember", "OfficeNotController", "OfficeFull", "OfficeAlreadyMember", "OfficeShareSum", "OfficeOverShare", "OfficeNoCash", "OfficePositions", "OfficeZeroAmount", "OfficeZeroUnits", "OfficeZeroValue", "OfficeNotHeld", "OfficeMergeSize", "OfficeNotMergeable", "OfficeMergeMismatch", "OfficeNotSeller", "OfficeWrongQuote", "OfficeControllerLeaves", "OfficeSlippage", "OfficeOverflow", "OfficeExists", "OfficeMergeLocked", "OfficeNoMerge",
42
50
  ] as const;
43
51
 
44
52
  export const V2_ERROR_BASE = FLOOR_AMM_ERRORS.BurnTooLarge + 1;
@@ -112,6 +120,178 @@ export function creditBackingInstructionV2(p: { donor: string; launch: string; b
112
120
  return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: p.quoteMint, srcOwner: p.donor, dstOwner: p.launch, programId: p.programId, hookProgramId: p.hookProgramId })] };
113
121
  }
114
122
 
123
+ export function creditPlatformInstruction(p: { payer: string; launch: string; baseMint: string; quoteMint: string; payerQuote: string; quoteVault: string; quoteTokenProgram: string; amount: bigint; memo?: Uint8Array; quoteIsLaunch?: boolean } & Ctx): Instruction {
124
+ if (p.amount <= 0n) throw new RangeError("credit_platform: the amount must be > 0 (NothingToDo)");
125
+ const memo = p.memo ?? new Uint8Array(32);
126
+ if (memo.length !== 32) throw new RangeError("credit_platform: the memo is 32 bytes");
127
+ const base = ix("credit_platform", [RS(p.payer), W(p.launch), R(p.baseMint), R(p.quoteMint), W(p.payerQuote), W(p.quoteVault), R(p.quoteTokenProgram)], (w) => w.u64(p.amount).bytes(memo), p);
128
+ if (!p.quoteIsLaunch) return base;
129
+ return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: p.quoteMint, srcOwner: p.payer, dstOwner: p.launch, programId: p.programId, hookProgramId: p.hookProgramId })] };
130
+ }
131
+
132
+ export const ESCROW_KIND_QUOTE = 0;
133
+
134
+ export const ESCROW_KIND_TOKEN = 1;
135
+
136
+ export function dealEscrowPda(launch: string, kol: string, ref32: Uint8Array, programId = FLOOR_AMM_PROGRAM_ID): Pda {
137
+ if (ref32.length !== 32) throw new RangeError("deal_escrow: ref32 is 32 bytes");
138
+ return findProgramAddress(["deal_escrow", k(launch), k(kol), ref32], programId);
139
+ }
140
+
141
+ const i64le = (w: Writer, v: bigint): Writer => {
142
+ if (v < -(1n << 63n) || v >= 1n << 63n) throw new RangeError("an i64 out of range");
143
+ return w.uint(BigInt.asUintN(64, v), 8);
144
+ };
145
+
146
+ function escrowAsset(p: { kind: number; baseMint: string; quoteMint?: string; quoteTokenProgram?: string }): [mint: string, tokenProgram: string] {
147
+ if (p.kind === ESCROW_KIND_TOKEN) return [p.baseMint, TOKEN_2022_PROGRAM_ID];
148
+ if (p.kind !== ESCROW_KIND_QUOTE) throw new RangeError("deal_escrow: kind is 0 (quote) or 1 (the launch's token)");
149
+ if (!p.quoteMint || !p.quoteTokenProgram) throw new RangeError("deal_escrow: a quote escrow names quoteMint and quoteTokenProgram");
150
+ return [p.quoteMint, p.quoteTokenProgram];
151
+ }
152
+
153
+ type EscrowAsset = { kind: number; baseMint: string; quoteMint?: string; quoteTokenProgram?: string; hooked?: boolean };
154
+
155
+ export function dealEscrowOpenInstruction(p: { launcher: string; launch: string; kol: string; ref32: Uint8Array; targets: readonly bigint[]; amounts: readonly bigint[]; expiry: bigint; escrow?: string; launcherAsset?: string; vault?: string } & EscrowAsset & Ctx): Instruction {
156
+ const n = p.targets.length;
157
+ if (n < 1 || n > DEAL_ESCROW_STEPS_MAX || p.amounts.length !== n) throw new RangeError(`deal_escrow_open: 1..=${DEAL_ESCROW_STEPS_MAX} steps, one amount each (DealEscrowSteps)`);
158
+ const [mint, tp] = escrowAsset(p);
159
+ const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
160
+ const accounts = [WS(p.launcher), R(p.launch), R(p.baseMint), W(escrow), R(mint), W(p.launcherAsset ?? associatedTokenAddress(p.launcher, mint, tp)), W(p.vault ?? associatedTokenAddress(escrow, mint, tp)), R(tp), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID)];
161
+ const base = ix("deal_escrow_open", accounts, (w) => {
162
+ w.pubkey(p.kol).bytes(p.ref32).u8(p.kind);
163
+ for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u128(i < n ? p.targets[i] : 0n);
164
+ for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u64(i < n ? p.amounts[i] : 0n);
165
+ return i64le(w.u8(n), p.expiry);
166
+ }, p);
167
+ if (!p.hooked) return base;
168
+ return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: p.launcher, dstOwner: escrow, programId: p.programId, hookProgramId: p.hookProgramId })] };
169
+ }
170
+
171
+ export function dealEscrowArmInstruction(p: { launch: string; baseMint: string; escrow: string; step: number } & Ctx): Instruction {
172
+ if (!Number.isInteger(p.step) || p.step < 0 || p.step >= DEAL_ESCROW_STEPS_MAX) throw new RangeError("deal_escrow_arm: step in 0..8");
173
+ return ix("deal_escrow_arm", [R(p.launch), R(p.baseMint), W(p.escrow)], (w) => w.u8(p.step), p);
174
+ }
175
+
176
+ export function dealEscrowReleaseInstruction(p: { caller: string; launch: string; kol: string; ref32: Uint8Array; step: number; treasury: string; quoteVault?: string; config?: string; escrow?: string; vault?: string; kolAsset?: string; feeDest?: string } & EscrowAsset & Ctx): Instruction {
177
+ if (!Number.isInteger(p.step) || p.step < 0 || p.step >= DEAL_ESCROW_STEPS_MAX) throw new RangeError("deal_escrow_release: step in 0..8");
178
+ const [mint, tp] = escrowAsset(p);
179
+ const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
180
+ const isToken = p.kind === ESCROW_KIND_TOKEN;
181
+ const feeOwner = isToken ? p.treasury : p.launch;
182
+ const feeDest = p.feeDest ?? (isToken ? associatedTokenAddress(p.treasury, mint, tp) : p.quoteVault ?? associatedTokenAddress(p.launch, mint, tp));
183
+ const accounts = [WS(p.caller), R(p.config ?? configPda(pid(p))[0]), W(p.launch), R(p.baseMint), W(escrow), R(mint), W(p.vault ?? associatedTokenAddress(escrow, mint, tp)), R(p.kol), W(p.kolAsset ?? associatedTokenAddress(p.kol, mint, tp)), W(feeDest), R(p.treasury), R(tp), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID)];
184
+ const base = ix("deal_escrow_release", accounts, (w) => w.u8(p.step), p);
185
+ if (!p.hooked) return base;
186
+ const h = (dst: string) => hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: dst, programId: p.programId, hookProgramId: p.hookProgramId });
187
+ return { ...base, accounts: [...base.accounts, ...h(p.kol), ...h(feeOwner)] };
188
+ }
189
+
190
+ export function dealEscrowRefundInstruction(p: { caller: string; launch: string; launcher: string; kol: string; ref32: Uint8Array; escrow?: string; vault?: string; launcherAsset?: string } & EscrowAsset & Ctx): Instruction {
191
+ const [mint, tp] = escrowAsset(p);
192
+ const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
193
+ const accounts = [WS(p.caller), W(escrow), R(mint), W(p.vault ?? associatedTokenAddress(escrow, mint, tp)), R(p.launcher), W(p.launcherAsset ?? associatedTokenAddress(p.launcher, mint, tp)), R(tp), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID)];
194
+ const base = ix("deal_escrow_refund", accounts, (w) => w, p);
195
+ if (!p.hooked) return base;
196
+ return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: p.launcher, programId: p.programId, hookProgramId: p.hookProgramId })] };
197
+ }
198
+
199
+ export function dealEscrowCancelInstruction(p: { party: string; launch: string; launcher: string; kol: string; ref32: Uint8Array; escrow?: string; vault?: string; launcherAsset?: string } & EscrowAsset & Ctx): Instruction {
200
+ const [mint, tp] = escrowAsset(p);
201
+ const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
202
+ const accounts = [WS(p.party), W(escrow), R(mint), W(p.vault ?? associatedTokenAddress(escrow, mint, tp)), R(p.launcher), W(p.launcherAsset ?? associatedTokenAddress(p.launcher, mint, tp)), R(tp), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID)];
203
+ const base = ix("deal_escrow_cancel", accounts, (w) => w, p);
204
+ if (!p.hooked) return base;
205
+ return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: p.launcher, programId: p.programId, hookProgramId: p.hookProgramId })] };
206
+ }
207
+
208
+ export function refVolumePda(launch: string, referrer: string, programId = FLOOR_AMM_PROGRAM_ID): Pda {
209
+ return findProgramAddress(["ref_volume", k(launch), k(referrer)], programId);
210
+ }
211
+
212
+ export function refVolumeBookPda(launch: string, programId = FLOOR_AMM_PROGRAM_ID): Pda {
213
+ return findProgramAddress(["ref_volume_book", k(launch)], programId);
214
+ }
215
+
216
+ const stepArg = (step: number, what: string): number => {
217
+ if (!Number.isInteger(step) || step < 0 || step >= DEAL_ESCROW_STEPS_MAX) throw new RangeError(`${what}: step in 0..8`);
218
+ return step;
219
+ };
220
+
221
+ export function openRefVolumeInstruction(p: { payer: string; launch: string; baseMint: string; referrer: string } & Ctx): Instruction {
222
+ return ix("open_ref_volume", [WS(p.payer), R(p.launch), R(p.baseMint), W(refVolumePda(p.launch, p.referrer, pid(p))[0]), R(SYSTEM_PROGRAM_ID)], (w) => w.pubkey(p.referrer), p);
223
+ }
224
+
225
+ export function dealEscrowOpenV3Instruction(p: { launcher: string; launch: string; kol: string; ref32: Uint8Array; targets: readonly bigint[]; amounts: readonly bigint[]; expiry: bigint; stepKinds: readonly number[]; proofMask?: number; agency?: string; agencyBps?: number; refVolume?: string | boolean; escrow?: string; launcherAsset?: string; vault?: string } & EscrowAsset & Ctx): Instruction {
226
+ const n = p.targets.length;
227
+ if (n < 1 || n > DEAL_ESCROW_STEPS_MAX || p.amounts.length !== n || p.stepKinds.length !== n) throw new RangeError(`deal_escrow_open_v3: 1..=${DEAL_ESCROW_STEPS_MAX} steps, one amount and one kind each (DealEscrowSteps)`);
228
+ const mask = p.proofMask ?? 0;
229
+ if (!Number.isInteger(mask) || mask < 0 || mask >> n !== 0) throw new RangeError("deal_escrow_open_v3: proofMask bits only below n (DealEscrowSteps)");
230
+ const [mint, tp] = escrowAsset(p);
231
+ const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
232
+ const wantsVolume = p.refVolume ?? (p.stepKinds.includes(STEP_VOLUME) ? "book" : false);
233
+ const rv = wantsVolume === "book" ? refVolumeBookPda(p.launch, pid(p))[0] : typeof wantsVolume === "string" ? wantsVolume : wantsVolume ? refVolumePda(p.launch, p.kol, pid(p))[0] : null;
234
+ const accounts = [WS(p.launcher), R(p.launch), R(p.baseMint), W(escrow), R(mint), W(p.launcherAsset ?? associatedTokenAddress(p.launcher, mint, tp)), W(p.vault ?? associatedTokenAddress(escrow, mint, tp)), R(tp), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID), opt(rv, p, W)];
235
+ const base = ix("deal_escrow_open_v3", accounts, (w) => {
236
+ w.pubkey(p.kol).bytes(p.ref32).u8(p.kind);
237
+ for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u128(i < n ? p.targets[i] : 0n);
238
+ for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u64(i < n ? p.amounts[i] : 0n);
239
+ i64le(w.u8(n), p.expiry);
240
+ for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u8(i < n ? p.stepKinds[i] : 0);
241
+ return w.u8(mask).pubkey(p.agency ?? SYSTEM_PROGRAM_ID).u16(p.agencyBps ?? 0);
242
+ }, p);
243
+ if (!p.hooked) return base;
244
+ return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: p.launcher, dstOwner: escrow, programId: p.programId, hookProgramId: p.hookProgramId })] };
245
+ }
246
+
247
+ const volumeCounter = (rv: string | boolean | undefined, launch: string, kol: string | undefined, p: Ctx): string | undefined => {
248
+ if (rv === undefined || rv === false) return undefined;
249
+ if (rv === "book") return refVolumeBookPda(launch, pid(p))[0];
250
+ if (rv === true) {
251
+ if (!kol) throw new RangeError("refVolume: true derives PDA(launch, kol): name the kol");
252
+ return refVolumePda(launch, kol, pid(p))[0];
253
+ }
254
+ return rv;
255
+ };
256
+
257
+ export function dealEscrowArmV3Instruction(p: { launch: string; baseMint: string; escrow: string; step: number; refVolume?: string | boolean; kol?: string } & Ctx): Instruction {
258
+ const step = stepArg(p.step, "deal_escrow_arm_v3");
259
+ return ix("deal_escrow_arm_v3", [R(p.launch), R(p.baseMint), W(p.escrow), opt(volumeCounter(p.refVolume, p.launch, p.kol, p), p, R)], (w) => w.u8(step), p);
260
+ }
261
+
262
+ export function dealEscrowReleaseV3Instruction(p: { caller: string; launch: string; kol: string; ref32: Uint8Array; step: number; treasury: string; agency?: string; refVolume?: string | boolean; kolTiers?: readonly string[]; quoteVault?: string; config?: string; escrow?: string; vault?: string; kolAsset?: string; feeDest?: string; agencyAsset?: string } & EscrowAsset & Ctx): Instruction {
263
+ const step = stepArg(p.step, "deal_escrow_release_v3");
264
+ const [mint, tp] = escrowAsset(p);
265
+ const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
266
+ const isToken = p.kind === ESCROW_KIND_TOKEN;
267
+ const feeOwner = isToken ? p.treasury : p.launch;
268
+ const feeDest = p.feeDest ?? (isToken ? associatedTokenAddress(p.treasury, mint, tp) : p.quoteVault ?? associatedTokenAddress(p.launch, mint, tp));
269
+ const agencyAsset = p.agency ? (p.agencyAsset ?? associatedTokenAddress(p.agency, mint, tp)) : null;
270
+ const accounts = [WS(p.caller), R(p.config ?? configPda(pid(p))[0]), W(p.launch), R(p.baseMint), W(escrow), R(mint), W(p.vault ?? associatedTokenAddress(escrow, mint, tp)), R(p.kol), W(p.kolAsset ?? associatedTokenAddress(p.kol, mint, tp)), W(feeDest), R(p.treasury), R(tp), R(ASSOCIATED_TOKEN_PROGRAM_ID), R(SYSTEM_PROGRAM_ID),
271
+ opt(p.agency, p, R), opt(agencyAsset, p, W), opt(volumeCounter(p.refVolume, p.launch, p.kol, p), p, R), R(traderLinkPda(p.kol, pid(p))[0])];
272
+ const base = ix("deal_escrow_release_v3", accounts, (w) => w.u8(step), p);
273
+ const tiers = p.kolTiers ?? [];
274
+ if (tiers.length > 3) throw new RangeError("deal_escrow_release_v3: at most 3 tiers");
275
+ const h = (dst: string) => hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: dst, programId: p.programId, hookProgramId: p.hookProgramId });
276
+ const groups: AccountMeta[] = p.hooked ? [...h(p.kol), ...h(feeOwner), ...(p.agency ? h(p.agency) : [])] : [];
277
+ for (const t of tiers) {
278
+ const owed = refOwedPda(t, mint, pid(p))[0];
279
+ groups.push(W(owed), W(associatedTokenAddress(owed, mint, tp)), ...(p.hooked ? h(owed) : []));
280
+ }
281
+ return { ...base, accounts: [...base.accounts, ...groups] };
282
+ }
283
+
284
+ export function dealEscrowSubmitProofInstruction(p: { kol: string; escrow: string; step: number; proofHash: Uint8Array } & Ctx): Instruction {
285
+ const step = stepArg(p.step, "deal_escrow_submit_proof");
286
+ if (p.proofHash.length !== 32) throw new RangeError("deal_escrow_submit_proof: the proof hash is 32 bytes");
287
+ return ix("deal_escrow_submit_proof", [RS(p.kol), W(p.escrow)], (w) => w.u8(step).bytes(p.proofHash), p);
288
+ }
289
+
290
+ export function dealEscrowObjectInstruction(p: { launcher: string; escrow: string; step: number } & Ctx): Instruction {
291
+ const step = stepArg(p.step, "deal_escrow_object");
292
+ return ix("deal_escrow_object", [RS(p.launcher), W(p.escrow)], (w) => w.u8(step), p);
293
+ }
294
+
115
295
  export const SYNC_DEAD_MAX_PAIRS = 8;
116
296
 
117
297
  export function syncDeadInstruction(p: { payer: string; launch: string; baseMint: string; deadTokenAccounts: readonly string[] } & Ctx): Instruction {
@@ -184,18 +364,20 @@ export type TeamShareBuyBaseV2 = {
184
364
 
185
365
  quoteIsLaunch?: boolean;
186
366
  } & Ctx;
187
- export function teamShareBuyInstructionV2(p: TeamShareBuyBaseV2 & { amountIn: bigint; minOut: bigint }): Instruction {
367
+
368
+ export function teamShareBuyInstructionV2(p: TeamShareBuyBaseV2 & { amountIn: bigint; minOut: bigint; seatAgency?: ShareBuyAgency }): Instruction {
188
369
  if (!p.traderRef !== !p.escrow) throw new RangeError("team_share_buy: traderRef and escrow go together");
189
370
  const referred = Boolean(p.traderRef);
190
371
  if (referred && !p.quoteTokenProgram) throw new RangeError("team_share_buy: a referred buyback needs quoteTokenProgram");
191
372
  const base = ix(
192
373
  "team_share_buy",
193
374
 
194
- [WS(p.member), W(p.launch), R(p.baseMint), R(p.quoteMint), W(p.tokenVault), referred ? W(p.quoteVault) : R(p.quoteVault), R(p.teamSlot ?? teamSlotPda(p.launch, pid(p))[0]), W(p.memberBase), R(TOKEN_2022_PROGRAM_ID)],
375
+ [WS(p.member), W(p.launch), R(p.baseMint), R(p.quoteMint), W(p.tokenVault), referred || p.seatAgency ? W(p.quoteVault) : R(p.quoteVault), R(p.teamSlot ?? teamSlotPda(p.launch, pid(p))[0]), W(p.memberBase), R(TOKEN_2022_PROGRAM_ID)],
195
376
  (w) => w.u64(p.amountIn).u64(minOut(p.minOut, "minOut")),
196
377
  p,
197
378
  );
198
379
  const accounts = [...base.accounts, ...hookAccountsFor({ baseMint: p.baseMint, srcOwner: p.launch, dstOwner: p.member, programId: p.programId, hookProgramId: p.hookProgramId })];
380
+ if (p.seatAgency) accounts.push(...shareBuyAgencyBlock(p.launch, p.quoteMint, p.seatAgency, p));
199
381
  if (!referred) return { ...base, accounts };
200
382
  accounts.push(W(p.traderRef!), W(p.escrow!), R(p.quoteTokenProgram!));
201
383
  if (p.quoteIsLaunch) {
@@ -205,6 +387,14 @@ export function teamShareBuyInstructionV2(p: TeamShareBuyBaseV2 & { amountIn: bi
205
387
  return { ...base, accounts };
206
388
  }
207
389
 
390
+ export type ShareBuyAgency = { index: number; agency: string; quoteTokenProgram: string; quoteIsLaunch?: boolean };
391
+
392
+ export function shareBuyAgencyBlock(launch: string, quoteMint: string, a: ShareBuyAgency, p: Ctx = {}): AccountMeta[] {
393
+ const b = [R(seatAgencyPda(launch, a.index, pid(p))[0]), R(a.agency), W(associatedTokenAddress(a.agency, quoteMint, a.quoteTokenProgram)), R(a.quoteTokenProgram)];
394
+ if (a.quoteIsLaunch) b.push(...hookAccountsFor({ baseMint: quoteMint, srcOwner: launch, dstOwner: a.agency, programId: p.programId, hookProgramId: p.hookProgramId }));
395
+ return b;
396
+ }
397
+
208
398
  const REM_HOOK_AT = 5;
209
399
 
210
400
  export interface TradeAccountsV2 extends TradeAccounts {
@@ -214,6 +404,10 @@ export interface TradeAccountsV2 extends TradeAccounts {
214
404
  quoteIsLaunch?: boolean;
215
405
 
216
406
  quoteOwner?: string;
407
+
408
+ refVolume?: string;
409
+
410
+ refVolumeBook?: string | boolean;
217
411
  }
218
412
 
219
413
  export const REM_QUOTE_HOOK_AT = 11;
@@ -250,13 +444,19 @@ function remMetas(a: TradeAccountsV2, isBuy: boolean, c?: Ctx): AccountMeta[] {
250
444
  return [...q, W(holderPositionPda(launchPda(a.quoteMint, pid(c))[0], a.traderRef, hid(c))[0])];
251
445
  }
252
446
 
447
+ const remWithVolume = (a: TradeAccountsV2, isBuy: boolean, c?: Ctx): AccountMeta[] => {
448
+ if (!isBuy) return remMetas(a, isBuy, c);
449
+ const book = a.refVolumeBook === true ? refVolumeBookPda(a.launch, pid(c))[0] : a.refVolumeBook || null;
450
+ return [...remMetas(a, isBuy, c), ...(a.refVolume ? [W(a.refVolume)] : []), ...(book ? [W(book)] : [])];
451
+ };
452
+
253
453
  const minOut = (v: bigint, what: string): bigint => {
254
454
  if (v <= 0n) throw new RangeError(`${what} must be > 0 (the NO_MINIMUM rule)`);
255
455
  return v;
256
456
  };
257
457
  function trade(name: string, a: TradeAccountsV2 & Ctx, isBuy: boolean, x: bigint, m: bigint, what: string): Instruction {
258
458
  const base = ix(name, tradeMetas(a, a), (w) => w.u64(x).u64(minOut(m, what)), a);
259
- return { ...base, accounts: [...base.accounts, ...remMetas(a, isBuy, a)] };
459
+ return { ...base, accounts: [...base.accounts, ...remWithVolume(a, isBuy, a)] };
260
460
  }
261
461
 
262
462
  export type BuyArgsV2 = TradeAccountsV2 & Ctx & { amountIn: bigint; minOut: bigint };
@@ -397,6 +597,8 @@ export interface ClaimLaunchV2 extends ClaimLaunch {
397
597
  holderBase?: string;
398
598
 
399
599
  baseMint?: string;
600
+
601
+ seatAgency?: { index: number; agency: string };
400
602
  }
401
603
 
402
604
  export function claimInstructionV2(p: {
@@ -439,9 +641,37 @@ export function claimInstructionV2(p: {
439
641
  if ((p.types & CLAIM_TRADER_REF) !== 0 && p.refOwed) payers.push(p.refOwed);
440
642
  rest.push(...quoteHookBlock(p.quoteMint, p.wallet, payers, p));
441
643
  }
644
+
645
+ if ((p.types & CLAIM_TEAM_SLOT) !== 0) {
646
+ for (const l of p.launches) if (l.seatAgency && l.teamSlot) rest.push(...seatAgencyBlock(l.launch, l.seatAgency.index, l.seatAgency.agency, p.quoteMint, p.quoteTokenProgram, !!p.quoteIsLaunch, p));
647
+ }
442
648
  return { ...base, accounts: [...base.accounts, ...rest] };
443
649
  }
444
650
 
651
+ export function seatAgencyPda(launch: string, index: number, programId = FLOOR_AMM_PROGRAM_ID): Pda {
652
+ if (!Number.isInteger(index) || index < 0 || index >= MEMBERS_MAX) throw new RangeError(`seat index in 0..${MEMBERS_MAX}`);
653
+ return findProgramAddress(["seat_agency", k(launch), Uint8Array.of(index)], programId);
654
+ }
655
+
656
+ export function seatAgencyBlock(launch: string, index: number, agency: string, quoteMint: string, quoteTokenProgram: string, quoteIsLaunch: boolean, p: Ctx = {}): AccountMeta[] {
657
+ const b = [R(seatAgencyPda(launch, index, pid(p))[0]), R(agency), W(associatedTokenAddress(agency, quoteMint, quoteTokenProgram))];
658
+ if (quoteIsLaunch) b.push(W(holderPositionPda(launchPda(quoteMint, pid(p))[0], agency, hid(p))[0]));
659
+ return b;
660
+ }
661
+
662
+ export const SEAT_AGENCY_BPS_MAX = 3_000;
663
+
664
+ export function teamSlotAddDealV3Instruction(p: { creator: string; launch: string; key: string; kind: number; amount: bigint; dealFeeBps: number; agency?: string; agencyBps: number; index: number; teamSlot?: string; config?: string; seatAgency?: string; rest?: AccountMeta[] } & Ctx): Instruction {
665
+ if (!Number.isInteger(p.dealFeeBps) || p.dealFeeBps < 0 || p.dealFeeBps > 0xffff) throw new RangeError("team_slot_add_deal_v3: deal_fee_bps is a u16");
666
+ const agency = p.agency ?? SYSTEM_PROGRAM_ID;
667
+ if (!Number.isInteger(p.agencyBps) || p.agencyBps < 0 || p.agencyBps > SEAT_AGENCY_BPS_MAX || (agency !== SYSTEM_PROGRAM_ID) !== p.agencyBps > 0) throw new RangeError("team_slot_add_deal_v3: an agency needs 1..=3000 bps, none needs 0 (DealEscrowAgency)");
668
+ if (p.amount <= 0n) throw new RangeError("team_slot_add_deal_v3: amount > 0 (NothingToDo)");
669
+ const g = pid(p);
670
+ const accounts = [WS(p.creator), W(p.launch), W(p.teamSlot ?? teamSlotPda(p.launch, g)[0]), R(p.config ?? configPda(g)[0]), W(p.seatAgency ?? seatAgencyPda(p.launch, p.index, g)[0]), R(SYSTEM_PROGRAM_ID)];
671
+ const base = ix("team_slot_add_deal_v3", accounts, (w) => w.pubkey(p.key).u8(p.kind).u64(p.amount).u16(p.dealFeeBps).pubkey(agency).u16(p.agencyBps), p);
672
+ return { ...base, accounts: [...base.accounts, ...(p.rest ?? [])] };
673
+ }
674
+
445
675
  export function setGenesisConvertBandInstruction(p: { authority: string; solPxMin: bigint; solPxMax: bigint; usdcPxMin: bigint; usdcPxMax: bigint; config?: string; genesisRaise?: string; convertBand?: string } & Ctx): Instruction {
446
676
  for (const v of [p.solPxMin, p.solPxMax, p.usdcPxMin, p.usdcPxMax]) if (v <= 0n || v >> 128n !== 0n) throw new RangeError("set_genesis_convert_band: each price is a u128 > 0");
447
677
  if (p.solPxMin > p.solPxMax || p.usdcPxMin > p.usdcPxMax) throw new RangeError("set_genesis_convert_band: min ≤ max");
@@ -74,6 +74,8 @@ export function solanaSettleInputsV2(l: LaunchV2Account, opts: { mintSupply?: bi
74
74
  nC: l.nC, bandF: [...l.bandF], bandFClaim: [...l.bandFClaim], ckAtF: l.ckAtF, ckFloorTokens: l.ckFloorTokens,
75
75
 
76
76
  kpot: l.kpot !== 0, kAtF: l.kAtF, kFloorTokens: l.kFloorTokens,
77
+
78
+ ...(l.kKept[0] | (l.kKept[1] << 8) | (l.kKept[2] << 16) ? { kKept: l.kKept[0] | (l.kKept[1] << 8) | (l.kKept[2] << 16) } : {}),
77
79
  feePpm: l.feePpm.map(n), feeStartPpm: l.feeStartPpm.map(n), sqrtFeeA: l.sqrtFeeA, sqrtFeeB: l.sqrtFeeB,
78
80
  graduated: l.graduated !== 0, nRanges: l.nRanges, ranges,
79
81
 
package/src/v2/tx/evm.ts CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
 
3
- import { bytesToHex, checksumAddress, decodeAbi, encodeCall, hexToBytes } from "../../evm/abi.ts";
3
+ import { bytesToHex, checksumAddress, decodeAbi, encodeAbi, encodeCall, hexToBytes } from "../../evm/abi.ts";
4
+ import { keccak256 } from "../../evm/keccak.ts";
4
5
  import type { AbiValue } from "../../evm/abi.ts";
5
6
  import { teamSlotHandleId } from "../../handle.ts";
6
7
  import { freshRegistryPrice } from "../../registryPrice.ts";
@@ -18,6 +19,14 @@ export const EVM_V2_TX = {
18
19
  createLaunch: evmSignature("createLaunch"),
19
20
 
20
21
  teamSlotAdd: evmSignature("teamSlotAdd"),
22
+
23
+ teamSlotAddDeal: evmSignature("teamSlotAddDeal"),
24
+
25
+ dealEscrowOpen: evmSignature("dealEscrowOpen"),
26
+ dealEscrowArm: evmSignature("dealEscrowArm"),
27
+ dealEscrowRelease: evmSignature("dealEscrowRelease"),
28
+ dealEscrowRefund: evmSignature("dealEscrowRefund"),
29
+ dealEscrowCancel: evmSignature("dealEscrowCancel"),
21
30
  unlockCreatorBuy: evmSignature("unlockCreatorBuy"),
22
31
  claim: evmSignature("claim"),
23
32
 
@@ -36,6 +45,8 @@ export const EVM_V2_TX_VIEWS = {
36
45
  launchCount: { sig: evmSignature("launchCount"), ret: ["uint256"] },
37
46
  predictToken: { sig: evmSignature("predictToken"), ret: ["address"] },
38
47
 
48
+ dealEscrowMarketCap: { sig: evmSignature("dealEscrowMarketCap"), ret: ["uint256"] },
49
+
39
50
  ogUserOf: { sig: evmSignature("ogUserOf"), ret: ["uint64", "uint64", "bool"] },
40
51
  ogCount: { sig: evmSignature("ogCount"), ret: ["uint16", "uint64"] },
41
52
  } as const;
@@ -124,6 +135,13 @@ export function teamSlotAddCallV2(p: { floorAmm: string; launchId: bigint; membe
124
135
  return call(p.floorAmm, EVM_V2_TX.teamSlotAdd, [p.launchId, hexToBytes(key), BigInt(kind), p.shares, false]);
125
136
  }
126
137
 
138
+ export function teamSlotAddDealCall(p: { floorAmm: string; launchId: bigint; member: SlotMemberEvm; shares: bigint; dealFeeBps: number }): EvmCall {
139
+ if (p.shares <= 0n) throw new RangeError("teamSlotAddDeal: shares > 0 (NothingToDo)");
140
+ if (!Number.isInteger(p.dealFeeBps) || p.dealFeeBps < 0 || p.dealFeeBps > 0xffff) throw new RangeError("teamSlotAddDeal: dealFeeBps is a uint16");
141
+ const { key, kind } = slotMemberKeyEvm(p.member);
142
+ return call(p.floorAmm, EVM_V2_TX.teamSlotAddDeal, [p.launchId, hexToBytes(key), BigInt(kind), p.shares, BigInt(p.dealFeeBps)]);
143
+ }
144
+
127
145
  export const unlockCreatorBuyCallV2 = (p: { floorAmm: string; launchId: bigint }): EvmCall => call(p.floorAmm, EVM_V2_TX.unlockCreatorBuy, [p.launchId]);
128
146
 
129
147
  export const EVM_V2_TX_ONE_PRESS = {
@@ -164,3 +182,35 @@ export const traderRefDataV2 = (trader: string): string => bytesToHex(encodeCall
164
182
  export const decodeTraderRefV2 = (data: string | Uint8Array): string[] => (decodeAbi(EVM_V2_TX_VIEWS.traderRef.ret, data)[0] as string[]).map((a) => checksumAddress(a));
165
183
 
166
184
  export const predictTokenDataV2 = (creator: string, salt: string): string => bytesToHex(encodeCall(EVM_V2_TX_VIEWS.predictToken.sig, [creator, hexToBytes(salt)]));
185
+
186
+ export function dealEscrowIdEvm(launchId: bigint, kol: string, ref32: Uint8Array): string {
187
+ if (ref32.length !== 32) throw new RangeError("dealEscrow: ref32 is 32 bytes");
188
+ return bytesToHex(keccak256(encodeAbi(["uint256", "address", "bytes32"], [launchId, kol, ref32])));
189
+ }
190
+
191
+ export function dealEscrowOpenCall(p: { floorAmm: string; launchId: bigint; kol: string; ref32: Uint8Array; assetIsToken: boolean; quote: string; targets: readonly bigint[]; amounts: readonly bigint[]; expiry: bigint }): EvmCall {
192
+ const n = p.targets.length;
193
+ if (n < 1 || n > 8 || p.amounts.length !== n) throw new RangeError("dealEscrowOpen: 1..=8 steps, one amount each (DealEscrowSteps)");
194
+ if (p.ref32.length !== 32) throw new RangeError("dealEscrowOpen: ref32 is 32 bytes");
195
+ const total = p.amounts.reduce((a, b) => a + b, 0n);
196
+ const value = !p.assetIsToken && p.quote.toLowerCase() === NATIVE ? total : 0n;
197
+ return call(p.floorAmm, EVM_V2_TX.dealEscrowOpen, [p.launchId, p.kol, p.ref32, p.assetIsToken, [...p.targets], [...p.amounts], p.expiry], value);
198
+ }
199
+
200
+ export function dealEscrowArmCall(floorAmm: string, escrow: string, step: number): EvmCall {
201
+ if (!Number.isInteger(step) || step < 0 || step > 7) throw new RangeError("dealEscrowArm: step in 0..8");
202
+ return call(floorAmm, EVM_V2_TX.dealEscrowArm, [hexToBytes(escrow), BigInt(step)]);
203
+ }
204
+
205
+ export function dealEscrowReleaseCall(floorAmm: string, escrow: string, step: number): EvmCall {
206
+ if (!Number.isInteger(step) || step < 0 || step > 7) throw new RangeError("dealEscrowRelease: step in 0..8");
207
+ return call(floorAmm, EVM_V2_TX.dealEscrowRelease, [hexToBytes(escrow), BigInt(step)]);
208
+ }
209
+
210
+ export function dealEscrowRefundCall(floorAmm: string, escrow: string): EvmCall {
211
+ return call(floorAmm, EVM_V2_TX.dealEscrowRefund, [hexToBytes(escrow)]);
212
+ }
213
+
214
+ export function dealEscrowCancelCall(floorAmm: string, escrow: string): EvmCall {
215
+ return call(floorAmm, EVM_V2_TX.dealEscrowCancel, [hexToBytes(escrow)]);
216
+ }
@@ -117,6 +117,8 @@ export function teamShareBuyAndClaimInstructionsV2(
117
117
  memberBase?: string; quoteTokenProgram: string; config?: string; destination?: string; openMemberBase?: boolean; unwrapSol?: boolean;
118
118
 
119
119
  quoteIsLaunch?: boolean;
120
+
121
+ seatAgency?: { index: number; agency: string };
120
122
  },
121
123
  ): Instruction[] {
122
124
  const amount = p.amountIn;
@@ -124,17 +126,17 @@ export function teamShareBuyAndClaimInstructionsV2(
124
126
  const teamSlot = p.teamSlot ?? teamSlotPdaOf(p.launch, p.programId)[0];
125
127
  const memberBase = p.memberBase ?? associatedTokenAddress(p.member, p.baseMint, TOKEN_2022_PROGRAM_ID);
126
128
  const open = p.openMemberBase ?? p.memberBase === undefined;
127
- const { quoteTokenProgram, config, destination, openMemberBase: _o, unwrapSol, quoteIsLaunch, ...buy } = p;
129
+ const { quoteTokenProgram, config, destination, openMemberBase: _o, unwrapSol, quoteIsLaunch, seatAgency, ...buy } = p;
128
130
  const claim = claimInstructionV2({
129
131
  programId: p.programId, hookProgramId: p.hookProgramId, sender: p.member, wallet: p.member, quoteMint: p.quoteMint, quoteTokenProgram,
130
132
  destination: destination ?? associatedTokenAddress(p.member, p.quoteMint, quoteTokenProgram), config: config ?? configPdaOf(p.programId)[0],
131
133
  refOwed: null, refOwedVault: null, types: TEAM_SHARE_BUY_AND_CLAIM_TYPES_V2,
132
134
  unwrap: (unwrapSol ?? true) && p.quoteMint === WSOL_MINT && quoteTokenProgram === TOKEN_PROGRAM_ID, quoteIsLaunch,
133
- launches: [{ launch: p.launch, quoteVault: p.quoteVault, teamSlot, teamBuy: { baseMint: p.baseMint, tokenVault: p.tokenVault, walletBase: memberBase } }],
135
+ launches: [{ launch: p.launch, quoteVault: p.quoteVault, teamSlot, teamBuy: { baseMint: p.baseMint, tokenVault: p.tokenVault, walletBase: memberBase }, ...(seatAgency ? { seatAgency } : {}) }],
134
136
  });
135
137
  return [
136
138
  ...(open ? [createAssociatedTokenAccountIdempotentInstruction({ payer: p.member, owner: p.member, mint: p.baseMint, tokenProgram: TOKEN_2022_PROGRAM_ID })] : []),
137
- teamShareBuyInstructionV2({ ...buy, teamSlot, memberBase, quoteTokenProgram, quoteIsLaunch }),
139
+ teamShareBuyInstructionV2({ ...buy, teamSlot, memberBase, quoteTokenProgram, quoteIsLaunch, ...(seatAgency ? { seatAgency: { ...seatAgency, quoteTokenProgram, quoteIsLaunch } } : {}) }),
138
140
  claim,
139
141
  ];
140
142
  }
package/src/v2/types.ts CHANGED
@@ -118,7 +118,7 @@ export interface LaunchV2Account {
118
118
  kAtF: bigint;
119
119
  kFloorTokens: bigint;
120
120
  kpot: number;
121
- padOg: Uint8Array;
121
+ kKept: Uint8Array;
122
122
  creatorRefOgUntil: number[];
123
123
  }
124
124
 
@@ -156,6 +156,67 @@ export interface DeadMarkAccount {
156
156
  counted: bigint;
157
157
  }
158
158
 
159
+ export interface DealEscrowAccount {
160
+ version: number;
161
+ bump: number;
162
+ n: number;
163
+ kind: number;
164
+ released: number;
165
+ refunded: number;
166
+ decimals: number;
167
+ padFeeBps: number;
168
+ feeBps: number;
169
+ cancel: number;
170
+ padExpiry: Uint8Array;
171
+ expiry: bigint;
172
+ openedAt: bigint;
173
+ launch: string;
174
+ launcher: string;
175
+ kol: string;
176
+ assetMint: string;
177
+ assetTokenProgram: string;
178
+ vault: string;
179
+ ref32: Uint8Array;
180
+ targets: bigint[];
181
+ amounts: bigint[];
182
+ armedAt: bigint[];
183
+ armedSlot: bigint[];
184
+ agency: string;
185
+ volAtLock: bigint;
186
+ proofEnds: bigint[];
187
+ proofHash: Uint8Array[];
188
+ kinds: number[];
189
+ proof: number[];
190
+ agencyBps: number;
191
+ volSrc: number;
192
+ padSize: Uint8Array;
193
+ }
194
+
195
+ export interface RefVolumeAccount {
196
+ launch: string;
197
+ referrer: string;
198
+ volume: bigint;
199
+ bump: number;
200
+ padSize: Uint8Array;
201
+ }
202
+
203
+ export interface RefVolumeBookAccount {
204
+ launch: string;
205
+ len: number;
206
+ bump: number;
207
+ padEntries: Uint8Array;
208
+ entries: Uint8Array;
209
+ }
210
+
211
+ export interface SeatAgencyAccount {
212
+ launch: string;
213
+ agency: string;
214
+ agencyBps: number;
215
+ index: number;
216
+ bump: number;
217
+ padSize: Uint8Array;
218
+ }
219
+
159
220
  export interface LaunchCreatedV2EventV2 {
160
221
  launch: string;
161
222
  mint: string;
@@ -292,6 +353,10 @@ export const decodeLaunchV2Typed = (d: Uint8Array): LaunchV2Account => decodeAcc
292
353
  export const decodeHolderPositionTyped = (d: Uint8Array): HolderPositionAccount => decodeAccountV2("HolderPosition", d) as HolderPositionAccount;
293
354
  export const decodeHolderBookTyped = (d: Uint8Array): HolderBookAccount => decodeAccountV2("HolderBook", d) as HolderBookAccount;
294
355
  export const decodeDeadMarkTyped = (d: Uint8Array): DeadMarkAccount => decodeAccountV2("DeadMark", d) as DeadMarkAccount;
356
+ export const decodeDealEscrowTyped = (d: Uint8Array): DealEscrowAccount => decodeAccountV2("DealEscrow", d) as DealEscrowAccount;
357
+ export const decodeRefVolumeTyped = (d: Uint8Array): RefVolumeAccount => decodeAccountV2("RefVolume", d) as RefVolumeAccount;
358
+ export const decodeRefVolumeBookTyped = (d: Uint8Array): RefVolumeBookAccount => decodeAccountV2("RefVolumeBook", d) as RefVolumeBookAccount;
359
+ export const decodeSeatAgencyTyped = (d: Uint8Array): SeatAgencyAccount => decodeAccountV2("SeatAgency", d) as SeatAgencyAccount;
295
360
 
296
361
  export const decodeEventV2Typed = (d: Uint8Array): FloorEventV2Typed | null => decodeEventDataV2(d) as FloorEventV2Typed | null;
297
362
  export type { DevBuy, DevBuyRole } from "./devbuy.ts";