@gangfun/cli 0.17.4 → 0.17.5
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/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/package.json +1 -1
- package/src/bond.js +3 -3
- package/src/buyback.js +3 -3
- package/src/chain.js +4 -4
- package/src/fair.js +3 -3
- package/src/gangpad.js +62 -3
- package/src/index.js +2 -2
- package/src/launch.js +3 -3
- package/src/v3.js +3 -3
package/README.md
CHANGED
|
@@ -251,7 +251,7 @@ timed-out `gang_execute`, check `gang_status` / the wallet history instead of ex
|
|
|
251
251
|
|
|
252
252
|
| Var | Meaning |
|
|
253
253
|
|---|---|
|
|
254
|
-
| `GANG_RPC_URL` | BSC HTTP RPC |
|
|
254
|
+
| `GANG_RPC_URL` | BSC HTTP RPC: one URL, or a comma-separated list tried in order. Unset: five public nodes (BNB Chain's dataseed nodes, then PublicNode); a call that fails on one (rate limit, timeout) moves to the next, and later calls start at the one that answered (0.17.5+). A revert is never retried on another node |
|
|
255
255
|
| `GANG_LOGO_API` | Logo upload endpoint (default `https://gang.fun/api/logos`) |
|
|
256
256
|
| `GANG_CDN_BASE` | CDN serving uploads as `<base>/ipfs/<cid>` (default `https://cdn.gang.fun`) |
|
|
257
257
|
| `GANG_API` | Indexer API for discovery and note publishing (default `https://gang.fun/api`) |
|
|
@@ -260,10 +260,10 @@ timed-out `gang_execute`, check `gang_status` / the wallet history instead of ex
|
|
|
260
260
|
| `GANG_UPDATE_CHECK` | `0` turns off the once-a-day check for a newer CLI on npm (cached in `~/.gang/update.json`) |
|
|
261
261
|
| `GANG_UPDATE_URL` | Where that check asks, default `https://registry.npmjs.org/@gangfun/cli/latest`; set an npm mirror's `…/@gangfun/cli/latest` if npmjs is slow or blocked |
|
|
262
262
|
| `GANG_PAD` / `GANG_TESTNET_PAD` | Override the merged GangLaunchpad (mainnet / testnet) behind V3 and 打新 (defaults: mainnet `0x15CF…4365`, testnet set 10 `0xFebF…5BB1`). Old names `GANG_V3_PAD` / `GANG_FAIR_PAD`, `GANG_V3_TESTNET_PAD` / `GANG_FAIR_TESTNET_PAD` still work as aliases |
|
|
263
|
-
| `GANG_TESTNET_RPC_URL` | Testnet RPC; old names `GANG_V3_TESTNET_RPC_URL` / `GANG_FAIR_TESTNET_RPC_URL` still work |
|
|
263
|
+
| `GANG_TESTNET_RPC_URL` | Testnet RPC, one URL or a comma list (unset: PublicNode, then BNB Chain's testnet nodes); old names `GANG_V3_TESTNET_RPC_URL` / `GANG_FAIR_TESTNET_RPC_URL` still work |
|
|
264
264
|
| `GANG_BOND` / `GANG_TESTNET_BOND` | GangBond (creator bonds, `gang bond`). Defaults: mainnet `0xe92d…14E4` (since 2026-10-29, CLI 0.16.2+), testnet `0xd6a8…1086` |
|
|
265
265
|
| `GANG_ROUTER` / `GANG_TESTNET_ROUTER` | GangRouter proxy (native-BNB V3 buys / mints, and every PancakeSwap trade of a graduated token); old name `GANG_ROUTER_TESTNET` still works. Defaults: mainnet `0xE040…79C4`, testnet set 10 `0x6bB6…C9F6` |
|
|
266
266
|
|
|
267
267
|
## Version
|
|
268
268
|
|
|
269
|
-
`0.17.
|
|
269
|
+
`0.17.5` · repo [gangfun/cli](https://github.com/gangfun/cli) · published to [npm](https://www.npmjs.com/package/@gangfun/cli) on push to `main`
|
package/README.zh-CN.md
CHANGED
|
@@ -215,7 +215,7 @@ Claude Code:`claude mcp add gang -- gang mcp`。同一台机器上 `baw` 要
|
|
|
215
215
|
|
|
216
216
|
| 变量 | 含义 |
|
|
217
217
|
|---|---|
|
|
218
|
-
| `GANG_RPC_URL` | BSC RPC |
|
|
218
|
+
| `GANG_RPC_URL` | BSC RPC:填一个地址,或用逗号分隔的多个地址(按顺序使用)。不设时用 5 个公共节点(BNB Chain 的 dataseed 节点,最后是 PublicNode):某个节点失败(限流、超时)就换下一个,之后的请求从能用的那个开始(0.17.5+)。合约 revert 不会换节点重试 |
|
|
219
219
|
| `GANG_LOGO_API` | Logo 上传 API(默认 `https://gang.fun/api/logos`) |
|
|
220
220
|
| `GANG_CDN_BASE` | 上传文件的 CDN,地址为 `<base>/ipfs/<cid>`(默认 `https://cdn.gang.fun`) |
|
|
221
221
|
| `GANG_API` | indexer API,发现命令和公开附言都用它(默认 `https://gang.fun/api`) |
|
|
@@ -224,10 +224,10 @@ Claude Code:`claude mcp add gang -- gang mcp`。同一台机器上 `baw` 要
|
|
|
224
224
|
| `GANG_UPDATE_CHECK` | 设为 `0` 关闭每天一次的新版本检查(查 npm,缓存在 `~/.gang/update.json`) |
|
|
225
225
|
| `GANG_UPDATE_URL` | 新版本检查查询的地址,默认 `https://registry.npmjs.org/@gangfun/cli/latest`;npmjs 慢或打不开时,可以换成 npm 镜像的 `…/@gangfun/cli/latest` |
|
|
226
226
|
| `GANG_PAD` / `GANG_TESTNET_PAD` | 覆盖合并后的内盘合约 GangLaunchpad(主网 / 测试网),V3 和打新共用(默认:主网 `0x15CF…4365`,测试网第 10 套 `0xFebF…5BB1`)。旧名 `GANG_V3_PAD` / `GANG_FAIR_PAD`、`GANG_V3_TESTNET_PAD` / `GANG_FAIR_TESTNET_PAD` 仍可用(别名) |
|
|
227
|
-
| `GANG_TESTNET_RPC_URL` | 测试网 RPC
|
|
227
|
+
| `GANG_TESTNET_RPC_URL` | 测试网 RPC,可填一个或逗号分隔的多个(不设时先用 PublicNode,再用 BNB Chain 的测试网节点);旧名 `GANG_V3_TESTNET_RPC_URL` / `GANG_FAIR_TESTNET_RPC_URL` 仍可用 |
|
|
228
228
|
| `GANG_BOND` / `GANG_TESTNET_BOND` | GangBond(押金承诺,`gang bond`)。默认:主网 `0xe92d…14E4`(2026-10-29 起,CLI 0.16.2+),测试网 `0xd6a8…1086` |
|
|
229
229
|
| `GANG_ROUTER` / `GANG_TESTNET_ROUTER` | GangRouter 代理(用原生 BNB 买 V3 / 打新,以及已毕业币的所有外盘买卖);旧名 `GANG_ROUTER_TESTNET` 仍可用。默认:主网 `0xE040…79C4`,测试网第 10 套 `0x6bB6…C9F6` |
|
|
230
230
|
|
|
231
231
|
## 版本
|
|
232
232
|
|
|
233
|
-
`0.17.
|
|
233
|
+
`0.17.5` · [gangfun/cli](https://github.com/gangfun/cli) · push 到 `main` 自动发布到 [npm](https://www.npmjs.com/package/@gangfun/cli)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.5",
|
|
4
4
|
"description": "Gang launchpad CLI for Binance Agentic Wallet agents: create on GangLaunchpad (untaxed or tax tokens), 打新 fair mint, PancakeSwap pool trades, LaunchpadV2 and legacy Soft/U/S trade.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/bond.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createPublicClient,
|
|
1
|
+
import { createPublicClient, parseAbi, encodeFunctionData, decodeEventLog, formatUnits, parseUnits, isAddress, zeroAddress } from 'viem'
|
|
2
2
|
import { decimalsOf, fundingStep as fund, parseAmount, parseIntIn, parseNum, revertOf as revertIn, step, units, GAS_RESERVE } from './steps.js'
|
|
3
|
-
import { MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, padNets } from './gangpad.js'
|
|
3
|
+
import { MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, padNets, rpcTransport } from './gangpad.js'
|
|
4
4
|
import { bawAddress } from './baw.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -115,7 +115,7 @@ function bondCtx(testnet) {
|
|
|
115
115
|
if (!net.pad) throw new Error(NOT_ON_MAINNET)
|
|
116
116
|
const bond = bondAddress(testnet)
|
|
117
117
|
if (!bond) throw new Error(`GangBond is not deployed on ${testnet ? 'the BSC testnet' : 'BSC mainnet'} in this CLI version: set ${testnet ? 'GANG_TESTNET_BOND' : 'GANG_BOND'} to its address`)
|
|
118
|
-
const client = createPublicClient({ chain: net.chain, transport:
|
|
118
|
+
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
119
119
|
return { ...net, bond, client, read: (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args }) }
|
|
120
120
|
}
|
|
121
121
|
|
package/src/buyback.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createPublicClient,
|
|
2
|
-
import { padNets, NOT_ON_MAINNET } from './gangpad.js'
|
|
1
|
+
import { createPublicClient, parseAbi, encodeFunctionData, formatUnits, hexToString, isAddress, zeroAddress } from 'viem'
|
|
2
|
+
import { padNets, NOT_ON_MAINNET, rpcTransport } from './gangpad.js'
|
|
3
3
|
import { walletFor } from './fair.js'
|
|
4
4
|
import { parseNum, revertOf as revertIn, step } from './steps.js'
|
|
5
5
|
|
|
@@ -122,7 +122,7 @@ export async function splitterOf(read, addr) {
|
|
|
122
122
|
function buybackCtx(testnet) {
|
|
123
123
|
const net = padNets('v3')[testnet ? 'testnet' : 'mainnet']
|
|
124
124
|
if (!net.pad) throw new Error(NOT_ON_MAINNET)
|
|
125
|
-
const client = createPublicClient({ chain: net.chain, transport:
|
|
125
|
+
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
126
126
|
return { ...net, client, read: (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args }) }
|
|
127
127
|
}
|
|
128
128
|
|
package/src/chain.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createPublicClient,
|
|
1
|
+
import { createPublicClient, formatEther, parseEther, encodeFunctionData, decodeEventLog, isAddress, zeroAddress } from 'viem'
|
|
2
2
|
import { bsc } from 'viem/chains'
|
|
3
3
|
import { SOFT_ABI, V2_ABI, S_ABI, ERC20_ABI, WBNB_ABI } from './abi.js'
|
|
4
|
-
import { kindOf, padNets } from './gangpad.js'
|
|
4
|
+
import { kindOf, padNets, rpcTransport } from './gangpad.js'
|
|
5
5
|
|
|
6
6
|
export const ADDR = {
|
|
7
7
|
v2: '0x1B8F3f69DFa0a7F63d308C7EB0Fd38D8b099966E',
|
|
@@ -12,11 +12,11 @@ export const ADDR = {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const CONFIG = {
|
|
15
|
-
rpc: process.env.GANG_RPC_URL || 'https://bsc-dataseed.binance.org',
|
|
16
15
|
chainId: '56',
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
// GANG_RPC_URL or the public nodes (gangpad.js), shared with the GangLaunchpad clients
|
|
19
|
+
export const client = createPublicClient({ chain: bsc, transport: rpcTransport(padNets('v3').mainnet.rpcs) })
|
|
20
20
|
export const fmt = (wei) => formatEther(wei)
|
|
21
21
|
export const fmtTok = (units) => Number(formatEther(units)).toLocaleString('en-US', { maximumFractionDigits: 2 })
|
|
22
22
|
export { parseEther, encodeFunctionData, isAddress, zeroAddress }
|
package/src/fair.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createPublicClient,
|
|
1
|
+
import { createPublicClient, parseAbi, encodeFunctionData, decodeEventLog, formatUnits, parseEther, parseUnits, isAddress, zeroAddress } from 'viem'
|
|
2
2
|
import { bawAddress } from './baw.js'
|
|
3
3
|
import { defaultRefPool, dividendOf, fundingStep as fund, parseAmount, parseIntIn, parseNum, poolSellQuote, POOL_SELL_HINT, revertOf as revertIn, ROUTER_ABI, ROUTER_HINTS, routerDeadline, step, swapBackState, units, viaRouter, GAS_RESERVE } from './steps.js'
|
|
4
4
|
import { API } from './discover.js'
|
|
5
5
|
import { UA } from './version.js'
|
|
6
|
-
import { MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, notThisKind, padNets } from './gangpad.js'
|
|
6
|
+
import { MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, notThisKind, padNets, rpcTransport } from './gangpad.js'
|
|
7
7
|
import { poolPayBnb, poolTrade } from './pool.js'
|
|
8
8
|
import { bondAddress, bondGuard } from './bond.js'
|
|
9
9
|
|
|
@@ -111,7 +111,7 @@ export const FAIR_EVENT_ABIS = [PAD_ABI, VAULT_ABI]
|
|
|
111
111
|
export function fairCtx(testnet) {
|
|
112
112
|
const net = FAIR_NETS[testnet ? 'testnet' : 'mainnet']
|
|
113
113
|
if (!net.pad) throw new Error(NOT_ON_MAINNET)
|
|
114
|
-
const client = createPublicClient({ chain: net.chain, transport:
|
|
114
|
+
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
115
115
|
return { ...net, client, read: (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args }) }
|
|
116
116
|
}
|
|
117
117
|
|
package/src/gangpad.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseAbi } from 'viem'
|
|
1
|
+
import { createTransport, http, parseAbi } from 'viem'
|
|
2
2
|
import { bsc, bscTestnet } from 'viem/chains'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -12,6 +12,7 @@ import { bsc, bscTestnet } from 'viem/chains'
|
|
|
12
12
|
* testnet: GANG_TESTNET_PAD (aliases GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD),
|
|
13
13
|
* GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET),
|
|
14
14
|
* GANG_TESTNET_RPC_URL (aliases GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL)
|
|
15
|
+
* An RPC variable takes one URL or a comma-separated list; set, it replaces the public nodes below.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
// the current testnet set (set 10, 2026-10-27: §23 aggregator entries); the name is kept from set 8
|
|
@@ -29,6 +30,64 @@ const TESTNET_SET7 = {
|
|
|
29
30
|
router: '0x9dBb3D25Ff5c8107814fBD96A88D6eD015dfA279',
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
// Public BSC nodes, tried in this order (2026-10-30: each answered eth_call with revert data, tx and receipt reads).
|
|
34
|
+
// Several operators, so one node's rate limit or outage does not stop a preview.
|
|
35
|
+
export const MAINNET_RPCS = [
|
|
36
|
+
'https://bsc-dataseed.binance.org', 'https://bsc-dataseed.bnbchain.org', 'https://bsc-dataseed1.defibit.io',
|
|
37
|
+
'https://bsc-dataseed1.ninicoin.io', 'https://bsc-rpc.publicnode.com',
|
|
38
|
+
]
|
|
39
|
+
// publicnode first: the data-seed nodes keep little state and answer `missing trie node` sooner
|
|
40
|
+
export const TESTNET_RPCS = [
|
|
41
|
+
'https://bsc-testnet-rpc.publicnode.com', 'https://bsc-testnet.bnbchain.org',
|
|
42
|
+
'https://data-seed-prebsc-1-s1.bnbchain.org:8545', 'https://data-seed-prebsc-2-s1.bnbchain.org:8545',
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
/** An RPC variable's value → its URLs (one, or a comma-separated list), or null when unset / empty. */
|
|
46
|
+
export const rpcList = (v) => {
|
|
47
|
+
const urls = (v ?? '').split(',').map((s) => s.trim()).filter(Boolean)
|
|
48
|
+
return urls.length ? urls : null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// what every node would answer alike: the contract's revert, gas or funds the call lacks. Thrown at once, not retried
|
|
52
|
+
const SAME_ON_EVERY_NODE = /execution reverted|gas required exceeds allowance|insufficient funds/i
|
|
53
|
+
const sameOnEveryNode = (e) => e?.code === 3 || SAME_ON_EVERY_NODE.test(e?.details ?? '')
|
|
54
|
+
// list → the index of the node that answered last; the next call (of any client on that list) starts there
|
|
55
|
+
const lastGood = new Map()
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* viem transport over a list of nodes. A call goes to the node that answered last and moves down the list when it
|
|
59
|
+
* fails (rate limit, timeout, the node's own error), so a dead node costs one timeout, not one per call. A revert is the
|
|
60
|
+
* contract's answer and is thrown as it is. One URL: plain http with viem's retries, as before. (viem's fallback()
|
|
61
|
+
* starts every call at the first node, and its ranking keeps a timer that holds the process open.)
|
|
62
|
+
*/
|
|
63
|
+
export function rpcTransport(urls) {
|
|
64
|
+
if (urls.length === 1) return http(urls[0])
|
|
65
|
+
const key = urls.join(',')
|
|
66
|
+
const nodes = urls.map((u) => http(u, { retryCount: 0, timeout: 8_000 }))
|
|
67
|
+
return ({ chain }) => {
|
|
68
|
+
const live = nodes.map((n) => n({ chain }))
|
|
69
|
+
return createTransport({
|
|
70
|
+
key: 'gang', name: 'Gang RPC', type: 'gang', retryCount: 1,
|
|
71
|
+
async request({ method, params }) {
|
|
72
|
+
const first = lastGood.get(key) ?? 0
|
|
73
|
+
let error
|
|
74
|
+
for (let k = 0; k < live.length; k++) {
|
|
75
|
+
const i = (first + k) % live.length
|
|
76
|
+
try {
|
|
77
|
+
const r = await live[i].request({ method, params })
|
|
78
|
+
lastGood.set(key, i)
|
|
79
|
+
return r
|
|
80
|
+
} catch (e) {
|
|
81
|
+
if (sameOnEveryNode(e)) throw e
|
|
82
|
+
error = e
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw error
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
32
91
|
const env = (...names) => {
|
|
33
92
|
for (const n of names) if (process.env[n]) return process.env[n]
|
|
34
93
|
return null
|
|
@@ -43,7 +102,7 @@ export function padNets(kind) {
|
|
|
43
102
|
mainnet: {
|
|
44
103
|
chainId: '56', chain: bsc,
|
|
45
104
|
pad: env('GANG_PAD', `GANG_${alias}_PAD`) || MAINNET_GANG.pad || null,
|
|
46
|
-
|
|
105
|
+
rpcs: rpcList(env('GANG_RPC_URL')) || MAINNET_RPCS,
|
|
47
106
|
wbnb: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', explorer: 'https://bscscan.com',
|
|
48
107
|
router: env('GANG_ROUTER') || MAINNET_GANG.router || null,
|
|
49
108
|
},
|
|
@@ -51,7 +110,7 @@ export function padNets(kind) {
|
|
|
51
110
|
chainId: '97', chain: bscTestnet,
|
|
52
111
|
pad: env('GANG_TESTNET_PAD', `GANG_${alias}_TESTNET_PAD`) || set.pad,
|
|
53
112
|
router: env('GANG_TESTNET_ROUTER', 'GANG_ROUTER_TESTNET') || set.router || null,
|
|
54
|
-
|
|
113
|
+
rpcs: rpcList(env('GANG_TESTNET_RPC_URL', `GANG_${alias}_TESTNET_RPC_URL`)) || TESTNET_RPCS,
|
|
55
114
|
wbnb: '0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd', explorer: 'https://testnet.bscscan.com',
|
|
56
115
|
},
|
|
57
116
|
}
|
package/src/index.js
CHANGED
|
@@ -396,8 +396,8 @@ A buy / sell / create preview without --note says so in agentNote.hint (also gan
|
|
|
396
396
|
update: { current, latest, cmd, skill } (npm is asked at most once a day in the background; GANG_UPDATE_CHECK=0 turns it
|
|
397
397
|
off, GANG_UPDATE_URL points it at an npm mirror).
|
|
398
398
|
|
|
399
|
-
env: GANG_RPC_URL
|
|
400
|
-
GANG_UPDATE_CHECK, GANG_UPDATE_URL,
|
|
399
|
+
env: GANG_RPC_URL (one URL or a comma list; unset: five public BSC nodes, the next one tried when one fails),
|
|
400
|
+
GANG_LOGO_API, GANG_API (default ${API}), GANG_NOTES_DIR (default ~/.gang/notes), GANG_UPDATE_CHECK, GANG_UPDATE_URL,
|
|
401
401
|
GANG_PAD / GANG_TESTNET_PAD (the one GangLaunchpad behind both gang v3 and gang fair; old names GANG_V3_PAD / GANG_FAIR_PAD
|
|
402
402
|
and GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD still work as aliases), GANG_TESTNET_RPC_URL (aliases
|
|
403
403
|
GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL), GANG_ROUTER / GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET; GangRouter
|
package/src/launch.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto'
|
|
2
2
|
import { mkdirSync, readdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
3
3
|
import { dirname, join } from 'node:path'
|
|
4
|
-
import { createPublicClient,
|
|
4
|
+
import { createPublicClient, parseAbi, formatUnits, encodeFunctionData, isAddress, zeroAddress } from 'viem'
|
|
5
5
|
import { DIR } from './notes.js'
|
|
6
|
-
import { padNets, NOT_ON_MAINNET } from './gangpad.js'
|
|
6
|
+
import { padNets, NOT_ON_MAINNET, rpcTransport } from './gangpad.js'
|
|
7
7
|
import { bondAddress, BOND_ABI } from './bond.js'
|
|
8
8
|
import { walletFor } from './fair.js'
|
|
9
9
|
import { parseAmount, parseIntIn, step } from './steps.js'
|
|
@@ -154,7 +154,7 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
154
154
|
buyback = { bps: buybackBpsOf(fail, opt('buyback')), factory, payee }
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
const client = createPublicClient({ chain: net.chain, transport:
|
|
157
|
+
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
158
158
|
const read = (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args })
|
|
159
159
|
const me = walletFor({ chainId: net.chainId }, opt('from'))
|
|
160
160
|
const key = [net.chainId, net.pad, me.toLowerCase(), kind, name, symbol].join('|')
|
package/src/v3.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createPublicClient,
|
|
1
|
+
import { createPublicClient, parseAbi, encodeFunctionData, decodeEventLog, formatUnits, parseUnits, isAddress, zeroAddress } from 'viem'
|
|
2
2
|
import { decimalsOf, defaultRefPool, dividendOf, VAULT_ABI, fundingStep as fund, parseAmount, parseNum, poolSellQuote, POOL_SELL_HINT, revertOf as revertIn, ROUTER_ABI as GANG_ROUTER_ABI, ROUTER_HINTS, routerDeadline, step, swapBackState, units, viaRouter, GAS_RESERVE } from './steps.js'
|
|
3
3
|
import { API } from './discover.js'
|
|
4
4
|
import { UA } from './version.js'
|
|
5
5
|
import { walletFor } from './fair.js'
|
|
6
|
-
import { MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, notThisKind, padNets } from './gangpad.js'
|
|
6
|
+
import { MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, notThisKind, padNets, rpcTransport } from './gangpad.js'
|
|
7
7
|
import { poolPayBnb, poolTrade } from './pool.js'
|
|
8
8
|
import { bondGuard } from './bond.js'
|
|
9
9
|
import { splitterOf } from './buyback.js'
|
|
@@ -98,7 +98,7 @@ export const V3_EVENT_ABIS = [PAD_ABI, TAX_ROUTER_ABI, VAULT_ABI]
|
|
|
98
98
|
export function v3Ctx(testnet) {
|
|
99
99
|
const net = V3_NETS[testnet ? 'testnet' : 'mainnet']
|
|
100
100
|
if (!net.pad) throw new Error(NOT_ON_MAINNET)
|
|
101
|
-
const client = createPublicClient({ chain: net.chain, transport:
|
|
101
|
+
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
102
102
|
return { ...net, client, read: (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args }) }
|
|
103
103
|
}
|
|
104
104
|
|