@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
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { bytesToHex, checksumAddress, decodeAbi, encodeAbi, encodeCall } from "./abi.js";
|
|
4
|
+
import { chainById } from "./chains.js";
|
|
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.js";
|
|
6
|
+
|
|
7
|
+
import { EVM_NATIVE, coinKey } from "../route/graph.js";
|
|
8
|
+
|
|
9
|
+
export const DEX_FAMILY = { v2: 1, v3: 2, universal: 3, solidly: 4, algebra: 5 } ;
|
|
10
|
+
|
|
11
|
+
const SLOT_OF = {
|
|
12
|
+
uniswap: "uniswap-ur", aerodrome: "aerodrome-ur", pancake: "pancake-ur", "project-x": "prjx", nest: "nest", ramses: "ramses-ur", hyperswap: "hyperswap",
|
|
13
|
+
};
|
|
14
|
+
const FEES_UNI = [100, 500, 3000, 10000] ;
|
|
15
|
+
const FEES_PANCAKE = [100, 500, 2500, 10000] ;
|
|
16
|
+
const WETH_OP = "0x4200000000000000000000000000000000000006";
|
|
17
|
+
const WHYPE = "0x5555555555555555555555555555555555555555";
|
|
18
|
+
|
|
19
|
+
const routerOf = (chainId , venue ) => {
|
|
20
|
+
const r = chainById(chainId)?.zapRouters.find((z) => z.slot === SLOT_OF[venue]);
|
|
21
|
+
if (!r) throw new Error(`no router row ${venue} on ${chainId}`);
|
|
22
|
+
return checksumAddress(r.router);
|
|
23
|
+
};
|
|
24
|
+
const wethOf = (chainId ) => checksumAddress(chainById(chainId)?.wrappedNative ?? WETH_OP);
|
|
25
|
+
|
|
26
|
+
export const UNISWAP_V3_QUOTER = Object.freeze({
|
|
27
|
+
1: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
28
|
+
8453: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",
|
|
29
|
+
56: "0x78D78E420Da98ad378D7799bE8f4AF69033EB077",
|
|
30
|
+
42161: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
31
|
+
4663: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",
|
|
32
|
+
5042: "0x7DfD4F31be6814D2906BDE155c3e1B146EAc1468",
|
|
33
|
+
99901: "0x204FAca1764B154221e35c0d20aBb3c525710498",
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const UNISWAP_V3_FEES = Object.freeze([...FEES_UNI]);
|
|
37
|
+
|
|
38
|
+
function leg(chainId , venue , l ) {
|
|
39
|
+
return Object.freeze({ chainId, venue, router: routerOf(chainId, venue), ...l, quoter: checksumAddress(l.quoter) });
|
|
40
|
+
}
|
|
41
|
+
const uniswap = (chainId ) =>
|
|
42
|
+
leg(chainId, "uniswap", { quoter: UNISWAP_V3_QUOTER[chainId], quoteKind: "fee", legKind: "ur", weth: wethOf(chainId), keys: FEES_UNI, urTail: "minHop" });
|
|
43
|
+
const pancake = (chainId , weth ) =>
|
|
44
|
+
leg(chainId, "pancake", { quoter: "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997", quoteKind: "fee", legKind: "ur", weth: checksumAddress(weth), keys: FEES_PANCAKE, urTail: "none" });
|
|
45
|
+
const ramsesKeys = [1, 5, 10, 50, 100, 200];
|
|
46
|
+
|
|
47
|
+
export const VENUE_LEGS = Object.freeze({
|
|
48
|
+
1: [uniswap(1)],
|
|
49
|
+
8453: [
|
|
50
|
+
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 }),
|
|
51
|
+
uniswap(8453),
|
|
52
|
+
pancake(8453, WETH_OP),
|
|
53
|
+
],
|
|
54
|
+
56: [pancake(56, "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"), uniswap(56)],
|
|
55
|
+
42161: [uniswap(42161)],
|
|
56
|
+
999: [
|
|
57
|
+
leg(999, "project-x", { quoter: "0x239F11a7A3E08f2B8110D4CA9F6B95d4c8865258", quoteKind: "fee", legKind: "v3-router", weth: checksumAddress(WHYPE), keys: FEES_UNI }),
|
|
58
|
+
leg(999, "hyperswap", { quoter: "0x03A918028f22D9E1473B7959C927AD7425A45C7C", quoteKind: "fee", legKind: "router02", weth: checksumAddress(WHYPE), keys: FEES_UNI }),
|
|
59
|
+
leg(999, "nest", { quoter: "0xBea20609A4772311c5b81F814Cd4f9ECaEF5DFAd", quoteKind: "algebra", legKind: "algebra", weth: checksumAddress(WHYPE), keys: [0] }),
|
|
60
|
+
leg(999, "ramses", { quoter: "0x403Bf94fe505cA0F0b1563C350B57dCeC8303ECd", quoteKind: "tick", legKind: "ur", weth: checksumAddress(WHYPE), keys: ramsesKeys, urTail: "none" }),
|
|
61
|
+
],
|
|
62
|
+
4663: [
|
|
63
|
+
uniswap(4663),
|
|
64
|
+
leg(4663, "ramses", { quoter: "0x4730e03EB4a58A5e20244062D5f9A99bCf5770a6", quoteKind: "tick", legKind: "ur", weth: checksumAddress("0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"), keys: ramsesKeys, urTail: "none" }),
|
|
65
|
+
],
|
|
66
|
+
|
|
67
|
+
99901: [
|
|
68
|
+
leg(99901, "uniswap", { quoter: "0x379F556c5a748BD7Cc9baF0F7A344094Ac1814f5", quoteKind: "v4", legKind: "ur-v4", weth: checksumAddress(V4_NATIVE), keys: [3000, 10000], v4TickOf: { 3000: 60, 10000: 200 } }),
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
5042: [
|
|
72
|
+
leg(5042, "uniswap", { quoter: "0x7DfD4F31be6814D2906BDE155c3e1B146EAc1468", quoteKind: "fee", legKind: "ur", weth: null, nativeView: { token: checksumAddress("0x3600000000000000000000000000000000000000"), scale: 10n ** 12n }, keys: FEES_UNI, urTail: "minHop" }),
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export function venueLegOf(chainId , router ) {
|
|
77
|
+
return (VENUE_LEGS[chainId] ?? []).find((l) => l.router.toLowerCase() === router.toLowerCase()) ?? null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const FAMILY_OF_LEG = { ur: DEX_FAMILY.universal, "ur-v4": DEX_FAMILY.universal, "v3-router": DEX_FAMILY.v3, router02: DEX_FAMILY.v3, algebra: DEX_FAMILY.algebra };
|
|
81
|
+
|
|
82
|
+
export const WIRED_DEX_FAMILIES = Object.freeze([DEX_FAMILY.v2, DEX_FAMILY.universal, DEX_FAMILY.v3, DEX_FAMILY.algebra]);
|
|
83
|
+
export const dexFamilyWired = (family ) => WIRED_DEX_FAMILIES.includes(family);
|
|
84
|
+
|
|
85
|
+
export const wiredLegOf = (chainId , family , dex ) => {
|
|
86
|
+
const l = venueLegOf(chainId, dex);
|
|
87
|
+
return l !== null && FAMILY_OF_LEG[l.legKind] === family ? l : null;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const dexLegWired = (chainId , family , dex ) =>
|
|
91
|
+
family === DEX_FAMILY.v2 || (dexFamilyWired(family) && wiredLegOf(chainId, family, dex) !== null);
|
|
92
|
+
|
|
93
|
+
export const legTokenOf = (l , native , token ) =>
|
|
94
|
+
native ? (l.weth ?? (l.nativeView ).token) : checksumAddress(token);
|
|
95
|
+
|
|
96
|
+
const QUOTE_SIG = {
|
|
97
|
+
fee: "quoteExactInputSingle((address,address,uint256,uint24,uint160))",
|
|
98
|
+
tick: "quoteExactInputSingle((address,address,uint256,int24,uint160))",
|
|
99
|
+
algebra: "quoteExactInputSingle((address,address,uint256,uint160))",
|
|
100
|
+
v4: "quoteExactInputSingle(((address,address,uint24,int24,address),bool,uint128,bytes))",
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const v4PoolAt = (l , key ) => {
|
|
104
|
+
const tickSpacing = l.v4TickOf?.[key];
|
|
105
|
+
return tickSpacing === undefined ? null : { fee: key, tickSpacing };
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const firstWord = (hex ) => {
|
|
109
|
+
const h = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
110
|
+
if (h.length < 64) return null;
|
|
111
|
+
const out = BigInt("0x" + h.slice(0, 64));
|
|
112
|
+
return out > 0n ? out : null;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
async function quoteAt(reads , l , tokenIn , tokenOut , amountIn , key ) {
|
|
116
|
+
try {
|
|
117
|
+
let data ;
|
|
118
|
+
if (l.quoteKind === "v4") {
|
|
119
|
+
const pool = v4PoolAt(l, key);
|
|
120
|
+
if (pool === null || amountIn >= 1n << 128n) return null;
|
|
121
|
+
const { key: k, zeroForOne } = v4PoolKey(tokenIn, tokenOut, pool);
|
|
122
|
+
data = bytesToHex(encodeCall(QUOTE_SIG.v4, [[[k.currency0, k.currency1, BigInt(k.fee), BigInt(k.tickSpacing), k.hooks], zeroForOne, amountIn, "0x"]]));
|
|
123
|
+
} else {
|
|
124
|
+
const tail = l.quoteKind === "algebra" ? [] : [BigInt(key)];
|
|
125
|
+
data = bytesToHex(encodeCall(QUOTE_SIG[l.quoteKind], [[tokenIn, tokenOut, amountIn, ...tail, 0n]]));
|
|
126
|
+
}
|
|
127
|
+
return firstWord(await reads.simulate({ to: l.quoter, data }));
|
|
128
|
+
} catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export async function bestVenueHop(reads , l , a ) {
|
|
134
|
+
if (a.fromNative && a.toNative) return null;
|
|
135
|
+
const tokenIn = legTokenOf(l, a.fromNative, a.from);
|
|
136
|
+
const tokenOut = legTokenOf(l, a.toNative, a.to);
|
|
137
|
+
if (tokenIn === tokenOut) return null;
|
|
138
|
+
const scale = l.nativeView?.scale ?? 1n;
|
|
139
|
+
if (a.fromNative && a.amountIn % scale !== 0n) return null;
|
|
140
|
+
const amountIn = a.fromNative ? a.amountIn / scale : a.amountIn;
|
|
141
|
+
if (amountIn <= 0n) return null;
|
|
142
|
+
const outs = await Promise.all(l.keys.map(async (key) => ({ key, out: await quoteAt(reads, l, tokenIn, tokenOut, amountIn, key) })));
|
|
143
|
+
let best = null;
|
|
144
|
+
for (const o of outs) if (o.out !== null && (best === null || o.out > best.out)) best = { key: o.key, out: o.out };
|
|
145
|
+
return best === null ? null : { key: best.key, out: a.toNative ? best.out * scale : best.out };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const UR_EXECUTE = "execute(bytes,bytes[],uint256)";
|
|
149
|
+
const SWAP_HEAD = ["address", "uint256", "uint256", "bytes", "bool"];
|
|
150
|
+
const cmdsHex = (cs ) => "0x" + cs.map((c) => c.toString(16).padStart(2, "0")).join("");
|
|
151
|
+
const enc = (types , values ) => bytesToHex(encodeAbi(types, values ));
|
|
152
|
+
const call = (sig , values ) => bytesToHex(encodeCall(sig, values ));
|
|
153
|
+
|
|
154
|
+
const V3_SWAP = "exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160))";
|
|
155
|
+
const R02_SWAP = "exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))";
|
|
156
|
+
const ALG_SWAP = "exactInputSingle((address,address,address,uint256,uint256,uint256,uint160))";
|
|
157
|
+
|
|
158
|
+
export function venueLegData(l , a ) {
|
|
159
|
+
if (a.amountIn <= 0n || a.minOut <= 0n) throw new RangeError("a leg needs an amount and a minimum");
|
|
160
|
+
if (a.fromNative && a.toNative) throw new RangeError("a leg swaps the coin into itself");
|
|
161
|
+
const tokenIn = legTokenOf(l, a.fromNative, a.from);
|
|
162
|
+
const tokenOut = legTokenOf(l, a.toNative, a.to);
|
|
163
|
+
if (tokenIn === tokenOut) throw new RangeError("a leg swaps a coin into itself");
|
|
164
|
+
if (!l.keys.includes(a.key)) throw new RangeError("a leg at a key its venue does not ask");
|
|
165
|
+
const recipient = checksumAddress(a.recipient);
|
|
166
|
+
if (l.legKind === "ur-v4") {
|
|
167
|
+
|
|
168
|
+
const pool = v4PoolAt(l, a.key);
|
|
169
|
+
if (pool === null) throw new RangeError("a v4 leg at a key with no pool");
|
|
170
|
+
return zapSwapData({ family: "uniswap-ur", route: { tokens: [tokenIn, tokenOut], v4: pool }, amountIn: a.amountIn, minQuoteOut: a.minOut, zap: recipient, deadline: a.deadline });
|
|
171
|
+
}
|
|
172
|
+
if (l.legKind === "ur") {
|
|
173
|
+
const scale = l.nativeView?.scale ?? 1n;
|
|
174
|
+
if (a.fromNative && a.amountIn % scale !== 0n) throw new RangeError("a native amount the view cannot carry");
|
|
175
|
+
const amountIn = a.fromNative ? a.amountIn / scale : a.amountIn;
|
|
176
|
+
|
|
177
|
+
const minOut = a.toNative && l.nativeView ? (a.minOut + scale - 1n) / scale : a.minOut;
|
|
178
|
+
const wrap = l.weth !== null;
|
|
179
|
+
const path = v3Path([tokenIn, tokenOut], [(l.pathKey ?? ((k ) => k))(a.key)]);
|
|
180
|
+
const swapTo = a.toNative && wrap ? UR_ADDRESS_THIS : UR_MSG_SENDER;
|
|
181
|
+
const head = [swapTo, amountIn, minOut, path, false];
|
|
182
|
+
const swap = l.urTail === "minHop" ? enc([...SWAP_HEAD, "uint256[]"], [...head, []]) : l.urTail === "isUni" ? enc([...SWAP_HEAD, "bool"], [...head, false]) : enc(SWAP_HEAD, head);
|
|
183
|
+
const cmds = [];
|
|
184
|
+
const inputs = [];
|
|
185
|
+
if (a.fromNative && wrap) { cmds.push(UR_WRAP_ETH); inputs.push(enc(["address", "uint256"], [UR_ADDRESS_THIS, amountIn])); }
|
|
186
|
+
cmds.push(UR_V3_SWAP_EXACT_IN); inputs.push(swap);
|
|
187
|
+
if (a.toNative && wrap) { cmds.push(UR_UNWRAP_WETH); inputs.push(enc(["address", "uint256"], [UR_MSG_SENDER, minOut])); }
|
|
188
|
+
return call(UR_EXECUTE, [cmdsHex(cmds), inputs, a.deadline]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (l.legKind === "algebra") {
|
|
192
|
+
const swap = (to ) => call(ALG_SWAP, [[tokenIn, tokenOut, to, a.deadline, a.amountIn, a.minOut, 0n]]);
|
|
193
|
+
if (!a.toNative) return swap(recipient);
|
|
194
|
+
|
|
195
|
+
return call("multicall(bytes[])", [[swap(V4_NATIVE), call("unwrapWNativeToken(uint256,address)", [a.minOut, recipient])]]);
|
|
196
|
+
}
|
|
197
|
+
if (l.legKind === "v3-router") {
|
|
198
|
+
const swap = (to ) => call(V3_SWAP, [[tokenIn, tokenOut, BigInt(a.key), to, a.deadline, a.amountIn, a.minOut, 0n]]);
|
|
199
|
+
if (!a.toNative) return swap(recipient);
|
|
200
|
+
return call("multicall(bytes[])", [[swap(l.router), call("unwrapWETH9(uint256,address)", [a.minOut, recipient])]]);
|
|
201
|
+
}
|
|
202
|
+
const swap = (to ) => call(R02_SWAP, [[tokenIn, tokenOut, BigInt(a.key), to, a.amountIn, a.minOut, 0n]]);
|
|
203
|
+
const calls = a.toNative ? [swap(UR_ADDRESS_THIS), call("unwrapWETH9(uint256,address)", [a.minOut, recipient])] : [swap(recipient)];
|
|
204
|
+
return call("multicall(uint256,bytes[])", [a.deadline, calls]);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function uniswapLegData(top , a ) {
|
|
208
|
+
if (a.amountIn <= 0n || a.minOut <= 0n) throw new RangeError("a Uniswap leg needs an amount and a minimum");
|
|
209
|
+
if (a.nativeIn && a.nativeOut) throw new RangeError("a Uniswap leg swaps the coin into itself");
|
|
210
|
+
const tokenIn = a.nativeIn ? checksumAddress(top.weth) : checksumAddress(a.tokenIn);
|
|
211
|
+
const tokenOut = a.nativeOut ? checksumAddress(top.weth) : checksumAddress(a.tokenOut);
|
|
212
|
+
if (tokenIn === tokenOut) throw new RangeError("a Uniswap leg swaps a coin into itself");
|
|
213
|
+
const swapTo = a.nativeOut ? UR_ADDRESS_THIS : UR_MSG_SENDER;
|
|
214
|
+
const swap = enc([...SWAP_HEAD, "uint256[]"], [swapTo, a.amountIn, a.minOut, v3Path([tokenIn, tokenOut], [a.fee]), false, []]);
|
|
215
|
+
const cmds = [];
|
|
216
|
+
const inputs = [];
|
|
217
|
+
if (a.nativeIn) { cmds.push(UR_WRAP_ETH); inputs.push(enc(["address", "uint256"], [UR_ADDRESS_THIS, a.amountIn])); }
|
|
218
|
+
cmds.push(UR_V3_SWAP_EXACT_IN); inputs.push(swap);
|
|
219
|
+
if (a.nativeOut) { cmds.push(UR_UNWRAP_WETH); inputs.push(enc(["address", "uint256"], [UR_MSG_SENDER, a.minOut])); }
|
|
220
|
+
return call(UR_EXECUTE, [cmdsHex(cmds), inputs, a.deadline]);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export const isDexEdgeRaw = (raw ) =>
|
|
224
|
+
typeof raw === "object" && raw !== null && (raw ).provider === "dex";
|
|
225
|
+
|
|
226
|
+
const isNative = (coin ) => coinKey(coin) === EVM_NATIVE;
|
|
227
|
+
|
|
228
|
+
export function legMinOut(out , slippageBps ) {
|
|
229
|
+
const m = (out * BigInt(10_000 - slippageBps)) / 10_000n;
|
|
230
|
+
return m > 0n ? m : 1n;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const WETH_CACHE = new WeakMap ();
|
|
234
|
+
|
|
235
|
+
function v2WethOf(reads , dex ) {
|
|
236
|
+
let m = WETH_CACHE.get(reads);
|
|
237
|
+
if (m === undefined) { m = new Map(); WETH_CACHE.set(reads, m); }
|
|
238
|
+
const k = dex.toLowerCase();
|
|
239
|
+
let hit = m.get(k);
|
|
240
|
+
if (hit === undefined) {
|
|
241
|
+
hit = reads.call({ to: dex, data: call("WETH()", []) }).then((h) => checksumAddress(decodeAbi(["address"], h)[0] ));
|
|
242
|
+
m.set(k, hit);
|
|
243
|
+
const mm = m;
|
|
244
|
+
hit.catch(() => { mm.delete(k); });
|
|
245
|
+
}
|
|
246
|
+
return hit;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async function v2PathOf(reads , dex , from , to ) {
|
|
250
|
+
const weth = isNative(from) || isNative(to) ? await v2WethOf(reads, dex) : null;
|
|
251
|
+
const tok = (c ) => (isNative(c) ? (weth ) : checksumAddress(c));
|
|
252
|
+
const path = [tok(from), tok(to)];
|
|
253
|
+
if (path[0] === path[1]) throw new RangeError("the edge leg swaps a coin into itself");
|
|
254
|
+
return path;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function v2EdgeQuoter(reads , dex ) {
|
|
258
|
+
return async (req) => {
|
|
259
|
+
const path = await v2PathOf(reads, dex, req.from, req.to);
|
|
260
|
+
const amounts = decodeAbi(["uint256[]"], await reads.call({ to: dex, data: call("getAmountsOut(uint256,address[])", [req.amountIn, path]) }))[0] ;
|
|
261
|
+
const out = amounts[amounts.length - 1] ?? 0n;
|
|
262
|
+
if (amounts.length !== path.length || amounts[0] !== req.amountIn || out <= 0n) throw new RangeError("no edge route");
|
|
263
|
+
const raw = { provider: "dex", family: DEX_FAMILY.v2, dex, path, from: req.from, to: req.to };
|
|
264
|
+
return { inAmount: req.amountIn, outAmount: out, minOut: legMinOut(out, req.slippageBps), raw };
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function venueEdgeQuoter(reads , row ) {
|
|
269
|
+
return async (req) => {
|
|
270
|
+
const l = wiredLegOf(row.chainId, row.family, row.router);
|
|
271
|
+
if (l === null) throw new RangeError("no edge route");
|
|
272
|
+
const fromNative = isNative(req.from), toNative = isNative(req.to);
|
|
273
|
+
const path = [legTokenOf(l, fromNative, req.from), legTokenOf(l, toNative, req.to)];
|
|
274
|
+
if (path[0] === path[1]) throw new RangeError("the edge leg swaps a coin into itself");
|
|
275
|
+
const hop = await bestVenueHop(reads, l, { fromNative, from: path[0], toNative, to: path[1], amountIn: req.amountIn });
|
|
276
|
+
if (hop === null) throw new RangeError("no edge route");
|
|
277
|
+
const raw = { provider: "dex", family: row.family, dex: l.router, path, from: req.from, to: req.to, chainId: row.chainId, key: hop.key };
|
|
278
|
+
return { inAmount: req.amountIn, outAmount: hop.out, minOut: legMinOut(hop.out, req.slippageBps), raw };
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function dexEdgeQuoter(row , reads ) {
|
|
283
|
+
return row.family === DEX_FAMILY.v2 ? v2EdgeQuoter(reads, row.router) : venueEdgeQuoter(reads, row);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const V2_ETH_FOR_TOKENS = "swapExactETHForTokens(uint256,address[],address,uint256)";
|
|
287
|
+
const V2_TOKENS_FOR_TOKENS = "swapExactTokensForTokens(uint256,uint256,address[],address,uint256)";
|
|
288
|
+
const V2_TOKENS_FOR_ETH = "swapExactTokensForETH(uint256,uint256,address[],address,uint256)";
|
|
289
|
+
|
|
290
|
+
export function dexSwapData(raw , p ) {
|
|
291
|
+
if (!isDexEdgeRaw(raw) || !dexFamilyWired(raw.family)) throw new RangeError("edge build refused");
|
|
292
|
+
if (p.amountIn <= 0n || p.minOut <= 0n) throw new RangeError("edge build refused");
|
|
293
|
+
if (raw.family !== DEX_FAMILY.v2) {
|
|
294
|
+
const l = raw.chainId === undefined ? null : wiredLegOf(raw.chainId, raw.family, raw.dex);
|
|
295
|
+
if (l === null || raw.key === undefined || raw.path.length !== 2) throw new RangeError("edge build refused");
|
|
296
|
+
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 });
|
|
297
|
+
}
|
|
298
|
+
const path = [...raw.path];
|
|
299
|
+
if (isNative(raw.from)) return call(V2_ETH_FOR_TOKENS, [p.minOut, path, p.recipient, p.deadline]);
|
|
300
|
+
if (isNative(raw.to)) return call(V2_TOKENS_FOR_ETH, [p.amountIn, p.minOut, path, p.recipient, p.deadline]);
|
|
301
|
+
return call(V2_TOKENS_FOR_TOKENS, [p.amountIn, p.minOut, path, p.recipient, p.deadline]);
|
|
302
|
+
}
|
|
@@ -29,7 +29,9 @@ export const EVM_FUNCTION_SELECTORS = [
|
|
|
29
29
|
{ name: "burnFrom", signature: "burnFrom(address,uint256)", selector: "0x79cc6790", sources: ["floorToken","floorTokenIndexed"] },
|
|
30
30
|
{ name: "burnTeamV2", signature: "burnTeamV2(uint256,uint8,uint256)", selector: "0x2f7bf11b", sources: ["floorAmmClaimsV2"] },
|
|
31
31
|
{ name: "buy", signature: "buy(uint256,uint256,uint256,address,uint256)", selector: "0x102d8c79", sources: ["floorAmm","floorAmmV2"] },
|
|
32
|
+
{ name: "buyFor", signature: "buyFor(uint256,uint256,uint256,address,uint256,address)", selector: "0x67105875", sources: ["floorAmm","floorAmmV2"] },
|
|
32
33
|
{ name: "buyFromBalance", signature: "buyFromBalance(uint256,uint256,address,address,uint256)", selector: "0x5f9f56d2", sources: ["floorAmm","floorAmmV2"] },
|
|
34
|
+
{ name: "buyFromBalanceFor", signature: "buyFromBalanceFor(uint256,uint256,address,address,uint256,address)", selector: "0xbb6cda49", sources: ["floorAmm","floorAmmV2"] },
|
|
33
35
|
{ name: "buyWithEth", signature: "buyWithEth(uint256,bytes,uint256,uint256,address,uint256)", selector: "0xef8772c4", sources: ["floorZap"] },
|
|
34
36
|
{ name: "buyWithToken", signature: "buyWithToken(uint256,address,uint256,bytes,uint256,uint256,address,uint256)", selector: "0x9fd30605", sources: ["floorZap"] },
|
|
35
37
|
{ name: "checkPreset", signature: "checkPreset(bytes)", selector: "0x6337513e", sources: ["floorAmm"] },
|
|
@@ -41,7 +43,22 @@ export const EVM_FUNCTION_SELECTORS = [
|
|
|
41
43
|
{ name: "createLaunch", signature: "createLaunch((uint8,address,string,string,uint256,uint256,bool,bytes32,uint256,uint16))", selector: "0x25b62f18", sources: ["floorAmm","floorAmmCreateV2"] },
|
|
42
44
|
{ name: "createPaused", signature: "createPaused()", selector: "0xbac7b497", sources: ["floorAmm","floorAmmGovV2"] },
|
|
43
45
|
{ name: "creditBacking", signature: "creditBacking(uint256,uint256)", selector: "0x1f341504", sources: ["floorAmmV2"] },
|
|
46
|
+
{ name: "creditPlatform", signature: "creditPlatform(uint256,uint256,bytes32)", selector: "0x93fe58a2", sources: ["floorAmm","floorAmmV2"] },
|
|
44
47
|
{ name: "DEAD", signature: "DEAD()", selector: "0x03fd2a45", sources: ["floorTokenIndexed"] },
|
|
48
|
+
{ name: "dealEscrowArm", signature: "dealEscrowArm(bytes32,uint8)", selector: "0x3fe96415", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
49
|
+
{ name: "dealEscrowArmV3", signature: "dealEscrowArmV3(bytes32,uint8)", selector: "0x32037a0e", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
50
|
+
{ name: "dealEscrowCancel", signature: "dealEscrowCancel(bytes32)", selector: "0x16d11c50", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
51
|
+
{ name: "dealEscrowMarketCap", signature: "dealEscrowMarketCap(uint256)", selector: "0x96cefeb9", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
52
|
+
{ name: "dealEscrowObject", signature: "dealEscrowObject(bytes32,uint8)", selector: "0xd8071cc0", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
53
|
+
{ name: "dealEscrowOf", signature: "dealEscrowOf(bytes32)", selector: "0x2a144918", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
54
|
+
{ name: "dealEscrowOpen", signature: "dealEscrowOpen(uint256,address,bytes32,bool,uint256[],uint256[],int64)", selector: "0xe279a5e8", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
55
|
+
{ name: "dealEscrowOpenV3", signature: "dealEscrowOpenV3(uint256,address,bytes32,bool,(uint8[],uint256[],uint256[],uint8,address,uint16,int64))", selector: "0xa1330ee1", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
56
|
+
{ name: "dealEscrowRefund", signature: "dealEscrowRefund(bytes32)", selector: "0x947a9b41", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
57
|
+
{ name: "dealEscrowRelease", signature: "dealEscrowRelease(bytes32,uint8)", selector: "0xcd129e2e", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
58
|
+
{ name: "dealEscrowReleaseV3", signature: "dealEscrowReleaseV3(bytes32,uint8)", selector: "0xb25894ac", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
59
|
+
{ name: "dealEscrowSubmitProof", signature: "dealEscrowSubmitProof(bytes32,uint8,bytes32)", selector: "0x236f5ea6", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
60
|
+
{ name: "dealEscrowV3Of", signature: "dealEscrowV3Of(bytes32)", selector: "0xaffbc4bb", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
61
|
+
{ name: "dealFeeCapBps", signature: "dealFeeCapBps()", selector: "0xfd066b8a", sources: ["floorAmm","floorAmmGovV2"] },
|
|
45
62
|
{ name: "decimals", signature: "decimals()", selector: "0x313ce567", sources: ["floorToken","floorTokenIndexed"] },
|
|
46
63
|
{ name: "decodeRow", signature: "decodeRow(bytes)", selector: "0x8fff698d", sources: ["floorAmmCreateV2"] },
|
|
47
64
|
{ name: "deletePreset", signature: "deletePreset(uint8)", selector: "0xb2d0d2a5", sources: ["floorAmm"] },
|
|
@@ -72,12 +89,29 @@ export const EVM_FUNCTION_SELECTORS = [
|
|
|
72
89
|
{ name: "name", signature: "name()", selector: "0x06fdde03", sources: ["floorToken","floorTokenIndexed"] },
|
|
73
90
|
{ name: "NATIVE", signature: "NATIVE()", selector: "0xa0cf0aea", sources: ["floorAmm","floorAmmGovV2"] },
|
|
74
91
|
{ name: "nativeCreateFee", signature: "nativeCreateFee()", selector: "0x10b51e45", sources: ["floorAmm","floorAmmGovV2"] },
|
|
75
|
-
{ name: "nextModule", signature: "nextModule()", selector: "0xf85abfc7", sources: ["floorAmmV2","floorAmmViewsV2","floorAmmCreateV2","floorAmmClaimsV2"] },
|
|
92
|
+
{ name: "nextModule", signature: "nextModule()", selector: "0xf85abfc7", sources: ["floorAmmV2","floorAmmViewsV2","floorAmmCreateV2","floorAmmClaimsV2","floorAmmOfficeV2"] },
|
|
76
93
|
{ name: "nextPresetId", signature: "nextPresetId()", selector: "0xc8a768e6", sources: ["floorAmm"] },
|
|
77
94
|
{ name: "nonces", signature: "nonces(address)", selector: "0x7ecebe00", sources: ["floorToken","floorTokenIndexed"] },
|
|
78
95
|
{ name: "noteBurn", signature: "noteBurn(uint256)", selector: "0x6db7cd01", sources: ["floorAmmCreateV2"] },
|
|
79
96
|
{ name: "noteDead", signature: "noteDead(uint256)", selector: "0xbdf3b0de", sources: ["floorAmmCreateV2"] },
|
|
80
97
|
{ name: "noteMove", signature: "noteMove(address,address,uint256,uint256,uint256)", selector: "0xe6b761ea", sources: ["floorAmmV2"] },
|
|
98
|
+
{ name: "officeAcceptController", signature: "officeAcceptController(bytes32)", selector: "0x94a408e4", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
99
|
+
{ name: "officeAcceptMerge", signature: "officeAcceptMerge(bytes32,bytes32,address)", selector: "0x5b134957", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
100
|
+
{ name: "officeAddMember", signature: "officeAddMember(bytes32,address)", selector: "0xe65ac3d9", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
101
|
+
{ name: "officeBuy", signature: "officeBuy(bytes32,uint256,uint256,uint256)", selector: "0xad7e22ec", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
102
|
+
{ name: "officeCancelMerge", signature: "officeCancelMerge(bytes32)", selector: "0x009048f9", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
103
|
+
{ name: "officeDeposit", signature: "officeDeposit(bytes32,uint256)", selector: "0x303a9f22", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
104
|
+
{ name: "officeLeave", signature: "officeLeave(bytes32)", selector: "0xa3c22110", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
105
|
+
{ name: "officeMemberOf", signature: "officeMemberOf(bytes32,address)", selector: "0x17883590", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
106
|
+
{ name: "officeMergeStep", signature: "officeMergeStep(bytes32)", selector: "0x8c2973f8", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
107
|
+
{ name: "officeOf", signature: "officeOf(bytes32)", selector: "0x525c1680", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
108
|
+
{ name: "officeOpen", signature: "officeOpen(bytes32,address)", selector: "0x749cd130", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
109
|
+
{ name: "officeProposeController", signature: "officeProposeController(bytes32,address)", selector: "0x7dc27095", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
110
|
+
{ name: "officeProposeMerge", signature: "officeProposeMerge(bytes32,bytes32,address)", selector: "0x95660c91", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
111
|
+
{ name: "officeRemoveMember", signature: "officeRemoveMember(bytes32,address)", selector: "0xf1b0f92d", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
112
|
+
{ name: "officeSell", signature: "officeSell(bytes32,uint256,address,uint256,uint256)", selector: "0x6b8325c5", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
113
|
+
{ name: "officeSetShare", signature: "officeSetShare(bytes32,address,uint16)", selector: "0x1569850a", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
114
|
+
{ name: "officeValue", signature: "officeValue(bytes32)", selector: "0x7f2683e3", sources: ["floorAmm","floorAmmOfficeV2"] },
|
|
81
115
|
{ name: "ogCount", signature: "ogCount()", selector: "0x9457990a", sources: ["floorAmmGovV2"] },
|
|
82
116
|
{ name: "ogUserOf", signature: "ogUserOf(address)", selector: "0x6df29e2f", sources: ["floorAmmGovV2"] },
|
|
83
117
|
{ name: "optedIn", signature: "optedIn(address)", selector: "0x4824b8fd", sources: ["floorTokenIndexed"] },
|
|
@@ -102,13 +136,20 @@ export const EVM_FUNCTION_SELECTORS = [
|
|
|
102
136
|
{ name: "quotes", signature: "quotes()", selector: "0xd6a5d7db", sources: ["floorAmm","floorAmmGovV2"] },
|
|
103
137
|
{ name: "quoteSell", signature: "quoteSell(uint256,uint256,address)", selector: "0x0cff08d1", sources: ["floorAmm","floorAmmV2"] },
|
|
104
138
|
{ name: "referralAuthority", signature: "referralAuthority()", selector: "0x2fe0a99a", sources: ["floorAmm","floorAmmGovV2"] },
|
|
139
|
+
{ name: "refVolume", signature: "refVolume(uint256,address)", selector: "0xe6a32581", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
140
|
+
{ name: "relayBook", signature: "relayBook(uint256)", selector: "0xd1f6ab70", sources: ["floorAmmV2"] },
|
|
141
|
+
{ name: "relayBooks", signature: "relayBooks(uint256,uint256)", selector: "0xcf90be94", sources: ["floorAmmV2"] },
|
|
105
142
|
{ name: "releaseSkipped", signature: "releaseSkipped(address)", selector: "0x215fa9eb", sources: ["floorTokenIndexed"] },
|
|
106
143
|
{ name: "revokeOgUser", signature: "revokeOgUser(address)", selector: "0x52e52ecc", sources: ["floorAmmGovV2"] },
|
|
144
|
+
{ name: "roomOf", signature: "roomOf()", selector: "0x7a0be43c", sources: ["floorAmmV2"] },
|
|
107
145
|
{ name: "router", signature: "router()", selector: "0xf887ea40", sources: ["floorZap"] },
|
|
146
|
+
{ name: "routerDeployer", signature: "routerDeployer()", selector: "0xe8381015", sources: ["floorAmm","floorAmmV2"] },
|
|
108
147
|
{ name: "sell", signature: "sell(uint256,uint256,uint256,address,uint256)", selector: "0xbadb999b", sources: ["floorAmm","floorAmmV2"] },
|
|
109
148
|
{ name: "sellFromBalance", signature: "sellFromBalance(uint256,uint256,address,uint256)", selector: "0x611b00a8", sources: ["floorAmm","floorAmmV2"] },
|
|
149
|
+
{ name: "sellFromBalanceFor", signature: "sellFromBalanceFor(uint256,uint256,address,uint256,address)", selector: "0x54590af6", sources: ["floorAmm","floorAmmV2"] },
|
|
110
150
|
{ name: "sellWithPermit", signature: "sellWithPermit(uint256,uint256,uint256,address,uint256,uint256,uint8,bytes32,bytes32)", selector: "0x2ab030d3", sources: ["floorAmm","floorAmmV2"] },
|
|
111
151
|
{ name: "setCreatePaused", signature: "setCreatePaused(bool)", selector: "0x83bcec85", sources: ["floorAmm","floorAmmGovV2"] },
|
|
152
|
+
{ name: "setDealFeeCap", signature: "setDealFeeCap(uint16)", selector: "0x041a4410", sources: ["floorAmm","floorAmmGovV2"] },
|
|
112
153
|
{ name: "setHolderDest", signature: "setHolderDest(address)", selector: "0x6ad3e66d", sources: ["floorAmm","floorAmmGovV2"] },
|
|
113
154
|
{ name: "setMetadataBase", signature: "setMetadataBase(string)", selector: "0xd3811c0f", sources: ["floorAmm","floorAmmGovV2"] },
|
|
114
155
|
{ name: "setNativeCreateFee", signature: "setNativeCreateFee(uint256)", selector: "0xa4433667", sources: ["floorAmm","floorAmmGovV2"] },
|
|
@@ -129,6 +170,9 @@ export const EVM_FUNCTION_SELECTORS = [
|
|
|
129
170
|
{ name: "teamShareBuyAndClaim", signature: "teamShareBuyAndClaim(uint256,uint256,uint256,uint256)", selector: "0xc7f1048c", sources: ["floorAmmViewsV2"] },
|
|
130
171
|
{ name: "teamShareOf", signature: "teamShareOf(uint256,address)", selector: "0xb2280af2", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
131
172
|
{ name: "teamSlotAdd", signature: "teamSlotAdd(uint256,bytes32,uint8,uint256,bool)", selector: "0xd5402e81", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
173
|
+
{ name: "teamSlotAddDeal", signature: "teamSlotAddDeal(uint256,bytes32,uint8,uint256,uint16)", selector: "0xed6c1829", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
174
|
+
{ name: "teamSlotAddDealV3", signature: "teamSlotAddDealV3(uint256,bytes32,uint8,uint256,uint16,address,uint16)", selector: "0x883baaa4", sources: ["floorAmm","floorAmmClaimsV2"] },
|
|
175
|
+
{ name: "teamSlotAgencyOf", signature: "teamSlotAgencyOf(uint256,uint8)", selector: "0x1764d99f", sources: ["floorAmm","floorAmmViewsV2"] },
|
|
132
176
|
{ name: "teamSlotOf", signature: "teamSlotOf(uint256)", selector: "0x8744aded", sources: ["floorAmmViewsV2"] },
|
|
133
177
|
{ name: "timelock", signature: "timelock()", selector: "0xd33219b4", sources: ["floorAmm","floorAmmGovV2"] },
|
|
134
178
|
{ name: "TOKEN_SCALE", signature: "TOKEN_SCALE()", selector: "0xcae07d2a", sources: ["floorTokenIndexed"] },
|
package/dist/index.js
CHANGED
|
@@ -19,11 +19,15 @@ export * as solanaTx from "./solana/tx.js";
|
|
|
19
19
|
export * as solanaAlt from "./solana/alt.js";
|
|
20
20
|
export * as handle from "./handle.js";
|
|
21
21
|
export * as burn from "./burn.js";
|
|
22
|
+
export * as scaledUi from "./scaledUi.js";
|
|
23
|
+
export * as stockRefresh from "./stockRefresh.js";
|
|
24
|
+
export * as reprice from "./reprice.js";
|
|
22
25
|
export * as evmKeccak from "./evm/keccak.js";
|
|
23
26
|
export * as evmAbi from "./evm/abi.js";
|
|
24
27
|
export * as evmItems from "./evm/items.js";
|
|
25
28
|
export * as evmZap from "./evm/zap.js";
|
|
26
29
|
export * as evmRouter from "./evm/router.js";
|
|
30
|
+
export * as evmVenues from "./evm/venues.js";
|
|
27
31
|
export * as evmChains from "./evm/chains.js";
|
|
28
32
|
export * as evmMulticall from "./evm/multicall.js";
|
|
29
33
|
export * as evmFloorAbiGen from "./evm/floor/abi.gen.js";
|
|
@@ -66,6 +70,7 @@ export * as mathV2Error from "./math/v2/error.js";
|
|
|
66
70
|
export * as mathV2Holders from "./math/v2/holders.js";
|
|
67
71
|
export * as mathV2Milestones from "./math/v2/milestones.js";
|
|
68
72
|
export * as mathV2Rows from "./math/v2/rows.js";
|
|
73
|
+
export * as mathV2Escrow from "./math/v2/escrow.js";
|
|
69
74
|
export * as mathV2Circulating from "./math/v2/circulating.js";
|
|
70
75
|
export * as mathV2Ask from "./math/v2/ask.js";
|
|
71
76
|
export * as mathV2Feasibility from "./math/v2/feasibility.js";
|
|
@@ -92,3 +97,5 @@ export * as fixtures from "./fixtures.js";
|
|
|
92
97
|
export * as client from "./client/index.js";
|
|
93
98
|
export * as errors from "./errors.js";
|
|
94
99
|
export * as generated from "./generated/index.js";
|
|
100
|
+
export * as v2OfficeRead from "./v2/office-read.js";
|
|
101
|
+
export * as v2OfficeTrade from "./v2/office-trade.js";
|
package/dist/indexer/bodies.js
CHANGED
|
@@ -73,7 +73,7 @@ const LAUNCH_FIELDS = {
|
|
|
73
73
|
|
|
74
74
|
graduation: nullable(object({ block: int, timestamp: int, tx: str })),
|
|
75
75
|
|
|
76
|
-
teamSlot: array(object({ wallet: str, place: int })),
|
|
76
|
+
teamSlot: array(object({ wallet: str, place: int, shareBps: optional(nullable(int)), owed: optional(nullable(big)), claimed: optional(nullable(big)), teamBuy: optional(nullable(big)), teamBuyLocked: optional(nullable(big)), unlockAt: optional(nullable(int)) })),
|
|
77
77
|
phase: oneOf("bonding", "stacks", "tail"),
|
|
78
78
|
floorX64: big,
|
|
79
79
|
sqrtF: big,
|
|
@@ -336,6 +336,18 @@ export const CANDLE = object({
|
|
|
336
336
|
floorX64: optional(nullable(big)),
|
|
337
337
|
});
|
|
338
338
|
|
|
339
|
+
export const MCAP_INTERVALS = ["1h", "1d"] ;
|
|
340
|
+
|
|
341
|
+
export const MCAP_PAGE_MAX = 2_000;
|
|
342
|
+
|
|
343
|
+
export const MCAP_POINT = object({ time: int, marketCap: big, supply: big, priceX64: big });
|
|
344
|
+
|
|
345
|
+
export const MCAP = object({ indexed, launch: str, interval: oneOf(...MCAP_INTERVALS), points: array(MCAP_POINT), next: nullable(int) });
|
|
346
|
+
|
|
347
|
+
export const HELD_ROW = object({ at: int, wallets: int, tokens: big });
|
|
348
|
+
|
|
349
|
+
export const HELD = object({ indexed, launch: str, interval: nullable(oneOf(...MCAP_INTERVALS)), rows: array(HELD_ROW), next: nullable(int) });
|
|
350
|
+
|
|
339
351
|
const USD_RATE = object({ centsX64: nullable(big), source: nullable(str), ageS: nullable(int) });
|
|
340
352
|
|
|
341
353
|
export const CANDLES = object({
|
|
@@ -488,11 +500,71 @@ export const POSITION_TOTALS = checked(
|
|
|
488
500
|
(b) => (b.positions.some((r) => (r.fold === null) === (r.foldReason === null)) ? "fold or its reason, one of them" : b.positions.some((r) => r.fills !== r.buys + r.sells) ? "fills = buys + sells" : null),
|
|
489
501
|
);
|
|
490
502
|
|
|
503
|
+
export const STATS_MONEY = object({ byQuote: record(big), usd: decimal, usdMissing: int });
|
|
504
|
+
|
|
505
|
+
export const WALLET_STATS = object({
|
|
506
|
+
indexed: nullable(INDEXED),
|
|
507
|
+
wallet: str,
|
|
508
|
+
trader: object({
|
|
509
|
+
trades: int, buys: int, sells: int, launches: int,
|
|
510
|
+
volume: STATS_MONEY,
|
|
511
|
+
realised: object({ byQuote: record(roundTrip), usd: decimal, usdMissing: int }),
|
|
512
|
+
closed: int, wins: int, winRateBps: nullable(int),
|
|
513
|
+
biggestWin: nullable(object({ usd: decimal, launch: str })),
|
|
514
|
+
biggestLoss: nullable(object({ usd: decimal, launch: str })),
|
|
515
|
+
early: object({ firstBuyers: int, firstMinutes: int, buyersN: int, windowS: int }),
|
|
516
|
+
avgHoldS: nullable(int),
|
|
517
|
+
resaleBps: nullable(int),
|
|
518
|
+
}),
|
|
519
|
+
member: object({
|
|
520
|
+
places: int, launches: int,
|
|
521
|
+
buybacks: object({ count: int, spent: STATS_MONEY, tokens: big, weightedBps: nullable(int), weightedBpsByQuote: record(int), meanBps: nullable(int), firstTs: nullable(int), lastTs: nullable(int) }),
|
|
522
|
+
buybackDays: object({ days: int, streak: int, bestStreak: int, lastDay: nullable(int) }),
|
|
523
|
+
teamShare: object({ withdrawn: STATS_MONEY, boughtBack: STATS_MONEY, owed: nullable(STATS_MONEY), owedShareBoughtTokens: nullable(big) }),
|
|
524
|
+
burns: object({ count: int, tokens: big, supplyBps: int, usd: decimal, usdMissing: int }),
|
|
525
|
+
sold: object({ count: int, tokens: big, quote: STATS_MONEY, boughtTokens: big, soldBps: nullable(int) }),
|
|
526
|
+
teamBuy: object({
|
|
527
|
+
launches: int, tokens: big, burned: big, sold: big, kept: big, locked: big, unsplit: int,
|
|
528
|
+
launchesSold: int, launchesKept: int, firstSoldTs: nullable(int), avgHeldAfterLockS: nullable(int),
|
|
529
|
+
owedTokens: nullable(big), lockedTokens: nullable(big),
|
|
530
|
+
}),
|
|
531
|
+
}),
|
|
532
|
+
creator: object({
|
|
533
|
+
launches: int, graduated: int, graduationBps: nullable(int), medianGraduateS: nullable(int),
|
|
534
|
+
peakMcap: object({ bestUsd: nullable(decimal), bestLaunch: nullable(str), medianUsd: nullable(decimal) }),
|
|
535
|
+
volume: STATS_MONEY, holders: int, activeLaunches: int, activeWindowS: int,
|
|
536
|
+
teamBuy: object({ launches: int, tokens: big, cost: STATS_MONEY, unsplit: int, toOtherPlaces: big }),
|
|
537
|
+
teamSlot: object({ launches: int, members: int, maxMembers: int }),
|
|
538
|
+
refs: object({ takenFromTeamShare: STATS_MONEY }),
|
|
539
|
+
}),
|
|
540
|
+
referrer: object({ referred: int, earned: STATS_MONEY, owed: nullable(STATS_MONEY) }),
|
|
541
|
+
});
|
|
542
|
+
|
|
491
543
|
export const LAUNCH_TRADED = checked(
|
|
492
544
|
object({ indexed, launch: str, traded: array(object({ wallet: str, traded: bool, firstTs: nullable(int) })), asOf: nullable(str) }),
|
|
493
545
|
(b) => (b.traded.some((r) => r.traded === (r.firstTs === null)) ? "firstTs exactly where traded" : null),
|
|
494
546
|
);
|
|
495
547
|
|
|
548
|
+
export const DEAL_PROOF = object({ state: int, hash: nullable(str), windowEnds: nullable(big), objected: bool });
|
|
549
|
+
|
|
550
|
+
export const DEAL_SPLIT = object({ kind: int, kol: str, kolPart: big, agency: nullable(str), agencyPart: big, tiers: array(nullable(str)), refs: array(big), feeRest: big });
|
|
551
|
+
|
|
552
|
+
export const DEAL_UPFRONT = object({ amount: big, fee: big, token: str, timestamp: int, tx: str });
|
|
553
|
+
|
|
554
|
+
export const DEAL = object({
|
|
555
|
+
escrow: str, launcher: str, kol: str, ref32: str, asset: str, isToken: bool, version: int,
|
|
556
|
+
targets: array(big), amounts: array(big), total: big, expiry: big, armedAt: array(big),
|
|
557
|
+
released: array(nullable(object({ amount: big, fee: big, marketCap: big }))),
|
|
558
|
+
|
|
559
|
+
upfront: array(DEAL_UPFRONT),
|
|
560
|
+
refunded: nullable(big), cancelAgreed: int, cancelled: bool,
|
|
561
|
+
kinds: array(int), proofMask: int, agency: nullable(str), agencyBps: int, volAtLock: big,
|
|
562
|
+
proof: array(nullable(DEAL_PROOF)), split: array(nullable(DEAL_SPLIT)),
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
export const SEAT_AGENCY = object({ place: int, key: str, agency: str, agencyBps: int, paid: big });
|
|
566
|
+
export const DEALS = object({ indexed, launch: str, deals: array(DEAL), seatAgencies: array(SEAT_AGENCY) });
|
|
567
|
+
|
|
496
568
|
const LOCK_HOLDER = object({ wallet: str, place: nullable(int) });
|
|
497
569
|
|
|
498
570
|
export const TEAM_BUY_LOCK = object({ kind: oneOf("teamBuy"), tokens: big, createdAt: int, unlocked: bool, unlockedAt: nullable(int), unlockAt: nullable(int), locked: big, claimed: big, holders: array(LOCK_HOLDER) });
|
|
@@ -647,7 +719,7 @@ export const PEOPLE_ROLE = object({ kind: oneOf("trader", "creator"), tier: int,
|
|
|
647
719
|
export const PEOPLE = object({
|
|
648
720
|
indexed,
|
|
649
721
|
wallet: str,
|
|
650
|
-
people: array(object({ wallet: str, chain: str, roles: array(PEOPLE_ROLE), earned: PER_QUOTE, teamMilestone: PER_QUOTE, unclaimed: PER_QUOTE })),
|
|
722
|
+
people: array(object({ wallet: str, chain: str, boundAt: optional(int), roles: array(PEOPLE_ROLE), earned: PER_QUOTE, teamMilestone: PER_QUOTE, unclaimed: PER_QUOTE })),
|
|
651
723
|
pooled: PER_QUOTE,
|
|
652
724
|
|
|
653
725
|
accountsAt: optional(nullable(int)),
|
|
@@ -657,6 +729,86 @@ export const PEOPLE = object({
|
|
|
657
729
|
next: optional(nullable(str)),
|
|
658
730
|
});
|
|
659
731
|
|
|
732
|
+
export const TIE_FIRST_BUY = object({ ts: int, quote: big, usd: nullable(decimal) });
|
|
733
|
+
|
|
734
|
+
const TIE_FLOW = { buys: int, buyQuote: big, buyUsd: decimal, sells: int, sellQuote: big, sellUsd: decimal, usdMissing: int } ;
|
|
735
|
+
|
|
736
|
+
const TIE_EARNED_TIER = object({ quote: big, usd: decimal });
|
|
737
|
+
|
|
738
|
+
export const TIE_EARNED = object({ tier1: TIE_EARNED_TIER, tier2: TIE_EARNED_TIER, tier3: TIE_EARNED_TIER, usdMissing: int });
|
|
739
|
+
|
|
740
|
+
export const REFERRAL_LAUNCH_ROW = object({
|
|
741
|
+
launch: str,
|
|
742
|
+
token: str,
|
|
743
|
+
quote: str,
|
|
744
|
+
createdTs: int,
|
|
745
|
+
self: nullable(TIE_FIRST_BUY),
|
|
746
|
+
creator: bool,
|
|
747
|
+
teamSlot: bool,
|
|
748
|
+
buyers: int,
|
|
749
|
+
before: int,
|
|
750
|
+
after: int,
|
|
751
|
+
medianLeadS: nullable(int),
|
|
752
|
+
medianLagS: nullable(int),
|
|
753
|
+
earned: TIE_EARNED,
|
|
754
|
+
teamMilestone: TIE_EARNED,
|
|
755
|
+
referees: array(object({
|
|
756
|
+
wallet: str,
|
|
757
|
+
linked: array(object({ quote: str, tier: int })),
|
|
758
|
+
credited: array(object({ kind: oneOf("trader", "creator"), tier: int })),
|
|
759
|
+
teamSlot: bool,
|
|
760
|
+
firstBuy: TIE_FIRST_BUY,
|
|
761
|
+
offsetS: nullable(int),
|
|
762
|
+
...TIE_FLOW,
|
|
763
|
+
followed: nullable(object(TIE_FLOW)),
|
|
764
|
+
})),
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
export const REFERRAL_LAUNCHES = object({
|
|
768
|
+
indexed,
|
|
769
|
+
wallet: str,
|
|
770
|
+
membership: oneOf("linkedNowOrEverCredited"),
|
|
771
|
+
|
|
772
|
+
people: int,
|
|
773
|
+
launches: array(REFERRAL_LAUNCH_ROW),
|
|
774
|
+
|
|
775
|
+
next: nullable(str),
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
export const LAUNCH_TIES = object({
|
|
779
|
+
indexed,
|
|
780
|
+
launch: str,
|
|
781
|
+
quote: str,
|
|
782
|
+
at: int,
|
|
783
|
+
from: int,
|
|
784
|
+
to: int,
|
|
785
|
+
activeFrom: int,
|
|
786
|
+
activeTo: int,
|
|
787
|
+
holdingSource: oneOf("trades"),
|
|
788
|
+
wallets: array(object({
|
|
789
|
+
wallet: str,
|
|
790
|
+
active: bool,
|
|
791
|
+
firstFloorTradeAt: nullable(int),
|
|
792
|
+
teamSlot: bool,
|
|
793
|
+
firstBuy: nullable(TIE_FIRST_BUY),
|
|
794
|
+
offsetS: nullable(int),
|
|
795
|
+
inWindow: bool,
|
|
796
|
+
...TIE_FLOW,
|
|
797
|
+
holding: array(object({ days: int, at: int, peak: nullable(big), held: nullable(big) })),
|
|
798
|
+
})),
|
|
799
|
+
base: object({ active: int, bought: int, ratePpm: nullable(int) }),
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
export const COBUYS = object({
|
|
803
|
+
indexed,
|
|
804
|
+
wallet: str,
|
|
805
|
+
windowS: int,
|
|
806
|
+
minLaunches: int,
|
|
807
|
+
launches: int,
|
|
808
|
+
total: int,
|
|
809
|
+
cobuys: array(object({ wallet: str, launches: int, firstTs: int, lastTs: int })),
|
|
810
|
+
});
|
|
811
|
+
|
|
660
812
|
export const ROLES = object({
|
|
661
813
|
indexed,
|
|
662
814
|
wallet: str,
|