@floorlaunchpad/sdk 0.6.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 (125) hide show
  1. package/CHANGELOG.md +279 -0
  2. package/README.md +12 -1
  3. package/dist/abi/evm-event-names.js +7 -0
  4. package/dist/abi/evm.gen.js +81 -2
  5. package/dist/abi/functions.gen.js +135 -1
  6. package/dist/abi/solana.gen.js +64 -0
  7. package/dist/client/solana/index.js +25 -6
  8. package/dist/config/generated.js +803 -26374
  9. package/dist/errors.js +21 -2
  10. package/dist/events/types.gen.js +1 -1
  11. package/dist/evm/chains.js +80 -0
  12. package/dist/evm/floor/abi.gen.js +115 -0
  13. package/dist/evm/floor/calls.js +5 -0
  14. package/dist/evm/squid.js +21 -5
  15. package/dist/evm/venues.js +302 -0
  16. package/dist/generated/interface.gen.js +93 -44
  17. package/dist/index.js +7 -0
  18. package/dist/indexer/bodies.js +288 -5
  19. package/dist/indexer/client.js +17 -1
  20. package/dist/indexer/contract.js +141 -15
  21. package/dist/indexer/paths.js +80 -7
  22. package/dist/indexer/read.js +25 -3
  23. package/dist/indexer/stream.js +2 -2
  24. package/dist/math/v2/book.js +24 -7
  25. package/dist/math/v2/create.js +1 -1
  26. package/dist/math/v2/escrow.js +205 -0
  27. package/dist/math/v2/fees.js +30 -4
  28. package/dist/math/v2/milestones.js +1 -1
  29. package/dist/math/v2/office.js +110 -0
  30. package/dist/math/v2/receipt.js +3 -3
  31. package/dist/math/v2/relay.js +263 -96
  32. package/dist/math/v2/rows.js +17 -0
  33. package/dist/math/v2/team.js +42 -1
  34. package/dist/math/v2/trade.js +3 -1
  35. package/dist/reprice.js +88 -0
  36. package/dist/route/quote.js +16 -0
  37. package/dist/scaledUi.js +113 -0
  38. package/dist/solana/floor/accounts.js +38 -5
  39. package/dist/solana/floor/events.js +62 -1
  40. package/dist/solana/floor/instructions.js +39 -1
  41. package/dist/solana/floor/program.js +3 -0
  42. package/dist/stockRefresh.js +99 -0
  43. package/dist/ton/consts.generated.js +2 -2
  44. package/dist/ton/gas.js +3 -3
  45. package/dist/v2/claims.js +28 -5
  46. package/dist/v2/devbuy.js +28 -3
  47. package/dist/v2/events.js +2 -0
  48. package/dist/v2/evm.js +183 -5
  49. package/dist/v2/layouts.js +102 -2
  50. package/dist/v2/office-events.js +127 -0
  51. package/dist/v2/office-evm.js +68 -0
  52. package/dist/v2/office-read.js +182 -0
  53. package/dist/v2/office-solana.js +134 -0
  54. package/dist/v2/office-trade.js +73 -0
  55. package/dist/v2/route-alt.js +1 -0
  56. package/dist/v2/route.js +1 -1
  57. package/dist/v2/solana.js +224 -5
  58. package/dist/v2/solanaSettle.js +2 -0
  59. package/dist/v2/tx/evm.js +66 -2
  60. package/dist/v2/tx/solana.js +3 -3
  61. package/dist/v2/types.js +4 -0
  62. package/docs/aggregator.md +19 -0
  63. package/docs/cursor-pages.md +9 -3
  64. package/docs/ton.md +1 -1
  65. package/examples/floor-line.html +1 -1
  66. package/package.json +26 -1
  67. package/src/abi/evm-event-names.ts +7 -0
  68. package/src/abi/evm.gen.ts +81 -2
  69. package/src/abi/functions.gen.ts +135 -1
  70. package/src/abi/solana.gen.ts +64 -0
  71. package/src/client/solana/index.ts +25 -6
  72. package/src/config/generated.ts +803 -26374
  73. package/src/errors.ts +21 -2
  74. package/src/events/types.gen.ts +458 -1
  75. package/src/evm/chains.ts +89 -0
  76. package/src/evm/floor/abi.gen.ts +115 -0
  77. package/src/evm/floor/calls.ts +5 -0
  78. package/src/evm/squid.ts +22 -6
  79. package/src/evm/venues.ts +340 -0
  80. package/src/generated/interface.gen.ts +93 -44
  81. package/src/index.ts +7 -0
  82. package/src/indexer/bodies.ts +308 -5
  83. package/src/indexer/client.ts +31 -4
  84. package/src/indexer/contract.ts +148 -17
  85. package/src/indexer/paths.ts +139 -7
  86. package/src/indexer/read.ts +27 -5
  87. package/src/indexer/stream.ts +4 -4
  88. package/src/math/v2/book.ts +23 -7
  89. package/src/math/v2/create.ts +1 -1
  90. package/src/math/v2/escrow.ts +213 -0
  91. package/src/math/v2/fees.ts +30 -4
  92. package/src/math/v2/milestones.ts +1 -1
  93. package/src/math/v2/office.ts +114 -0
  94. package/src/math/v2/receipt.ts +7 -3
  95. package/src/math/v2/relay.ts +269 -96
  96. package/src/math/v2/rows.ts +17 -0
  97. package/src/math/v2/team.ts +42 -1
  98. package/src/math/v2/trade.ts +3 -1
  99. package/src/reprice.ts +121 -0
  100. package/src/route/quote.ts +16 -0
  101. package/src/scaledUi.ts +123 -0
  102. package/src/solana/floor/accounts.ts +38 -5
  103. package/src/solana/floor/events.ts +63 -2
  104. package/src/solana/floor/instructions.ts +39 -1
  105. package/src/solana/floor/program.ts +3 -0
  106. package/src/stockRefresh.ts +131 -0
  107. package/src/ton/consts.generated.ts +2 -2
  108. package/src/ton/gas.ts +3 -3
  109. package/src/v2/claims.ts +34 -5
  110. package/src/v2/devbuy.ts +38 -3
  111. package/src/v2/events.ts +3 -1
  112. package/src/v2/evm.ts +209 -5
  113. package/src/v2/layouts.ts +102 -2
  114. package/src/v2/office-events.ts +133 -0
  115. package/src/v2/office-evm.ts +76 -0
  116. package/src/v2/office-read.ts +264 -0
  117. package/src/v2/office-solana.ts +159 -0
  118. package/src/v2/office-trade.ts +96 -0
  119. package/src/v2/route-alt.ts +1 -0
  120. package/src/v2/route.ts +1 -1
  121. package/src/v2/solana.ts +235 -5
  122. package/src/v2/solanaSettle.ts +2 -0
  123. package/src/v2/tx/evm.ts +66 -2
  124. package/src/v2/tx/solana.ts +5 -3
  125. package/src/v2/types.ts +76 -1
@@ -0,0 +1,340 @@
1
+
2
+
3
+ import { bytesToHex, checksumAddress, decodeAbi, encodeAbi, encodeCall } from "./abi.ts";
4
+ import { chainById } from "./chains.ts";
5
+ import { AERODROME_SLIPSTREAM_KEY, UR_ADDRESS_THIS, UR_MSG_SENDER, UR_UNWRAP_WETH, UR_V3_SWAP_EXACT_IN, UR_WRAP_ETH, V4_NATIVE, v3Path, v4PoolKey, zapSwapData } from "./zap.ts";
6
+ import type { EdgeQuote, EdgeQuoter } from "../route/quote.ts";
7
+ import { EVM_NATIVE, coinKey } from "../route/graph.ts";
8
+
9
+ export const DEX_FAMILY = { v2: 1, v3: 2, universal: 3, solidly: 4, algebra: 5 } as const;
10
+
11
+ export type DexVenue = "uniswap" | "aerodrome" | "pancake" | "project-x" | "nest" | "ramses" | "hyperswap";
12
+ export type LegKind = "ur" | "ur-v4" | "v3-router" | "router02" | "algebra";
13
+
14
+ export type QuoteKind = "fee" | "tick" | "algebra" | "v4";
15
+
16
+ export interface VenueLeg {
17
+ readonly chainId: number;
18
+ readonly venue: DexVenue;
19
+ readonly router: string;
20
+ readonly quoter: string;
21
+ readonly quoteKind: QuoteKind;
22
+ readonly legKind: LegKind;
23
+
24
+ readonly weth: string | null;
25
+
26
+ readonly nativeView?: { readonly token: string; readonly scale: bigint };
27
+
28
+ readonly keys: readonly number[];
29
+
30
+ readonly urTail?: "minHop" | "isUni" | "none";
31
+
32
+ readonly pathKey?: (key: number) => number;
33
+
34
+ readonly v4TickOf?: Readonly<Record<number, number>>;
35
+ }
36
+
37
+ export interface VenueReads {
38
+
39
+ simulate(a: { to: string; data: string }): Promise<string>;
40
+
41
+ call(a: { to: string; data: string }): Promise<string>;
42
+ }
43
+
44
+ const SLOT_OF: Readonly<Record<DexVenue, string>> = {
45
+ uniswap: "uniswap-ur", aerodrome: "aerodrome-ur", pancake: "pancake-ur", "project-x": "prjx", nest: "nest", ramses: "ramses-ur", hyperswap: "hyperswap",
46
+ };
47
+ const FEES_UNI = [100, 500, 3000, 10000] as const;
48
+ const FEES_PANCAKE = [100, 500, 2500, 10000] as const;
49
+ const WETH_OP = "0x4200000000000000000000000000000000000006";
50
+ const WHYPE = "0x5555555555555555555555555555555555555555";
51
+
52
+ const routerOf = (chainId: number, venue: DexVenue): string => {
53
+ const r = chainById(chainId)?.zapRouters.find((z) => z.slot === SLOT_OF[venue]);
54
+ if (!r) throw new Error(`no router row ${venue} on ${chainId}`);
55
+ return checksumAddress(r.router);
56
+ };
57
+ const wethOf = (chainId: number): string => checksumAddress(chainById(chainId)?.wrappedNative ?? WETH_OP);
58
+
59
+ export const UNISWAP_V3_QUOTER: Readonly<Record<number, string>> = Object.freeze({
60
+ 1: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
61
+ 8453: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",
62
+ 56: "0x78D78E420Da98ad378D7799bE8f4AF69033EB077",
63
+ 42161: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
64
+ 4663: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",
65
+ 5042: "0x7DfD4F31be6814D2906BDE155c3e1B146EAc1468",
66
+ 99901: "0x204FAca1764B154221e35c0d20aBb3c525710498",
67
+ });
68
+
69
+ export const UNISWAP_V3_FEES: readonly number[] = Object.freeze([...FEES_UNI]);
70
+
71
+ function leg(chainId: number, venue: DexVenue, l: Omit<VenueLeg, "chainId" | "venue" | "router">): VenueLeg {
72
+ return Object.freeze({ chainId, venue, router: routerOf(chainId, venue), ...l, quoter: checksumAddress(l.quoter) });
73
+ }
74
+ const uniswap = (chainId: number): VenueLeg =>
75
+ leg(chainId, "uniswap", { quoter: UNISWAP_V3_QUOTER[chainId], quoteKind: "fee", legKind: "ur", weth: wethOf(chainId), keys: FEES_UNI, urTail: "minHop" });
76
+ const pancake = (chainId: number, weth: string): VenueLeg =>
77
+ leg(chainId, "pancake", { quoter: "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997", quoteKind: "fee", legKind: "ur", weth: checksumAddress(weth), keys: FEES_PANCAKE, urTail: "none" });
78
+ const ramsesKeys = [1, 5, 10, 50, 100, 200];
79
+
80
+ export const VENUE_LEGS: Readonly<Record<number, readonly VenueLeg[]>> = Object.freeze({
81
+ 1: [uniswap(1)],
82
+ 8453: [
83
+ leg(8453, "aerodrome", { quoter: "0x254cF9E1E6e233aa1AC962CB9B05b2cfeAaE15b0", quoteKind: "tick", legKind: "ur", weth: checksumAddress(WETH_OP), keys: [1, 10, 50, 100, 200, 2000], urTail: "isUni", pathKey: (ts) => AERODROME_SLIPSTREAM_KEY | ts }),
84
+ uniswap(8453),
85
+ pancake(8453, WETH_OP),
86
+ ],
87
+ 56: [pancake(56, "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"), uniswap(56)],
88
+ 42161: [uniswap(42161)],
89
+ 999: [
90
+ leg(999, "project-x", { quoter: "0x239F11a7A3E08f2B8110D4CA9F6B95d4c8865258", quoteKind: "fee", legKind: "v3-router", weth: checksumAddress(WHYPE), keys: FEES_UNI }),
91
+ leg(999, "hyperswap", { quoter: "0x03A918028f22D9E1473B7959C927AD7425A45C7C", quoteKind: "fee", legKind: "router02", weth: checksumAddress(WHYPE), keys: FEES_UNI }),
92
+ leg(999, "nest", { quoter: "0xBea20609A4772311c5b81F814Cd4f9ECaEF5DFAd", quoteKind: "algebra", legKind: "algebra", weth: checksumAddress(WHYPE), keys: [0] }),
93
+ leg(999, "ramses", { quoter: "0x403Bf94fe505cA0F0b1563C350B57dCeC8303ECd", quoteKind: "tick", legKind: "ur", weth: checksumAddress(WHYPE), keys: ramsesKeys, urTail: "none" }),
94
+ ],
95
+ 4663: [
96
+ uniswap(4663),
97
+ leg(4663, "ramses", { quoter: "0x4730e03EB4a58A5e20244062D5f9A99bCf5770a6", quoteKind: "tick", legKind: "ur", weth: checksumAddress("0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"), keys: ramsesKeys, urTail: "none" }),
98
+ ],
99
+
100
+ 99901: [
101
+ leg(99901, "uniswap", { quoter: "0x379F556c5a748BD7Cc9baF0F7A344094Ac1814f5", quoteKind: "v4", legKind: "ur-v4", weth: checksumAddress(V4_NATIVE), keys: [3000, 10000], v4TickOf: { 3000: 60, 10000: 200 } }),
102
+ ],
103
+
104
+ 5042: [
105
+ leg(5042, "uniswap", { quoter: "0x7DfD4F31be6814D2906BDE155c3e1B146EAc1468", quoteKind: "fee", legKind: "ur", weth: null, nativeView: { token: checksumAddress("0x3600000000000000000000000000000000000000"), scale: 10n ** 12n }, keys: FEES_UNI, urTail: "minHop" }),
106
+ ],
107
+ });
108
+
109
+ export function venueLegOf(chainId: number, router: string): VenueLeg | null {
110
+ return (VENUE_LEGS[chainId] ?? []).find((l) => l.router.toLowerCase() === router.toLowerCase()) ?? null;
111
+ }
112
+
113
+ const FAMILY_OF_LEG: Readonly<Record<LegKind, number>> = { ur: DEX_FAMILY.universal, "ur-v4": DEX_FAMILY.universal, "v3-router": DEX_FAMILY.v3, router02: DEX_FAMILY.v3, algebra: DEX_FAMILY.algebra };
114
+
115
+ export const WIRED_DEX_FAMILIES: readonly number[] = Object.freeze([DEX_FAMILY.v2, DEX_FAMILY.universal, DEX_FAMILY.v3, DEX_FAMILY.algebra]);
116
+ export const dexFamilyWired = (family: number): boolean => WIRED_DEX_FAMILIES.includes(family);
117
+
118
+ export const wiredLegOf = (chainId: number, family: number, dex: string): VenueLeg | null => {
119
+ const l = venueLegOf(chainId, dex);
120
+ return l !== null && FAMILY_OF_LEG[l.legKind] === family ? l : null;
121
+ };
122
+
123
+ export const dexLegWired = (chainId: number, family: number, dex: string): boolean =>
124
+ family === DEX_FAMILY.v2 || (dexFamilyWired(family) && wiredLegOf(chainId, family, dex) !== null);
125
+
126
+ export const legTokenOf = (l: VenueLeg, native: boolean, token: string): string =>
127
+ native ? (l.weth ?? (l.nativeView as { token: string }).token) : checksumAddress(token);
128
+
129
+ const QUOTE_SIG: Readonly<Record<QuoteKind, string>> = {
130
+ fee: "quoteExactInputSingle((address,address,uint256,uint24,uint160))",
131
+ tick: "quoteExactInputSingle((address,address,uint256,int24,uint160))",
132
+ algebra: "quoteExactInputSingle((address,address,uint256,uint160))",
133
+ v4: "quoteExactInputSingle(((address,address,uint24,int24,address),bool,uint128,bytes))",
134
+ };
135
+
136
+ const v4PoolAt = (l: VenueLeg, key: number): { fee: number; tickSpacing: number } | null => {
137
+ const tickSpacing = l.v4TickOf?.[key];
138
+ return tickSpacing === undefined ? null : { fee: key, tickSpacing };
139
+ };
140
+
141
+ const firstWord = (hex: string): bigint | null => {
142
+ const h = hex.startsWith("0x") ? hex.slice(2) : hex;
143
+ if (h.length < 64) return null;
144
+ const out = BigInt("0x" + h.slice(0, 64));
145
+ return out > 0n ? out : null;
146
+ };
147
+
148
+ async function quoteAt(reads: VenueReads, l: VenueLeg, tokenIn: string, tokenOut: string, amountIn: bigint, key: number): Promise<bigint | null> {
149
+ try {
150
+ let data: string;
151
+ if (l.quoteKind === "v4") {
152
+ const pool = v4PoolAt(l, key);
153
+ if (pool === null || amountIn >= 1n << 128n) return null;
154
+ const { key: k, zeroForOne } = v4PoolKey(tokenIn, tokenOut, pool);
155
+ data = bytesToHex(encodeCall(QUOTE_SIG.v4, [[[k.currency0, k.currency1, BigInt(k.fee), BigInt(k.tickSpacing), k.hooks], zeroForOne, amountIn, "0x"]]));
156
+ } else {
157
+ const tail = l.quoteKind === "algebra" ? [] : [BigInt(key)];
158
+ data = bytesToHex(encodeCall(QUOTE_SIG[l.quoteKind], [[tokenIn, tokenOut, amountIn, ...tail, 0n]]));
159
+ }
160
+ return firstWord(await reads.simulate({ to: l.quoter, data }));
161
+ } catch {
162
+ return null;
163
+ }
164
+ }
165
+
166
+ export async function bestVenueHop(reads: VenueReads, l: VenueLeg, a: { fromNative: boolean; from: string; toNative: boolean; to: string; amountIn: bigint }): Promise<{ key: number; out: bigint } | null> {
167
+ if (a.fromNative && a.toNative) return null;
168
+ const tokenIn = legTokenOf(l, a.fromNative, a.from);
169
+ const tokenOut = legTokenOf(l, a.toNative, a.to);
170
+ if (tokenIn === tokenOut) return null;
171
+ const scale = l.nativeView?.scale ?? 1n;
172
+ if (a.fromNative && a.amountIn % scale !== 0n) return null;
173
+ const amountIn = a.fromNative ? a.amountIn / scale : a.amountIn;
174
+ if (amountIn <= 0n) return null;
175
+ const outs = await Promise.all(l.keys.map(async (key) => ({ key, out: await quoteAt(reads, l, tokenIn, tokenOut, amountIn, key) })));
176
+ let best: { key: number; out: bigint } | null = null;
177
+ for (const o of outs) if (o.out !== null && (best === null || o.out > best.out)) best = { key: o.key, out: o.out };
178
+ return best === null ? null : { key: best.key, out: a.toNative ? best.out * scale : best.out };
179
+ }
180
+
181
+ const UR_EXECUTE = "execute(bytes,bytes[],uint256)";
182
+ const SWAP_HEAD = ["address", "uint256", "uint256", "bytes", "bool"];
183
+ const cmdsHex = (cs: readonly number[]): string => "0x" + cs.map((c) => c.toString(16).padStart(2, "0")).join("");
184
+ const enc = (types: string[], values: unknown[]): string => bytesToHex(encodeAbi(types, values as never));
185
+ const call = (sig: string, values: unknown[]): string => bytesToHex(encodeCall(sig, values as never));
186
+
187
+ const V3_SWAP = "exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160))";
188
+ const R02_SWAP = "exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))";
189
+ const ALG_SWAP = "exactInputSingle((address,address,address,uint256,uint256,uint256,uint160))";
190
+
191
+ export interface LegCall { fromNative: boolean; from: string; toNative: boolean; to: string; key: number; amountIn: bigint; minOut: bigint; recipient: string; deadline: bigint }
192
+
193
+ export function venueLegData(l: VenueLeg, a: LegCall): string {
194
+ if (a.amountIn <= 0n || a.minOut <= 0n) throw new RangeError("a leg needs an amount and a minimum");
195
+ if (a.fromNative && a.toNative) throw new RangeError("a leg swaps the coin into itself");
196
+ const tokenIn = legTokenOf(l, a.fromNative, a.from);
197
+ const tokenOut = legTokenOf(l, a.toNative, a.to);
198
+ if (tokenIn === tokenOut) throw new RangeError("a leg swaps a coin into itself");
199
+ if (!l.keys.includes(a.key)) throw new RangeError("a leg at a key its venue does not ask");
200
+ const recipient = checksumAddress(a.recipient);
201
+ if (l.legKind === "ur-v4") {
202
+
203
+ const pool = v4PoolAt(l, a.key);
204
+ if (pool === null) throw new RangeError("a v4 leg at a key with no pool");
205
+ return zapSwapData({ family: "uniswap-ur", route: { tokens: [tokenIn, tokenOut], v4: pool }, amountIn: a.amountIn, minQuoteOut: a.minOut, zap: recipient, deadline: a.deadline });
206
+ }
207
+ if (l.legKind === "ur") {
208
+ const scale = l.nativeView?.scale ?? 1n;
209
+ if (a.fromNative && a.amountIn % scale !== 0n) throw new RangeError("a native amount the view cannot carry");
210
+ const amountIn = a.fromNative ? a.amountIn / scale : a.amountIn;
211
+
212
+ const minOut = a.toNative && l.nativeView ? (a.minOut + scale - 1n) / scale : a.minOut;
213
+ const wrap = l.weth !== null;
214
+ const path = v3Path([tokenIn, tokenOut], [(l.pathKey ?? ((k: number) => k))(a.key)]);
215
+ const swapTo = a.toNative && wrap ? UR_ADDRESS_THIS : UR_MSG_SENDER;
216
+ const head = [swapTo, amountIn, minOut, path, false];
217
+ const swap = l.urTail === "minHop" ? enc([...SWAP_HEAD, "uint256[]"], [...head, []]) : l.urTail === "isUni" ? enc([...SWAP_HEAD, "bool"], [...head, false]) : enc(SWAP_HEAD, head);
218
+ const cmds: number[] = [];
219
+ const inputs: string[] = [];
220
+ if (a.fromNative && wrap) { cmds.push(UR_WRAP_ETH); inputs.push(enc(["address", "uint256"], [UR_ADDRESS_THIS, amountIn])); }
221
+ cmds.push(UR_V3_SWAP_EXACT_IN); inputs.push(swap);
222
+ if (a.toNative && wrap) { cmds.push(UR_UNWRAP_WETH); inputs.push(enc(["address", "uint256"], [UR_MSG_SENDER, minOut])); }
223
+ return call(UR_EXECUTE, [cmdsHex(cmds), inputs, a.deadline]);
224
+ }
225
+
226
+ if (l.legKind === "algebra") {
227
+ const swap = (to: string): string => call(ALG_SWAP, [[tokenIn, tokenOut, to, a.deadline, a.amountIn, a.minOut, 0n]]);
228
+ if (!a.toNative) return swap(recipient);
229
+
230
+ return call("multicall(bytes[])", [[swap(V4_NATIVE), call("unwrapWNativeToken(uint256,address)", [a.minOut, recipient])]]);
231
+ }
232
+ if (l.legKind === "v3-router") {
233
+ const swap = (to: string): string => call(V3_SWAP, [[tokenIn, tokenOut, BigInt(a.key), to, a.deadline, a.amountIn, a.minOut, 0n]]);
234
+ if (!a.toNative) return swap(recipient);
235
+ return call("multicall(bytes[])", [[swap(l.router), call("unwrapWETH9(uint256,address)", [a.minOut, recipient])]]);
236
+ }
237
+ const swap = (to: string): string => call(R02_SWAP, [[tokenIn, tokenOut, BigInt(a.key), to, a.amountIn, a.minOut, 0n]]);
238
+ const calls = a.toNative ? [swap(UR_ADDRESS_THIS), call("unwrapWETH9(uint256,address)", [a.minOut, recipient])] : [swap(recipient)];
239
+ return call("multicall(uint256,bytes[])", [a.deadline, calls]);
240
+ }
241
+
242
+ export function uniswapLegData(top: { weth: string }, a: { tokenIn: string; tokenOut: string; nativeIn: boolean; nativeOut: boolean; fee: number; amountIn: bigint; minOut: bigint; deadline: bigint }): string {
243
+ if (a.amountIn <= 0n || a.minOut <= 0n) throw new RangeError("a Uniswap leg needs an amount and a minimum");
244
+ if (a.nativeIn && a.nativeOut) throw new RangeError("a Uniswap leg swaps the coin into itself");
245
+ const tokenIn = a.nativeIn ? checksumAddress(top.weth) : checksumAddress(a.tokenIn);
246
+ const tokenOut = a.nativeOut ? checksumAddress(top.weth) : checksumAddress(a.tokenOut);
247
+ if (tokenIn === tokenOut) throw new RangeError("a Uniswap leg swaps a coin into itself");
248
+ const swapTo = a.nativeOut ? UR_ADDRESS_THIS : UR_MSG_SENDER;
249
+ const swap = enc([...SWAP_HEAD, "uint256[]"], [swapTo, a.amountIn, a.minOut, v3Path([tokenIn, tokenOut], [a.fee]), false, []]);
250
+ const cmds: number[] = [];
251
+ const inputs: string[] = [];
252
+ if (a.nativeIn) { cmds.push(UR_WRAP_ETH); inputs.push(enc(["address", "uint256"], [UR_ADDRESS_THIS, a.amountIn])); }
253
+ cmds.push(UR_V3_SWAP_EXACT_IN); inputs.push(swap);
254
+ if (a.nativeOut) { cmds.push(UR_UNWRAP_WETH); inputs.push(enc(["address", "uint256"], [UR_MSG_SENDER, a.minOut])); }
255
+ return call(UR_EXECUTE, [cmdsHex(cmds), inputs, a.deadline]);
256
+ }
257
+
258
+ export interface DexEdgeRaw { readonly provider: "dex"; readonly family: number; readonly dex: string; readonly path: readonly string[]; readonly from: string; readonly to: string; readonly chainId?: number; readonly key?: number }
259
+ export const isDexEdgeRaw = (raw: unknown): raw is DexEdgeRaw =>
260
+ typeof raw === "object" && raw !== null && (raw as { provider?: unknown }).provider === "dex";
261
+
262
+ export interface DexEdgeRow { chainId: number; router: string; family: number }
263
+
264
+ const isNative = (coin: string): boolean => coinKey(coin) === EVM_NATIVE;
265
+
266
+ export function legMinOut(out: bigint, slippageBps: number): bigint {
267
+ const m = (out * BigInt(10_000 - slippageBps)) / 10_000n;
268
+ return m > 0n ? m : 1n;
269
+ }
270
+
271
+ const WETH_CACHE = new WeakMap<object, Map<string, Promise<string>>>();
272
+
273
+ function v2WethOf(reads: VenueReads, dex: string): Promise<string> {
274
+ let m = WETH_CACHE.get(reads);
275
+ if (m === undefined) { m = new Map(); WETH_CACHE.set(reads, m); }
276
+ const k = dex.toLowerCase();
277
+ let hit = m.get(k);
278
+ if (hit === undefined) {
279
+ hit = reads.call({ to: dex, data: call("WETH()", []) }).then((h) => checksumAddress(decodeAbi(["address"], h)[0] as string));
280
+ m.set(k, hit);
281
+ const mm = m;
282
+ hit.catch(() => { mm.delete(k); });
283
+ }
284
+ return hit;
285
+ }
286
+
287
+ async function v2PathOf(reads: VenueReads, dex: string, from: string, to: string): Promise<string[]> {
288
+ const weth = isNative(from) || isNative(to) ? await v2WethOf(reads, dex) : null;
289
+ const tok = (c: string): string => (isNative(c) ? (weth as string) : checksumAddress(c));
290
+ const path = [tok(from), tok(to)];
291
+ if (path[0] === path[1]) throw new RangeError("the edge leg swaps a coin into itself");
292
+ return path;
293
+ }
294
+
295
+ function v2EdgeQuoter(reads: VenueReads, dex: string): EdgeQuoter {
296
+ return async (req): Promise<EdgeQuote> => {
297
+ const path = await v2PathOf(reads, dex, req.from, req.to);
298
+ const amounts = decodeAbi(["uint256[]"], await reads.call({ to: dex, data: call("getAmountsOut(uint256,address[])", [req.amountIn, path]) }))[0] as bigint[];
299
+ const out = amounts[amounts.length - 1] ?? 0n;
300
+ if (amounts.length !== path.length || amounts[0] !== req.amountIn || out <= 0n) throw new RangeError("no edge route");
301
+ const raw: DexEdgeRaw = { provider: "dex", family: DEX_FAMILY.v2, dex, path, from: req.from, to: req.to };
302
+ return { inAmount: req.amountIn, outAmount: out, minOut: legMinOut(out, req.slippageBps), raw };
303
+ };
304
+ }
305
+
306
+ function venueEdgeQuoter(reads: VenueReads, row: DexEdgeRow): EdgeQuoter {
307
+ return async (req): Promise<EdgeQuote> => {
308
+ const l = wiredLegOf(row.chainId, row.family, row.router);
309
+ if (l === null) throw new RangeError("no edge route");
310
+ const fromNative = isNative(req.from), toNative = isNative(req.to);
311
+ const path = [legTokenOf(l, fromNative, req.from), legTokenOf(l, toNative, req.to)];
312
+ if (path[0] === path[1]) throw new RangeError("the edge leg swaps a coin into itself");
313
+ const hop = await bestVenueHop(reads, l, { fromNative, from: path[0], toNative, to: path[1], amountIn: req.amountIn });
314
+ if (hop === null) throw new RangeError("no edge route");
315
+ const raw: DexEdgeRaw = { provider: "dex", family: row.family, dex: l.router, path, from: req.from, to: req.to, chainId: row.chainId, key: hop.key };
316
+ return { inAmount: req.amountIn, outAmount: hop.out, minOut: legMinOut(hop.out, req.slippageBps), raw };
317
+ };
318
+ }
319
+
320
+ export function dexEdgeQuoter(row: DexEdgeRow, reads: VenueReads): EdgeQuoter {
321
+ return row.family === DEX_FAMILY.v2 ? v2EdgeQuoter(reads, row.router) : venueEdgeQuoter(reads, row);
322
+ }
323
+
324
+ const V2_ETH_FOR_TOKENS = "swapExactETHForTokens(uint256,address[],address,uint256)";
325
+ const V2_TOKENS_FOR_TOKENS = "swapExactTokensForTokens(uint256,uint256,address[],address,uint256)";
326
+ const V2_TOKENS_FOR_ETH = "swapExactTokensForETH(uint256,uint256,address[],address,uint256)";
327
+
328
+ export function dexSwapData(raw: unknown, p: { amountIn: bigint; minOut: bigint; recipient: string; deadline: bigint }): string {
329
+ if (!isDexEdgeRaw(raw) || !dexFamilyWired(raw.family)) throw new RangeError("edge build refused");
330
+ if (p.amountIn <= 0n || p.minOut <= 0n) throw new RangeError("edge build refused");
331
+ if (raw.family !== DEX_FAMILY.v2) {
332
+ const l = raw.chainId === undefined ? null : wiredLegOf(raw.chainId, raw.family, raw.dex);
333
+ if (l === null || raw.key === undefined || raw.path.length !== 2) throw new RangeError("edge build refused");
334
+ return venueLegData(l, { fromNative: isNative(raw.from), from: raw.path[0], toNative: isNative(raw.to), to: raw.path[1], key: raw.key, amountIn: p.amountIn, minOut: p.minOut, recipient: p.recipient, deadline: p.deadline });
335
+ }
336
+ const path = [...raw.path];
337
+ if (isNative(raw.from)) return call(V2_ETH_FOR_TOKENS, [p.minOut, path, p.recipient, p.deadline]);
338
+ if (isNative(raw.to)) return call(V2_TOKENS_FOR_ETH, [p.amountIn, p.minOut, path, p.recipient, p.deadline]);
339
+ return call(V2_TOKENS_FOR_TOKENS, [p.amountIn, p.minOut, path, p.recipient, p.deadline]);
340
+ }
@@ -18,17 +18,17 @@ export interface EvmFunctionSelectorRow {
18
18
  }
19
19
 
20
20
  export const EVM_FUNCTION_SELECTORS: readonly EvmFunctionSelectorRow[] = [
21
- { name: "acceptAuthority", signature: "acceptAuthority()", selector: "0x1580798f", sources: ["floorAmm"] },
22
- { name: "accounted", signature: "accounted(address)", selector: "0xee1a56ce", sources: ["floorAmm"] },
21
+ { name: "acceptAuthority", signature: "acceptAuthority()", selector: "0x1580798f", sources: ["floorAmm","floorAmmGovV2"] },
22
+ { name: "accounted", signature: "accounted(address)", selector: "0xee1a56ce", sources: ["floorAmm","floorAmmGovV2"] },
23
23
  { name: "addPreset", signature: "addPreset(uint8,bytes)", selector: "0xb88257b1", sources: ["floorAmm"] },
24
- { name: "addQuote", signature: "addQuote(address,uint256,uint256)", selector: "0x488c664b", sources: ["floorAmm"] },
24
+ { name: "addQuote", signature: "addQuote(address,uint256,uint256)", selector: "0x488c664b", sources: ["floorAmm","floorAmmGovV2"] },
25
25
  { name: "addReward", signature: "addReward(uint256)", selector: "0x74de4ec4", sources: ["floorTokenIndexed"] },
26
26
  { name: "allowance", signature: "allowance(address,address)", selector: "0xdd62ed3e", sources: ["floorToken","floorTokenIndexed"] },
27
27
  { name: "approve", signature: "approve(address,uint256)", selector: "0x095ea7b3", sources: ["floorToken","floorTokenIndexed"] },
28
- { name: "authority", signature: "authority()", selector: "0xbf7e214f", sources: ["floorAmm"] },
28
+ { name: "authority", signature: "authority()", selector: "0xbf7e214f", sources: ["floorAmm","floorAmmGovV2"] },
29
29
  { name: "balanceOf", signature: "balanceOf(address)", selector: "0x70a08231", sources: ["floorToken","floorTokenIndexed"] },
30
30
  { name: "bidMoney", signature: "bidMoney(uint256)", selector: "0x8e403c51", sources: ["floorAmmViewsV2"] },
31
- { name: "bindHandle", signature: "bindHandle(bytes32,address,address[],uint256,bytes,bytes)", selector: "0xcea3463e", sources: ["floorAmm"] },
31
+ { name: "bindHandle", signature: "bindHandle(bytes32,address,address[],uint256,bytes,bytes)", selector: "0xcea3463e", sources: ["floorAmm","floorAmmGovV2"] },
32
32
  { name: "bookEngine", signature: "bookEngine()", selector: "0x72148c77", sources: ["floorAmmV2"] },
33
33
  { name: "bookState", signature: "bookState()", selector: "0x2c14e3f2", sources: ["floorTokenIndexed"] },
34
34
  { name: "bookTotals", signature: "bookTotals()", selector: "0xbffc2073", sources: ["floorTokenIndexed"] },
@@ -36,32 +36,49 @@ export const EVM_FUNCTION_SELECTORS: readonly EvmFunctionSelectorRow[] = [
36
36
  { name: "burnFrom", signature: "burnFrom(address,uint256)", selector: "0x79cc6790", sources: ["floorToken","floorTokenIndexed"] },
37
37
  { name: "burnTeamV2", signature: "burnTeamV2(uint256,uint8,uint256)", selector: "0x2f7bf11b", sources: ["floorAmmClaimsV2"] },
38
38
  { name: "buy", signature: "buy(uint256,uint256,uint256,address,uint256)", selector: "0x102d8c79", sources: ["floorAmm","floorAmmV2"] },
39
+ { name: "buyFor", signature: "buyFor(uint256,uint256,uint256,address,uint256,address)", selector: "0x67105875", sources: ["floorAmm","floorAmmV2"] },
39
40
  { name: "buyFromBalance", signature: "buyFromBalance(uint256,uint256,address,address,uint256)", selector: "0x5f9f56d2", sources: ["floorAmm","floorAmmV2"] },
41
+ { name: "buyFromBalanceFor", signature: "buyFromBalanceFor(uint256,uint256,address,address,uint256,address)", selector: "0xbb6cda49", sources: ["floorAmm","floorAmmV2"] },
40
42
  { name: "buyWithEth", signature: "buyWithEth(uint256,bytes,uint256,uint256,address,uint256)", selector: "0xef8772c4", sources: ["floorZap"] },
41
43
  { name: "buyWithToken", signature: "buyWithToken(uint256,address,uint256,bytes,uint256,uint256,address,uint256)", selector: "0x9fd30605", sources: ["floorZap"] },
42
44
  { name: "checkPreset", signature: "checkPreset(bytes)", selector: "0x6337513e", sources: ["floorAmm"] },
43
45
  { name: "circulatingOf", signature: "circulatingOf(uint256)", selector: "0x72812fcf", sources: ["floorAmmViewsV2"] },
44
46
  { name: "claim", signature: "claim(address,uint256,uint256[],address[])", selector: "0xa461a90d", sources: ["floorAmm","floorAmmClaimsV2"] },
45
- { name: "claimPayoutTo", signature: "claimPayoutTo(address,address)", selector: "0xc14ab75d", sources: ["floorAmm"] },
46
- { name: "clearTraderRef", signature: "clearTraderRef(address)", selector: "0x53550430", sources: ["floorAmm"] },
47
+ { name: "claimPayoutTo", signature: "claimPayoutTo(address,address)", selector: "0xc14ab75d", sources: ["floorAmm","floorAmmGovV2"] },
48
+ { name: "clearTraderRef", signature: "clearTraderRef(address)", selector: "0x53550430", sources: ["floorAmm","floorAmmGovV2"] },
47
49
  { name: "createBookEngine", signature: "createBookEngine()", selector: "0x0fdf26a7", sources: ["floorAmmCreateV2"] },
48
50
  { name: "createLaunch", signature: "createLaunch((uint8,address,string,string,uint256,uint256,bool,bytes32,uint256,uint16))", selector: "0x25b62f18", sources: ["floorAmm","floorAmmCreateV2"] },
49
- { name: "createPaused", signature: "createPaused()", selector: "0xbac7b497", sources: ["floorAmm"] },
51
+ { name: "createPaused", signature: "createPaused()", selector: "0xbac7b497", sources: ["floorAmm","floorAmmGovV2"] },
50
52
  { name: "creditBacking", signature: "creditBacking(uint256,uint256)", selector: "0x1f341504", sources: ["floorAmmV2"] },
53
+ { name: "creditPlatform", signature: "creditPlatform(uint256,uint256,bytes32)", selector: "0x93fe58a2", sources: ["floorAmm","floorAmmV2"] },
51
54
  { name: "DEAD", signature: "DEAD()", selector: "0x03fd2a45", sources: ["floorTokenIndexed"] },
55
+ { name: "dealEscrowArm", signature: "dealEscrowArm(bytes32,uint8)", selector: "0x3fe96415", sources: ["floorAmm","floorAmmClaimsV2"] },
56
+ { name: "dealEscrowArmV3", signature: "dealEscrowArmV3(bytes32,uint8)", selector: "0x32037a0e", sources: ["floorAmm","floorAmmClaimsV2"] },
57
+ { name: "dealEscrowCancel", signature: "dealEscrowCancel(bytes32)", selector: "0x16d11c50", sources: ["floorAmm","floorAmmViewsV2"] },
58
+ { name: "dealEscrowMarketCap", signature: "dealEscrowMarketCap(uint256)", selector: "0x96cefeb9", sources: ["floorAmm","floorAmmViewsV2"] },
59
+ { name: "dealEscrowObject", signature: "dealEscrowObject(bytes32,uint8)", selector: "0xd8071cc0", sources: ["floorAmm","floorAmmViewsV2"] },
60
+ { name: "dealEscrowOf", signature: "dealEscrowOf(bytes32)", selector: "0x2a144918", sources: ["floorAmm","floorAmmViewsV2"] },
61
+ { name: "dealEscrowOpen", signature: "dealEscrowOpen(uint256,address,bytes32,bool,uint256[],uint256[],int64)", selector: "0xe279a5e8", sources: ["floorAmm","floorAmmClaimsV2"] },
62
+ { name: "dealEscrowOpenV3", signature: "dealEscrowOpenV3(uint256,address,bytes32,bool,(uint8[],uint256[],uint256[],uint8,address,uint16,int64))", selector: "0xa1330ee1", sources: ["floorAmm","floorAmmClaimsV2"] },
63
+ { name: "dealEscrowRefund", signature: "dealEscrowRefund(bytes32)", selector: "0x947a9b41", sources: ["floorAmm","floorAmmClaimsV2"] },
64
+ { name: "dealEscrowRelease", signature: "dealEscrowRelease(bytes32,uint8)", selector: "0xcd129e2e", sources: ["floorAmm","floorAmmClaimsV2"] },
65
+ { name: "dealEscrowReleaseV3", signature: "dealEscrowReleaseV3(bytes32,uint8)", selector: "0xb25894ac", sources: ["floorAmm","floorAmmClaimsV2"] },
66
+ { name: "dealEscrowSubmitProof", signature: "dealEscrowSubmitProof(bytes32,uint8,bytes32)", selector: "0x236f5ea6", sources: ["floorAmm","floorAmmViewsV2"] },
67
+ { name: "dealEscrowV3Of", signature: "dealEscrowV3Of(bytes32)", selector: "0xaffbc4bb", sources: ["floorAmm","floorAmmViewsV2"] },
68
+ { name: "dealFeeCapBps", signature: "dealFeeCapBps()", selector: "0xfd066b8a", sources: ["floorAmm","floorAmmGovV2"] },
52
69
  { name: "decimals", signature: "decimals()", selector: "0x313ce567", sources: ["floorToken","floorTokenIndexed"] },
53
70
  { name: "decodeRow", signature: "decodeRow(bytes)", selector: "0x8fff698d", sources: ["floorAmmCreateV2"] },
54
71
  { name: "deletePreset", signature: "deletePreset(uint8)", selector: "0xb2d0d2a5", sources: ["floorAmm"] },
55
72
  { name: "DOMAIN_SEPARATOR", signature: "DOMAIN_SEPARATOR()", selector: "0x3644e515", sources: ["floorToken","floorTokenIndexed"] },
56
73
  { name: "eip712Domain", signature: "eip712Domain()", selector: "0x84b0196e", sources: ["floorTokenIndexed"] },
57
74
  { name: "floorAmm", signature: "floorAmm()", selector: "0x78164d52", sources: ["floorZap"] },
58
- { name: "floorTokenAccrued", signature: "floorTokenAccrued(address)", selector: "0xf3a261f9", sources: ["floorAmm"] },
59
- { name: "handleOwed", signature: "handleOwed(bytes32,address)", selector: "0xaad2ed5c", sources: ["floorAmm"] },
60
- { name: "handleWallet", signature: "handleWallet(bytes32)", selector: "0xc6da686d", sources: ["floorAmm"] },
75
+ { name: "floorTokenAccrued", signature: "floorTokenAccrued(address)", selector: "0xf3a261f9", sources: ["floorAmm","floorAmmGovV2"] },
76
+ { name: "handleOwed", signature: "handleOwed(bytes32,address)", selector: "0xaad2ed5c", sources: ["floorAmm","floorAmmGovV2"] },
77
+ { name: "handleWallet", signature: "handleWallet(bytes32)", selector: "0xc6da686d", sources: ["floorAmm","floorAmmGovV2"] },
61
78
  { name: "holderBook", signature: "holderBook(uint256)", selector: "0xf5d23b14", sources: ["floorAmmViewsV2"] },
62
- { name: "holderBucket", signature: "holderBucket(address)", selector: "0x088806d0", sources: ["floorAmm"] },
63
- { name: "holderDest", signature: "holderDest()", selector: "0x84a6263a", sources: ["floorAmm"] },
64
- { name: "initialize", signature: "initialize(address,address,address,address)", selector: "0xf8c8765e", sources: ["floorAmm"] },
79
+ { name: "holderBucket", signature: "holderBucket(address)", selector: "0x088806d0", sources: ["floorAmm","floorAmmGovV2"] },
80
+ { name: "holderDest", signature: "holderDest()", selector: "0x84a6263a", sources: ["floorAmm","floorAmmGovV2"] },
81
+ { name: "initialize", signature: "initialize(address,address,address,address)", selector: "0xf8c8765e", sources: ["floorAmm","floorAmmGovV2"] },
65
82
  { name: "initialize", signature: "initialize(string,string,uint256)", selector: "0xb119490e", sources: ["floorTokenIndexed"] },
66
83
  { name: "launchBook", signature: "launchBook(uint256)", selector: "0x926310f1", sources: ["floorAmmViewsV2"] },
67
84
  { name: "launchCount", signature: "launchCount()", selector: "0x27cca59f", sources: ["floorAmm","floorAmmViewsV2"] },
@@ -73,56 +90,85 @@ export const EVM_FUNCTION_SELECTORS: readonly EvmFunctionSelectorRow[] = [
73
90
  { name: "launchQuote", signature: "launchQuote(uint256)", selector: "0x98032919", sources: ["floorAmm","floorAmmViewsV2"] },
74
91
  { name: "launchState", signature: "launchState(uint256)", selector: "0xac3307e8", sources: ["floorAmm","floorAmmViewsV2"] },
75
92
  { name: "launchToken", signature: "launchToken(uint256)", selector: "0x6a19197b", sources: ["floorAmm","floorAmmViewsV2"] },
76
- { name: "metadataBase", signature: "metadataBase()", selector: "0x65b973c3", sources: ["floorAmm"] },
93
+ { name: "metadataBase", signature: "metadataBase()", selector: "0x65b973c3", sources: ["floorAmm","floorAmmGovV2"] },
77
94
  { name: "metadataURI", signature: "metadataURI()", selector: "0x03ee438c", sources: ["floorToken","floorTokenIndexed"] },
78
- { name: "moveHandleOwed", signature: "moveHandleOwed(bytes32,address[])", selector: "0xc43594a1", sources: ["floorAmm"] },
95
+ { name: "moveHandleOwed", signature: "moveHandleOwed(bytes32,address[])", selector: "0xc43594a1", sources: ["floorAmm","floorAmmGovV2"] },
79
96
  { name: "name", signature: "name()", selector: "0x06fdde03", sources: ["floorToken","floorTokenIndexed"] },
80
- { name: "NATIVE", signature: "NATIVE()", selector: "0xa0cf0aea", sources: ["floorAmm"] },
81
- { name: "nativeCreateFee", signature: "nativeCreateFee()", selector: "0x10b51e45", sources: ["floorAmm"] },
82
- { name: "nextModule", signature: "nextModule()", selector: "0xf85abfc7", sources: ["floorAmmV2","floorAmmViewsV2","floorAmmCreateV2","floorAmmClaimsV2"] },
97
+ { name: "NATIVE", signature: "NATIVE()", selector: "0xa0cf0aea", sources: ["floorAmm","floorAmmGovV2"] },
98
+ { name: "nativeCreateFee", signature: "nativeCreateFee()", selector: "0x10b51e45", sources: ["floorAmm","floorAmmGovV2"] },
99
+ { name: "nextModule", signature: "nextModule()", selector: "0xf85abfc7", sources: ["floorAmmV2","floorAmmViewsV2","floorAmmCreateV2","floorAmmClaimsV2","floorAmmOfficeV2"] },
83
100
  { name: "nextPresetId", signature: "nextPresetId()", selector: "0xc8a768e6", sources: ["floorAmm"] },
84
101
  { name: "nonces", signature: "nonces(address)", selector: "0x7ecebe00", sources: ["floorToken","floorTokenIndexed"] },
85
102
  { name: "noteBurn", signature: "noteBurn(uint256)", selector: "0x6db7cd01", sources: ["floorAmmCreateV2"] },
86
103
  { name: "noteDead", signature: "noteDead(uint256)", selector: "0xbdf3b0de", sources: ["floorAmmCreateV2"] },
104
+ { name: "noteMove", signature: "noteMove(address,address,uint256,uint256,uint256)", selector: "0xe6b761ea", sources: ["floorAmmV2"] },
105
+ { name: "officeAcceptController", signature: "officeAcceptController(bytes32)", selector: "0x94a408e4", sources: ["floorAmm","floorAmmOfficeV2"] },
106
+ { name: "officeAcceptMerge", signature: "officeAcceptMerge(bytes32,bytes32,address)", selector: "0x5b134957", sources: ["floorAmm","floorAmmOfficeV2"] },
107
+ { name: "officeAddMember", signature: "officeAddMember(bytes32,address)", selector: "0xe65ac3d9", sources: ["floorAmm","floorAmmOfficeV2"] },
108
+ { name: "officeBuy", signature: "officeBuy(bytes32,uint256,uint256,uint256)", selector: "0xad7e22ec", sources: ["floorAmm","floorAmmOfficeV2"] },
109
+ { name: "officeCancelMerge", signature: "officeCancelMerge(bytes32)", selector: "0x009048f9", sources: ["floorAmm","floorAmmOfficeV2"] },
110
+ { name: "officeDeposit", signature: "officeDeposit(bytes32,uint256)", selector: "0x303a9f22", sources: ["floorAmm","floorAmmOfficeV2"] },
111
+ { name: "officeLeave", signature: "officeLeave(bytes32)", selector: "0xa3c22110", sources: ["floorAmm","floorAmmOfficeV2"] },
112
+ { name: "officeMemberOf", signature: "officeMemberOf(bytes32,address)", selector: "0x17883590", sources: ["floorAmm","floorAmmOfficeV2"] },
113
+ { name: "officeMergeStep", signature: "officeMergeStep(bytes32)", selector: "0x8c2973f8", sources: ["floorAmm","floorAmmOfficeV2"] },
114
+ { name: "officeOf", signature: "officeOf(bytes32)", selector: "0x525c1680", sources: ["floorAmm","floorAmmOfficeV2"] },
115
+ { name: "officeOpen", signature: "officeOpen(bytes32,address)", selector: "0x749cd130", sources: ["floorAmm","floorAmmOfficeV2"] },
116
+ { name: "officeProposeController", signature: "officeProposeController(bytes32,address)", selector: "0x7dc27095", sources: ["floorAmm","floorAmmOfficeV2"] },
117
+ { name: "officeProposeMerge", signature: "officeProposeMerge(bytes32,bytes32,address)", selector: "0x95660c91", sources: ["floorAmm","floorAmmOfficeV2"] },
118
+ { name: "officeRemoveMember", signature: "officeRemoveMember(bytes32,address)", selector: "0xf1b0f92d", sources: ["floorAmm","floorAmmOfficeV2"] },
119
+ { name: "officeSell", signature: "officeSell(bytes32,uint256,address,uint256,uint256)", selector: "0x6b8325c5", sources: ["floorAmm","floorAmmOfficeV2"] },
120
+ { name: "officeSetShare", signature: "officeSetShare(bytes32,address,uint16)", selector: "0x1569850a", sources: ["floorAmm","floorAmmOfficeV2"] },
121
+ { name: "officeValue", signature: "officeValue(bytes32)", selector: "0x7f2683e3", sources: ["floorAmm","floorAmmOfficeV2"] },
122
+ { name: "ogCount", signature: "ogCount()", selector: "0x9457990a", sources: ["floorAmmGovV2"] },
123
+ { name: "ogUserOf", signature: "ogUserOf(address)", selector: "0x6df29e2f", sources: ["floorAmmGovV2"] },
87
124
  { name: "optedIn", signature: "optedIn(address)", selector: "0x4824b8fd", sources: ["floorTokenIndexed"] },
88
125
  { name: "optIn", signature: "optIn()", selector: "0x5b48684e", sources: ["floorTokenIndexed"] },
89
- { name: "owedOf", signature: "owedOf(address,address)", selector: "0xfacba08d", sources: ["floorAmm"] },
90
- { name: "owedOfMany", signature: "owedOfMany(address,address[])", selector: "0xa1efa4ba", sources: ["floorAmm"] },
126
+ { name: "owedOf", signature: "owedOf(address,address)", selector: "0xfacba08d", sources: ["floorAmm","floorAmmGovV2"] },
127
+ { name: "owedOfMany", signature: "owedOfMany(address,address[])", selector: "0xa1efa4ba", sources: ["floorAmm","floorAmmGovV2"] },
91
128
  { name: "owedV2", signature: "owedV2(address,uint256[],address[])", selector: "0xdd3ee1ef", sources: ["floorAmmViewsV2"] },
92
129
  { name: "pairIdOf", signature: "pairIdOf(uint256)", selector: "0x83a74ea3", sources: ["floorAmmViewsV2"] },
93
- { name: "payoutOwed", signature: "payoutOwed(address,address)", selector: "0xae3f9120", sources: ["floorAmm"] },
94
- { name: "pendingAuthority", signature: "pendingAuthority()", selector: "0xfabb94bb", sources: ["floorAmm"] },
130
+ { name: "payoutOwed", signature: "payoutOwed(address,address)", selector: "0xae3f9120", sources: ["floorAmm","floorAmmGovV2"] },
131
+ { name: "pendingAuthority", signature: "pendingAuthority()", selector: "0xfabb94bb", sources: ["floorAmm","floorAmmGovV2"] },
95
132
  { name: "permit", signature: "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)", selector: "0xd505accf", sources: ["floorToken","floorTokenIndexed"] },
96
- { name: "platformOwed", signature: "platformOwed(address)", selector: "0x240b9586", sources: ["floorAmm"] },
133
+ { name: "platformOwed", signature: "platformOwed(address)", selector: "0x240b9586", sources: ["floorAmm","floorAmmGovV2"] },
97
134
  { name: "positionOf", signature: "positionOf(address)", selector: "0xfd2d39c5", sources: ["floorTokenIndexed"] },
98
135
  { name: "predictToken", signature: "predictToken(address,bytes32)", selector: "0x486e36c8", sources: ["floorAmm","floorAmmCreateV2"] },
99
136
  { name: "presetRow", signature: "presetRow(uint8)", selector: "0xa0c15861", sources: ["floorAmm"] },
100
- { name: "priceUpdater", signature: "priceUpdater()", selector: "0xfc612a8d", sources: ["floorAmm"] },
137
+ { name: "priceUpdater", signature: "priceUpdater()", selector: "0xfc612a8d", sources: ["floorAmm","floorAmmGovV2"] },
101
138
  { name: "program", signature: "program()", selector: "0xc860ebc6", sources: ["floorToken","floorTokenIndexed"] },
102
139
  { name: "proxiableUUID", signature: "proxiableUUID()", selector: "0x52d1902d", sources: ["floorAmmV2"] },
103
140
  { name: "quoteBuy", signature: "quoteBuy(uint256,uint256,address)", selector: "0xec7a34c9", sources: ["floorAmm","floorAmmV2"] },
104
- { name: "quoteEntry", signature: "quoteEntry(address)", selector: "0x77665076", sources: ["floorAmm"] },
105
- { name: "quoteRisk", signature: "quoteRisk(address)", selector: "0x1461d14e", sources: ["floorAmm"] },
106
- { name: "quotes", signature: "quotes()", selector: "0xd6a5d7db", sources: ["floorAmm"] },
141
+ { name: "quoteEntry", signature: "quoteEntry(address)", selector: "0x77665076", sources: ["floorAmm","floorAmmGovV2"] },
142
+ { name: "quoteRisk", signature: "quoteRisk(address)", selector: "0x1461d14e", sources: ["floorAmm","floorAmmGovV2"] },
143
+ { name: "quotes", signature: "quotes()", selector: "0xd6a5d7db", sources: ["floorAmm","floorAmmGovV2"] },
107
144
  { name: "quoteSell", signature: "quoteSell(uint256,uint256,address)", selector: "0x0cff08d1", sources: ["floorAmm","floorAmmV2"] },
108
- { name: "referralAuthority", signature: "referralAuthority()", selector: "0x2fe0a99a", sources: ["floorAmm"] },
145
+ { name: "referralAuthority", signature: "referralAuthority()", selector: "0x2fe0a99a", sources: ["floorAmm","floorAmmGovV2"] },
146
+ { name: "refVolume", signature: "refVolume(uint256,address)", selector: "0xe6a32581", sources: ["floorAmm","floorAmmViewsV2"] },
147
+ { name: "relayBook", signature: "relayBook(uint256)", selector: "0xd1f6ab70", sources: ["floorAmmV2"] },
148
+ { name: "relayBooks", signature: "relayBooks(uint256,uint256)", selector: "0xcf90be94", sources: ["floorAmmV2"] },
109
149
  { name: "releaseSkipped", signature: "releaseSkipped(address)", selector: "0x215fa9eb", sources: ["floorTokenIndexed"] },
150
+ { name: "revokeOgUser", signature: "revokeOgUser(address)", selector: "0x52e52ecc", sources: ["floorAmmGovV2"] },
151
+ { name: "roomOf", signature: "roomOf()", selector: "0x7a0be43c", sources: ["floorAmmV2"] },
110
152
  { name: "router", signature: "router()", selector: "0xf887ea40", sources: ["floorZap"] },
153
+ { name: "routerDeployer", signature: "routerDeployer()", selector: "0xe8381015", sources: ["floorAmm","floorAmmV2"] },
111
154
  { name: "sell", signature: "sell(uint256,uint256,uint256,address,uint256)", selector: "0xbadb999b", sources: ["floorAmm","floorAmmV2"] },
112
155
  { name: "sellFromBalance", signature: "sellFromBalance(uint256,uint256,address,uint256)", selector: "0x611b00a8", sources: ["floorAmm","floorAmmV2"] },
156
+ { name: "sellFromBalanceFor", signature: "sellFromBalanceFor(uint256,uint256,address,uint256,address)", selector: "0x54590af6", sources: ["floorAmm","floorAmmV2"] },
113
157
  { name: "sellWithPermit", signature: "sellWithPermit(uint256,uint256,uint256,address,uint256,uint256,uint8,bytes32,bytes32)", selector: "0x2ab030d3", sources: ["floorAmm","floorAmmV2"] },
114
- { name: "setCreatePaused", signature: "setCreatePaused(bool)", selector: "0x83bcec85", sources: ["floorAmm"] },
115
- { name: "setHolderDest", signature: "setHolderDest(address)", selector: "0x6ad3e66d", sources: ["floorAmm"] },
116
- { name: "setMetadataBase", signature: "setMetadataBase(string)", selector: "0xd3811c0f", sources: ["floorAmm"] },
117
- { name: "setNativeCreateFee", signature: "setNativeCreateFee(uint256)", selector: "0xa4433667", sources: ["floorAmm"] },
158
+ { name: "setCreatePaused", signature: "setCreatePaused(bool)", selector: "0x83bcec85", sources: ["floorAmm","floorAmmGovV2"] },
159
+ { name: "setDealFeeCap", signature: "setDealFeeCap(uint16)", selector: "0x041a4410", sources: ["floorAmm","floorAmmGovV2"] },
160
+ { name: "setHolderDest", signature: "setHolderDest(address)", selector: "0x6ad3e66d", sources: ["floorAmm","floorAmmGovV2"] },
161
+ { name: "setMetadataBase", signature: "setMetadataBase(string)", selector: "0xd3811c0f", sources: ["floorAmm","floorAmmGovV2"] },
162
+ { name: "setNativeCreateFee", signature: "setNativeCreateFee(uint256)", selector: "0xa4433667", sources: ["floorAmm","floorAmmGovV2"] },
163
+ { name: "setOgUser", signature: "setOgUser(address,uint256,bytes)", selector: "0x02cb4469", sources: ["floorAmmGovV2"] },
118
164
  { name: "setPresetEnabled", signature: "setPresetEnabled(uint8,bool)", selector: "0x673fb9a9", sources: ["floorAmm"] },
119
- { name: "setPriceUpdater", signature: "setPriceUpdater(address)", selector: "0x97c4a5f3", sources: ["floorAmm"] },
120
- { name: "setQuoteCap", signature: "setQuoteCap(address,uint128)", selector: "0x42adf398", sources: ["floorAmm"] },
121
- { name: "setQuotePrice", signature: "setQuotePrice(address,uint256)", selector: "0x3857ed9e", sources: ["floorAmm"] },
122
- { name: "setReferralAuthority", signature: "setReferralAuthority(address)", selector: "0x46325d7a", sources: ["floorAmm"] },
123
- { name: "setTimelock", signature: "setTimelock(address)", selector: "0xbdacb303", sources: ["floorAmm"] },
124
- { name: "setTraderRef", signature: "setTraderRef(address,address[3],uint256,bytes,bytes)", selector: "0xd7426758", sources: ["floorAmm"] },
125
- { name: "setTreasury", signature: "setTreasury(address)", selector: "0xf0f44260", sources: ["floorAmm"] },
165
+ { name: "setPriceUpdater", signature: "setPriceUpdater(address)", selector: "0x97c4a5f3", sources: ["floorAmm","floorAmmGovV2"] },
166
+ { name: "setQuoteCap", signature: "setQuoteCap(address,uint128)", selector: "0x42adf398", sources: ["floorAmm","floorAmmGovV2"] },
167
+ { name: "setQuotePrice", signature: "setQuotePrice(address,uint256)", selector: "0x3857ed9e", sources: ["floorAmm","floorAmmGovV2"] },
168
+ { name: "setReferralAuthority", signature: "setReferralAuthority(address)", selector: "0x46325d7a", sources: ["floorAmm","floorAmmGovV2"] },
169
+ { name: "setTimelock", signature: "setTimelock(address)", selector: "0xbdacb303", sources: ["floorAmm","floorAmmGovV2"] },
170
+ { name: "setTraderRef", signature: "setTraderRef(address,address[3],uint256,bytes,bytes)", selector: "0xd7426758", sources: ["floorAmm","floorAmmGovV2"] },
171
+ { name: "setTreasury", signature: "setTreasury(address)", selector: "0xf0f44260", sources: ["floorAmm","floorAmmGovV2"] },
126
172
  { name: "simBuy", signature: "simBuy(uint256,uint256,address)", selector: "0xf69acbed", sources: ["floorAmmV2"] },
127
173
  { name: "simSell", signature: "simSell(uint256,uint256,address)", selector: "0xd3536ecd", sources: ["floorAmmV2"] },
128
174
  { name: "symbol", signature: "symbol()", selector: "0x95d89b41", sources: ["floorToken","floorTokenIndexed"] },
@@ -131,20 +177,23 @@ export const EVM_FUNCTION_SELECTORS: readonly EvmFunctionSelectorRow[] = [
131
177
  { name: "teamShareBuyAndClaim", signature: "teamShareBuyAndClaim(uint256,uint256,uint256,uint256)", selector: "0xc7f1048c", sources: ["floorAmmViewsV2"] },
132
178
  { name: "teamShareOf", signature: "teamShareOf(uint256,address)", selector: "0xb2280af2", sources: ["floorAmm","floorAmmViewsV2"] },
133
179
  { name: "teamSlotAdd", signature: "teamSlotAdd(uint256,bytes32,uint8,uint256,bool)", selector: "0xd5402e81", sources: ["floorAmm","floorAmmClaimsV2"] },
180
+ { name: "teamSlotAddDeal", signature: "teamSlotAddDeal(uint256,bytes32,uint8,uint256,uint16)", selector: "0xed6c1829", sources: ["floorAmm","floorAmmClaimsV2"] },
181
+ { name: "teamSlotAddDealV3", signature: "teamSlotAddDealV3(uint256,bytes32,uint8,uint256,uint16,address,uint16)", selector: "0x883baaa4", sources: ["floorAmm","floorAmmClaimsV2"] },
182
+ { name: "teamSlotAgencyOf", signature: "teamSlotAgencyOf(uint256,uint8)", selector: "0x1764d99f", sources: ["floorAmm","floorAmmViewsV2"] },
134
183
  { name: "teamSlotOf", signature: "teamSlotOf(uint256)", selector: "0x8744aded", sources: ["floorAmmViewsV2"] },
135
- { name: "timelock", signature: "timelock()", selector: "0xd33219b4", sources: ["floorAmm"] },
184
+ { name: "timelock", signature: "timelock()", selector: "0xd33219b4", sources: ["floorAmm","floorAmmGovV2"] },
136
185
  { name: "TOKEN_SCALE", signature: "TOKEN_SCALE()", selector: "0xcae07d2a", sources: ["floorTokenIndexed"] },
137
186
  { name: "tokenImplV2", signature: "tokenImplV2()", selector: "0x01b9b386", sources: ["floorAmmCreateV2"] },
138
187
  { name: "TOTAL_SUPPLY", signature: "TOTAL_SUPPLY()", selector: "0x902d55a5", sources: ["floorTokenIndexed"] },
139
188
  { name: "totalSupply", signature: "totalSupply()", selector: "0x18160ddd", sources: ["floorToken","floorTokenIndexed"] },
140
189
  { name: "traderRef", signature: "traderRef(address)", selector: "0xcfc18291", sources: ["floorAmm","floorAmmViewsV2"] },
141
190
  { name: "transfer", signature: "transfer(address,uint256)", selector: "0xa9059cbb", sources: ["floorToken","floorTokenIndexed"] },
142
- { name: "transferAuthority", signature: "transferAuthority(address)", selector: "0x3078db6c", sources: ["floorAmm"] },
191
+ { name: "transferAuthority", signature: "transferAuthority(address)", selector: "0x3078db6c", sources: ["floorAmm","floorAmmGovV2"] },
143
192
  { name: "transferFrom", signature: "transferFrom(address,address,uint256)", selector: "0x23b872dd", sources: ["floorToken","floorTokenIndexed"] },
144
- { name: "treasury", signature: "treasury()", selector: "0x61d027b3", sources: ["floorAmm"] },
193
+ { name: "treasury", signature: "treasury()", selector: "0x61d027b3", sources: ["floorAmm","floorAmmGovV2"] },
145
194
  { name: "unlockCreatorBuy", signature: "unlockCreatorBuy(uint256)", selector: "0xf03d6d5e", sources: ["floorAmm","floorAmmClaimsV2"] },
146
195
  { name: "updatePreset", signature: "updatePreset(uint8,bytes)", selector: "0x005d9e72", sources: ["floorAmm"] },
147
- { name: "updateQuote", signature: "updateQuote(address,bool,uint256,uint256)", selector: "0x21593d6e", sources: ["floorAmm"] },
196
+ { name: "updateQuote", signature: "updateQuote(address,bool,uint256,uint256)", selector: "0x21593d6e", sources: ["floorAmm","floorAmmGovV2"] },
148
197
  { name: "UPGRADE_INTERFACE_VERSION", signature: "UPGRADE_INTERFACE_VERSION()", selector: "0xad3cb1cc", sources: ["floorAmmV2"] },
149
198
  { name: "upgradeToAndCall", signature: "upgradeToAndCall(address,bytes)", selector: "0x4f1ef286", sources: ["floorAmmV2"] },
150
199
  { name: "withdrawHolder", signature: "withdrawHolder(address,uint256)", selector: "0xfb90c8bf", sources: ["floorAmm","floorAmmCreateV2"] },
package/src/index.ts CHANGED
@@ -19,11 +19,15 @@ export * as solanaTx from "./solana/tx.ts";
19
19
  export * as solanaAlt from "./solana/alt.ts";
20
20
  export * as handle from "./handle.ts";
21
21
  export * as burn from "./burn.ts";
22
+ export * as scaledUi from "./scaledUi.ts";
23
+ export * as stockRefresh from "./stockRefresh.ts";
24
+ export * as reprice from "./reprice.ts";
22
25
  export * as evmKeccak from "./evm/keccak.ts";
23
26
  export * as evmAbi from "./evm/abi.ts";
24
27
  export * as evmItems from "./evm/items.ts";
25
28
  export * as evmZap from "./evm/zap.ts";
26
29
  export * as evmRouter from "./evm/router.ts";
30
+ export * as evmVenues from "./evm/venues.ts";
27
31
  export * as evmChains from "./evm/chains.ts";
28
32
  export * as evmMulticall from "./evm/multicall.ts";
29
33
  export * as evmFloorAbiGen from "./evm/floor/abi.gen.ts";
@@ -66,6 +70,7 @@ export * as mathV2Error from "./math/v2/error.ts";
66
70
  export * as mathV2Holders from "./math/v2/holders.ts";
67
71
  export * as mathV2Milestones from "./math/v2/milestones.ts";
68
72
  export * as mathV2Rows from "./math/v2/rows.ts";
73
+ export * as mathV2Escrow from "./math/v2/escrow.ts";
69
74
  export * as mathV2Circulating from "./math/v2/circulating.ts";
70
75
  export * as mathV2Ask from "./math/v2/ask.ts";
71
76
  export * as mathV2Feasibility from "./math/v2/feasibility.ts";
@@ -92,3 +97,5 @@ export * as fixtures from "./fixtures.ts";
92
97
  export * as client from "./client/index.ts";
93
98
  export * as errors from "./errors.ts";
94
99
  export * as generated from "./generated/index.ts";
100
+ export * as v2OfficeRead from "./v2/office-read.ts";
101
+ export * as v2OfficeTrade from "./v2/office-trade.ts";