@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.
- package/CHANGELOG.md +143 -0
- package/README.md +12 -1
- package/dist/abi/evm.gen.js +75 -2
- package/dist/abi/functions.gen.js +87 -1
- package/dist/abi/solana.gen.js +59 -0
- package/dist/client/solana/index.js +25 -6
- package/dist/config/generated.js +803 -26374
- package/dist/errors.js +20 -1
- package/dist/events/types.gen.js +1 -1
- package/dist/evm/chains.js +49 -0
- package/dist/evm/floor/abi.gen.js +115 -0
- package/dist/evm/squid.js +21 -5
- package/dist/evm/venues.js +302 -0
- package/dist/generated/interface.gen.js +45 -1
- package/dist/index.js +7 -0
- package/dist/indexer/bodies.js +154 -2
- package/dist/indexer/client.js +8 -1
- package/dist/indexer/contract.js +78 -11
- package/dist/indexer/paths.js +46 -0
- package/dist/indexer/read.js +14 -1
- package/dist/math/v2/book.js +24 -7
- package/dist/math/v2/create.js +1 -1
- package/dist/math/v2/escrow.js +205 -0
- package/dist/math/v2/office.js +110 -0
- package/dist/math/v2/relay.js +263 -96
- package/dist/math/v2/team.js +28 -0
- package/dist/math/v2/trade.js +3 -1
- package/dist/reprice.js +88 -0
- package/dist/route/quote.js +16 -0
- package/dist/scaledUi.js +113 -0
- package/dist/solana/floor/accounts.js +8 -2
- package/dist/solana/floor/events.js +56 -1
- package/dist/solana/floor/instructions.js +16 -0
- package/dist/stockRefresh.js +99 -0
- package/dist/ton/consts.generated.js +2 -2
- package/dist/ton/gas.js +3 -3
- package/dist/v2/claims.js +28 -5
- package/dist/v2/devbuy.js +28 -3
- package/dist/v2/evm.js +178 -5
- package/dist/v2/layouts.js +100 -2
- package/dist/v2/office-events.js +127 -0
- package/dist/v2/office-evm.js +68 -0
- package/dist/v2/office-read.js +182 -0
- package/dist/v2/office-solana.js +134 -0
- package/dist/v2/office-trade.js +73 -0
- package/dist/v2/route-alt.js +1 -0
- package/dist/v2/route.js +1 -1
- package/dist/v2/solana.js +224 -5
- package/dist/v2/solanaSettle.js +2 -0
- package/dist/v2/tx/evm.js +51 -1
- package/dist/v2/tx/solana.js +3 -3
- package/dist/v2/types.js +4 -0
- package/docs/aggregator.md +19 -0
- package/examples/floor-line.html +1 -1
- package/package.json +26 -1
- package/src/abi/evm.gen.ts +75 -2
- package/src/abi/functions.gen.ts +87 -1
- package/src/abi/solana.gen.ts +59 -0
- package/src/client/solana/index.ts +25 -6
- package/src/config/generated.ts +803 -26374
- package/src/errors.ts +20 -1
- package/src/events/types.gen.ts +402 -1
- package/src/evm/chains.ts +58 -0
- package/src/evm/floor/abi.gen.ts +115 -0
- package/src/evm/squid.ts +22 -6
- package/src/evm/venues.ts +340 -0
- package/src/generated/interface.gen.ts +45 -1
- package/src/index.ts +7 -0
- package/src/indexer/bodies.ts +167 -2
- package/src/indexer/client.ts +16 -2
- package/src/indexer/contract.ts +84 -12
- package/src/indexer/paths.ts +77 -0
- package/src/indexer/read.ts +16 -3
- package/src/math/v2/book.ts +23 -7
- package/src/math/v2/create.ts +1 -1
- package/src/math/v2/escrow.ts +213 -0
- package/src/math/v2/office.ts +114 -0
- package/src/math/v2/relay.ts +269 -96
- package/src/math/v2/team.ts +28 -0
- package/src/math/v2/trade.ts +3 -1
- package/src/reprice.ts +121 -0
- package/src/route/quote.ts +16 -0
- package/src/scaledUi.ts +123 -0
- package/src/solana/floor/accounts.ts +8 -2
- package/src/solana/floor/events.ts +57 -2
- package/src/solana/floor/instructions.ts +16 -0
- package/src/stockRefresh.ts +131 -0
- package/src/ton/consts.generated.ts +2 -2
- package/src/ton/gas.ts +3 -3
- package/src/v2/claims.ts +34 -5
- package/src/v2/devbuy.ts +38 -3
- package/src/v2/evm.ts +204 -5
- package/src/v2/layouts.ts +100 -2
- package/src/v2/office-events.ts +133 -0
- package/src/v2/office-evm.ts +76 -0
- package/src/v2/office-read.ts +264 -0
- package/src/v2/office-solana.ts +159 -0
- package/src/v2/office-trade.ts +96 -0
- package/src/v2/route-alt.ts +1 -0
- package/src/v2/route.ts +1 -1
- package/src/v2/solana.ts +235 -5
- package/src/v2/solanaSettle.ts +2 -0
- package/src/v2/tx/evm.ts +51 -1
- package/src/v2/tx/solana.ts +5 -3
- package/src/v2/types.ts +66 -1
package/dist/v2/solana.js
CHANGED
|
@@ -6,7 +6,7 @@ import { R, RS, W, WS, instructionDiscriminator } from "../solana/instruction.js
|
|
|
6
6
|
|
|
7
7
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, SYSTEM_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, WSOL_MINT, associatedTokenAddress, findProgramAddress } from "../solana/pda.js";
|
|
8
8
|
|
|
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.js";
|
|
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.js";
|
|
10
10
|
import { Writer } from "../solana/floor/borsh.js";
|
|
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.js";
|
|
12
12
|
|
|
@@ -14,6 +14,7 @@ import { MEMBERS_MAX, ROW_LEN } from "./layouts.js";
|
|
|
14
14
|
import { freshRegistryPrice } from "../registryPrice.js";
|
|
15
15
|
|
|
16
16
|
import { CLAIM_BITS, CLAIM_KNOWN_MASKS, PROGRAM_IDS } from "../generated/index.js";
|
|
17
|
+
import { DEAL_ESCROW_STEPS_MAX, STEP_VOLUME } from "../math/v2/escrow.js";
|
|
17
18
|
|
|
18
19
|
export const FLOOR_HOOK_PROGRAM_ID = PROGRAM_IDS.floorHook;
|
|
19
20
|
|
|
@@ -34,7 +35,14 @@ export const extraAccountMetasPda = (baseMint , hook = FLOOR_HOOK_PROGRAM
|
|
|
34
35
|
|
|
35
36
|
const V2_ERROR_NAMES = [
|
|
36
37
|
"NothingToSettle", "HolderPositionExists", "HolderPositionNotEmpty", "HolderBookMismatch", "DeadAccountNotDead",
|
|
37
|
-
"HookAccountsMissing", "RowTooManyRanges", "RowNotFeasible", "OgFull",
|
|
38
|
+
"HookAccountsMissing", "RowTooManyRanges", "RowNotFeasible", "OgFull", "DealFeeOverCap", "DealFeeFixed",
|
|
39
|
+
"DealEscrowSteps", "DealEscrowExpiry", "DealEscrowTarget", "DealEscrowNotArmed", "DealEscrowTooSoon", "DealEscrowDone", "DealEscrowExpired", "DealEscrowNotExpired", "DealEscrowFunding", "DealEscrowNotParty",
|
|
40
|
+
|
|
41
|
+
"DealEscrowAgency", "DealEscrowProofNotRequired", "DealEscrowProofState", "DealEscrowWindowClosed", "DealEscrowNoObjectionLeft", "DealEscrowNotProven", "DealEscrowVersion",
|
|
42
|
+
|
|
43
|
+
"RefVolumeBookFull",
|
|
44
|
+
|
|
45
|
+
"OfficeNotMember", "OfficeNotController", "OfficeFull", "OfficeAlreadyMember", "OfficeShareSum", "OfficeOverShare", "OfficeNoCash", "OfficePositions", "OfficeZeroAmount", "OfficeZeroUnits", "OfficeZeroValue", "OfficeNotHeld", "OfficeMergeSize", "OfficeNotMergeable", "OfficeMergeMismatch", "OfficeNotSeller", "OfficeWrongQuote", "OfficeControllerLeaves", "OfficeSlippage", "OfficeOverflow", "OfficeExists", "OfficeMergeLocked", "OfficeNoMerge",
|
|
38
46
|
] ;
|
|
39
47
|
|
|
40
48
|
export const V2_ERROR_BASE = FLOOR_AMM_ERRORS.BurnTooLarge + 1;
|
|
@@ -108,6 +116,176 @@ export function creditBackingInstructionV2(p
|
|
|
108
116
|
return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: p.quoteMint, srcOwner: p.donor, dstOwner: p.launch, programId: p.programId, hookProgramId: p.hookProgramId })] };
|
|
109
117
|
}
|
|
110
118
|
|
|
119
|
+
export function creditPlatformInstruction(p ) {
|
|
120
|
+
if (p.amount <= 0n) throw new RangeError("credit_platform: the amount must be > 0 (NothingToDo)");
|
|
121
|
+
const memo = p.memo ?? new Uint8Array(32);
|
|
122
|
+
if (memo.length !== 32) throw new RangeError("credit_platform: the memo is 32 bytes");
|
|
123
|
+
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);
|
|
124
|
+
if (!p.quoteIsLaunch) return base;
|
|
125
|
+
return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: p.quoteMint, srcOwner: p.payer, dstOwner: p.launch, programId: p.programId, hookProgramId: p.hookProgramId })] };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const ESCROW_KIND_QUOTE = 0;
|
|
129
|
+
|
|
130
|
+
export const ESCROW_KIND_TOKEN = 1;
|
|
131
|
+
|
|
132
|
+
export function dealEscrowPda(launch , kol , ref32 , programId = FLOOR_AMM_PROGRAM_ID) {
|
|
133
|
+
if (ref32.length !== 32) throw new RangeError("deal_escrow: ref32 is 32 bytes");
|
|
134
|
+
return findProgramAddress(["deal_escrow", k(launch), k(kol), ref32], programId);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const i64le = (w , v ) => {
|
|
138
|
+
if (v < -(1n << 63n) || v >= 1n << 63n) throw new RangeError("an i64 out of range");
|
|
139
|
+
return w.uint(BigInt.asUintN(64, v), 8);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
function escrowAsset(p ) {
|
|
143
|
+
if (p.kind === ESCROW_KIND_TOKEN) return [p.baseMint, TOKEN_2022_PROGRAM_ID];
|
|
144
|
+
if (p.kind !== ESCROW_KIND_QUOTE) throw new RangeError("deal_escrow: kind is 0 (quote) or 1 (the launch's token)");
|
|
145
|
+
if (!p.quoteMint || !p.quoteTokenProgram) throw new RangeError("deal_escrow: a quote escrow names quoteMint and quoteTokenProgram");
|
|
146
|
+
return [p.quoteMint, p.quoteTokenProgram];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function dealEscrowOpenInstruction(p ) {
|
|
150
|
+
const n = p.targets.length;
|
|
151
|
+
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)`);
|
|
152
|
+
const [mint, tp] = escrowAsset(p);
|
|
153
|
+
const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
|
|
154
|
+
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)];
|
|
155
|
+
const base = ix("deal_escrow_open", accounts, (w) => {
|
|
156
|
+
w.pubkey(p.kol).bytes(p.ref32).u8(p.kind);
|
|
157
|
+
for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u128(i < n ? p.targets[i] : 0n);
|
|
158
|
+
for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u64(i < n ? p.amounts[i] : 0n);
|
|
159
|
+
return i64le(w.u8(n), p.expiry);
|
|
160
|
+
}, p);
|
|
161
|
+
if (!p.hooked) return base;
|
|
162
|
+
return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: p.launcher, dstOwner: escrow, programId: p.programId, hookProgramId: p.hookProgramId })] };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function dealEscrowArmInstruction(p ) {
|
|
166
|
+
if (!Number.isInteger(p.step) || p.step < 0 || p.step >= DEAL_ESCROW_STEPS_MAX) throw new RangeError("deal_escrow_arm: step in 0..8");
|
|
167
|
+
return ix("deal_escrow_arm", [R(p.launch), R(p.baseMint), W(p.escrow)], (w) => w.u8(p.step), p);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function dealEscrowReleaseInstruction(p ) {
|
|
171
|
+
if (!Number.isInteger(p.step) || p.step < 0 || p.step >= DEAL_ESCROW_STEPS_MAX) throw new RangeError("deal_escrow_release: step in 0..8");
|
|
172
|
+
const [mint, tp] = escrowAsset(p);
|
|
173
|
+
const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
|
|
174
|
+
const isToken = p.kind === ESCROW_KIND_TOKEN;
|
|
175
|
+
const feeOwner = isToken ? p.treasury : p.launch;
|
|
176
|
+
const feeDest = p.feeDest ?? (isToken ? associatedTokenAddress(p.treasury, mint, tp) : p.quoteVault ?? associatedTokenAddress(p.launch, mint, tp));
|
|
177
|
+
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)];
|
|
178
|
+
const base = ix("deal_escrow_release", accounts, (w) => w.u8(p.step), p);
|
|
179
|
+
if (!p.hooked) return base;
|
|
180
|
+
const h = (dst ) => hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: dst, programId: p.programId, hookProgramId: p.hookProgramId });
|
|
181
|
+
return { ...base, accounts: [...base.accounts, ...h(p.kol), ...h(feeOwner)] };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function dealEscrowRefundInstruction(p ) {
|
|
185
|
+
const [mint, tp] = escrowAsset(p);
|
|
186
|
+
const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
|
|
187
|
+
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)];
|
|
188
|
+
const base = ix("deal_escrow_refund", accounts, (w) => w, p);
|
|
189
|
+
if (!p.hooked) return base;
|
|
190
|
+
return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: p.launcher, programId: p.programId, hookProgramId: p.hookProgramId })] };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function dealEscrowCancelInstruction(p ) {
|
|
194
|
+
const [mint, tp] = escrowAsset(p);
|
|
195
|
+
const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
|
|
196
|
+
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)];
|
|
197
|
+
const base = ix("deal_escrow_cancel", accounts, (w) => w, p);
|
|
198
|
+
if (!p.hooked) return base;
|
|
199
|
+
return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: p.launcher, programId: p.programId, hookProgramId: p.hookProgramId })] };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function refVolumePda(launch , referrer , programId = FLOOR_AMM_PROGRAM_ID) {
|
|
203
|
+
return findProgramAddress(["ref_volume", k(launch), k(referrer)], programId);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function refVolumeBookPda(launch , programId = FLOOR_AMM_PROGRAM_ID) {
|
|
207
|
+
return findProgramAddress(["ref_volume_book", k(launch)], programId);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const stepArg = (step , what ) => {
|
|
211
|
+
if (!Number.isInteger(step) || step < 0 || step >= DEAL_ESCROW_STEPS_MAX) throw new RangeError(`${what}: step in 0..8`);
|
|
212
|
+
return step;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export function openRefVolumeInstruction(p ) {
|
|
216
|
+
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);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function dealEscrowOpenV3Instruction(p ) {
|
|
220
|
+
const n = p.targets.length;
|
|
221
|
+
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)`);
|
|
222
|
+
const mask = p.proofMask ?? 0;
|
|
223
|
+
if (!Number.isInteger(mask) || mask < 0 || mask >> n !== 0) throw new RangeError("deal_escrow_open_v3: proofMask bits only below n (DealEscrowSteps)");
|
|
224
|
+
const [mint, tp] = escrowAsset(p);
|
|
225
|
+
const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
|
|
226
|
+
const wantsVolume = p.refVolume ?? (p.stepKinds.includes(STEP_VOLUME) ? "book" : false);
|
|
227
|
+
const rv = wantsVolume === "book" ? refVolumeBookPda(p.launch, pid(p))[0] : typeof wantsVolume === "string" ? wantsVolume : wantsVolume ? refVolumePda(p.launch, p.kol, pid(p))[0] : null;
|
|
228
|
+
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)];
|
|
229
|
+
const base = ix("deal_escrow_open_v3", accounts, (w) => {
|
|
230
|
+
w.pubkey(p.kol).bytes(p.ref32).u8(p.kind);
|
|
231
|
+
for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u128(i < n ? p.targets[i] : 0n);
|
|
232
|
+
for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u64(i < n ? p.amounts[i] : 0n);
|
|
233
|
+
i64le(w.u8(n), p.expiry);
|
|
234
|
+
for (let i = 0; i < DEAL_ESCROW_STEPS_MAX; i++) w.u8(i < n ? p.stepKinds[i] : 0);
|
|
235
|
+
return w.u8(mask).pubkey(p.agency ?? SYSTEM_PROGRAM_ID).u16(p.agencyBps ?? 0);
|
|
236
|
+
}, p);
|
|
237
|
+
if (!p.hooked) return base;
|
|
238
|
+
return { ...base, accounts: [...base.accounts, ...hookAccountsFor({ baseMint: mint, srcOwner: p.launcher, dstOwner: escrow, programId: p.programId, hookProgramId: p.hookProgramId })] };
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const volumeCounter = (rv , launch , kol , p ) => {
|
|
242
|
+
if (rv === undefined || rv === false) return undefined;
|
|
243
|
+
if (rv === "book") return refVolumeBookPda(launch, pid(p))[0];
|
|
244
|
+
if (rv === true) {
|
|
245
|
+
if (!kol) throw new RangeError("refVolume: true derives PDA(launch, kol): name the kol");
|
|
246
|
+
return refVolumePda(launch, kol, pid(p))[0];
|
|
247
|
+
}
|
|
248
|
+
return rv;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export function dealEscrowArmV3Instruction(p ) {
|
|
252
|
+
const step = stepArg(p.step, "deal_escrow_arm_v3");
|
|
253
|
+
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);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function dealEscrowReleaseV3Instruction(p ) {
|
|
257
|
+
const step = stepArg(p.step, "deal_escrow_release_v3");
|
|
258
|
+
const [mint, tp] = escrowAsset(p);
|
|
259
|
+
const escrow = p.escrow ?? dealEscrowPda(p.launch, p.kol, p.ref32, pid(p))[0];
|
|
260
|
+
const isToken = p.kind === ESCROW_KIND_TOKEN;
|
|
261
|
+
const feeOwner = isToken ? p.treasury : p.launch;
|
|
262
|
+
const feeDest = p.feeDest ?? (isToken ? associatedTokenAddress(p.treasury, mint, tp) : p.quoteVault ?? associatedTokenAddress(p.launch, mint, tp));
|
|
263
|
+
const agencyAsset = p.agency ? (p.agencyAsset ?? associatedTokenAddress(p.agency, mint, tp)) : null;
|
|
264
|
+
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),
|
|
265
|
+
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])];
|
|
266
|
+
const base = ix("deal_escrow_release_v3", accounts, (w) => w.u8(step), p);
|
|
267
|
+
const tiers = p.kolTiers ?? [];
|
|
268
|
+
if (tiers.length > 3) throw new RangeError("deal_escrow_release_v3: at most 3 tiers");
|
|
269
|
+
const h = (dst ) => hookAccountsFor({ baseMint: mint, srcOwner: escrow, dstOwner: dst, programId: p.programId, hookProgramId: p.hookProgramId });
|
|
270
|
+
const groups = p.hooked ? [...h(p.kol), ...h(feeOwner), ...(p.agency ? h(p.agency) : [])] : [];
|
|
271
|
+
for (const t of tiers) {
|
|
272
|
+
const owed = refOwedPda(t, mint, pid(p))[0];
|
|
273
|
+
groups.push(W(owed), W(associatedTokenAddress(owed, mint, tp)), ...(p.hooked ? h(owed) : []));
|
|
274
|
+
}
|
|
275
|
+
return { ...base, accounts: [...base.accounts, ...groups] };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function dealEscrowSubmitProofInstruction(p ) {
|
|
279
|
+
const step = stepArg(p.step, "deal_escrow_submit_proof");
|
|
280
|
+
if (p.proofHash.length !== 32) throw new RangeError("deal_escrow_submit_proof: the proof hash is 32 bytes");
|
|
281
|
+
return ix("deal_escrow_submit_proof", [RS(p.kol), W(p.escrow)], (w) => w.u8(step).bytes(p.proofHash), p);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function dealEscrowObjectInstruction(p ) {
|
|
285
|
+
const step = stepArg(p.step, "deal_escrow_object");
|
|
286
|
+
return ix("deal_escrow_object", [RS(p.launcher), W(p.escrow)], (w) => w.u8(step), p);
|
|
287
|
+
}
|
|
288
|
+
|
|
111
289
|
export const SYNC_DEAD_MAX_PAIRS = 8;
|
|
112
290
|
|
|
113
291
|
export function syncDeadInstruction(p ) {
|
|
@@ -177,18 +355,19 @@ export function presetV2Instructions(p
|
|
|
177
355
|
|
|
178
356
|
|
|
179
357
|
|
|
180
|
-
export function teamShareBuyInstructionV2(p
|
|
358
|
+
export function teamShareBuyInstructionV2(p ) {
|
|
181
359
|
if (!p.traderRef !== !p.escrow) throw new RangeError("team_share_buy: traderRef and escrow go together");
|
|
182
360
|
const referred = Boolean(p.traderRef);
|
|
183
361
|
if (referred && !p.quoteTokenProgram) throw new RangeError("team_share_buy: a referred buyback needs quoteTokenProgram");
|
|
184
362
|
const base = ix(
|
|
185
363
|
"team_share_buy",
|
|
186
364
|
|
|
187
|
-
[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)],
|
|
365
|
+
[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)],
|
|
188
366
|
(w) => w.u64(p.amountIn).u64(minOut(p.minOut, "minOut")),
|
|
189
367
|
p,
|
|
190
368
|
);
|
|
191
369
|
const accounts = [...base.accounts, ...hookAccountsFor({ baseMint: p.baseMint, srcOwner: p.launch, dstOwner: p.member, programId: p.programId, hookProgramId: p.hookProgramId })];
|
|
370
|
+
if (p.seatAgency) accounts.push(...shareBuyAgencyBlock(p.launch, p.quoteMint, p.seatAgency, p));
|
|
192
371
|
if (!referred) return { ...base, accounts };
|
|
193
372
|
accounts.push(W(p.traderRef ), W(p.escrow ), R(p.quoteTokenProgram ));
|
|
194
373
|
if (p.quoteIsLaunch) {
|
|
@@ -198,6 +377,12 @@ export function teamShareBuyInstructionV2(p
|
|
|
198
377
|
return { ...base, accounts };
|
|
199
378
|
}
|
|
200
379
|
|
|
380
|
+
export function shareBuyAgencyBlock(launch , quoteMint , a , p = {}) {
|
|
381
|
+
const b = [R(seatAgencyPda(launch, a.index, pid(p))[0]), R(a.agency), W(associatedTokenAddress(a.agency, quoteMint, a.quoteTokenProgram)), R(a.quoteTokenProgram)];
|
|
382
|
+
if (a.quoteIsLaunch) b.push(...hookAccountsFor({ baseMint: quoteMint, srcOwner: launch, dstOwner: a.agency, programId: p.programId, hookProgramId: p.hookProgramId }));
|
|
383
|
+
return b;
|
|
384
|
+
}
|
|
385
|
+
|
|
201
386
|
const REM_HOOK_AT = 5;
|
|
202
387
|
|
|
203
388
|
export const REM_QUOTE_HOOK_AT = 11;
|
|
@@ -234,13 +419,19 @@ function remMetas(a , isBuy , c ) {
|
|
|
234
419
|
return [...q, W(holderPositionPda(launchPda(a.quoteMint, pid(c))[0], a.traderRef, hid(c))[0])];
|
|
235
420
|
}
|
|
236
421
|
|
|
422
|
+
const remWithVolume = (a , isBuy , c ) => {
|
|
423
|
+
if (!isBuy) return remMetas(a, isBuy, c);
|
|
424
|
+
const book = a.refVolumeBook === true ? refVolumeBookPda(a.launch, pid(c))[0] : a.refVolumeBook || null;
|
|
425
|
+
return [...remMetas(a, isBuy, c), ...(a.refVolume ? [W(a.refVolume)] : []), ...(book ? [W(book)] : [])];
|
|
426
|
+
};
|
|
427
|
+
|
|
237
428
|
const minOut = (v , what ) => {
|
|
238
429
|
if (v <= 0n) throw new RangeError(`${what} must be > 0 (the NO_MINIMUM rule)`);
|
|
239
430
|
return v;
|
|
240
431
|
};
|
|
241
432
|
function trade(name , a , isBuy , x , m , what ) {
|
|
242
433
|
const base = ix(name, tradeMetas(a, a), (w) => w.u64(x).u64(minOut(m, what)), a);
|
|
243
|
-
return { ...base, accounts: [...base.accounts, ...
|
|
434
|
+
return { ...base, accounts: [...base.accounts, ...remWithVolume(a, isBuy, a)] };
|
|
244
435
|
}
|
|
245
436
|
|
|
246
437
|
export const buyInstructionV2 = (p ) => trade("buy", p, true, p.amountIn, p.minOut, "minOut");
|
|
@@ -389,9 +580,37 @@ export function claimInstructionV2(p
|
|
|
389
580
|
if ((p.types & CLAIM_TRADER_REF) !== 0 && p.refOwed) payers.push(p.refOwed);
|
|
390
581
|
rest.push(...quoteHookBlock(p.quoteMint, p.wallet, payers, p));
|
|
391
582
|
}
|
|
583
|
+
|
|
584
|
+
if ((p.types & CLAIM_TEAM_SLOT) !== 0) {
|
|
585
|
+
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));
|
|
586
|
+
}
|
|
392
587
|
return { ...base, accounts: [...base.accounts, ...rest] };
|
|
393
588
|
}
|
|
394
589
|
|
|
590
|
+
export function seatAgencyPda(launch , index , programId = FLOOR_AMM_PROGRAM_ID) {
|
|
591
|
+
if (!Number.isInteger(index) || index < 0 || index >= MEMBERS_MAX) throw new RangeError(`seat index in 0..${MEMBERS_MAX}`);
|
|
592
|
+
return findProgramAddress(["seat_agency", k(launch), Uint8Array.of(index)], programId);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export function seatAgencyBlock(launch , index , agency , quoteMint , quoteTokenProgram , quoteIsLaunch , p = {}) {
|
|
596
|
+
const b = [R(seatAgencyPda(launch, index, pid(p))[0]), R(agency), W(associatedTokenAddress(agency, quoteMint, quoteTokenProgram))];
|
|
597
|
+
if (quoteIsLaunch) b.push(W(holderPositionPda(launchPda(quoteMint, pid(p))[0], agency, hid(p))[0]));
|
|
598
|
+
return b;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
export const SEAT_AGENCY_BPS_MAX = 3_000;
|
|
602
|
+
|
|
603
|
+
export function teamSlotAddDealV3Instruction(p ) {
|
|
604
|
+
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");
|
|
605
|
+
const agency = p.agency ?? SYSTEM_PROGRAM_ID;
|
|
606
|
+
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)");
|
|
607
|
+
if (p.amount <= 0n) throw new RangeError("team_slot_add_deal_v3: amount > 0 (NothingToDo)");
|
|
608
|
+
const g = pid(p);
|
|
609
|
+
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)];
|
|
610
|
+
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);
|
|
611
|
+
return { ...base, accounts: [...base.accounts, ...(p.rest ?? [])] };
|
|
612
|
+
}
|
|
613
|
+
|
|
395
614
|
export function setGenesisConvertBandInstruction(p ) {
|
|
396
615
|
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");
|
|
397
616
|
if (p.solPxMin > p.solPxMax || p.usdcPxMin > p.usdcPxMax) throw new RangeError("set_genesis_convert_band: min ≤ max");
|
package/dist/v2/solanaSettle.js
CHANGED
|
@@ -54,6 +54,8 @@ export function solanaSettleInputsV2(l , opts
|
|
|
54
54
|
nC: l.nC, bandF: [...l.bandF], bandFClaim: [...l.bandFClaim], ckAtF: l.ckAtF, ckFloorTokens: l.ckFloorTokens,
|
|
55
55
|
|
|
56
56
|
kpot: l.kpot !== 0, kAtF: l.kAtF, kFloorTokens: l.kFloorTokens,
|
|
57
|
+
|
|
58
|
+
...(l.kKept[0] | (l.kKept[1] << 8) | (l.kKept[2] << 16) ? { kKept: l.kKept[0] | (l.kKept[1] << 8) | (l.kKept[2] << 16) } : {}),
|
|
57
59
|
feePpm: l.feePpm.map(n), feeStartPpm: l.feeStartPpm.map(n), sqrtFeeA: l.sqrtFeeA, sqrtFeeB: l.sqrtFeeB,
|
|
58
60
|
graduated: l.graduated !== 0, nRanges: l.nRanges, ranges,
|
|
59
61
|
|
package/dist/v2/tx/evm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { bytesToHex, checksumAddress, decodeAbi, encodeCall, hexToBytes } from "../../evm/abi.js";
|
|
3
|
+
import { bytesToHex, checksumAddress, decodeAbi, encodeAbi, encodeCall, hexToBytes } from "../../evm/abi.js";
|
|
4
|
+
import { keccak256 } from "../../evm/keccak.js";
|
|
4
5
|
|
|
5
6
|
import { teamSlotHandleId } from "../../handle.js";
|
|
6
7
|
import { freshRegistryPrice } from "../../registryPrice.js";
|
|
@@ -17,6 +18,14 @@ export const EVM_V2_TX = {
|
|
|
17
18
|
createLaunch: evmSignature("createLaunch"),
|
|
18
19
|
|
|
19
20
|
teamSlotAdd: evmSignature("teamSlotAdd"),
|
|
21
|
+
|
|
22
|
+
teamSlotAddDeal: evmSignature("teamSlotAddDeal"),
|
|
23
|
+
|
|
24
|
+
dealEscrowOpen: evmSignature("dealEscrowOpen"),
|
|
25
|
+
dealEscrowArm: evmSignature("dealEscrowArm"),
|
|
26
|
+
dealEscrowRelease: evmSignature("dealEscrowRelease"),
|
|
27
|
+
dealEscrowRefund: evmSignature("dealEscrowRefund"),
|
|
28
|
+
dealEscrowCancel: evmSignature("dealEscrowCancel"),
|
|
20
29
|
unlockCreatorBuy: evmSignature("unlockCreatorBuy"),
|
|
21
30
|
claim: evmSignature("claim"),
|
|
22
31
|
|
|
@@ -35,6 +44,8 @@ export const EVM_V2_TX_VIEWS = {
|
|
|
35
44
|
launchCount: { sig: evmSignature("launchCount"), ret: ["uint256"] },
|
|
36
45
|
predictToken: { sig: evmSignature("predictToken"), ret: ["address"] },
|
|
37
46
|
|
|
47
|
+
dealEscrowMarketCap: { sig: evmSignature("dealEscrowMarketCap"), ret: ["uint256"] },
|
|
48
|
+
|
|
38
49
|
ogUserOf: { sig: evmSignature("ogUserOf"), ret: ["uint64", "uint64", "bool"] },
|
|
39
50
|
ogCount: { sig: evmSignature("ogCount"), ret: ["uint16", "uint64"] },
|
|
40
51
|
} ;
|
|
@@ -98,6 +109,13 @@ export function teamSlotAddCallV2(p
|
|
|
98
109
|
return call(p.floorAmm, EVM_V2_TX.teamSlotAdd, [p.launchId, hexToBytes(key), BigInt(kind), p.shares, false]);
|
|
99
110
|
}
|
|
100
111
|
|
|
112
|
+
export function teamSlotAddDealCall(p ) {
|
|
113
|
+
if (p.shares <= 0n) throw new RangeError("teamSlotAddDeal: shares > 0 (NothingToDo)");
|
|
114
|
+
if (!Number.isInteger(p.dealFeeBps) || p.dealFeeBps < 0 || p.dealFeeBps > 0xffff) throw new RangeError("teamSlotAddDeal: dealFeeBps is a uint16");
|
|
115
|
+
const { key, kind } = slotMemberKeyEvm(p.member);
|
|
116
|
+
return call(p.floorAmm, EVM_V2_TX.teamSlotAddDeal, [p.launchId, hexToBytes(key), BigInt(kind), p.shares, BigInt(p.dealFeeBps)]);
|
|
117
|
+
}
|
|
118
|
+
|
|
101
119
|
export const unlockCreatorBuyCallV2 = (p ) => call(p.floorAmm, EVM_V2_TX.unlockCreatorBuy, [p.launchId]);
|
|
102
120
|
|
|
103
121
|
export const EVM_V2_TX_ONE_PRESS = {
|
|
@@ -138,3 +156,35 @@ export const traderRefDataV2 = (trader ) => bytesToHex(encodeCall
|
|
|
138
156
|
export const decodeTraderRefV2 = (data ) => (decodeAbi(EVM_V2_TX_VIEWS.traderRef.ret, data)[0] ).map((a) => checksumAddress(a));
|
|
139
157
|
|
|
140
158
|
export const predictTokenDataV2 = (creator , salt ) => bytesToHex(encodeCall(EVM_V2_TX_VIEWS.predictToken.sig, [creator, hexToBytes(salt)]));
|
|
159
|
+
|
|
160
|
+
export function dealEscrowIdEvm(launchId , kol , ref32 ) {
|
|
161
|
+
if (ref32.length !== 32) throw new RangeError("dealEscrow: ref32 is 32 bytes");
|
|
162
|
+
return bytesToHex(keccak256(encodeAbi(["uint256", "address", "bytes32"], [launchId, kol, ref32])));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function dealEscrowOpenCall(p ) {
|
|
166
|
+
const n = p.targets.length;
|
|
167
|
+
if (n < 1 || n > 8 || p.amounts.length !== n) throw new RangeError("dealEscrowOpen: 1..=8 steps, one amount each (DealEscrowSteps)");
|
|
168
|
+
if (p.ref32.length !== 32) throw new RangeError("dealEscrowOpen: ref32 is 32 bytes");
|
|
169
|
+
const total = p.amounts.reduce((a, b) => a + b, 0n);
|
|
170
|
+
const value = !p.assetIsToken && p.quote.toLowerCase() === NATIVE ? total : 0n;
|
|
171
|
+
return call(p.floorAmm, EVM_V2_TX.dealEscrowOpen, [p.launchId, p.kol, p.ref32, p.assetIsToken, [...p.targets], [...p.amounts], p.expiry], value);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function dealEscrowArmCall(floorAmm , escrow , step ) {
|
|
175
|
+
if (!Number.isInteger(step) || step < 0 || step > 7) throw new RangeError("dealEscrowArm: step in 0..8");
|
|
176
|
+
return call(floorAmm, EVM_V2_TX.dealEscrowArm, [hexToBytes(escrow), BigInt(step)]);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function dealEscrowReleaseCall(floorAmm , escrow , step ) {
|
|
180
|
+
if (!Number.isInteger(step) || step < 0 || step > 7) throw new RangeError("dealEscrowRelease: step in 0..8");
|
|
181
|
+
return call(floorAmm, EVM_V2_TX.dealEscrowRelease, [hexToBytes(escrow), BigInt(step)]);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function dealEscrowRefundCall(floorAmm , escrow ) {
|
|
185
|
+
return call(floorAmm, EVM_V2_TX.dealEscrowRefund, [hexToBytes(escrow)]);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function dealEscrowCancelCall(floorAmm , escrow ) {
|
|
189
|
+
return call(floorAmm, EVM_V2_TX.dealEscrowCancel, [hexToBytes(escrow)]);
|
|
190
|
+
}
|
package/dist/v2/tx/solana.js
CHANGED
|
@@ -102,17 +102,17 @@ export function teamShareBuyAndClaimInstructionsV2(
|
|
|
102
102
|
const teamSlot = p.teamSlot ?? teamSlotPdaOf(p.launch, p.programId)[0];
|
|
103
103
|
const memberBase = p.memberBase ?? associatedTokenAddress(p.member, p.baseMint, TOKEN_2022_PROGRAM_ID);
|
|
104
104
|
const open = p.openMemberBase ?? p.memberBase === undefined;
|
|
105
|
-
const { quoteTokenProgram, config, destination, openMemberBase: _o, unwrapSol, quoteIsLaunch, ...buy } = p;
|
|
105
|
+
const { quoteTokenProgram, config, destination, openMemberBase: _o, unwrapSol, quoteIsLaunch, seatAgency, ...buy } = p;
|
|
106
106
|
const claim = claimInstructionV2({
|
|
107
107
|
programId: p.programId, hookProgramId: p.hookProgramId, sender: p.member, wallet: p.member, quoteMint: p.quoteMint, quoteTokenProgram,
|
|
108
108
|
destination: destination ?? associatedTokenAddress(p.member, p.quoteMint, quoteTokenProgram), config: config ?? configPdaOf(p.programId)[0],
|
|
109
109
|
refOwed: null, refOwedVault: null, types: TEAM_SHARE_BUY_AND_CLAIM_TYPES_V2,
|
|
110
110
|
unwrap: (unwrapSol ?? true) && p.quoteMint === WSOL_MINT && quoteTokenProgram === TOKEN_PROGRAM_ID, quoteIsLaunch,
|
|
111
|
-
launches: [{ launch: p.launch, quoteVault: p.quoteVault, teamSlot, teamBuy: { baseMint: p.baseMint, tokenVault: p.tokenVault, walletBase: memberBase } }],
|
|
111
|
+
launches: [{ launch: p.launch, quoteVault: p.quoteVault, teamSlot, teamBuy: { baseMint: p.baseMint, tokenVault: p.tokenVault, walletBase: memberBase }, ...(seatAgency ? { seatAgency } : {}) }],
|
|
112
112
|
});
|
|
113
113
|
return [
|
|
114
114
|
...(open ? [createAssociatedTokenAccountIdempotentInstruction({ payer: p.member, owner: p.member, mint: p.baseMint, tokenProgram: TOKEN_2022_PROGRAM_ID })] : []),
|
|
115
|
-
teamShareBuyInstructionV2({ ...buy, teamSlot, memberBase, quoteTokenProgram, quoteIsLaunch }),
|
|
115
|
+
teamShareBuyInstructionV2({ ...buy, teamSlot, memberBase, quoteTokenProgram, quoteIsLaunch, ...(seatAgency ? { seatAgency: { ...seatAgency, quoteTokenProgram, quoteIsLaunch } } : {}) }),
|
|
116
116
|
claim,
|
|
117
117
|
];
|
|
118
118
|
}
|
package/dist/v2/types.js
CHANGED
|
@@ -8,6 +8,10 @@ export const decodeLaunchV2Typed = (d ) => decodeAcc
|
|
|
8
8
|
export const decodeHolderPositionTyped = (d ) => decodeAccountV2("HolderPosition", d) ;
|
|
9
9
|
export const decodeHolderBookTyped = (d ) => decodeAccountV2("HolderBook", d) ;
|
|
10
10
|
export const decodeDeadMarkTyped = (d ) => decodeAccountV2("DeadMark", d) ;
|
|
11
|
+
export const decodeDealEscrowTyped = (d ) => decodeAccountV2("DealEscrow", d) ;
|
|
12
|
+
export const decodeRefVolumeTyped = (d ) => decodeAccountV2("RefVolume", d) ;
|
|
13
|
+
export const decodeRefVolumeBookTyped = (d ) => decodeAccountV2("RefVolumeBook", d) ;
|
|
14
|
+
export const decodeSeatAgencyTyped = (d ) => decodeAccountV2("SeatAgency", d) ;
|
|
11
15
|
|
|
12
16
|
export const decodeEventV2Typed = (d ) => decodeEventDataV2(d) ;
|
|
13
17
|
|
package/docs/aggregator.md
CHANGED
|
@@ -51,6 +51,25 @@ const call = evmRouteCallV2(q, { router, to: recipient, deadline });
|
|
|
51
51
|
// { to, data, ... }: send it from the trader's wallet
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
## Any coin in, any coin out on EVM: FloorRouter
|
|
55
|
+
|
|
56
|
+
The any-coin path on EVM is `FloorRouter` (`@floorlaunchpad/sdk/evm/router`): `buy` (any input coin to a launch token), `sell` (a launch token to any output coin) and `swap` (up one quote chain, down another). One router instance wraps one DEX router; the outside leg is a call you encode with `zapSwapData` (`@floorlaunchpad/sdk/evm/zap`, the DEX-leg encoder), and the router runs it for you inside the same transaction.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { encodeRouterBuy, encodeRouterSell, encodeRouterSwap } from "@floorlaunchpad/sdk/evm/router";
|
|
60
|
+
import { FLOOR_ROUTER_ADDRESSES, floorRouterAddressV2 } from "@floorlaunchpad/sdk/evm/chains";
|
|
61
|
+
import { zapSwapData } from "@floorlaunchpad/sdk/evm/zap";
|
|
62
|
+
|
|
63
|
+
// the router instances of a chain, one per DEX slot, both builds
|
|
64
|
+
const books = FLOOR_ROUTER_ADDRESSES.base; // [{ slot, address, forCaller, deployer }, ...]
|
|
65
|
+
const router = books.find((b) => b.forCaller && b.slot === "uniswap-ur")!.address;
|
|
66
|
+
const data = encodeRouterBuy({ path, tokenIn, amountIn, swapData, minQuoteIn, minTokensOut, to, deadline }, chainId);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- Two builds are booked. The earlier one is live. The newer one (`forCaller: true`) names the CALLER on every trade it makes, so a person's trade is theirs in the logs; it is deployed after each chain's FloorAmm upgrade, so read `getCode` at the address before you rely on it. `floorRouterAddressV2({ deployer, slot })` derives an instance from its deployer and slot; the SDK derives the newer build's instances and never hard-codes them.
|
|
70
|
+
- A multi-hop route through the newer build leaves the middle hops under the router's name in the raw logs. To read which person a `Trade` belongs to, pass the first `Sold` / `Bought` / `Zapped` after it to `ownProofOf` and `routedPerson` (`@floorlaunchpad/sdk/v2/devbuy`).
|
|
71
|
+
- `FloorZap` stays on chain and its past trades still read, but the FLOOR site no longer uses it: start new integrations on `FloorRouter`.
|
|
72
|
+
|
|
54
73
|
## Things to know
|
|
55
74
|
|
|
56
75
|
- The SDK never sends or signs. It returns instructions or calldata.
|
package/examples/floor-line.html
CHANGED
|
@@ -238,7 +238,7 @@ const floor = floorOf(BigInt(event.sqrtF), quoteDecimals);</script>
|
|
|
238
238
|
</div></script>
|
|
239
239
|
|
|
240
240
|
<script>
|
|
241
|
-
const DATA = /*DATA*/{"run":"A simulated launch with a USDC quote at $1: 74 buys and 8 sells","quoteDecimals":6,"series":[{"i":0,"price":0.01,"floor":null,"graduated":false,"side":"open"},{"i":1,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":2,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":3,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":4,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":5,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":6,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":7,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":8,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":9,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":10,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":11,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":12,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":13,"price":0.01022274,"floor":0.01,"graduated":true,"side":"buy"},{"i":14,"price":0.01045981,"floor":0.01000702,"graduated":true,"side":"buy"},{"i":15,"price":0.01069961,"floor":0.01001356,"graduated":true,"side":"buy"},{"i":16,"price":0.01092692,"floor":0.01001968,"graduated":true,"side":"buy"},{"i":17,"price":0.01110845,"floor":0.01002545,"graduated":true,"side":"buy"},{"i":18,"price":0.0112915,"floor":0.0100309,"graduated":true,"side":"buy"},{"i":19,"price":0.01147605,"floor":0.01003607,"graduated":true,"side":"buy"},{"i":20,"price":0.0116621,"floor":0.01004098,"graduated":true,"side":"buy"},{"i":21,"price":0.01184832,"floor":0.01004568,"graduated":true,"side":"buy"},{"i":22,"price":0.0119884,"floor":0.01005016,"graduated":true,"side":"buy"},{"i":23,"price":0.01212932,"floor":0.01005447,"graduated":true,"side":"buy"},{"i":24,"price":0.01227106,"floor":0.0100586,"graduated":true,"side":"buy"},{"i":25,"price":0.01284634,"floor":0.01007293,"graduated":true,"side":"buy"},{"i":26,"price":0.01329322,"floor":0.01008562,"graduated":true,"side":"buy"},{"i":27,"price":0.01373598,"floor":0.01030198,"graduated":true,"side":"buy"},{"i":28,"price":0.01414542,"floor":0.01060907,"graduated":true,"side":"buy"},{"i":29,"price":0.01448348,"floor":0.01086261,"graduated":true,"side":"buy"},{"i":30,"price":0.01482555,"floor":0.01111917,"graduated":true,"side":"buy"},{"i":31,"price":0.01517165,"floor":0.01137874,"graduated":true,"side":"buy"},{"i":32,"price":0.01545607,"floor":0.01159206,"graduated":true,"side":"buy"},{"i":33,"price":0.0157178,"floor":0.01178835,"graduated":true,"side":"buy"},{"i":34,"price":0.01598174,"floor":0.01198631,"graduated":true,"side":"buy"},{"i":35,"price":0.01624789,"floor":0.01218592,"graduated":true,"side":"buy"},{"i":36,"price":0.01651626,"floor":0.0123872,"graduated":true,"side":"buy"},{"i":37,"price":0.01674282,"floor":0.01255712,"graduated":true,"side":"buy"},{"i":38,"price":0.01694468,"floor":0.01270851,"graduated":true,"side":"buy"},{"i":39,"price":0.01714776,"floor":0.01286082,"graduated":true,"side":"buy"},{"i":40,"price":0.01735205,"floor":0.01301404,"graduated":true,"side":"buy"},{"i":41,"price":0.01755756,"floor":0.01316817,"graduated":true,"side":"buy"},{"i":42,"price":0.01776429,"floor":0.01332322,"graduated":true,"side":"buy"},{"i":43,"price":0.01797224,"floor":0.01347918,"graduated":true,"side":"buy"},{"i":44,"price":0.01815632,"floor":0.01361724,"graduated":true,"side":"buy"},{"i":45,"price":0.01831214,"floor":0.01373411,"graduated":true,"side":"buy"},{"i":46,"price":0.01846863,"floor":0.01385147,"graduated":true,"side":"buy"},{"i":47,"price":0.0186258,"floor":0.01396935,"graduated":true,"side":"buy"},{"i":48,"price":0.01878363,"floor":0.01408772,"graduated":true,"side":"buy"},{"i":49,"price":0.01859303,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":50,"price":0.01830951,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":51,"price":0.01718636,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":52,"price":0.01619404,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":53,"price":0.
|
|
241
|
+
const DATA = /*DATA*/{"run":"A simulated launch with a USDC quote at $1: 74 buys and 8 sells","quoteDecimals":6,"series":[{"i":0,"price":0.01,"floor":null,"graduated":false,"side":"open"},{"i":1,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":2,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":3,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":4,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":5,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":6,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":7,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":8,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":9,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":10,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":11,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":12,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":13,"price":0.01022274,"floor":0.01,"graduated":true,"side":"buy"},{"i":14,"price":0.01045981,"floor":0.01000702,"graduated":true,"side":"buy"},{"i":15,"price":0.01069961,"floor":0.01001356,"graduated":true,"side":"buy"},{"i":16,"price":0.01092692,"floor":0.01001968,"graduated":true,"side":"buy"},{"i":17,"price":0.01110845,"floor":0.01002545,"graduated":true,"side":"buy"},{"i":18,"price":0.0112915,"floor":0.0100309,"graduated":true,"side":"buy"},{"i":19,"price":0.01147605,"floor":0.01003607,"graduated":true,"side":"buy"},{"i":20,"price":0.0116621,"floor":0.01004098,"graduated":true,"side":"buy"},{"i":21,"price":0.01184832,"floor":0.01004568,"graduated":true,"side":"buy"},{"i":22,"price":0.0119884,"floor":0.01005016,"graduated":true,"side":"buy"},{"i":23,"price":0.01212932,"floor":0.01005447,"graduated":true,"side":"buy"},{"i":24,"price":0.01227106,"floor":0.0100586,"graduated":true,"side":"buy"},{"i":25,"price":0.01284634,"floor":0.01007293,"graduated":true,"side":"buy"},{"i":26,"price":0.01329322,"floor":0.01008562,"graduated":true,"side":"buy"},{"i":27,"price":0.01373598,"floor":0.01030198,"graduated":true,"side":"buy"},{"i":28,"price":0.01414542,"floor":0.01060907,"graduated":true,"side":"buy"},{"i":29,"price":0.01448348,"floor":0.01086261,"graduated":true,"side":"buy"},{"i":30,"price":0.01482555,"floor":0.01111917,"graduated":true,"side":"buy"},{"i":31,"price":0.01517165,"floor":0.01137874,"graduated":true,"side":"buy"},{"i":32,"price":0.01545607,"floor":0.01159206,"graduated":true,"side":"buy"},{"i":33,"price":0.0157178,"floor":0.01178835,"graduated":true,"side":"buy"},{"i":34,"price":0.01598174,"floor":0.01198631,"graduated":true,"side":"buy"},{"i":35,"price":0.01624789,"floor":0.01218592,"graduated":true,"side":"buy"},{"i":36,"price":0.01651626,"floor":0.0123872,"graduated":true,"side":"buy"},{"i":37,"price":0.01674282,"floor":0.01255712,"graduated":true,"side":"buy"},{"i":38,"price":0.01694468,"floor":0.01270851,"graduated":true,"side":"buy"},{"i":39,"price":0.01714776,"floor":0.01286082,"graduated":true,"side":"buy"},{"i":40,"price":0.01735205,"floor":0.01301404,"graduated":true,"side":"buy"},{"i":41,"price":0.01755756,"floor":0.01316817,"graduated":true,"side":"buy"},{"i":42,"price":0.01776429,"floor":0.01332322,"graduated":true,"side":"buy"},{"i":43,"price":0.01797224,"floor":0.01347918,"graduated":true,"side":"buy"},{"i":44,"price":0.01815632,"floor":0.01361724,"graduated":true,"side":"buy"},{"i":45,"price":0.01831214,"floor":0.01373411,"graduated":true,"side":"buy"},{"i":46,"price":0.01846863,"floor":0.01385147,"graduated":true,"side":"buy"},{"i":47,"price":0.0186258,"floor":0.01396935,"graduated":true,"side":"buy"},{"i":48,"price":0.01878363,"floor":0.01408772,"graduated":true,"side":"buy"},{"i":49,"price":0.01859303,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":50,"price":0.01830951,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":51,"price":0.01718636,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":52,"price":0.01619404,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":53,"price":0.01855911,"floor":0.01408772,"graduated":true,"side":"buy"},{"i":54,"price":0.01903377,"floor":0.01427533,"graduated":true,"side":"buy"},{"i":55,"price":0.01951447,"floor":0.01463586,"graduated":true,"side":"buy"},{"i":56,"price":0.01991842,"floor":0.01493882,"graduated":true,"side":"buy"},{"i":57,"price":0.02028259,"floor":0.01521194,"graduated":true,"side":"buy"},{"i":58,"price":0.02065008,"floor":0.01548756,"graduated":true,"side":"buy"},{"i":59,"price":0.02102089,"floor":0.01576567,"graduated":true,"side":"buy"},{"i":60,"price":0.02139503,"floor":0.01604627,"graduated":true,"side":"buy"},{"i":61,"price":0.02168116,"floor":0.01626087,"graduated":true,"side":"buy"},{"i":62,"price":0.02196268,"floor":0.01647201,"graduated":true,"side":"buy"},{"i":63,"price":0.02224603,"floor":0.01668452,"graduated":true,"side":"buy"},{"i":64,"price":0.02253121,"floor":0.01689841,"graduated":true,"side":"buy"},{"i":65,"price":0.02281821,"floor":0.01711366,"graduated":true,"side":"buy"},{"i":66,"price":0.02310705,"floor":0.01733029,"graduated":true,"side":"buy"},{"i":67,"price":0.02337552,"floor":0.01753164,"graduated":true,"side":"buy"},{"i":68,"price":0.02359219,"floor":0.01769414,"graduated":true,"side":"buy"},{"i":69,"price":0.02347577,"floor":0.01769414,"graduated":true,"side":"sell"},{"i":70,"price":0.02334141,"floor":0.01769414,"graduated":true,"side":"sell"},{"i":71,"price":0.02185808,"floor":0.01769414,"graduated":true,"side":"sell"},{"i":72,"price":0.02053319,"floor":0.01769414,"graduated":true,"side":"sell"},{"i":73,"price":0.02337129,"floor":0.01769414,"graduated":true,"side":"buy"},{"i":74,"price":0.02358794,"floor":0.01769414,"graduated":true,"side":"buy"},{"i":75,"price":0.0238056,"floor":0.0178542,"graduated":true,"side":"buy"},{"i":76,"price":0.02402426,"floor":0.0180182,"graduated":true,"side":"buy"},{"i":77,"price":0.02424393,"floor":0.01818295,"graduated":true,"side":"buy"},{"i":78,"price":0.02446461,"floor":0.01834846,"graduated":true,"side":"buy"},{"i":79,"price":0.02468629,"floor":0.01851472,"graduated":true,"side":"buy"},{"i":80,"price":0.02490898,"floor":0.01868174,"graduated":true,"side":"buy"},{"i":81,"price":0.02513268,"floor":0.01884951,"graduated":true,"side":"buy"},{"i":82,"price":0.02535738,"floor":0.01901804,"graduated":true,"side":"buy"}]}/*END*/;
|
|
242
242
|
const SUPPLY = 1e9; // a FLOOR launch mints 1B tokens; market cap = price x total supply
|
|
243
243
|
const pts = DATA.series;
|
|
244
244
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floorlaunchpad/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "The FLOOR Program in TypeScript: the math, the quoter, decoders, PDAs and instruction builders for Solana and EVM",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -71,6 +71,21 @@
|
|
|
71
71
|
"import": "./dist/burn.js",
|
|
72
72
|
"default": "./dist/burn.js"
|
|
73
73
|
},
|
|
74
|
+
"./scaledUi": {
|
|
75
|
+
"types": "./src/scaledUi.ts",
|
|
76
|
+
"import": "./dist/scaledUi.js",
|
|
77
|
+
"default": "./dist/scaledUi.js"
|
|
78
|
+
},
|
|
79
|
+
"./stockRefresh": {
|
|
80
|
+
"types": "./src/stockRefresh.ts",
|
|
81
|
+
"import": "./dist/stockRefresh.js",
|
|
82
|
+
"default": "./dist/stockRefresh.js"
|
|
83
|
+
},
|
|
84
|
+
"./reprice": {
|
|
85
|
+
"types": "./src/reprice.ts",
|
|
86
|
+
"import": "./dist/reprice.js",
|
|
87
|
+
"default": "./dist/reprice.js"
|
|
88
|
+
},
|
|
74
89
|
"./evm/keccak": {
|
|
75
90
|
"types": "./src/evm/keccak.ts",
|
|
76
91
|
"import": "./dist/evm/keccak.js",
|
|
@@ -96,6 +111,11 @@
|
|
|
96
111
|
"import": "./dist/evm/router.js",
|
|
97
112
|
"default": "./dist/evm/router.js"
|
|
98
113
|
},
|
|
114
|
+
"./evm/venues": {
|
|
115
|
+
"types": "./src/evm/venues.ts",
|
|
116
|
+
"import": "./dist/evm/venues.js",
|
|
117
|
+
"default": "./dist/evm/venues.js"
|
|
118
|
+
},
|
|
99
119
|
"./evm/chains": {
|
|
100
120
|
"types": "./src/evm/chains.ts",
|
|
101
121
|
"import": "./dist/evm/chains.js",
|
|
@@ -366,6 +386,11 @@
|
|
|
366
386
|
"import": "./dist/v2/market-evm.js",
|
|
367
387
|
"default": "./dist/v2/market-evm.js"
|
|
368
388
|
},
|
|
389
|
+
"./math/v2/escrow": {
|
|
390
|
+
"types": "./src/math/v2/escrow.ts",
|
|
391
|
+
"import": "./dist/math/v2/escrow.js",
|
|
392
|
+
"default": "./dist/math/v2/escrow.js"
|
|
393
|
+
},
|
|
369
394
|
"./math/v2/team": {
|
|
370
395
|
"types": "./src/math/v2/team.ts",
|
|
371
396
|
"import": "./dist/math/v2/team.js",
|