@floorlaunchpad/sdk 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/dist/abi/evm.gen.js +5 -0
- package/dist/abi/functions.gen.js +1 -1
- package/dist/client/solana/index.js +13 -8
- package/dist/config/generated.js +78 -1
- package/dist/config/registry.gen.js +1 -1
- package/dist/evm/chains.js +56 -18
- package/dist/evm/squid.js +10 -10
- package/dist/evm/zap.js +148 -35
- package/dist/index.js +1 -0
- package/dist/indexer/bodies.js +9 -0
- package/dist/indexer/client.js +2 -0
- package/dist/indexer/contract.js +48 -2
- package/dist/indexer/paths.js +26 -0
- package/dist/indexer/read.js +3 -0
- package/dist/math/v2/book.js +40 -7
- package/dist/math/v2/create.js +1 -1
- package/dist/math/v2/relay.js +201 -1
- package/dist/math/v2/split.js +60 -15
- package/dist/math/v2/trade.js +16 -8
- package/dist/ton/addresses.js +36 -0
- package/dist/ton/book-check.js +23 -0
- package/dist/ton/book.js +119 -0
- package/dist/ton/cell.js +542 -0
- package/dist/ton/consts.generated.js +17 -0
- package/dist/ton/content.js +83 -0
- package/dist/ton/gas.js +198 -0
- package/dist/ton/governance.js +401 -0
- package/dist/ton/index.js +18 -0
- package/dist/ton/messages.js +340 -0
- package/dist/ton/ops.js +37 -0
- package/dist/ton/price.js +51 -0
- package/dist/ton/quote-entry.js +116 -0
- package/dist/ton/quote.js +25 -0
- package/dist/ton/reader.js +378 -0
- package/dist/ton/types.js +43 -0
- package/dist/ton/wallet.js +26 -0
- package/dist/v2/devbuy.js +6 -4
- package/dist/v2/evm.js +3 -1
- package/dist/v2/layouts.js +5 -1
- package/dist/v2/presetRowEvm.js +21 -2
- package/dist/v2/router.js +2 -2
- package/dist/v2/solanaSettle.js +2 -0
- package/docs/ton.md +107 -0
- package/examples/floor-line.html +1 -1
- package/package.json +6 -1
- package/src/abi/evm.gen.ts +5 -0
- package/src/abi/functions.gen.ts +1 -1
- package/src/client/solana/index.ts +13 -8
- package/src/config/generated.ts +78 -1
- package/src/config/registry.gen.ts +1 -1
- package/src/evm/chains.ts +63 -17
- package/src/evm/squid.ts +10 -10
- package/src/evm/zap.ts +185 -36
- package/src/index.ts +1 -0
- package/src/indexer/bodies.ts +11 -0
- package/src/indexer/client.ts +5 -1
- package/src/indexer/contract.ts +48 -2
- package/src/indexer/paths.ts +47 -0
- package/src/indexer/read.ts +5 -2
- package/src/math/v2/book.ts +42 -7
- package/src/math/v2/create.ts +1 -1
- package/src/math/v2/relay.ts +208 -1
- package/src/math/v2/split.ts +70 -16
- package/src/math/v2/trade.ts +16 -8
- package/src/ton/addresses.ts +38 -0
- package/src/ton/book-check.ts +24 -0
- package/src/ton/book.ts +136 -0
- package/src/ton/cell.ts +547 -0
- package/src/ton/consts.generated.ts +17 -0
- package/src/ton/content.ts +97 -0
- package/src/ton/gas.ts +209 -0
- package/src/ton/governance.ts +452 -0
- package/src/ton/index.ts +18 -0
- package/src/ton/messages.ts +343 -0
- package/src/ton/ops.ts +37 -0
- package/src/ton/price.ts +54 -0
- package/src/ton/quote-entry.ts +138 -0
- package/src/ton/quote.ts +67 -0
- package/src/ton/reader.ts +420 -0
- package/src/ton/types.ts +201 -0
- package/src/ton/wallet.ts +30 -0
- package/src/v2/devbuy.ts +6 -4
- package/src/v2/evm.ts +5 -1
- package/src/v2/layouts.ts +5 -1
- package/src/v2/presetRowEvm.ts +21 -2
- package/src/v2/router.ts +2 -2
- package/src/v2/solanaSettle.ts +2 -0
- package/src/v2/types.ts +4 -1
package/src/v2/evm.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const CLAIM_KNOWN_V2_EVM = CLAIM_KNOWN_MASKS.evm.v2;
|
|
|
22
22
|
|
|
23
23
|
const BOOK_RANGE = "(uint128,uint128,uint64,uint64,uint64,uint128,uint16,uint16,uint8,uint8)";
|
|
24
24
|
|
|
25
|
-
const LAUNCH_BOOK = `(uint128,uint128,uint128,uint128[],uint8,${BOOK_RANGE}[48],uint128,uint64,uint64[],uint128[],uint8,uint8,uint128[],uint128[],uint128,uint64,bool,uint32[5])`;
|
|
25
|
+
const LAUNCH_BOOK = `(uint128,uint128,uint128,uint128[],uint8,${BOOK_RANGE}[48],uint128,uint64,uint64[],uint128[],uint8,uint8,uint128[],uint128[],uint128,uint64,bool,uint32[5],uint128,uint64,bool)`;
|
|
26
26
|
|
|
27
27
|
const BUY_OUT = "(uint256,uint256,uint256,uint128,uint8,bool,bool)";
|
|
28
28
|
|
|
@@ -128,6 +128,8 @@ export interface LaunchBookV2 {
|
|
|
128
128
|
bandF: bigint[]; bandFClaim: bigint[];
|
|
129
129
|
|
|
130
130
|
ckAtF: bigint; ckFloorTokens: bigint;
|
|
131
|
+
|
|
132
|
+
kpot: boolean; kAtF: bigint; kFloorTokens: bigint;
|
|
131
133
|
graduated: boolean;
|
|
132
134
|
|
|
133
135
|
feePpm: number[];
|
|
@@ -155,6 +157,7 @@ export function decodeLaunchBook(data: string | Uint8Array): LaunchBookV2 {
|
|
|
155
157
|
sqrtP: big(t[0]), sqrtF: big(t[1]), f: big(t[2]), bandMoney: bigs(t[3]), nRanges: nR, ranges,
|
|
156
158
|
sqrtLMax: big(t[6]), floorTokens: big(t[7]), bandTokens: bigs(t[8]), bandEdge: bigs(t[9]), nBands: n(t[10]), nC: n(t[11]),
|
|
157
159
|
bandF: bigs(t[12]), bandFClaim: bigs(t[13]), ckAtF: big(t[14]), ckFloorTokens: big(t[15]), graduated: t[16] as boolean, feePpm: nums(t[17]),
|
|
160
|
+
kAtF: big(t[18]), kFloorTokens: big(t[19]), kpot: t[20] as boolean,
|
|
158
161
|
};
|
|
159
162
|
}
|
|
160
163
|
export function decodeSimBuy(data: string | Uint8Array): SimBuyV2 {
|
|
@@ -294,6 +297,7 @@ export function evmSettleInputsV2(b: LaunchBookV2, row: SplitRow, sup: Supply, m
|
|
|
294
297
|
bandEdge: pad(b.bandEdge, BIDS_MAX + 1, 0n).slice(0, BIDS_MAX + 1), bandMoney: pad(b.bandMoney, BIDS_MAX, 0n).slice(0, BIDS_MAX),
|
|
295
298
|
bandTokens: pad(b.bandTokens, BIDS_MAX, 0n).slice(0, BIDS_MAX), bandF: pad(b.bandF, BIDS_MAX, 0n).slice(0, BIDS_MAX),
|
|
296
299
|
bandFClaim: pad(b.bandFClaim, BIDS_MAX, 0n).slice(0, BIDS_MAX), ckAtF: b.ckAtF, ckFloorTokens: b.ckFloorTokens,
|
|
300
|
+
kpot: b.kpot, kAtF: b.kAtF, kFloorTokens: b.kFloorTokens,
|
|
297
301
|
feePpm: [...b.feePpm], graduated: b.graduated,
|
|
298
302
|
|
|
299
303
|
feeStartPpm: curve ? [...curve.feeStartPpm] : [0, 0, 0, 0, 0], sqrtFeeA: curve?.sqrtFeeA ?? 0n, sqrtFeeB: curve?.sqrtFeeB ?? 0n,
|
package/src/v2/layouts.ts
CHANGED
|
@@ -131,7 +131,11 @@ export const LAUNCH_V2: Layout = [
|
|
|
131
131
|
["backing_credited", "u64"],
|
|
132
132
|
["incinerated", "u64"],
|
|
133
133
|
["last_ts", "i64"],
|
|
134
|
-
|
|
134
|
+
|
|
135
|
+
["k_at_f", "u64"],
|
|
136
|
+
["k_floor_tokens", "u64"],
|
|
137
|
+
["kpot", "u8"],
|
|
138
|
+
["pad_end", "bytes:15"],
|
|
135
139
|
];
|
|
136
140
|
|
|
137
141
|
export const HOLDER_POSITION: Layout = [
|
package/src/v2/presetRowEvm.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ROW_LEN, decodeRowV2 } from "../math/v2/preset.ts";
|
|
|
6
6
|
import type { RowV2 } from "../math/v2/preset.ts";
|
|
7
7
|
import type { PresetRowV2Account } from "./types.ts";
|
|
8
8
|
import { evmSignature } from "../generated/index.ts";
|
|
9
|
+
import { MULTICALL3_ADDRESS, aggregate3Call, decodeAggregate3Result } from "../evm/multicall.ts";
|
|
9
10
|
|
|
10
11
|
export const PRESET_ROW_VIEW_EVM = { sig: evmSignature("presetRow"), ret: ["(uint8,bool,bool,uint32,bytes32,bytes)"] } as const;
|
|
11
12
|
export const NEXT_PRESET_ID_VIEW_EVM = { sig: evmSignature("nextPresetId"), ret: ["uint8"] } as const;
|
|
@@ -46,9 +47,27 @@ export function presetMenuV2(rows: readonly (PresetRowV2Account | null)[]): Pres
|
|
|
46
47
|
.map((r) => ({ id: r.id, version: r.version, rowHash: bytesToHex(r.rowHash), row: decodeRowV2(r.row) }));
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
const PRESET_MENU_BATCH = 100;
|
|
51
|
+
|
|
52
|
+
export async function readPresetMenuEvmV2(
|
|
53
|
+
rpc: { ethCall: (to: string, data: string) => Promise<string> }, amm: string, opts: { multicall?: string | null } = {},
|
|
54
|
+
): Promise<PresetMenuItemV2[]> {
|
|
50
55
|
const next = decodeNextPresetIdEvmV2(await rpc.ethCall(amm, nextPresetIdCallV2()));
|
|
51
56
|
const ids = Array.from({ length: Math.max(0, next - 1) }, (_, i) => i + 1).filter((id) => id !== RETIRED_ID);
|
|
52
|
-
|
|
57
|
+
if (opts.multicall === null) {
|
|
58
|
+
return presetMenuV2(await Promise.all(ids.map(async (id) => decodePresetRowEvmV2(await rpc.ethCall(amm, presetRowCallV2(id))))));
|
|
59
|
+
}
|
|
60
|
+
const multicall = opts.multicall ?? MULTICALL3_ADDRESS;
|
|
61
|
+
const chunks: number[][] = [];
|
|
62
|
+
for (let i = 0; i < ids.length; i += PRESET_MENU_BATCH) chunks.push(ids.slice(i, i + PRESET_MENU_BATCH));
|
|
63
|
+
const rows = (await Promise.all(chunks.map(async (chunk) => {
|
|
64
|
+
const call = aggregate3Call(chunk.map((id) => ({ target: amm, allowFailure: true, callData: presetRowCallV2(id) })), multicall);
|
|
65
|
+
const res = decodeAggregate3Result(await rpc.ethCall(call.to, call.data));
|
|
66
|
+
if (res.length !== chunk.length) throw new RangeError(`aggregate3: ${res.length} results, ${chunk.length} calls`);
|
|
67
|
+
return res.map((r, i) => {
|
|
68
|
+
if (!r.success) throw new Error(`presetRow(${chunk[i]}) failed: ${r.returnData}`);
|
|
69
|
+
return decodePresetRowEvmV2(r.returnData);
|
|
70
|
+
});
|
|
71
|
+
}))).flat();
|
|
53
72
|
return presetMenuV2(rows);
|
|
54
73
|
}
|
package/src/v2/router.ts
CHANGED
|
@@ -8,9 +8,9 @@ export function carriesNoRefund(gross: bigint, refund: bigint, budgetHit: boolea
|
|
|
8
8
|
return refund === 0n || isDustRefund(gross, refund, budgetHit);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const GAS_FLAT = { buy:
|
|
11
|
+
export const GAS_FLAT = { buy: 1_100_000, sell: 850_000 } as const;
|
|
12
12
|
|
|
13
|
-
export const GAS_PER_STEP = { buy:
|
|
13
|
+
export const GAS_PER_STEP = { buy: 45_000, sell: 40_000 } as const;
|
|
14
14
|
|
|
15
15
|
export const GAS_FLAT_STEPS = 4;
|
|
16
16
|
|
package/src/v2/solanaSettle.ts
CHANGED
|
@@ -72,6 +72,8 @@ export function solanaSettleInputsV2(l: LaunchV2Account, opts: { mintSupply?: bi
|
|
|
72
72
|
nBands: l.nBands,
|
|
73
73
|
bandEdge: [...l.bandEdge], bandMoney: [...l.bandMoney], bandTokens: [...l.bandTokens],
|
|
74
74
|
nC: l.nC, bandF: [...l.bandF], bandFClaim: [...l.bandFClaim], ckAtF: l.ckAtF, ckFloorTokens: l.ckFloorTokens,
|
|
75
|
+
|
|
76
|
+
kpot: l.kpot !== 0, kAtF: l.kAtF, kFloorTokens: l.kFloorTokens,
|
|
75
77
|
feePpm: l.feePpm.map(n), feeStartPpm: l.feeStartPpm.map(n), sqrtFeeA: l.sqrtFeeA, sqrtFeeB: l.sqrtFeeB,
|
|
76
78
|
graduated: l.graduated !== 0, nRanges: l.nRanges, ranges,
|
|
77
79
|
|
package/src/v2/types.ts
CHANGED
|
@@ -115,7 +115,10 @@ export interface LaunchV2Account {
|
|
|
115
115
|
backingCredited: bigint;
|
|
116
116
|
incinerated: bigint;
|
|
117
117
|
lastTs: bigint;
|
|
118
|
-
|
|
118
|
+
kAtF: bigint;
|
|
119
|
+
kFloorTokens: bigint;
|
|
120
|
+
kpot: number;
|
|
121
|
+
padEnd: Uint8Array;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
export interface HolderPositionAccount {
|