@floorlaunchpad/sdk 0.4.1 → 0.7.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +219 -18
  2. package/README.md +0 -2
  3. package/dist/abi/evm-event-names.js +7 -0
  4. package/dist/abi/evm.gen.js +6 -0
  5. package/dist/abi/functions.gen.js +49 -1
  6. package/dist/abi/solana.gen.js +5 -0
  7. package/dist/config/generated.js +77 -0
  8. package/dist/errors.js +2 -2
  9. package/dist/events/types.gen.js +1 -1
  10. package/dist/evm/chains.js +32 -24
  11. package/dist/evm/floor/calls.js +5 -0
  12. package/dist/evm/router.js +1 -25
  13. package/dist/evm/squid.js +3 -3
  14. package/dist/generated/interface.gen.js +48 -43
  15. package/dist/index.js +1 -0
  16. package/dist/indexer/bodies.js +137 -2
  17. package/dist/indexer/client.js +10 -1
  18. package/dist/indexer/contract.js +65 -6
  19. package/dist/indexer/paths.js +34 -7
  20. package/dist/indexer/read.js +12 -3
  21. package/dist/indexer/stream.js +2 -2
  22. package/dist/math/v2/book.js +40 -7
  23. package/dist/math/v2/create.js +1 -1
  24. package/dist/math/v2/fees.js +30 -4
  25. package/dist/math/v2/milestones.js +1 -1
  26. package/dist/math/v2/receipt.js +3 -3
  27. package/dist/math/v2/relay.js +201 -1
  28. package/dist/math/v2/rows.js +17 -0
  29. package/dist/math/v2/split.js +60 -15
  30. package/dist/math/v2/team.js +14 -1
  31. package/dist/math/v2/trade.js +16 -8
  32. package/dist/solana/floor/accounts.js +30 -3
  33. package/dist/solana/floor/events.js +6 -0
  34. package/dist/solana/floor/instructions.js +23 -1
  35. package/dist/solana/floor/program.js +3 -0
  36. package/dist/ton/addresses.js +36 -0
  37. package/dist/ton/book-check.js +23 -0
  38. package/dist/ton/book.js +119 -0
  39. package/dist/ton/cell.js +542 -0
  40. package/dist/ton/consts.generated.js +17 -0
  41. package/dist/ton/content.js +83 -0
  42. package/dist/ton/gas.js +198 -0
  43. package/dist/ton/governance.js +401 -0
  44. package/dist/ton/index.js +18 -0
  45. package/dist/ton/messages.js +340 -0
  46. package/dist/ton/ops.js +37 -0
  47. package/dist/ton/price.js +51 -0
  48. package/dist/ton/quote-entry.js +116 -0
  49. package/dist/ton/quote.js +25 -0
  50. package/dist/ton/reader.js +378 -0
  51. package/dist/ton/types.js +43 -0
  52. package/dist/ton/wallet.js +26 -0
  53. package/dist/v2/events.js +2 -0
  54. package/dist/v2/evm.js +8 -1
  55. package/dist/v2/layouts.js +7 -1
  56. package/dist/v2/router.js +2 -2
  57. package/dist/v2/solana.js +1 -1
  58. package/dist/v2/solanaSettle.js +2 -0
  59. package/dist/v2/tx/evm.js +15 -1
  60. package/docs/aggregator.md +0 -22
  61. package/docs/bot.md +0 -8
  62. package/docs/cursor-pages.md +9 -5
  63. package/docs/frontend.md +0 -2
  64. package/docs/ton.md +107 -0
  65. package/docs/wallet.md +0 -2
  66. package/examples/floor-line.html +1 -1
  67. package/package.json +6 -1
  68. package/src/abi/evm-event-names.ts +7 -0
  69. package/src/abi/evm.gen.ts +6 -0
  70. package/src/abi/functions.gen.ts +49 -1
  71. package/src/abi/solana.gen.ts +5 -0
  72. package/src/config/generated.ts +77 -0
  73. package/src/errors.ts +2 -2
  74. package/src/events/types.gen.ts +57 -1
  75. package/src/evm/chains.ts +34 -28
  76. package/src/evm/floor/calls.ts +5 -0
  77. package/src/evm/router.ts +1 -26
  78. package/src/evm/squid.ts +3 -3
  79. package/src/generated/interface.gen.ts +48 -43
  80. package/src/index.ts +1 -0
  81. package/src/indexer/bodies.ts +144 -2
  82. package/src/indexer/client.ts +17 -4
  83. package/src/indexer/contract.ts +66 -7
  84. package/src/indexer/paths.ts +62 -7
  85. package/src/indexer/read.ts +14 -5
  86. package/src/indexer/stream.ts +4 -4
  87. package/src/math/v2/book.ts +42 -7
  88. package/src/math/v2/create.ts +1 -1
  89. package/src/math/v2/fees.ts +30 -4
  90. package/src/math/v2/milestones.ts +1 -1
  91. package/src/math/v2/receipt.ts +7 -3
  92. package/src/math/v2/relay.ts +208 -1
  93. package/src/math/v2/rows.ts +17 -0
  94. package/src/math/v2/split.ts +70 -16
  95. package/src/math/v2/team.ts +14 -1
  96. package/src/math/v2/trade.ts +16 -8
  97. package/src/solana/floor/accounts.ts +30 -3
  98. package/src/solana/floor/events.ts +6 -0
  99. package/src/solana/floor/instructions.ts +23 -1
  100. package/src/solana/floor/program.ts +3 -0
  101. package/src/ton/addresses.ts +38 -0
  102. package/src/ton/book-check.ts +24 -0
  103. package/src/ton/book.ts +136 -0
  104. package/src/ton/cell.ts +547 -0
  105. package/src/ton/consts.generated.ts +17 -0
  106. package/src/ton/content.ts +97 -0
  107. package/src/ton/gas.ts +209 -0
  108. package/src/ton/governance.ts +452 -0
  109. package/src/ton/index.ts +18 -0
  110. package/src/ton/messages.ts +343 -0
  111. package/src/ton/ops.ts +37 -0
  112. package/src/ton/price.ts +54 -0
  113. package/src/ton/quote-entry.ts +138 -0
  114. package/src/ton/quote.ts +67 -0
  115. package/src/ton/reader.ts +420 -0
  116. package/src/ton/types.ts +201 -0
  117. package/src/ton/wallet.ts +30 -0
  118. package/src/v2/events.ts +3 -1
  119. package/src/v2/evm.ts +10 -1
  120. package/src/v2/layouts.ts +7 -1
  121. package/src/v2/router.ts +2 -2
  122. package/src/v2/solana.ts +1 -1
  123. package/src/v2/solanaSettle.ts +2 -0
  124. package/src/v2/tx/evm.ts +15 -1
  125. package/src/v2/types.ts +14 -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 {
@@ -235,6 +238,9 @@ export const V2_EVENTS_ELSEWHERE = [
235
238
  "Initialized", "LaunchCreated", "PayoutOwed", "TeamSlotOpened", "Upgraded", "Approval", "Transfer", "EIP712DomainChanged", "Claimed", "ClaimSkipped",
236
239
  "HolderWithdrawn", "PlatformWithdrawn", "PayoutClaimed", "PotsSwept", "TeamBuyClaimed", "TeamShareBoughtClaimed", "CreatorBuyUnlocked",
237
240
  "TeamSlotMember",
241
+
242
+ "ConfigWritten", "HandleBound", "HandleOwedMoved", "MetadataBaseSet", "NativeCreateFeeSet", "PriceUpdaterSet", "QuoteCapSet",
243
+ "QuoteWritten", "TraderRefCleared", "TraderRefOpened", "TreasurySet",
238
244
  ] as const;
239
245
 
240
246
  let topics: Map<string, keyof typeof V2_EVENTS> | undefined;
@@ -262,6 +268,8 @@ export const V2_ERRORS_EVM = [
262
268
  "NotProgram",
263
269
 
264
270
  "BadMember",
271
+
272
+ "OgFull", "OgAlreadySet",
265
273
  ] as const;
266
274
 
267
275
  export const V2_ERRORS_ARGS_EVM = ["UnknownClaimType(uint256)"] as const;
@@ -294,6 +302,7 @@ export function evmSettleInputsV2(b: LaunchBookV2, row: SplitRow, sup: Supply, m
294
302
  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
303
  bandTokens: pad(b.bandTokens, BIDS_MAX, 0n).slice(0, BIDS_MAX), bandF: pad(b.bandF, BIDS_MAX, 0n).slice(0, BIDS_MAX),
296
304
  bandFClaim: pad(b.bandFClaim, BIDS_MAX, 0n).slice(0, BIDS_MAX), ckAtF: b.ckAtF, ckFloorTokens: b.ckFloorTokens,
305
+ kpot: b.kpot, kAtF: b.kAtF, kFloorTokens: b.kFloorTokens,
297
306
  feePpm: [...b.feePpm], graduated: b.graduated,
298
307
 
299
308
  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,13 @@ export const LAUNCH_V2: Layout = [
131
131
  ["backing_credited", "u64"],
132
132
  ["incinerated", "u64"],
133
133
  ["last_ts", "i64"],
134
- ["book_hash", "bytes:32"],
134
+
135
+ ["k_at_f", "u64"],
136
+ ["k_floor_tokens", "u64"],
137
+ ["kpot", "u8"],
138
+
139
+ ["pad_og", "bytes:3"],
140
+ ["creator_ref_og_until", "u32[3]"],
135
141
  ];
136
142
 
137
143
  export const HOLDER_POSITION: Layout = [
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: 700_000, sell: 750_000 } as const;
11
+ export const GAS_FLAT = { buy: 1_100_000, sell: 850_000 } as const;
12
12
 
13
- export const GAS_PER_STEP = { buy: 40_000, sell: 40_000 } as const;
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/solana.ts CHANGED
@@ -38,7 +38,7 @@ export const extraAccountMetasPda = (baseMint: string, hook = FLOOR_HOOK_PROGRAM
38
38
 
39
39
  const V2_ERROR_NAMES = [
40
40
  "NothingToSettle", "HolderPositionExists", "HolderPositionNotEmpty", "HolderBookMismatch", "DeadAccountNotDead",
41
- "HookAccountsMissing", "RowTooManyRanges", "RowNotFeasible",
41
+ "HookAccountsMissing", "RowTooManyRanges", "RowNotFeasible", "OgFull",
42
42
  ] as const;
43
43
 
44
44
  export const V2_ERROR_BASE = FLOOR_AMM_ERRORS.BurnTooLarge + 1;
@@ -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/tx/evm.ts CHANGED
@@ -10,7 +10,7 @@ import { evmSignature } from "../../generated/index.ts";
10
10
 
11
11
  export { claimV2Call, CLAIM_HOLDER_EVM, CLAIM_KNOWN_V2_EVM, creditBackingCall, optInCall, viewCall, decodeTeamShareOf } from "../evm.ts";
12
12
  export type { EvmCall } from "../evm.ts";
13
- export { traderRefDigest, traderRefAuthDigest, bindHandleDigest, bindHandleAuthDigest } from "../../evm/floor/calls.ts";
13
+ export { traderRefDigest, traderRefAuthDigest, bindHandleDigest, bindHandleAuthDigest, ogUserAuthDigest } from "../../evm/floor/calls.ts";
14
14
  export { CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, CLAIM_PAYOUT, CLAIM_TEAM_BUY, CLAIM_SHARE_BOUGHT, MEMBER_WALLET, MEMBER_HANDLE, NATIVE_QUOTE } from "../../evm/floor/iface.ts";
15
15
 
16
16
  export const EVM_V2_TX = {
@@ -26,12 +26,18 @@ export const EVM_V2_TX = {
26
26
  setTraderRef: evmSignature("setTraderRef"),
27
27
  bindHandle: evmSignature("bindHandle"),
28
28
  claimPayoutTo: evmSignature("claimPayoutTo"),
29
+
30
+ setOgUser: evmSignature("setOgUser"),
31
+ revokeOgUser: evmSignature("revokeOgUser"),
29
32
  } as const;
30
33
 
31
34
  export const EVM_V2_TX_VIEWS = {
32
35
  traderRef: { sig: evmSignature("traderRef"), ret: ["address[3]"] },
33
36
  launchCount: { sig: evmSignature("launchCount"), ret: ["uint256"] },
34
37
  predictToken: { sig: evmSignature("predictToken"), ret: ["address"] },
38
+
39
+ ogUserOf: { sig: evmSignature("ogUserOf"), ret: ["uint64", "uint64", "bool"] },
40
+ ogCount: { sig: evmSignature("ogCount"), ret: ["uint16", "uint64"] },
35
41
  } as const;
36
42
 
37
43
  const NATIVE = "0x0000000000000000000000000000000000000000";
@@ -140,6 +146,14 @@ export function setTraderRefCallV2(p: { floorAmm: string; trader: string; tiers:
140
146
  return call(p.floorAmm, EVM_V2_TX.setTraderRef, [p.trader, [...p.tiers], p.deadline, hexToBytes(p.authSig), hexToBytes(p.traderSig ?? "0x")]);
141
147
  }
142
148
 
149
+ export function setOgUserCall(p: { floorAmm: string; referrer: string; deadline: bigint; authSig: string }): EvmCall {
150
+ return call(p.floorAmm, EVM_V2_TX.setOgUser, [p.referrer, p.deadline, hexToBytes(p.authSig)]);
151
+ }
152
+
153
+ export function revokeOgUserCall(p: { floorAmm: string; referrer: string }): EvmCall {
154
+ return call(p.floorAmm, EVM_V2_TX.revokeOgUser, [p.referrer]);
155
+ }
156
+
143
157
  export function bindHandleCallV2(p: { floorAmm: string; handleId: string; wallet: string; quotes: readonly string[]; deadline: bigint; authSig: string; walletSig?: string }): EvmCall {
144
158
  return call(p.floorAmm, EVM_V2_TX.bindHandle, [hexToBytes(p.handleId), p.wallet, [...p.quotes], p.deadline, hexToBytes(p.authSig), hexToBytes(p.walletSig ?? "0x")]);
145
159
  }
package/src/v2/types.ts CHANGED
@@ -115,7 +115,11 @@ export interface LaunchV2Account {
115
115
  backingCredited: bigint;
116
116
  incinerated: bigint;
117
117
  lastTs: bigint;
118
- bookHash: Uint8Array;
118
+ kAtF: bigint;
119
+ kFloorTokens: bigint;
120
+ kpot: number;
121
+ padOg: Uint8Array;
122
+ creatorRefOgUntil: number[];
119
123
  }
120
124
 
121
125
  export interface HolderPositionAccount {
@@ -235,6 +239,14 @@ export interface DeadSyncedEventV2 {
235
239
  sCirc: bigint;
236
240
  }
237
241
 
242
+ export interface RefSlicesEvent {
243
+ launch: string;
244
+ trader: string;
245
+ traderParts: bigint[];
246
+ creatorParts: bigint[];
247
+ og: number;
248
+ }
249
+
238
250
  export interface GenesisRaiseBoughtEventV2 {
239
251
  launch: string;
240
252
  trader: string;
@@ -272,6 +284,7 @@ export type FloorEventV2Typed =
272
284
  | { name: "HolderPositionClosed"; fields: HolderPositionClosedEventV2 }
273
285
  | { name: "HolderIndexRolled"; fields: HolderIndexRolledEventV2 }
274
286
  | { name: "DeadSynced"; fields: DeadSyncedEventV2 }
287
+ | { name: "RefSlices"; fields: RefSlicesEvent }
275
288
  | { name: "GenesisRaiseBought"; fields: GenesisRaiseBoughtEventV2 };
276
289
 
277
290
  export const decodePresetRowV2Typed = (d: Uint8Array): PresetRowV2Account => decodeAccountV2("PresetRowV2", d) as PresetRowV2Account;