@floorlaunchpad/sdk 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/dist/abi/evm.gen.js +5 -0
- package/dist/abi/functions.gen.js +1 -1
- package/dist/client/solana/index.js +13 -8
- package/dist/config/generated.js +78 -1
- package/dist/config/registry.gen.js +1 -1
- package/dist/evm/chains.js +56 -18
- package/dist/evm/squid.js +10 -10
- package/dist/evm/zap.js +148 -35
- package/dist/index.js +1 -0
- package/dist/indexer/bodies.js +9 -0
- package/dist/indexer/client.js +2 -0
- package/dist/indexer/contract.js +48 -2
- package/dist/indexer/paths.js +26 -0
- package/dist/indexer/read.js +3 -0
- package/dist/math/v2/book.js +40 -7
- package/dist/math/v2/create.js +1 -1
- package/dist/math/v2/relay.js +201 -1
- package/dist/math/v2/split.js +60 -15
- package/dist/math/v2/trade.js +16 -8
- package/dist/ton/addresses.js +36 -0
- package/dist/ton/book-check.js +23 -0
- package/dist/ton/book.js +119 -0
- package/dist/ton/cell.js +542 -0
- package/dist/ton/consts.generated.js +17 -0
- package/dist/ton/content.js +83 -0
- package/dist/ton/gas.js +198 -0
- package/dist/ton/governance.js +401 -0
- package/dist/ton/index.js +18 -0
- package/dist/ton/messages.js +340 -0
- package/dist/ton/ops.js +37 -0
- package/dist/ton/price.js +51 -0
- package/dist/ton/quote-entry.js +116 -0
- package/dist/ton/quote.js +25 -0
- package/dist/ton/reader.js +378 -0
- package/dist/ton/types.js +43 -0
- package/dist/ton/wallet.js +26 -0
- package/dist/v2/devbuy.js +6 -4
- package/dist/v2/evm.js +3 -1
- package/dist/v2/layouts.js +5 -1
- package/dist/v2/presetRowEvm.js +21 -2
- package/dist/v2/router.js +2 -2
- package/dist/v2/solanaSettle.js +2 -0
- package/docs/ton.md +107 -0
- package/examples/floor-line.html +1 -1
- package/package.json +6 -1
- package/src/abi/evm.gen.ts +5 -0
- package/src/abi/functions.gen.ts +1 -1
- package/src/client/solana/index.ts +13 -8
- package/src/config/generated.ts +78 -1
- package/src/config/registry.gen.ts +1 -1
- package/src/evm/chains.ts +63 -17
- package/src/evm/squid.ts +10 -10
- package/src/evm/zap.ts +185 -36
- package/src/index.ts +1 -0
- package/src/indexer/bodies.ts +11 -0
- package/src/indexer/client.ts +5 -1
- package/src/indexer/contract.ts +48 -2
- package/src/indexer/paths.ts +47 -0
- package/src/indexer/read.ts +5 -2
- package/src/math/v2/book.ts +42 -7
- package/src/math/v2/create.ts +1 -1
- package/src/math/v2/relay.ts +208 -1
- package/src/math/v2/split.ts +70 -16
- package/src/math/v2/trade.ts +16 -8
- package/src/ton/addresses.ts +38 -0
- package/src/ton/book-check.ts +24 -0
- package/src/ton/book.ts +136 -0
- package/src/ton/cell.ts +547 -0
- package/src/ton/consts.generated.ts +17 -0
- package/src/ton/content.ts +97 -0
- package/src/ton/gas.ts +209 -0
- package/src/ton/governance.ts +452 -0
- package/src/ton/index.ts +18 -0
- package/src/ton/messages.ts +343 -0
- package/src/ton/ops.ts +37 -0
- package/src/ton/price.ts +54 -0
- package/src/ton/quote-entry.ts +138 -0
- package/src/ton/quote.ts +67 -0
- package/src/ton/reader.ts +420 -0
- package/src/ton/types.ts +201 -0
- package/src/ton/wallet.ts +30 -0
- package/src/v2/devbuy.ts +6 -4
- package/src/v2/evm.ts +5 -1
- package/src/v2/layouts.ts +5 -1
- package/src/v2/presetRowEvm.ts +21 -2
- package/src/v2/router.ts +2 -2
- package/src/v2/solanaSettle.ts +2 -0
- package/src/v2/types.ts +4 -1
package/docs/ton.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# FLOOR on TON
|
|
2
|
+
|
|
3
|
+
> TON is not deployed yet: the module ships in `@floorlaunchpad/sdk` 0.6.0, switched off: the TON chain row stays off until a mainnet factory is live.
|
|
4
|
+
|
|
5
|
+
`@floorlaunchpad/sdk/ton` builds the messages a wallet sends to the FLOOR program on TON and reads what the program answers.
|
|
6
|
+
It holds no key, sends nothing and opens no connection of its own: you give it a read function (`TonRpc`) and a wallet.
|
|
7
|
+
Amounts are in nanoGRAM (GRAM has 9 decimals).
|
|
8
|
+
|
|
9
|
+
## Build a trade
|
|
10
|
+
|
|
11
|
+
A trade is a `TonTx`: `{ family: "ton", messages }`, each message with a destination, a value in nanoGRAM, a body cell and a
|
|
12
|
+
`bounce` flag. Build the chain once (`tonChainOf()` uses the built-in mainnet constants; see "Built-in constants"), then build the message:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { tonChainOf, launchAddress, buildBuyGram, simBuy } from "@floorlaunchpad/sdk/ton";
|
|
16
|
+
|
|
17
|
+
const chain = tonChainOf(); // mainnet, from the SDK's own constants
|
|
18
|
+
const launch = launchAddress(chain, launchId); // needs the launch init code, see below
|
|
19
|
+
const quote = await simBuy(rpc, launch, 1_000_000_000n, BigInt(nowSeconds));
|
|
20
|
+
const tx = buildBuyGram({ launch, money: 1_000_000_000n, minTokens: quote.tokens * 99n / 100n, deadline: nowSeconds + 300, recipient: myAddress });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`simBuy` and `simSell` run the program's own `get` methods on the launch: they are the quote path. There is no second
|
|
24
|
+
price formula in the SDK for TON. A builder refuses bad input (a zero amount, a deadline in the past) with a `RangeError`
|
|
25
|
+
before it makes a message.
|
|
26
|
+
|
|
27
|
+
`tonChainOf` can derive the wallet, account and trader addresses. It cannot derive a launch address, because the launch
|
|
28
|
+
init code is not in the book: `launchAddress` throws `launch init code not supplied` rather than guess. Pass the launch
|
|
29
|
+
address you read from the factory, or supply the code.
|
|
30
|
+
|
|
31
|
+
## Send it
|
|
32
|
+
|
|
33
|
+
`tonConnectRequest` turns a `TonTx` into the request a TON Connect wallet takes:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { tonConnectRequest } from "@floorlaunchpad/sdk/ton";
|
|
37
|
+
|
|
38
|
+
const request = tonConnectRequest(tx, { nowS: Math.floor(Date.now() / 1000) });
|
|
39
|
+
await tonConnectUi.sendTransaction(request);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Each message maps to `{ address, amount, payload, stateInit? }`: the address with its bounce flag, the value as a decimal
|
|
43
|
+
string, the body and any state init as base64. `validUntil` is `nowS` plus `validForS` (default 300, at most 600). A
|
|
44
|
+
request carries 1 to `maxMessages` messages (default 4); more is a `RangeError`. The function is pure.
|
|
45
|
+
|
|
46
|
+
## Read the result
|
|
47
|
+
|
|
48
|
+
A message that reaches the chain can still be refused by the program. Ask the indexer, by the wallet and the message's
|
|
49
|
+
query id:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { readTonOutcome } from "@floorlaunchpad/sdk";
|
|
53
|
+
|
|
54
|
+
const outcome = await readTonOutcome(get, walletAddress, queryId);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The answer says whether the message landed, was refused (with the program's error) or is not seen yet. Treat "not seen yet"
|
|
58
|
+
as pending, never as failed. Use a fresh `queryId` for each message.
|
|
59
|
+
|
|
60
|
+
## Built-in constants
|
|
61
|
+
|
|
62
|
+
The SDK carries TON mainnet's factory and timelock addresses and the three small init codes (wallet, account, trader) as
|
|
63
|
+
constants in a generated module (`TON_MAINNET`, `TON_INIT_CODES_BASE64`, `TON_PINNED_CODE_HASHES`). `tonChainOf()` with no
|
|
64
|
+
argument builds the mainnet chain from them: no file to fetch. The module is written by `node sdk/scripts/gen-ton-consts.mjs`
|
|
65
|
+
from the pinned codes (`ton/contracts/codes.mjs`) and the deploy output (`sdk/scripts/ton-mainnet-deploy.json`); `--check`
|
|
66
|
+
fails while the committed module differs. Mainnet is not deployed yet, so `TON_MAINNET.factory` and `.timelock` are `null`
|
|
67
|
+
(`placeholder: true`) and `tonChainOf()` throws `TonBookError` until the deploy output is filled in and the generator re-run.
|
|
68
|
+
|
|
69
|
+
## The book file (another network or deployment)
|
|
70
|
+
|
|
71
|
+
For a testnet or any other deployment, pass a book: a small JSON file for one network:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"chain": "ton", "network": "mainnet", "globalId": -239,
|
|
76
|
+
"factory": "0:<64 hex>", "timelock": "0:<64 hex>",
|
|
77
|
+
"codeHashes": { "factory": "…", "timelock": "…", "launch": "…", "wallet": "…", "account": "…", "trader": "…" },
|
|
78
|
+
"familyInit": { "launch": "…", "account": "…", "trader": "…" },
|
|
79
|
+
"codes": { "wallet": "<base64 BoC>", "account": "<base64 BoC>", "trader": "<base64 BoC>" },
|
|
80
|
+
"readAt": "<ISO 8601 time>", "deploySeqno": 123456
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { parseTonBook, tonChainOf } from "@floorlaunchpad/sdk/ton";
|
|
86
|
+
const chain = tonChainOf(parseTonBook(JSON.parse(bookFileText), { file: "ton-testnet.json" }));
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`network` is `mainnet` with `globalId` -239, or `testnet` with -3. `familyInit` and `deploySeqno` are optional; other keys
|
|
90
|
+
are ignored. `parseTonBook` checks every field and the three code cells against their hashes and the pinned code, and throws
|
|
91
|
+
`TonBookError` (`ton book <file>: <field>: <what>`) on the first fault. A book that parses derives addresses identical to
|
|
92
|
+
the chain's. `checkTonBookOnChain(rpc, book)` compares the book with the chain and returns a list of mismatches (empty means
|
|
93
|
+
consistent); run it from your own machine, not in a page.
|
|
94
|
+
|
|
95
|
+
## Gas
|
|
96
|
+
|
|
97
|
+
Every builder has a default value that covers the program's gas and forwarding on the current network prices. The claim
|
|
98
|
+
costs are priced in `gas.ts` from a `TonGasConfig` (basechain prices); the default is the mainnet config, and you can pass
|
|
99
|
+
a live one. Unused value comes back as a refund. A message that carries too little value is refused by the program, so
|
|
100
|
+
raise the value rather than lower it.
|
|
101
|
+
|
|
102
|
+
## What the SDK does not do
|
|
103
|
+
|
|
104
|
+
- It does not sign and it does not send. `tonConnectRequest` is the end of its work.
|
|
105
|
+
- It has no decoder for the book's cells beyond what `parseTonBook` checks, and no reader for the factory's internals.
|
|
106
|
+
- It has no price formula for TON: `simBuy` and `simSell` are the quote path.
|
|
107
|
+
- It does not guess an address it cannot derive: it throws.
|
package/examples/floor-line.html
CHANGED
|
@@ -238,7 +238,7 @@ const floor = floorOf(BigInt(event.sqrtF), quoteDecimals);</script>
|
|
|
238
238
|
</div></script>
|
|
239
239
|
|
|
240
240
|
<script>
|
|
241
|
-
const DATA = /*DATA*/{"run":"A simulated launch with a USDC quote at $1: 74 buys and 8 sells","quoteDecimals":6,"series":[{"i":0,"price":0.01,"floor":null,"graduated":false,"side":"open"},{"i":1,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":2,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":3,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":4,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":5,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":6,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":7,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":8,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":9,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":10,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":11,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":12,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":13,"price":0.01022274,"floor":0.01,"graduated":true,"side":"buy"},{"i":14,"price":0.01045981,"floor":0.01000702,"graduated":true,"side":"buy"},{"i":15,"price":0.01069961,"floor":0.01001356,"graduated":true,"side":"buy"},{"i":16,"price":0.01092692,"floor":0.01001968,"graduated":true,"side":"buy"},{"i":17,"price":0.01110845,"floor":0.01002545,"graduated":true,"side":"buy"},{"i":18,"price":0.0112915,"floor":0.0100309,"graduated":true,"side":"buy"},{"i":19,"price":0.01147605,"floor":0.01003607,"graduated":true,"side":"buy"},{"i":20,"price":0.0116621,"floor":0.01004098,"graduated":true,"side":"buy"},{"i":21,"price":0.01184832,"floor":0.01004568,"graduated":true,"side":"buy"},{"i":22,"price":0.0119884,"floor":0.01005016,"graduated":true,"side":"buy"},{"i":23,"price":0.01212932,"floor":0.01005447,"graduated":true,"side":"buy"},{"i":24,"price":0.01227106,"floor":0.0100586,"graduated":true,"side":"buy"},{"i":25,"price":0.01284634,"floor":0.01007293,"graduated":true,"side":"buy"},{"i":26,"price":0.01329322,"floor":0.01008562,"graduated":true,"side":"buy"},{"i":27,"price":0.01373598,"floor":0.01030198,"graduated":true,"side":"buy"},{"i":28,"price":0.01414542,"floor":0.01060907,"graduated":true,"side":"buy"},{"i":29,"price":0.01448348,"floor":0.01086261,"graduated":true,"side":"buy"},{"i":30,"price":0.01482555,"floor":0.01111917,"graduated":true,"side":"buy"},{"i":31,"price":0.01517165,"floor":0.01137874,"graduated":true,"side":"buy"},{"i":32,"price":0.01545607,"floor":0.01159206,"graduated":true,"side":"buy"},{"i":33,"price":0.0157178,"floor":0.01178835,"graduated":true,"side":"buy"},{"i":34,"price":0.01598174,"floor":0.01198631,"graduated":true,"side":"buy"},{"i":35,"price":0.01624789,"floor":0.01218592,"graduated":true,"side":"buy"},{"i":36,"price":0.01651626,"floor":0.0123872,"graduated":true,"side":"buy"},{"i":37,"price":0.01674282,"floor":0.01255712,"graduated":true,"side":"buy"},{"i":38,"price":0.01694468,"floor":0.01270851,"graduated":true,"side":"buy"},{"i":39,"price":0.01714776,"floor":0.01286082,"graduated":true,"side":"buy"},{"i":40,"price":0.01735205,"floor":0.01301404,"graduated":true,"side":"buy"},{"i":41,"price":0.01755756,"floor":0.01316817,"graduated":true,"side":"buy"},{"i":42,"price":0.01776429,"floor":0.01332322,"graduated":true,"side":"buy"},{"i":43,"price":0.01797224,"floor":0.01347918,"graduated":true,"side":"buy"},{"i":44,"price":0.01815632,"floor":0.01361724,"graduated":true,"side":"buy"},{"i":45,"price":0.01831214,"floor":0.01373411,"graduated":true,"side":"buy"},{"i":46,"price":0.01846863,"floor":0.01385147,"graduated":true,"side":"buy"},{"i":47,"price":0.0186258,"floor":0.01396935,"graduated":true,"side":"buy"},{"i":48,"price":0.01878363,"floor":0.01408772,"graduated":true,"side":"buy"},{"i":49,"price":0.01859303,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":50,"price":0.
|
|
241
|
+
const DATA = /*DATA*/{"run":"A simulated launch with a USDC quote at $1: 74 buys and 8 sells","quoteDecimals":6,"series":[{"i":0,"price":0.01,"floor":null,"graduated":false,"side":"open"},{"i":1,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":2,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":3,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":4,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":5,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":6,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":7,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":8,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":9,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":10,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":11,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":12,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":13,"price":0.01022274,"floor":0.01,"graduated":true,"side":"buy"},{"i":14,"price":0.01045981,"floor":0.01000702,"graduated":true,"side":"buy"},{"i":15,"price":0.01069961,"floor":0.01001356,"graduated":true,"side":"buy"},{"i":16,"price":0.01092692,"floor":0.01001968,"graduated":true,"side":"buy"},{"i":17,"price":0.01110845,"floor":0.01002545,"graduated":true,"side":"buy"},{"i":18,"price":0.0112915,"floor":0.0100309,"graduated":true,"side":"buy"},{"i":19,"price":0.01147605,"floor":0.01003607,"graduated":true,"side":"buy"},{"i":20,"price":0.0116621,"floor":0.01004098,"graduated":true,"side":"buy"},{"i":21,"price":0.01184832,"floor":0.01004568,"graduated":true,"side":"buy"},{"i":22,"price":0.0119884,"floor":0.01005016,"graduated":true,"side":"buy"},{"i":23,"price":0.01212932,"floor":0.01005447,"graduated":true,"side":"buy"},{"i":24,"price":0.01227106,"floor":0.0100586,"graduated":true,"side":"buy"},{"i":25,"price":0.01284634,"floor":0.01007293,"graduated":true,"side":"buy"},{"i":26,"price":0.01329322,"floor":0.01008562,"graduated":true,"side":"buy"},{"i":27,"price":0.01373598,"floor":0.01030198,"graduated":true,"side":"buy"},{"i":28,"price":0.01414542,"floor":0.01060907,"graduated":true,"side":"buy"},{"i":29,"price":0.01448348,"floor":0.01086261,"graduated":true,"side":"buy"},{"i":30,"price":0.01482555,"floor":0.01111917,"graduated":true,"side":"buy"},{"i":31,"price":0.01517165,"floor":0.01137874,"graduated":true,"side":"buy"},{"i":32,"price":0.01545607,"floor":0.01159206,"graduated":true,"side":"buy"},{"i":33,"price":0.0157178,"floor":0.01178835,"graduated":true,"side":"buy"},{"i":34,"price":0.01598174,"floor":0.01198631,"graduated":true,"side":"buy"},{"i":35,"price":0.01624789,"floor":0.01218592,"graduated":true,"side":"buy"},{"i":36,"price":0.01651626,"floor":0.0123872,"graduated":true,"side":"buy"},{"i":37,"price":0.01674282,"floor":0.01255712,"graduated":true,"side":"buy"},{"i":38,"price":0.01694468,"floor":0.01270851,"graduated":true,"side":"buy"},{"i":39,"price":0.01714776,"floor":0.01286082,"graduated":true,"side":"buy"},{"i":40,"price":0.01735205,"floor":0.01301404,"graduated":true,"side":"buy"},{"i":41,"price":0.01755756,"floor":0.01316817,"graduated":true,"side":"buy"},{"i":42,"price":0.01776429,"floor":0.01332322,"graduated":true,"side":"buy"},{"i":43,"price":0.01797224,"floor":0.01347918,"graduated":true,"side":"buy"},{"i":44,"price":0.01815632,"floor":0.01361724,"graduated":true,"side":"buy"},{"i":45,"price":0.01831214,"floor":0.01373411,"graduated":true,"side":"buy"},{"i":46,"price":0.01846863,"floor":0.01385147,"graduated":true,"side":"buy"},{"i":47,"price":0.0186258,"floor":0.01396935,"graduated":true,"side":"buy"},{"i":48,"price":0.01878363,"floor":0.01408772,"graduated":true,"side":"buy"},{"i":49,"price":0.01859303,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":50,"price":0.01830951,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":51,"price":0.01718636,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":52,"price":0.01619404,"floor":0.01408772,"graduated":true,"side":"sell"},{"i":53,"price":0.01855915,"floor":0.01408772,"graduated":true,"side":"buy"},{"i":54,"price":0.01903381,"floor":0.01427536,"graduated":true,"side":"buy"},{"i":55,"price":0.01951452,"floor":0.01463589,"graduated":true,"side":"buy"},{"i":56,"price":0.01991845,"floor":0.01493884,"graduated":true,"side":"buy"},{"i":57,"price":0.02028262,"floor":0.01521197,"graduated":true,"side":"buy"},{"i":58,"price":0.02065011,"floor":0.01548759,"graduated":true,"side":"buy"},{"i":59,"price":0.02102093,"floor":0.01576569,"graduated":true,"side":"buy"},{"i":60,"price":0.02139506,"floor":0.0160463,"graduated":true,"side":"buy"},{"i":61,"price":0.02168119,"floor":0.01626089,"graduated":true,"side":"buy"},{"i":62,"price":0.02196271,"floor":0.01647203,"graduated":true,"side":"buy"},{"i":63,"price":0.02224606,"floor":0.01668454,"graduated":true,"side":"buy"},{"i":64,"price":0.02253123,"floor":0.01689842,"graduated":true,"side":"buy"},{"i":65,"price":0.02281824,"floor":0.01711368,"graduated":true,"side":"buy"},{"i":66,"price":0.02310707,"floor":0.01733031,"graduated":true,"side":"buy"},{"i":67,"price":0.02337554,"floor":0.01753165,"graduated":true,"side":"buy"},{"i":68,"price":0.02359221,"floor":0.01769416,"graduated":true,"side":"buy"},{"i":69,"price":0.02347579,"floor":0.01769416,"graduated":true,"side":"sell"},{"i":70,"price":0.02334103,"floor":0.01769416,"graduated":true,"side":"sell"},{"i":71,"price":0.02185754,"floor":0.01769416,"graduated":true,"side":"sell"},{"i":72,"price":0.02053252,"floor":0.01769416,"graduated":true,"side":"sell"},{"i":73,"price":0.02337134,"floor":0.01769416,"graduated":true,"side":"buy"},{"i":74,"price":0.02358799,"floor":0.01769416,"graduated":true,"side":"buy"},{"i":75,"price":0.02380564,"floor":0.01785423,"graduated":true,"side":"buy"},{"i":76,"price":0.02402431,"floor":0.01801823,"graduated":true,"side":"buy"},{"i":77,"price":0.02424398,"floor":0.01818298,"graduated":true,"side":"buy"},{"i":78,"price":0.02446465,"floor":0.01834849,"graduated":true,"side":"buy"},{"i":79,"price":0.02468634,"floor":0.01851475,"graduated":true,"side":"buy"},{"i":80,"price":0.02490903,"floor":0.01868177,"graduated":true,"side":"buy"},{"i":81,"price":0.02513272,"floor":0.01884954,"graduated":true,"side":"buy"},{"i":82,"price":0.02535743,"floor":0.01901807,"graduated":true,"side":"buy"}]}/*END*/;
|
|
242
242
|
const SUPPLY = 1e9; // a FLOOR launch mints 1B tokens; market cap = price x total supply
|
|
243
243
|
const pts = DATA.series;
|
|
244
244
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floorlaunchpad/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The FLOOR Program in TypeScript: the math, the quoter, decoders, PDAs and instruction builders for Solana and EVM",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -186,6 +186,11 @@
|
|
|
186
186
|
"import": "./dist/indexer/stream.js",
|
|
187
187
|
"default": "./dist/indexer/stream.js"
|
|
188
188
|
},
|
|
189
|
+
"./ton": {
|
|
190
|
+
"types": "./src/ton/index.ts",
|
|
191
|
+
"import": "./dist/ton/index.js",
|
|
192
|
+
"default": "./dist/ton/index.js"
|
|
193
|
+
},
|
|
189
194
|
"./evm/balances": {
|
|
190
195
|
"types": "./src/evm/balances.ts",
|
|
191
196
|
"import": "./dist/evm/balances.js",
|
package/src/abi/evm.gen.ts
CHANGED
|
@@ -106,6 +106,7 @@ export const EVM_ERRORS: readonly ProgramErrorRow[] = [
|
|
|
106
106
|
{ chain: "evm", name: "PresetDisabled", message: "PresetDisabled", code: null, selector: "0x5518d9cd", signature: "PresetDisabled()" },
|
|
107
107
|
{ chain: "evm", name: "PresetIdNotNext", message: "PresetIdNotNext", code: null, selector: "0x9b5a5243", signature: "PresetIdNotNext()" },
|
|
108
108
|
{ chain: "evm", name: "PresetInvalid", message: "PresetInvalid", code: null, selector: "0x46f63096", signature: "PresetInvalid()" },
|
|
109
|
+
{ chain: "evm", name: "PriceOrder", message: "PriceOrder", code: null, selector: "0x6b2c148b", signature: "PriceOrder()" },
|
|
109
110
|
{ chain: "evm", name: "QuoteDisabled", message: "QuoteDisabled", code: null, selector: "0x31ccdc5d", signature: "QuoteDisabled()" },
|
|
110
111
|
{ chain: "evm", name: "QuoteListed", message: "QuoteListed", code: null, selector: "0xe6faf0c2", signature: "QuoteListed()" },
|
|
111
112
|
{ chain: "evm", name: "QuoteNotListed", message: "QuoteNotListed", code: null, selector: "0x06ff137a", signature: "QuoteNotListed()" },
|
|
@@ -120,6 +121,7 @@ export const EVM_ERRORS: readonly ProgramErrorRow[] = [
|
|
|
120
121
|
{ chain: "evm", name: "SafeERC20FailedOperation", message: "SafeERC20FailedOperation", code: null, selector: "0x5274afe7", signature: "SafeERC20FailedOperation(address)" },
|
|
121
122
|
{ chain: "evm", name: "SellTooLarge", message: "SellTooLarge", code: null, selector: "0x8e4d208f", signature: "SellTooLarge()" },
|
|
122
123
|
{ chain: "evm", name: "SlippageExceeded", message: "SlippageExceeded", code: null, selector: "0x8199f5f3", signature: "SlippageExceeded()" },
|
|
124
|
+
{ chain: "evm", name: "SqrtRange", message: "SqrtRange", code: null, selector: "0x1e523888", signature: "SqrtRange()" },
|
|
123
125
|
{ chain: "evm", name: "StringsInsufficientHexLength", message: "StringsInsufficientHexLength", code: null, selector: "0xe22e27eb", signature: "StringsInsufficientHexLength(uint256,uint256)" },
|
|
124
126
|
{ chain: "evm", name: "SwapDataNotEmpty", message: "SwapDataNotEmpty", code: null, selector: "0x8821f518", signature: "SwapDataNotEmpty()" },
|
|
125
127
|
{ chain: "evm", name: "SwapFailed", message: "SwapFailed", code: null, selector: "0xff9fa595", signature: "SwapFailed(bytes)" },
|
|
@@ -135,5 +137,8 @@ export const EVM_ERRORS: readonly ProgramErrorRow[] = [
|
|
|
135
137
|
{ chain: "evm", name: "UnknownLaunch", message: "UnknownLaunch", code: null, selector: "0xf6806bf8", signature: "UnknownLaunch()" },
|
|
136
138
|
{ chain: "evm", name: "UUPSUnauthorizedCallContext", message: "UUPSUnauthorizedCallContext", code: null, selector: "0xe07c8dba", signature: "UUPSUnauthorizedCallContext()" },
|
|
137
139
|
{ chain: "evm", name: "UUPSUnsupportedProxiableUUID", message: "UUPSUnsupportedProxiableUUID", code: null, selector: "0xaa1d49a4", signature: "UUPSUnsupportedProxiableUUID(bytes32)" },
|
|
140
|
+
{ chain: "evm", name: "VaultShareOutOfRange", message: "VaultShareOutOfRange", code: null, selector: "0xdb8df2d8", signature: "VaultShareOutOfRange()" },
|
|
141
|
+
{ chain: "evm", name: "Zero", message: "Zero", code: null, selector: "0xf4560403", signature: "Zero()" },
|
|
138
142
|
{ chain: "evm", name: "ZeroAddress", message: "ZeroAddress", code: null, selector: "0xd92e233d", signature: "ZeroAddress()" },
|
|
143
|
+
{ chain: "evm", name: "ZeroLiquidity", message: "ZeroLiquidity", code: null, selector: "0x10074548", signature: "ZeroLiquidity()" },
|
|
139
144
|
];
|
package/src/abi/functions.gen.ts
CHANGED
|
@@ -119,7 +119,7 @@ export const FLOOR_AMM_V2_FUNCTIONS: readonly EvmFunctionRow[] = [
|
|
|
119
119
|
{ module: "floorAmmViewsV2", name: "bidMoney", signature: "bidMoney(uint256)", selector: "0x8e403c51", outputs: "(uint256)" },
|
|
120
120
|
{ module: "floorAmmViewsV2", name: "circulatingOf", signature: "circulatingOf(uint256)", selector: "0x72812fcf", outputs: "(uint256,uint256,uint256)" },
|
|
121
121
|
{ module: "floorAmmViewsV2", name: "holderBook", signature: "holderBook(uint256)", selector: "0xf5d23b14", outputs: "((uint128,uint64,uint64,uint128,uint128))" },
|
|
122
|
-
{ module: "floorAmmViewsV2", name: "launchBook", signature: "launchBook(uint256)", selector: "0x926310f1", outputs: "((uint128,uint128,uint128,uint128[],uint8,(uint128,uint128,uint64,uint64,uint64,uint128,uint16,uint16,uint8,uint8)[48],uint128,uint64,uint64[],uint128[],uint8,uint8,uint128[],uint128[],uint128,uint64,bool,uint32[5]))" },
|
|
122
|
+
{ module: "floorAmmViewsV2", name: "launchBook", signature: "launchBook(uint256)", selector: "0x926310f1", outputs: "((uint128,uint128,uint128,uint128[],uint8,(uint128,uint128,uint64,uint64,uint64,uint128,uint16,uint16,uint8,uint8)[48],uint128,uint64,uint64[],uint128[],uint8,uint8,uint128[],uint128[],uint128,uint64,bool,uint32[5],uint128,uint64,bool))" },
|
|
123
123
|
{ module: "floorAmmViewsV2", name: "launchCount", signature: "launchCount()", selector: "0x27cca59f", outputs: "(uint256)" },
|
|
124
124
|
{ module: "floorAmmViewsV2", name: "launchFeeCurve", signature: "launchFeeCurve(uint256)", selector: "0xc598083f", outputs: "((uint32[5],uint128,uint128))" },
|
|
125
125
|
{ module: "floorAmmViewsV2", name: "launchMilestones", signature: "launchMilestones(uint256)", selector: "0x2414ccf1", outputs: "((uint128[4],uint128[4]))" },
|
|
@@ -228,19 +228,24 @@ export function createSolanaClient(opts: FloorClientOptions<"solana">): FloorCli
|
|
|
228
228
|
|
|
229
229
|
claim: (p: ClaimParams<"solana">): Promise<SolanaTx> => guard(async () => {
|
|
230
230
|
const tok = (p.types & (CLAIM_TEAM_BUY | CLAIM_SHARE_BOUGHT)) !== 0;
|
|
231
|
-
const launches: ClaimLaunchV2[] = [];
|
|
232
231
|
let qtp: string | null = null;
|
|
233
232
|
let qIsLaunch = false;
|
|
234
|
-
|
|
233
|
+
|
|
234
|
+
const read = await Promise.all(p.launches.map(async (mint) => {
|
|
235
235
|
const { address, l } = await launchOf(mint);
|
|
236
236
|
if (l.quoteMint !== p.quote) throw bad(`launch ${mint} trades in ${l.quoteMint}, not ${p.quote}`);
|
|
237
|
-
qtp = l.quoteTokenProgram;
|
|
238
|
-
qIsLaunch = await quoteIsLaunchOf(l);
|
|
239
237
|
const slot = teamSlotPda(address, pid)[0];
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
238
|
+
const [isLaunch, slotAcc] = await Promise.all([quoteIsLaunchOf(l), get(slot)]);
|
|
239
|
+
return { mint, address, l, slot, isLaunch, slotAcc };
|
|
240
|
+
}));
|
|
241
|
+
const launches: ClaimLaunchV2[] = read.map(({ address, l, slot, slotAcc }) => ({
|
|
242
|
+
launch: address, quoteVault: l.quoteVault, teamSlot: slotAcc !== null ? slot : null, baseMint: l.baseMint,
|
|
243
|
+
...(tok ? { teamBuy: { baseMint: l.baseMint, tokenVault: l.tokenVault, walletBase: associatedTokenAddress(p.wallet, l.baseMint, TOKEN_2022_PROGRAM_ID) } } : {}),
|
|
244
|
+
}));
|
|
245
|
+
const last = read.at(-1);
|
|
246
|
+
if (last !== undefined) {
|
|
247
|
+
qtp = last.l.quoteTokenProgram;
|
|
248
|
+
qIsLaunch = last.isLaunch;
|
|
244
249
|
}
|
|
245
250
|
if (qtp === null) {
|
|
246
251
|
const m = await get(p.quote);
|
package/src/config/generated.ts
CHANGED
|
@@ -27113,6 +27113,83 @@ export const CHAIN_ROWS = [
|
|
|
27113
27113
|
"address": "0xfd6f06d323f6cb08ee9eeb2d201e9ec0e9112c88",
|
|
27114
27114
|
"decimals": 18,
|
|
27115
27115
|
"kind": "stock"
|
|
27116
|
+
},
|
|
27117
|
+
{
|
|
27118
|
+
"symbol": "EQQQQ",
|
|
27119
|
+
"name": "EQX Tokenized QQQ",
|
|
27120
|
+
"address": "0x095cca17f0619596115eA09bbE1D80431685Ba1A",
|
|
27121
|
+
"decimals": 8,
|
|
27122
|
+
"kind": "stock"
|
|
27123
|
+
},
|
|
27124
|
+
{
|
|
27125
|
+
"symbol": "EQSPY",
|
|
27126
|
+
"name": "EQX Tokenized SPY",
|
|
27127
|
+
"address": "0x07A76acCed707De999A54D39aFF62A2d7ac4CC81",
|
|
27128
|
+
"decimals": 8,
|
|
27129
|
+
"kind": "stock"
|
|
27130
|
+
},
|
|
27131
|
+
{
|
|
27132
|
+
"symbol": "EQNVDA",
|
|
27133
|
+
"name": "EQX Tokenized NVDA",
|
|
27134
|
+
"address": "0xA23aFe6Bd466BdB806a83AfDDA76F644FC4347CF",
|
|
27135
|
+
"decimals": 8,
|
|
27136
|
+
"kind": "stock"
|
|
27137
|
+
},
|
|
27138
|
+
{
|
|
27139
|
+
"symbol": "EQTSLA",
|
|
27140
|
+
"name": "EQX Tokenized TSLA",
|
|
27141
|
+
"address": "0x883DAd2Aa97175c0D1569E1de61204ac47b2b8fb",
|
|
27142
|
+
"decimals": 8,
|
|
27143
|
+
"kind": "stock"
|
|
27144
|
+
},
|
|
27145
|
+
{
|
|
27146
|
+
"symbol": "EQAAPL",
|
|
27147
|
+
"name": "EQX Tokenized AAPL",
|
|
27148
|
+
"address": "0x15d82780780Ca72570818f91587B752562D655bc",
|
|
27149
|
+
"decimals": 8,
|
|
27150
|
+
"kind": "stock"
|
|
27151
|
+
},
|
|
27152
|
+
{
|
|
27153
|
+
"symbol": "EQGOOG",
|
|
27154
|
+
"name": "EQX Tokenized GOOGL",
|
|
27155
|
+
"address": "0x4720b40C89Ff3A74C6bE8eA34Cf40FaE5eacEd79",
|
|
27156
|
+
"decimals": 8,
|
|
27157
|
+
"kind": "stock"
|
|
27158
|
+
},
|
|
27159
|
+
{
|
|
27160
|
+
"symbol": "EQMETA",
|
|
27161
|
+
"name": "EQX Tokenized META",
|
|
27162
|
+
"address": "0xF5c6190d9178097563372a4acA15D52Ec24F129A",
|
|
27163
|
+
"decimals": 8,
|
|
27164
|
+
"kind": "stock"
|
|
27165
|
+
},
|
|
27166
|
+
{
|
|
27167
|
+
"symbol": "EQMSFT",
|
|
27168
|
+
"name": "EQX Tokenized MSFT",
|
|
27169
|
+
"address": "0xca911A8ae21baAf9CDec0baa45259c64Ec8AE59E",
|
|
27170
|
+
"decimals": 8,
|
|
27171
|
+
"kind": "stock"
|
|
27172
|
+
},
|
|
27173
|
+
{
|
|
27174
|
+
"symbol": "EQAMZN",
|
|
27175
|
+
"name": "EQX Tokenized AMZN",
|
|
27176
|
+
"address": "0x582C6ADd0eb720EA1c2e2019fF9b7c21Fe99288F",
|
|
27177
|
+
"decimals": 8,
|
|
27178
|
+
"kind": "stock"
|
|
27179
|
+
},
|
|
27180
|
+
{
|
|
27181
|
+
"symbol": "EQMU",
|
|
27182
|
+
"name": "EQX Tokenized MU",
|
|
27183
|
+
"address": "0x9164Fd5f67FE4188Ff79675182183512bC37d66D",
|
|
27184
|
+
"decimals": 8,
|
|
27185
|
+
"kind": "stock"
|
|
27186
|
+
},
|
|
27187
|
+
{
|
|
27188
|
+
"symbol": "EQSPCX",
|
|
27189
|
+
"name": "EQX Tokenized SPCX",
|
|
27190
|
+
"address": "0xF115FF708A795cD0E06531Dec57ed716138bE8BD",
|
|
27191
|
+
"decimals": 8,
|
|
27192
|
+
"kind": "stock"
|
|
27116
27193
|
}
|
|
27117
27194
|
]
|
|
27118
27195
|
},
|
|
@@ -27120,7 +27197,7 @@ export const CHAIN_ROWS = [
|
|
|
27120
27197
|
"name": "elysium",
|
|
27121
27198
|
"label": "Elysium",
|
|
27122
27199
|
"family": "evm",
|
|
27123
|
-
"v2DayOne":
|
|
27200
|
+
"v2DayOne": true,
|
|
27124
27201
|
"chainId": 99901,
|
|
27125
27202
|
"native": "HYPE",
|
|
27126
27203
|
"nativeName": "Hype",
|
package/src/evm/chains.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { bytesToHex, checksumAddress, create2Address, encodeAbi, hexToBytes } from "./abi.ts";
|
|
4
4
|
import { keccak256 } from "./keccak.ts";
|
|
5
|
-
import type { ZapFamily } from "./zap.ts";
|
|
5
|
+
import type { ZapFamily, ZapUrFork } from "./zap.ts";
|
|
6
6
|
import { CHAIN_REGISTRY, EVM_CHAIN_SLUGS } from "../config/registry.gen.ts";
|
|
7
7
|
|
|
8
8
|
export type ChainKey = (typeof EVM_CHAIN_SLUGS)[number];
|
|
@@ -18,6 +18,10 @@ export interface ZapRouter {
|
|
|
18
18
|
optional: boolean;
|
|
19
19
|
|
|
20
20
|
forkEncoding?: boolean;
|
|
21
|
+
|
|
22
|
+
urFork?: ZapUrFork;
|
|
23
|
+
|
|
24
|
+
zap: string | null;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
export interface EvmChain {
|
|
@@ -42,79 +46,121 @@ function strict(a: string): string {
|
|
|
42
46
|
return c;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
type ZapRouterSpec = Omit<ZapRouter, "zap">;
|
|
50
|
+
|
|
51
|
+
const UR_FORK_OF_SLOT: Readonly<Record<string, ZapUrFork>> = { "aerodrome-ur": "aerodrome", "pancake-ur": "pancake", "ramses-ur": "ramses" };
|
|
52
|
+
function urForkOf(slot: string): ZapUrFork {
|
|
53
|
+
const f = UR_FORK_OF_SLOT[slot];
|
|
54
|
+
if (!f) throw new RangeError(`the UR fork row ${slot} names no fork`);
|
|
55
|
+
return f;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const r = (slot: string, amm: string, router: string, family: ZapFamily, confidence: ZapRouter["confidence"], optional = false, forkEncoding = false): ZapRouterSpec => ({
|
|
46
59
|
slot,
|
|
47
60
|
amm,
|
|
48
61
|
router: strict(router),
|
|
49
62
|
family,
|
|
50
63
|
confidence,
|
|
51
64
|
optional,
|
|
52
|
-
...(forkEncoding ? { forkEncoding } : {}),
|
|
65
|
+
...(forkEncoding ? { forkEncoding, urFork: urForkOf(slot) } : {}),
|
|
53
66
|
});
|
|
54
67
|
|
|
68
|
+
export const FLOOR_ZAP_ADDRESSES: Readonly<Record<ChainKey, Readonly<Record<string, string>>>> = {
|
|
69
|
+
ethereum: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
70
|
+
base: {
|
|
71
|
+
"aerodrome-ur": strict("0xD8329A195F26c27A911B5CE697B11947984dc0d1"),
|
|
72
|
+
"uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995"),
|
|
73
|
+
"pancake-ur": strict("0xE4335AaC829a788bb6988A372edfe3Cda41B0931"),
|
|
74
|
+
},
|
|
75
|
+
bsc: {
|
|
76
|
+
"pancake-ur": strict("0xE4335AaC829a788bb6988A372edfe3Cda41B0931"),
|
|
77
|
+
"uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995"),
|
|
78
|
+
},
|
|
79
|
+
arbitrum: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
80
|
+
hyperevm: {
|
|
81
|
+
prjx: strict("0x02E658B2B205F76850Cf6d584477A58cD797e46a"),
|
|
82
|
+
nest: strict("0x93aC608AA016271BBB92924C3838a0b550c34ce1"),
|
|
83
|
+
"ramses-ur": strict("0x4b22d4b3F104D76aB92A2CA4E5E4A08A27F18f52"),
|
|
84
|
+
hyperswap: strict("0x782DB7e687E16Bfe00C9a0CE41A76A7cC507566F"),
|
|
85
|
+
},
|
|
86
|
+
robinhood: {
|
|
87
|
+
"uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995"),
|
|
88
|
+
"ramses-ur": strict("0x4b22d4b3F104D76aB92A2CA4E5E4A08A27F18f52"),
|
|
89
|
+
},
|
|
90
|
+
arc: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
91
|
+
elysium: { "uniswap-ur": strict("0x56F22be922Ffc9e955169E0673D3Ae42B1151995") },
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
function withBookedZaps(key: ChainKey, rows: readonly ZapRouterSpec[]): ZapRouter[] {
|
|
95
|
+
const book = FLOOR_ZAP_ADDRESSES[key];
|
|
96
|
+
return rows.map((row) => ({ ...row, zap: book[row.slot] ?? null }));
|
|
97
|
+
}
|
|
98
|
+
|
|
55
99
|
const UNISWAP_UR = "uniswap-ur";
|
|
56
100
|
|
|
57
101
|
const ROUTES: Record<ChainKey, Omit<EvmChain, "key" | "chainId" | "name" | "nativeSymbol">> = {
|
|
58
102
|
ethereum: {
|
|
59
103
|
wrappedNative: strict("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
|
|
60
|
-
zapRouters: [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x4C82D1fBFe28C977cBB58D8C7FF8FCF9F70a2cCA", "uniswap-ur", "HIGH")],
|
|
104
|
+
zapRouters: withBookedZaps("ethereum", [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x4C82D1fBFe28C977cBB58D8C7FF8FCF9F70a2cCA", "uniswap-ur", "HIGH")]),
|
|
61
105
|
notes: [],
|
|
62
106
|
},
|
|
63
107
|
base: {
|
|
64
108
|
wrappedNative: strict("0x4200000000000000000000000000000000000006"),
|
|
65
|
-
zapRouters: [
|
|
109
|
+
zapRouters: withBookedZaps("base", [
|
|
66
110
|
r("aerodrome-ur", "Aerodrome V1 + Slipstream", "0xC5b6786D7B64767D775877b0B6A319AD946B11B5", "uniswap-ur", "HIGH", false, true),
|
|
67
111
|
r(UNISWAP_UR, "Uniswap v2/v3/v4", "0xFdf682F51FE81Aa4898F0AE2163d8A55c127fbC7", "uniswap-ur", "HIGH"),
|
|
68
112
|
r("pancake-ur", "PancakeSwap V3 / Infinity", "0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB", "uniswap-ur", "HIGH", true, true),
|
|
69
|
-
],
|
|
113
|
+
]),
|
|
70
114
|
notes: [],
|
|
71
115
|
},
|
|
72
116
|
bsc: {
|
|
73
117
|
wrappedNative: strict("0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"),
|
|
74
|
-
zapRouters: [
|
|
118
|
+
zapRouters: withBookedZaps("bsc", [
|
|
75
119
|
r("pancake-ur", "PancakeSwap V2 / V3 / Infinity", "0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB", "uniswap-ur", "HIGH", false, true),
|
|
76
120
|
r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x8B844f885672f333Bc0042cB669255f93a4C1E6b", "uniswap-ur", "HIGH"),
|
|
77
|
-
],
|
|
121
|
+
]),
|
|
78
122
|
notes: ["⚠ 0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD is Uniswap's UR v1.2, NOT PancakeSwap's: never use it as Pancake's."],
|
|
79
123
|
},
|
|
80
124
|
arbitrum: {
|
|
81
125
|
wrappedNative: strict("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),
|
|
82
|
-
zapRouters: [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x8B844f885672f333Bc0042cB669255f93a4C1E6b", "uniswap-ur", "HIGH")],
|
|
126
|
+
zapRouters: withBookedZaps("arbitrum", [r(UNISWAP_UR, "Uniswap v2/v3/v4", "0x8B844f885672f333Bc0042cB669255f93a4C1E6b", "uniswap-ur", "HIGH")]),
|
|
83
127
|
notes: [],
|
|
84
128
|
},
|
|
85
129
|
hyperevm: {
|
|
86
130
|
maxFloorHops: 2,
|
|
87
131
|
wrappedNative: strict("0x5555555555555555555555555555555555555555"),
|
|
88
|
-
zapRouters: [
|
|
132
|
+
zapRouters: withBookedZaps("hyperevm", [
|
|
89
133
|
r("prjx", "Project X", "0x1EbDFC75FfE3ba3de61E7138a3E8706aC841Af9B", "v3-router", "MEDIUM–HIGH"),
|
|
90
134
|
r("nest", "nest (CL)", "0xaA26B8e5Cadd04430c32787eCC3AA325e99681e9", "algebra", "HIGH"),
|
|
91
135
|
r("ramses-ur", "Ramses CL V2", "0xc43b33b5DF826A48DAE764817647824ED4f476a7", "uniswap-ur", "MEDIUM", false, true),
|
|
92
136
|
r("hyperswap", "HyperSwap V3", "0x6D99e7f6747AF2cDbB5164b6DD50e40D4fDe1e77", "v3-router02", "HIGH", true),
|
|
93
|
-
],
|
|
137
|
+
]),
|
|
94
138
|
notes: ["⚠ Small blocks cap a transaction at 3M gas: a buy that graduates a launch may need a big block."],
|
|
95
139
|
},
|
|
96
140
|
robinhood: {
|
|
97
141
|
wrappedNative: strict("0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"),
|
|
98
|
-
zapRouters: [
|
|
142
|
+
zapRouters: withBookedZaps("robinhood", [
|
|
99
143
|
r(UNISWAP_UR, "Uniswap v2/v3/v4 (+ Fables v4 pools)", "0x8876789976dEcBfCbBbe364623C63652db8C0904", "uniswap-ur", "HIGH"),
|
|
100
144
|
r("ramses-ur", "Ramses", "0xbFbb2BCBc9dfFA029C27A249ae9BE031E1d83b1C", "uniswap-ur", "HIGH", true, true),
|
|
101
|
-
],
|
|
145
|
+
]),
|
|
102
146
|
notes: [],
|
|
103
147
|
},
|
|
104
148
|
arc: {
|
|
105
149
|
wrappedNative: null,
|
|
106
|
-
zapRouters: [r(UNISWAP_UR, "Uniswap v4 (native-USDC pools)", "0x4fcA4a51Ab4F23A7447b3284fBd7D73289A89Fb1", "uniswap-ur", "HIGH")],
|
|
150
|
+
zapRouters: withBookedZaps("arc", [r(UNISWAP_UR, "Uniswap v4 (native-USDC pools)", "0x4fcA4a51Ab4F23A7447b3284fBd7D73289A89Fb1", "uniswap-ur", "HIGH")]),
|
|
107
151
|
notes: [
|
|
108
152
|
"⚠ The native coin is USDC (18 dp at the EVM level; its ERC-20 view 0x3600000000000000000000000000000000000000 has 6 dp and no deposit()).",
|
|
109
153
|
"⚠ 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.",
|
|
110
154
|
],
|
|
111
155
|
},
|
|
112
156
|
elysium: {
|
|
113
|
-
|
|
114
|
-
|
|
157
|
+
|
|
158
|
+
wrappedNative: strict("0xbA876237B0F021A6c6D852d6c26E107997cC5E81"),
|
|
159
|
+
|
|
160
|
+
zapRouters: withBookedZaps("elysium", [r(UNISWAP_UR, "Uniswap v4 (native HYPE / USDC pools)", "0xA13f7611115752DEB2B13813BDDE16A5073e4b45", "uniswap-ur", "HIGH")]),
|
|
115
161
|
notes: [
|
|
116
162
|
"⚠ Arbitrum Orbit on HyperEVM: in a contract block.number is HyperEVM's block; the receipt's block is Elysium's.",
|
|
117
|
-
"⚠
|
|
163
|
+
"⚠ 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.",
|
|
118
164
|
],
|
|
119
165
|
},
|
|
120
166
|
};
|
package/src/evm/squid.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type SquidHook = {
|
|
|
39
39
|
|
|
40
40
|
export const SQUID_TOKEN_SCALE = 10n ** 12n;
|
|
41
41
|
|
|
42
|
-
export const SQUID_GAS = { transfer: 65_000, buy:
|
|
42
|
+
export const SQUID_GAS = { transfer: 65_000, buy: 1_100_000, sell: 850_000, zapBuy: 1_300_000, passOn: 30_000 } as const;
|
|
43
43
|
|
|
44
44
|
type Common = {
|
|
45
45
|
chainId: number | string;
|
|
@@ -96,19 +96,19 @@ export function buyHookErc20(p: Common & { quote: string; minTokensOut: bigint }
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
export function buyHookNative(p: Common & { zap: string; swapData: string; minQuoteIn: bigint; minTokensOut: bigint }): SquidHook {
|
|
99
|
+
export function buyHookNative(p: Common & { zap: string; swapData: string; minQuoteIn: bigint; minTokensOut: bigint; quote: string }): SquidHook {
|
|
100
100
|
checkCommon(p);
|
|
101
101
|
const user = checkUser(p);
|
|
102
102
|
if (p.minQuoteIn <= 0n || p.minTokensOut <= 0n) throw new SquidHookError("NO_MINIMUM", "minQuoteIn and minTokensOut must be > 0");
|
|
103
103
|
const zap = lc(p.zap, "zap");
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
104
|
+
const quote = lc(p.quote, "quote");
|
|
105
|
+
const calls = [
|
|
106
|
+
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),
|
|
107
|
+
call(SQUID_CALL.FullNativeBalance, user, 0n, "0x", "0x", SQUID_GAS.passOn),
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
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));
|
|
111
|
+
return { provider: "FLOOR", description: "Buy a FLOOR launch token with the native coin", calls };
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export function sellHook(p: Common & { token: string; tokensIn: bigint; minQuoteOut: bigint; proceedsTo?: string }): SquidHook {
|