@floorlaunchpad/sdk 0.4.0 → 0.4.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 +28 -0
- package/README.md +2 -0
- package/dist/abi/evm.gen.js +5 -0
- package/dist/client/solana/index.js +13 -8
- package/dist/config/generated.js +1 -1
- package/dist/config/registry.gen.js +1 -1
- package/dist/evm/chains.js +79 -18
- package/dist/evm/router.js +25 -1
- package/dist/evm/squid.js +9 -9
- package/dist/evm/zap.js +148 -35
- package/dist/indexer/bodies.js +5 -0
- package/dist/indexer/client.js +2 -0
- package/dist/indexer/contract.js +48 -2
- package/dist/indexer/paths.js +26 -0
- package/dist/indexer/read.js +3 -0
- package/dist/v2/devbuy.js +6 -4
- package/dist/v2/presetRowEvm.js +21 -2
- package/docs/aggregator.md +22 -0
- package/docs/bot.md +8 -0
- package/docs/cursor-pages.md +2 -0
- package/docs/frontend.md +2 -0
- package/docs/wallet.md +2 -0
- package/package.json +1 -1
- package/src/abi/evm.gen.ts +5 -0
- package/src/client/solana/index.ts +13 -8
- package/src/config/generated.ts +1 -1
- package/src/config/registry.gen.ts +1 -1
- package/src/evm/chains.ts +88 -17
- package/src/evm/router.ts +26 -1
- package/src/evm/squid.ts +9 -9
- package/src/evm/zap.ts +185 -36
- package/src/indexer/bodies.ts +7 -0
- package/src/indexer/client.ts +5 -1
- package/src/indexer/contract.ts +48 -2
- package/src/indexer/paths.ts +47 -0
- package/src/indexer/read.ts +5 -2
- package/src/v2/devbuy.ts +6 -4
- package/src/v2/presetRowEvm.ts +21 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@floorlaunchpad/sdk`. The version follows semver; while the major number is 0, a minor bump may rename or remove an export and a patch bump never does.
|
|
4
4
|
|
|
5
|
+
## 0.4.1
|
|
6
|
+
|
|
7
|
+
Fixed:
|
|
8
|
+
|
|
9
|
+
- `zapSwapData` appends `SWEEP(address(0), MSG_SENDER, 0)` to a native-input Universal Router swap (Uniswap, Aerodrome, Pancake and Ramses forks, V2 / V3 and v4). A Squid hook forwards the whole bridged amount as the zap's value, the plan spent only `amountIn`, and the surplus stayed on the router for anyone to sweep; it now returns to the zap, which refunds it. Token-in and native-out routes, and every non-Universal-Router family, encode the same bytes as before.
|
|
10
|
+
- `zapSwapData` encodes a zap whose input is an ERC-20 (`buyWithToken`) and whose output is the native coin (a launch quoted in the native coin). Before, every route began with `WRAP_ETH` (or a native-only call) and paid the router's output in its wrapped form, so an ERC-20 → native-coin zap through a Universal Router, a V3 SwapRouter, SwapRouter02 or Algebra router reverted (`QuoteShort`; measured on forks of every zap row). New optional params: `input` ("native", the default, or "token"), `output` ("token", the default, or "native": the router unwraps and pays the zap, which accepts the native coin only from its router), and `router` (a SwapRouter v1 native output is paid to the router, then unwrapped). The defaults encode the same bytes as before.
|
|
11
|
+
- The Universal Router forks' swap input: `urFork` ("uniswap", the default, "aerodrome", "pancake" or "ramses"; each fork row in `EVM_CHAINS` names its own as `urFork`). Aerodrome's router reads a sixth `bool isUni` (sent false: its Slipstream pools, each key `0x100000 | tickSpacing`, `AERODROME_SLIPSTREAM_KEY`); PancakeSwap's and Ramses' read five fields. Before, every fork got Uniswap's sixth `uint256[]`, which Aerodrome's router reads as `isUni = true` and routes through Uniswap's pools instead of its own. A V2 leg through a fork's router is refused (its input is its own).
|
|
12
|
+
- `buyHookNative` (the Squid postHook that buys through the zap with a bridged native coin) takes the launch's `quote` and, when it is an ERC-20, adds a third call that passes the zap's quote refund on to `user` (`FullTokenBalance quote.transfer(user, FULL)`). Before, the unspent quote the program paid back stayed on the multicall, where anyone could sweep it. `quote` is optional: absent or address(0) (a launch quoted in the native coin), the hook is the same two calls as 0.4.0, byte for byte, so a 0.4.0 call still compiles and encodes as before; pass the ERC-20 quote to get the refund call.
|
|
13
|
+
- `devBuyFromTrade` takes an optional `ctx.buyer`: the person a known zap's or router's own event proves for a buy through it. A buy through the zap or the router has the contract as the trade's `trader`, so a creator's or team member's buy through either was not named a dev buy; with `ctx.buyer` it is, and the returned `trader` is that person. The trade's recipient alone never names one (anyone can buy with the creator as recipient).
|
|
14
|
+
- `EVM_ERRORS` and `decodeEvmProgramError` now know five errors the v2 contracts revert with from their math libraries, which the contracts' ABI does not list: `PriceOrder()`, `ZeroLiquidity()`, `SqrtRange()`, `Zero()` and `VaultShareOutOfRange()`. Before, a revert with one of them decoded as unknown; now it decodes by its selector like any other EVM error.
|
|
15
|
+
- `zapSwapData` now refuses a route that names address(0) (the wrapped native stands for the native coin) or swaps a coin into itself (neither names a pool a router can trade).
|
|
16
|
+
|
|
17
|
+
Added:
|
|
18
|
+
|
|
19
|
+
- `FLOOR_ZAP_ADDRESSES`: the deployed FloorZap instance address per chain and zap slot (15 instances on 8 chains, Elysium's `uniswap-ur` included; one address per slot on every chain that has it), and `zap` on each `EVM_CHAINS` zap row (the instance to call, or `null` where that slot is not deployed). A wallet or an integrator no longer needs its own copy of the zap addresses.
|
|
20
|
+
- Elysium's zap: `EVM_CHAINS.elysium.zapRouters` holds Uniswap's Universal Router 2.1.2 (`0xA13f7611115752DEB2B13813BDDE16A5073e4b45`, slot `uniswap-ur`) with its deployed zap booked (`FLOOR_ZAP_ADDRESSES.elysium`, the same `uniswap-ur` address as every other chain: 15 zaps in all), and `wrappedNative` is WHYPE (`0xbA876237B0F021A6c6D852d6c26E107997cC5E81`, 18 decimals). Elysium's depth is in Uniswap v4 only (native HYPE / USDC pools), so its zap routes through the v4 route below, never through WRAP_ETH.
|
|
21
|
+
- `zapSwapData` encodes Uniswap v4 through the Universal Router: one pool, exact in, given as `route.v4` (`ZapV4Pool`: fee, tick spacing, hooks, hook data) with `route.tokens` = [currency in, currency out] and `V4_NATIVE` (address(0)) for the native coin. The calldata is `V4_SWAP` with `SWAP_EXACT_IN_SINGLE`, `SETTLE` (paid by the router: the zap pays an ERC-20 input to it first; a native input rides as the call's value) and `TAKE`; a native output is taken to the router and then swept to the zap (`SWEEP`, at the same minimum), since the zap accepts the native coin only from its router. New beside it: `v4PoolKey` (the sorted pool key and the swap's direction), the type `V4PoolKey`, and the constants `UR_V4_SWAP`, `V4_SWAP_EXACT_IN_SINGLE`, `V4_SETTLE`, `V4_TAKE`, `V4_OPEN_DELTA` and `V4_NATIVE`. A route without `v4` encodes as before.
|
|
22
|
+
- Indexer batched reads: `floor-amm/launch-lists` (`indexerPath.launchLists`, `readLaunchLists`, body `LAUNCH_LISTS`) returns one `launches?quote=` page per asked quote in one request, each list resumed with its own cursor (`LAUNCH_LISTS_FIRST` asks a first page; at most `LAUNCH_LISTS_QUOTES_MAX` quotes and `LAUNCH_LISTS_ROWS_MAX` rows); `floor-amm/candles/many` (`indexerPath.candlesMany`, `readCandlesMany`, body `CANDLES_MANY`) returns many launches' newest candles at one interval in one request (at most `CANDLES_MANY_IDS_MAX` launches, `missing` names the unknown ones). Both are in `INDEXER_CONTRACT` and the client; against an indexer that does not serve them the readers throw `IndexerError`.
|
|
23
|
+
- `readPresetMenuEvmV2` reads the preset rows through one Multicall3 `aggregate3` per 100 ids (1 + ⌈K ÷ 100⌉ calls instead of 1 + K); a failed row throws, never a gap in the menu. New optional third argument `{ multicall }`: another Multicall3 address, or `null` to send one `presetRow` call per id on a chain without Multicall3.
|
|
24
|
+
- The Solana client's `claim` reads its launches side by side instead of one after another: the round trips no longer grow with the number of launches (5 launches: 15 round trips to 3). Same transaction, same refusals; the quote's fields still come from the last launch asked.
|
|
25
|
+
- FloorRouter addresses: `FLOOR_ROUTER_ADDRESSES` (per chain and zap slot), `floorRouter` on each `EVM_CHAINS` zap row, `FLOOR_ROUTER_DEPLOYER` and `floorRouterAddress(slot)`. One address per slot, the same on every chain that has it (7 routers over the 15 zap rows). The addresses are derived ahead of the routers' deploy, not read back from chain: each is usable only once it has code on that chain. A call to one with no code still succeeds and buys nothing, and a native-in buy's coin sent to it stays at that empty address and is lost. `floorRouterLive` and `assertFloorRouterLive` (`evm/router`) check the code through your `getCode` ("0x" or `undefined` is no code); check before you build a call to one, as `evmRouteCallV2` itself reads no chain.
|
|
26
|
+
|
|
27
|
+
Changed:
|
|
28
|
+
|
|
29
|
+
- Elysium is switched on: its chain registry row is no longer `v2DayOne: false`, so `v2DayOneChains()` now includes Elysium (eight EVM chains). Elysium is live at the same address as the other EVM chains.
|
|
30
|
+
|
|
31
|
+
Added (to carry the fixes; nothing removed or renamed): the type `ZapUrFork`, the constant `AERODROME_SLIPSTREAM_KEY`, the optional `ZapSwapParams` keys `input`, `output`, `router` and `urFork`, and the optional `urFork` on each `EVM_CHAINS` zap row.
|
|
32
|
+
|
|
5
33
|
## 0.4.0
|
|
6
34
|
|
|
7
35
|
Removed:
|
package/README.md
CHANGED
|
@@ -39,6 +39,8 @@ A launch's floor is the price the program's own money stands behind. Drawing it
|
|
|
39
39
|
|
|
40
40
|
The version follows semver. While the major number is 0, a minor bump (0.2 to 0.3) may rename or remove an export and a patch bump never does. The plan and the history are in [CHANGELOG.md](CHANGELOG.md).
|
|
41
41
|
|
|
42
|
+
0.4.1 adds, without renaming or removing anything: the deployed zap addresses (`FLOOR_ZAP_ADDRESSES`, `zap` on each zap row) and more `zapSwapData` routes ([aggregator.md](docs/aggregator.md)), batched indexer reads (`readLaunchLists`, `readCandlesMany`, [bot.md](docs/bot.md)), a batched EVM preset menu ([frontend.md](docs/frontend.md)), five more decoded EVM errors ([wallet.md](docs/wallet.md)) and an optional `ctx.buyer` for `devBuyFromTrade`.
|
|
43
|
+
|
|
42
44
|
**Fees in a quote.** A quote's `fees` has the five fee legs, each added on top of the trade, buys and sells alike: the
|
|
43
45
|
Backing Fee (`backing`), the Team Fee (`team`), the Platform fee (`platform`), the $FLOOR fee (`floor`) and the Holder Fee
|
|
44
46
|
(`holder`), with their `total`. Any leg can be 0. Before graduation a preset launch pays only the Platform fee and the
|
package/dist/abi/evm.gen.js
CHANGED
|
@@ -97,6 +97,7 @@ export const EVM_ERRORS = [
|
|
|
97
97
|
{ chain: "evm", name: "PresetDisabled", message: "PresetDisabled", code: null, selector: "0x5518d9cd", signature: "PresetDisabled()" },
|
|
98
98
|
{ chain: "evm", name: "PresetIdNotNext", message: "PresetIdNotNext", code: null, selector: "0x9b5a5243", signature: "PresetIdNotNext()" },
|
|
99
99
|
{ chain: "evm", name: "PresetInvalid", message: "PresetInvalid", code: null, selector: "0x46f63096", signature: "PresetInvalid()" },
|
|
100
|
+
{ chain: "evm", name: "PriceOrder", message: "PriceOrder", code: null, selector: "0x6b2c148b", signature: "PriceOrder()" },
|
|
100
101
|
{ chain: "evm", name: "QuoteDisabled", message: "QuoteDisabled", code: null, selector: "0x31ccdc5d", signature: "QuoteDisabled()" },
|
|
101
102
|
{ chain: "evm", name: "QuoteListed", message: "QuoteListed", code: null, selector: "0xe6faf0c2", signature: "QuoteListed()" },
|
|
102
103
|
{ chain: "evm", name: "QuoteNotListed", message: "QuoteNotListed", code: null, selector: "0x06ff137a", signature: "QuoteNotListed()" },
|
|
@@ -111,6 +112,7 @@ export const EVM_ERRORS = [
|
|
|
111
112
|
{ chain: "evm", name: "SafeERC20FailedOperation", message: "SafeERC20FailedOperation", code: null, selector: "0x5274afe7", signature: "SafeERC20FailedOperation(address)" },
|
|
112
113
|
{ chain: "evm", name: "SellTooLarge", message: "SellTooLarge", code: null, selector: "0x8e4d208f", signature: "SellTooLarge()" },
|
|
113
114
|
{ chain: "evm", name: "SlippageExceeded", message: "SlippageExceeded", code: null, selector: "0x8199f5f3", signature: "SlippageExceeded()" },
|
|
115
|
+
{ chain: "evm", name: "SqrtRange", message: "SqrtRange", code: null, selector: "0x1e523888", signature: "SqrtRange()" },
|
|
114
116
|
{ chain: "evm", name: "StringsInsufficientHexLength", message: "StringsInsufficientHexLength", code: null, selector: "0xe22e27eb", signature: "StringsInsufficientHexLength(uint256,uint256)" },
|
|
115
117
|
{ chain: "evm", name: "SwapDataNotEmpty", message: "SwapDataNotEmpty", code: null, selector: "0x8821f518", signature: "SwapDataNotEmpty()" },
|
|
116
118
|
{ chain: "evm", name: "SwapFailed", message: "SwapFailed", code: null, selector: "0xff9fa595", signature: "SwapFailed(bytes)" },
|
|
@@ -126,5 +128,8 @@ export const EVM_ERRORS = [
|
|
|
126
128
|
{ chain: "evm", name: "UnknownLaunch", message: "UnknownLaunch", code: null, selector: "0xf6806bf8", signature: "UnknownLaunch()" },
|
|
127
129
|
{ chain: "evm", name: "UUPSUnauthorizedCallContext", message: "UUPSUnauthorizedCallContext", code: null, selector: "0xe07c8dba", signature: "UUPSUnauthorizedCallContext()" },
|
|
128
130
|
{ chain: "evm", name: "UUPSUnsupportedProxiableUUID", message: "UUPSUnsupportedProxiableUUID", code: null, selector: "0xaa1d49a4", signature: "UUPSUnsupportedProxiableUUID(bytes32)" },
|
|
131
|
+
{ chain: "evm", name: "VaultShareOutOfRange", message: "VaultShareOutOfRange", code: null, selector: "0xdb8df2d8", signature: "VaultShareOutOfRange()" },
|
|
132
|
+
{ chain: "evm", name: "Zero", message: "Zero", code: null, selector: "0xf4560403", signature: "Zero()" },
|
|
129
133
|
{ chain: "evm", name: "ZeroAddress", message: "ZeroAddress", code: null, selector: "0xd92e233d", signature: "ZeroAddress()" },
|
|
134
|
+
{ chain: "evm", name: "ZeroLiquidity", message: "ZeroLiquidity", code: null, selector: "0x10074548", signature: "ZeroLiquidity()" },
|
|
130
135
|
];
|
|
@@ -227,19 +227,24 @@ export function createSolanaClient(opts )
|
|
|
227
227
|
|
|
228
228
|
claim: (p ) => guard(async () => {
|
|
229
229
|
const tok = (p.types & (CLAIM_TEAM_BUY | CLAIM_SHARE_BOUGHT)) !== 0;
|
|
230
|
-
const launches = [];
|
|
231
230
|
let qtp = null;
|
|
232
231
|
let qIsLaunch = false;
|
|
233
|
-
|
|
232
|
+
|
|
233
|
+
const read = await Promise.all(p.launches.map(async (mint) => {
|
|
234
234
|
const { address, l } = await launchOf(mint);
|
|
235
235
|
if (l.quoteMint !== p.quote) throw bad(`launch ${mint} trades in ${l.quoteMint}, not ${p.quote}`);
|
|
236
|
-
qtp = l.quoteTokenProgram;
|
|
237
|
-
qIsLaunch = await quoteIsLaunchOf(l);
|
|
238
236
|
const slot = teamSlotPda(address, pid)[0];
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
const [isLaunch, slotAcc] = await Promise.all([quoteIsLaunchOf(l), get(slot)]);
|
|
238
|
+
return { mint, address, l, slot, isLaunch, slotAcc };
|
|
239
|
+
}));
|
|
240
|
+
const launches = read.map(({ address, l, slot, slotAcc }) => ({
|
|
241
|
+
launch: address, quoteVault: l.quoteVault, teamSlot: slotAcc !== null ? slot : null, baseMint: l.baseMint,
|
|
242
|
+
...(tok ? { teamBuy: { baseMint: l.baseMint, tokenVault: l.tokenVault, walletBase: associatedTokenAddress(p.wallet, l.baseMint, TOKEN_2022_PROGRAM_ID) } } : {}),
|
|
243
|
+
}));
|
|
244
|
+
const last = read.at(-1);
|
|
245
|
+
if (last !== undefined) {
|
|
246
|
+
qtp = last.l.quoteTokenProgram;
|
|
247
|
+
qIsLaunch = last.isLaunch;
|
|
243
248
|
}
|
|
244
249
|
if (qtp === null) {
|
|
245
250
|
const m = await get(p.quote);
|
package/dist/config/generated.js
CHANGED
|
@@ -27120,7 +27120,7 @@ export const CHAIN_ROWS = [
|
|
|
27120
27120
|
"name": "elysium",
|
|
27121
27121
|
"label": "Elysium",
|
|
27122
27122
|
"family": "evm",
|
|
27123
|
-
"v2DayOne":
|
|
27123
|
+
"v2DayOne": true,
|
|
27124
27124
|
"chainId": 99901,
|
|
27125
27125
|
"native": "HYPE",
|
|
27126
27126
|
"nativeName": "Hype",
|
package/dist/evm/chains.js
CHANGED
|
@@ -10,8 +10,6 @@ import { CHAIN_REGISTRY, EVM_CHAIN_SLUGS } from "../config/registry.gen.js";
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
function strict(a ) {
|
|
16
14
|
const c = checksumAddress(a);
|
|
17
15
|
const body = a.slice(2);
|
|
@@ -19,79 +17,138 @@ function strict(a ) {
|
|
|
19
17
|
return c;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
const
|
|
20
|
+
const UR_FORK_OF_SLOT = { "aerodrome-ur": "aerodrome", "pancake-ur": "pancake", "ramses-ur": "ramses" };
|
|
21
|
+
function urForkOf(slot ) {
|
|
22
|
+
const f = UR_FORK_OF_SLOT[slot];
|
|
23
|
+
if (!f) throw new RangeError(`the UR fork row ${slot} names no fork`);
|
|
24
|
+
return f;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const r = (slot , amm , router , family , confidence , optional = false, forkEncoding = false) => ({
|
|
23
28
|
slot,
|
|
24
29
|
amm,
|
|
25
30
|
router: strict(router),
|
|
26
31
|
family,
|
|
27
32
|
confidence,
|
|
28
33
|
optional,
|
|
29
|
-
...(forkEncoding ? { forkEncoding } : {}),
|
|
34
|
+
...(forkEncoding ? { forkEncoding, urFork: urForkOf(slot) } : {}),
|
|
30
35
|
});
|
|
31
36
|
|
|
37
|
+
export const FLOOR_ZAP_ADDRESSES = {
|
|
38
|
+
ethereum: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
39
|
+
base: {
|
|
40
|
+
"aerodrome-ur": strict("0xD8329A195F26c27A911B5CE697B11947984dc0d1"),
|
|
41
|
+
"uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995"),
|
|
42
|
+
"pancake-ur": strict("0xE4335AaC829a788bb6988A372edfe3Cda41B0931"),
|
|
43
|
+
},
|
|
44
|
+
bsc: {
|
|
45
|
+
"pancake-ur": strict("0xE4335AaC829a788bb6988A372edfe3Cda41B0931"),
|
|
46
|
+
"uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995"),
|
|
47
|
+
},
|
|
48
|
+
arbitrum: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
49
|
+
hyperevm: {
|
|
50
|
+
prjx: strict("0x02E658B2B205F76850Cf6d584477A58cD797e46a"),
|
|
51
|
+
nest: strict("0x93aC608AA016271BBB92924C3838a0b550c34ce1"),
|
|
52
|
+
"ramses-ur": strict("0x4b22d4b3F104D76aB92A2CA4E5E4A08A27F18f52"),
|
|
53
|
+
hyperswap: strict("0x782DB7e687E16Bfe00C9a0CE41A76A7cC507566F"),
|
|
54
|
+
},
|
|
55
|
+
robinhood: {
|
|
56
|
+
"uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995"),
|
|
57
|
+
"ramses-ur": strict("0x4b22d4b3F104D76aB92A2CA4E5E4A08A27F18f52"),
|
|
58
|
+
},
|
|
59
|
+
arc: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
60
|
+
elysium: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const FLOOR_ROUTER_DEPLOYER = strict("0x3e70158e54E91d2984c0F3B66ce2cE730d1E0e11");
|
|
64
|
+
|
|
65
|
+
const ROUTER_PROXY_INITCODE = "0x67363d3d37363d34f03d5260086018f3";
|
|
66
|
+
|
|
67
|
+
function slotWord(slot ) {
|
|
68
|
+
const b = new TextEncoder().encode(slot);
|
|
69
|
+
if (b.length === 0 || b.length > 32) throw new RangeError(`a router slot is 1..32 bytes: ${JSON.stringify(slot)}`);
|
|
70
|
+
const w = new Uint8Array(32);
|
|
71
|
+
w.set(b);
|
|
72
|
+
return w;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function floorRouterAddress(slot , deployer = FLOOR_ROUTER_DEPLOYER) {
|
|
76
|
+
const s = keccak256(encodeAbi(["string", "bytes32"], ["floor-router.v1.FloorRouter", bytesToHex(slotWord(slot))]));
|
|
77
|
+
const proxy = create2Address({ deployer, salt: s, initCode: ROUTER_PROXY_INITCODE });
|
|
78
|
+
|
|
79
|
+
return checksumAddress(bytesToHex(keccak256(hexToBytes("0xd694" + proxy.slice(2) + "01")).slice(12)));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function withBookedZaps(key , rows ) {
|
|
83
|
+
const book = FLOOR_ZAP_ADDRESSES[key];
|
|
84
|
+
return rows.map((row) => ({ ...row, zap: book[row.slot] ?? null, floorRouter: floorRouterAddress(row.slot) }));
|
|
85
|
+
}
|
|
86
|
+
|
|
32
87
|
const UNISWAP_UR = "uniswap-ur";
|
|
33
88
|
|
|
34
89
|
const ROUTES = {
|
|
35
90
|
ethereum: {
|
|
36
91
|
wrappedNative: strict("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
|
|
37
|
-
zapRouters: [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x4C82D1fBFe28C977cBB58D8C7FF8FCF9F70a2cCA", "uniswap-ur", "HIGH")],
|
|
92
|
+
zapRouters: withBookedZaps("ethereum", [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x4C82D1fBFe28C977cBB58D8C7FF8FCF9F70a2cCA", "uniswap-ur", "HIGH")]),
|
|
38
93
|
notes: [],
|
|
39
94
|
},
|
|
40
95
|
base: {
|
|
41
96
|
wrappedNative: strict("0x4200000000000000000000000000000000000006"),
|
|
42
|
-
zapRouters: [
|
|
97
|
+
zapRouters: withBookedZaps("base", [
|
|
43
98
|
r("aerodrome-ur", "Aerodrome V1 + Slipstream", "0xC5b6786D7B64767D775877b0B6A319AD946B11B5", "uniswap-ur", "HIGH", false, true),
|
|
44
99
|
r(UNISWAP_UR, "Uniswap v2/v3/v4", "0xFdf682F51FE81Aa4898F0AE2163d8A55c127fbC7", "uniswap-ur", "HIGH"),
|
|
45
100
|
r("pancake-ur", "PancakeSwap V3 / Infinity", "0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB", "uniswap-ur", "HIGH", true, true),
|
|
46
|
-
],
|
|
101
|
+
]),
|
|
47
102
|
notes: [],
|
|
48
103
|
},
|
|
49
104
|
bsc: {
|
|
50
105
|
wrappedNative: strict("0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"),
|
|
51
|
-
zapRouters: [
|
|
106
|
+
zapRouters: withBookedZaps("bsc", [
|
|
52
107
|
r("pancake-ur", "PancakeSwap V2 / V3 / Infinity", "0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB", "uniswap-ur", "HIGH", false, true),
|
|
53
108
|
r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x8B844f885672f333Bc0042cB669255f93a4C1E6b", "uniswap-ur", "HIGH"),
|
|
54
|
-
],
|
|
109
|
+
]),
|
|
55
110
|
notes: ["⚠ 0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD is Uniswap's UR v1.2, NOT PancakeSwap's: never use it as Pancake's."],
|
|
56
111
|
},
|
|
57
112
|
arbitrum: {
|
|
58
113
|
wrappedNative: strict("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),
|
|
59
|
-
zapRouters: [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x8B844f885672f333Bc0042cB669255f93a4C1E6b", "uniswap-ur", "HIGH")],
|
|
114
|
+
zapRouters: withBookedZaps("arbitrum", [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x8B844f885672f333Bc0042cB669255f93a4C1E6b", "uniswap-ur", "HIGH")]),
|
|
60
115
|
notes: [],
|
|
61
116
|
},
|
|
62
117
|
hyperevm: {
|
|
63
118
|
maxFloorHops: 2,
|
|
64
119
|
wrappedNative: strict("0x5555555555555555555555555555555555555555"),
|
|
65
|
-
zapRouters: [
|
|
120
|
+
zapRouters: withBookedZaps("hyperevm", [
|
|
66
121
|
r("prjx", "Project X", "0x1EbDFC75FfE3ba3de61E7138a3E8706aC841Af9B", "v3-router", "MEDIUM–HIGH"),
|
|
67
122
|
r("nest", "nest (CL)", "0xaA26B8e5Cadd04430c32787eCC3AA325e99681e9", "algebra", "HIGH"),
|
|
68
123
|
r("ramses-ur", "Ramses CL V2", "0xc43b33b5DF826A48DAE764817647824ED4f476a7", "uniswap-ur", "MEDIUM", false, true),
|
|
69
124
|
r("hyperswap", "HyperSwap V3", "0x6D99e7f6747AF2cDbB5164b6DD50e40D4fDe1e77", "v3-router02", "HIGH", true),
|
|
70
|
-
],
|
|
125
|
+
]),
|
|
71
126
|
notes: ["⚠ Small blocks cap a transaction at 3M gas: a buy that graduates a launch may need a big block."],
|
|
72
127
|
},
|
|
73
128
|
robinhood: {
|
|
74
129
|
wrappedNative: strict("0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"),
|
|
75
|
-
zapRouters: [
|
|
130
|
+
zapRouters: withBookedZaps("robinhood", [
|
|
76
131
|
r(UNISWAP_UR, "Uniswap v2/v3/v4 (+ Fables v4 pools)", "0x8876789976dEcBfCbBbe364623C63652db8C0904", "uniswap-ur", "HIGH"),
|
|
77
132
|
r("ramses-ur", "Ramses", "0xbFbb2BCBc9dfFA029C27A249ae9BE031E1d83b1C", "uniswap-ur", "HIGH", true, true),
|
|
78
|
-
],
|
|
133
|
+
]),
|
|
79
134
|
notes: [],
|
|
80
135
|
},
|
|
81
136
|
arc: {
|
|
82
137
|
wrappedNative: null,
|
|
83
|
-
zapRouters: [r(UNISWAP_UR, "Uniswap v4 (native-USDC pools)", "0x4fcA4a51Ab4F23A7447b3284fBd7D73289A89Fb1", "uniswap-ur", "HIGH")],
|
|
138
|
+
zapRouters: withBookedZaps("arc", [r(UNISWAP_UR, "Uniswap v4 (native-USDC pools)", "0x4fcA4a51Ab4F23A7447b3284fBd7D73289A89Fb1", "uniswap-ur", "HIGH")]),
|
|
84
139
|
notes: [
|
|
85
140
|
"⚠ The native coin is USDC (18 dp at the EVM level; its ERC-20 view 0x3600000000000000000000000000000000000000 has 6 dp and no deposit()).",
|
|
86
141
|
"⚠ No WETH9: WRAP_ETH does not apply; only v4 pools in address(0) take the native coin. The zap is for third-token quotes only.",
|
|
87
142
|
],
|
|
88
143
|
},
|
|
89
144
|
elysium: {
|
|
90
|
-
|
|
91
|
-
|
|
145
|
+
|
|
146
|
+
wrappedNative: strict("0xbA876237B0F021A6c6D852d6c26E107997cC5E81"),
|
|
147
|
+
|
|
148
|
+
zapRouters: withBookedZaps("elysium", [r(UNISWAP_UR, "Uniswap v4 (native HYPE / USDC pools)", "0xA13f7611115752DEB2B13813BDDE16A5073e4b45", "uniswap-ur", "HIGH")]),
|
|
92
149
|
notes: [
|
|
93
150
|
"⚠ Arbitrum Orbit on HyperEVM: in a contract block.number is HyperEVM's block; the receipt's block is Elysium's.",
|
|
94
|
-
"⚠
|
|
151
|
+
"⚠ Depth is Uniswap v4 only (native HYPE / USDC pools, no hooks): route the zap through V4_SWAP (route.v4), never WRAP_ETH; the v3 and V2 pools hold no depth.",
|
|
95
152
|
],
|
|
96
153
|
},
|
|
97
154
|
};
|
|
@@ -100,6 +157,10 @@ export const EVM_CHAINS = Object.fromEntries(
|
|
|
100
157
|
CHAIN_REGISTRY.flatMap((c) => (c.family === "evm" ? [[c.slug, { key: c.slug, chainId: c.chainId, name: c.label, nativeSymbol: c.native.symbol, ...ROUTES[c.slug], ...((c.v2DayOne ) === false ? { v2DayOne: false } : {}) }]] : [])),
|
|
101
158
|
) ;
|
|
102
159
|
|
|
160
|
+
export const FLOOR_ROUTER_ADDRESSES = Object.freeze(
|
|
161
|
+
Object.fromEntries(Object.values(EVM_CHAINS).map((c) => [c.key, Object.freeze(Object.fromEntries(c.zapRouters.map((r) => [r.slot, r.floorRouter])))])),
|
|
162
|
+
) ;
|
|
163
|
+
|
|
103
164
|
export const v2DayOneChains = () => Object.values(EVM_CHAINS).filter((c) => c.v2DayOne !== false);
|
|
104
165
|
export const chainById = (chainId ) => Object.values(EVM_CHAINS).find((c) => c.chainId === chainId) ?? null;
|
|
105
166
|
|
package/dist/evm/router.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { encodeFunctionData } from "./items.js";
|
|
4
4
|
import { deadlineArg } from "./floor/calls.js";
|
|
5
5
|
import { EVM_NATIVE, NoRouteError, coinKey } from "../route/graph.js";
|
|
6
|
-
import { chainById } from "./chains.js";
|
|
6
|
+
import { EVM_CHAINS, chainById } from "./chains.js";
|
|
7
7
|
|
|
8
8
|
const BUY = [
|
|
9
9
|
{ name: "path", type: "uint256[]" },
|
|
@@ -182,3 +182,27 @@ export function evmRouteCall(q , p
|
|
|
182
182
|
const b = { path: ids(buys), tokenIn: s.tokenOut, amountIn: 0n, swapData: "0x", minQuoteIn: 0n, minTokensOut: mins(buys), to: p.to, deadline: p.deadline };
|
|
183
183
|
return call(encodeRouterSwap(s, b, p.chainId), 0n);
|
|
184
184
|
}
|
|
185
|
+
|
|
186
|
+
export async function floorRouterLive(rpc , at ) {
|
|
187
|
+
const address = floorRouterAt(at);
|
|
188
|
+
const code = await rpc.getCode(address);
|
|
189
|
+
if (code === undefined) return false;
|
|
190
|
+
if (typeof code !== "string" || !/^0x([0-9a-fA-F]{2})*$/.test(code)) throw new TypeError(`getCode(${address}) returned ${String(code)}, not hex bytes`);
|
|
191
|
+
return code.length > 2;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function assertFloorRouterLive(rpc , at ) {
|
|
195
|
+
const address = floorRouterAt(at);
|
|
196
|
+
if (!(await floorRouterLive(rpc, address))) throw new RangeError(`FloorRouter ${address} has no code on this chain yet: it is derived ahead of its deploy; do not send to it (a native coin sent to it is lost)`);
|
|
197
|
+
return address;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function floorRouterAt(at ) {
|
|
201
|
+
if (typeof at === "string") {
|
|
202
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(at)) throw new RangeError(`a FloorRouter is a 20-byte address: ${at}`);
|
|
203
|
+
return at;
|
|
204
|
+
}
|
|
205
|
+
const row = EVM_CHAINS[at.chain]?.zapRouters.find((r) => r.slot === at.slot);
|
|
206
|
+
if (row === undefined) throw new RangeError(`no FloorRouter slot ${at.slot} on ${at.chain}`);
|
|
207
|
+
return row.floorRouter;
|
|
208
|
+
}
|
package/dist/evm/squid.js
CHANGED
|
@@ -65,19 +65,19 @@ export function buyHookErc20(p
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export function buyHookNative(p
|
|
68
|
+
export function buyHookNative(p ) {
|
|
69
69
|
checkCommon(p);
|
|
70
70
|
const user = checkUser(p);
|
|
71
71
|
if (p.minQuoteIn <= 0n || p.minTokensOut <= 0n) throw new SquidHookError("NO_MINIMUM", "minQuoteIn and minTokensOut must be > 0");
|
|
72
72
|
const zap = lc(p.zap, "zap");
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
73
|
+
const quote = lc(p.quote ?? ZERO, "quote");
|
|
74
|
+
const calls = [
|
|
75
|
+
call(SQUID_CALL.FullNativeBalance, zap, 0n, bytesToHex(encodeCall("buyWithEth(uint256,bytes,uint256,uint256,address,uint256)", [p.launchId, p.swapData, p.minQuoteIn, p.minTokensOut, user, p.deadline])), "0x", SQUID_GAS.zapBuy),
|
|
76
|
+
call(SQUID_CALL.FullNativeBalance, user, 0n, "0x", "0x", SQUID_GAS.passOn),
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
if (quote !== ZERO) calls.push(call(SQUID_CALL.FullTokenBalance, quote, 0n, bytesToHex(encodeCall("transfer(address,uint256)", [user, SQUID_FULL])), bytesToHex(encodeAbi(["address", "uint256"], [quote, 1n])), SQUID_GAS.transfer));
|
|
80
|
+
return { provider: "FLOOR", description: "Buy a FLOOR launch token with the native coin", calls };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export function sellHook(p ) {
|