@black-market/sdk 0.1.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/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/abis.d.ts +2573 -0
- package/dist/abis.d.ts.map +1 -0
- package/dist/abis.js +1875 -0
- package/dist/abis.js.map +1 -0
- package/dist/abyss.d.ts +3650 -0
- package/dist/abyss.d.ts.map +1 -0
- package/dist/abyss.js +1522 -0
- package/dist/abyss.js.map +1 -0
- package/dist/addresses.d.ts +211 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +234 -0
- package/dist/addresses.js.map +1 -0
- package/dist/auction.d.ts +57 -0
- package/dist/auction.d.ts.map +1 -0
- package/dist/auction.js +88 -0
- package/dist/auction.js.map +1 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +18 -0
- package/dist/client.js.map +1 -0
- package/dist/format.d.ts +15 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +78 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/launch.d.ts +225 -0
- package/dist/launch.d.ts.map +1 -0
- package/dist/launch.js +511 -0
- package/dist/launch.js.map +1 -0
- package/dist/live.d.ts +185 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +205 -0
- package/dist/live.js.map +1 -0
- package/package.json +51 -0
- package/src/abis.ts +1896 -0
- package/src/abyss.ts +1574 -0
- package/src/addresses.ts +342 -0
- package/src/auction.ts +107 -0
- package/src/client.ts +37 -0
- package/src/format.ts +73 -0
- package/src/index.ts +8 -0
- package/src/launch.ts +724 -0
- package/src/live.ts +393 -0
package/src/addresses.ts
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import type { Address, Chain } from "viem";
|
|
2
|
+
import { defineChain } from "viem";
|
|
3
|
+
import { foundry } from "viem/chains";
|
|
4
|
+
|
|
5
|
+
export type SupportedChainId = 31337 | 4663 | 46631;
|
|
6
|
+
|
|
7
|
+
export type AbyssInfrastructureAddresses = {
|
|
8
|
+
abyssFactory: Address;
|
|
9
|
+
abyssFeeVault: Address;
|
|
10
|
+
abyssPoolDeployer: Address;
|
|
11
|
+
abyssRouter: Address;
|
|
12
|
+
abyssQuoter: Address;
|
|
13
|
+
abyssPositionManager: Address;
|
|
14
|
+
abyssPositionLocker: Address;
|
|
15
|
+
abyssToken: Address;
|
|
16
|
+
abyssBuybackBurnerImplementation: Address;
|
|
17
|
+
abyssBuybackBurner: Address;
|
|
18
|
+
abyssFeeRouterImplementation: Address;
|
|
19
|
+
abyssFeeRouter: Address;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type LaunchApplicationAddresses = {
|
|
23
|
+
launchTokenFactory: Address;
|
|
24
|
+
launchCoordinator: Address;
|
|
25
|
+
launchFactory: Address;
|
|
26
|
+
launchTemplateRegistry: Address;
|
|
27
|
+
launchModuleFactory: Address;
|
|
28
|
+
launchFeeOwnerRegistry: Address;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ProtocolAddresses = AbyssInfrastructureAddresses &
|
|
32
|
+
LaunchApplicationAddresses & {
|
|
33
|
+
lendingPool: Address;
|
|
34
|
+
addressesProvider: Address;
|
|
35
|
+
dataProvider: Address;
|
|
36
|
+
uiPoolDataProvider: Address;
|
|
37
|
+
walletBalanceProvider: Address;
|
|
38
|
+
aaveOracle: Address;
|
|
39
|
+
liquidationExecutor: Address;
|
|
40
|
+
protocolVault: Address;
|
|
41
|
+
ethUsdFeed: Address;
|
|
42
|
+
weth: Address;
|
|
43
|
+
wethGateway: Address;
|
|
44
|
+
lens: Address;
|
|
45
|
+
tokenVesting: Address;
|
|
46
|
+
faucet: Address;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const zero = "0x0000000000000000000000000000000000000000" as Address;
|
|
50
|
+
|
|
51
|
+
function readEnv(...keys: string[]): string | undefined {
|
|
52
|
+
if (typeof process === "undefined" || !process.env) return undefined;
|
|
53
|
+
for (const key of keys) {
|
|
54
|
+
const value = process.env[key];
|
|
55
|
+
if (value) return value;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const rpcUrl = readEnv("VITE_RPC_URL", "NEXT_PUBLIC_RPC_URL", "RPC_URL") ?? "http://127.0.0.1:8545";
|
|
61
|
+
|
|
62
|
+
/** Local Anvil (DeployLocal / plain forge). */
|
|
63
|
+
export const anvilLocal = foundry;
|
|
64
|
+
|
|
65
|
+
/** Robinhood-mainnet fork workbench (contracts/script/workbench.sh). */
|
|
66
|
+
export const workbenchChain = defineChain({
|
|
67
|
+
id: 46631,
|
|
68
|
+
name: "Black Market Workbench",
|
|
69
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
70
|
+
rpcUrls: {
|
|
71
|
+
default: { http: [rpcUrl] },
|
|
72
|
+
},
|
|
73
|
+
testnet: true,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/** Canonical Robinhood Chain mainnet. */
|
|
77
|
+
export const robinhoodMainnet = defineChain({
|
|
78
|
+
id: 4663,
|
|
79
|
+
name: "Robinhood Chain",
|
|
80
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
81
|
+
rpcUrls: {
|
|
82
|
+
default: { http: ["https://rpc.mainnet.chain.robinhood.com/"] },
|
|
83
|
+
},
|
|
84
|
+
blockExplorers: {
|
|
85
|
+
default: {
|
|
86
|
+
name: "Robinhood Chain Explorer",
|
|
87
|
+
url: "https://robinhoodchain.blockscout.com",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
contracts: {
|
|
91
|
+
multicall3: {
|
|
92
|
+
address: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function envAddr(keys: string[], fallback: Address = zero): Address {
|
|
98
|
+
return (readEnv(...keys) as Address | undefined) ?? fallback;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function abyssInfrastructureFromEnv(
|
|
102
|
+
fallback: AbyssInfrastructureAddresses,
|
|
103
|
+
): AbyssInfrastructureAddresses {
|
|
104
|
+
const address = (name: string, defaultAddress: Address) =>
|
|
105
|
+
envAddr([name, `VITE_${name}`, `NEXT_PUBLIC_${name}`], defaultAddress);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
abyssFactory: address("ABYSS_FACTORY", fallback.abyssFactory),
|
|
109
|
+
abyssFeeVault: address("ABYSS_FEE_VAULT", fallback.abyssFeeVault),
|
|
110
|
+
abyssPoolDeployer: address("ABYSS_POOL_DEPLOYER", fallback.abyssPoolDeployer),
|
|
111
|
+
abyssRouter: address("ABYSS_ROUTER", fallback.abyssRouter),
|
|
112
|
+
abyssQuoter: address("ABYSS_QUOTER", fallback.abyssQuoter),
|
|
113
|
+
abyssPositionManager: address("ABYSS_POSITION_MANAGER", fallback.abyssPositionManager),
|
|
114
|
+
abyssPositionLocker: address("ABYSS_POSITION_LOCKER", fallback.abyssPositionLocker),
|
|
115
|
+
abyssToken: address("ABYSS_TOKEN", fallback.abyssToken),
|
|
116
|
+
abyssBuybackBurnerImplementation: address(
|
|
117
|
+
"ABYSS_BUYBACK_BURNER_IMPLEMENTATION",
|
|
118
|
+
fallback.abyssBuybackBurnerImplementation,
|
|
119
|
+
),
|
|
120
|
+
abyssBuybackBurner: address("ABYSS_BUYBACK_BURNER", fallback.abyssBuybackBurner),
|
|
121
|
+
abyssFeeRouterImplementation: address(
|
|
122
|
+
"ABYSS_FEE_ROUTER_IMPLEMENTATION",
|
|
123
|
+
fallback.abyssFeeRouterImplementation,
|
|
124
|
+
),
|
|
125
|
+
abyssFeeRouter: address("ABYSS_FEE_ROUTER", fallback.abyssFeeRouter),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function launchApplicationFromEnv(
|
|
130
|
+
fallback: LaunchApplicationAddresses,
|
|
131
|
+
): LaunchApplicationAddresses {
|
|
132
|
+
const address = (name: string, defaultAddress: Address) =>
|
|
133
|
+
envAddr([name, `VITE_${name}`, `NEXT_PUBLIC_${name}`], defaultAddress);
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
launchTokenFactory: address("LAUNCH_TOKEN_FACTORY", fallback.launchTokenFactory),
|
|
137
|
+
launchCoordinator: address("LAUNCH_COORDINATOR", fallback.launchCoordinator),
|
|
138
|
+
launchFactory: address("LAUNCH_FACTORY", fallback.launchFactory),
|
|
139
|
+
launchTemplateRegistry: address("LAUNCH_TEMPLATE_REGISTRY", fallback.launchTemplateRegistry),
|
|
140
|
+
launchModuleFactory: address("LAUNCH_MODULE_FACTORY", fallback.launchModuleFactory),
|
|
141
|
+
launchFeeOwnerRegistry: address("LAUNCH_FEE_OWNER_REGISTRY", fallback.launchFeeOwnerRegistry),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const ROBINHOOD_WETH = "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73" as Address;
|
|
146
|
+
const ROBINHOOD_ETH_USD = "0x78F3556b67E17Df817D51Ef5a990cDaF09E8d3A9" as Address;
|
|
147
|
+
|
|
148
|
+
const zeroAbyssInfrastructure: AbyssInfrastructureAddresses = {
|
|
149
|
+
abyssFactory: zero,
|
|
150
|
+
abyssFeeVault: zero,
|
|
151
|
+
abyssPoolDeployer: zero,
|
|
152
|
+
abyssRouter: zero,
|
|
153
|
+
abyssQuoter: zero,
|
|
154
|
+
abyssPositionManager: zero,
|
|
155
|
+
abyssPositionLocker: zero,
|
|
156
|
+
abyssToken: zero,
|
|
157
|
+
abyssBuybackBurnerImplementation: zero,
|
|
158
|
+
abyssBuybackBurner: zero,
|
|
159
|
+
abyssFeeRouterImplementation: zero,
|
|
160
|
+
abyssFeeRouter: zero,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const zeroLaunchApplication: LaunchApplicationAddresses = {
|
|
164
|
+
launchTokenFactory: zero,
|
|
165
|
+
launchCoordinator: zero,
|
|
166
|
+
launchFactory: zero,
|
|
167
|
+
launchTemplateRegistry: zero,
|
|
168
|
+
launchModuleFactory: zero,
|
|
169
|
+
launchFeeOwnerRegistry: zero,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/** Canonical replacement: abyss/deployments/4663/abyss-canonical-replacement-20260830/deployment.json. */
|
|
173
|
+
export const robinhoodAbyssInfrastructure: AbyssInfrastructureAddresses = {
|
|
174
|
+
abyssFactory: "0xe7feF2BC860B25bbdEB6F6AB96d88bAAa77ddad7",
|
|
175
|
+
abyssFeeVault: "0x19b04F2E86fFDf26510ACf25344c406240214d5F",
|
|
176
|
+
abyssPoolDeployer: "0xe49Ff46f2Ca543D5504cDCF533fe84e0c95eF693",
|
|
177
|
+
abyssRouter: "0xF7818c69e31bf98eFF96C721B557Bb519659CD27",
|
|
178
|
+
abyssQuoter: "0xF1ff7c78605939df2d705F3E12Ac9CEB69Bcfe76",
|
|
179
|
+
abyssPositionManager: "0x1b2176d4D2C7bd36227D92Ed84F1A3aE30B635bF",
|
|
180
|
+
abyssPositionLocker: "0xa0d4fA31740FA0d8fc6b5b4173Da17864Eb6e888",
|
|
181
|
+
abyssToken: "0x15f3385625D7e364C5a6216FBbceadf10fa90e7d",
|
|
182
|
+
abyssBuybackBurnerImplementation: "0xd17F05C41FfdebB6b57b3e232c20a340906A0aAd",
|
|
183
|
+
abyssBuybackBurner: "0xF6C7159e967f28C65d9Fb5b919567E04540cD2FF",
|
|
184
|
+
abyssFeeRouterImplementation: "0xB35b85db23fEF3A146Fbd755D76be12F9e1eBfFC",
|
|
185
|
+
abyssFeeRouter: "0x2c3B1b6fe0EDa8e10C0445567b47e66E825B34cd",
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** Captured replacement: contracts/deployments/launch/robinhood-mainnet-replacement-deployment-record.json. */
|
|
189
|
+
export const robinhoodLaunchApplication: LaunchApplicationAddresses = {
|
|
190
|
+
launchTokenFactory: "0x7B6F6efb4536F579223423e31d9036D996bc90F0",
|
|
191
|
+
launchCoordinator: "0xE98A82202D794A7836316971e7ACf61F260f8399",
|
|
192
|
+
launchFactory: "0xAf3FdC499b3717EBE8aD51B66bA78Cb083552351",
|
|
193
|
+
launchTemplateRegistry: "0x5C22c6e02bAC8225eed64629447868bAA5774186",
|
|
194
|
+
launchModuleFactory: "0xb2D9988592eE245a36290A0992505ca0474434f2",
|
|
195
|
+
launchFeeOwnerRegistry: "0xdD3756269Db20F2a60055b0FE8c101FAd12525f9",
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/** Workbench deployment snapshot — override via env when redeploying. */
|
|
199
|
+
const workbenchDefaults: ProtocolAddresses = {
|
|
200
|
+
...robinhoodAbyssInfrastructure,
|
|
201
|
+
...launchApplicationFromEnv(zeroLaunchApplication),
|
|
202
|
+
lendingPool: "0xe1576c5CF12F670911BEd5Cc0AEDBcD4E5E9550c",
|
|
203
|
+
addressesProvider: "0x9Fcca440F19c62CDF7f973eB6DDF218B15d4C71D",
|
|
204
|
+
dataProvider: "0x79E8AB29Ff79805025c9462a2f2F12e9A496f81d",
|
|
205
|
+
uiPoolDataProvider: zero,
|
|
206
|
+
walletBalanceProvider: zero,
|
|
207
|
+
aaveOracle: "0x9c65f85425c619A6cB6D29fF8d57ef696323d188",
|
|
208
|
+
liquidationExecutor: zero,
|
|
209
|
+
protocolVault: "0xAe120F0df055428E45b264E7794A18c54a2a3fAF",
|
|
210
|
+
ethUsdFeed: ROBINHOOD_ETH_USD,
|
|
211
|
+
weth: ROBINHOOD_WETH,
|
|
212
|
+
wethGateway: zero,
|
|
213
|
+
lens: zero,
|
|
214
|
+
tokenVesting: zero,
|
|
215
|
+
faucet: zero,
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export const addresses: Record<SupportedChainId, ProtocolAddresses> = {
|
|
219
|
+
31337: {
|
|
220
|
+
...abyssInfrastructureFromEnv(zeroAbyssInfrastructure),
|
|
221
|
+
...launchApplicationFromEnv(zeroLaunchApplication),
|
|
222
|
+
lendingPool: envAddr(["LENDING_POOL", "VITE_LENDING_POOL", "NEXT_PUBLIC_LENDING_POOL"]),
|
|
223
|
+
addressesProvider: envAddr([
|
|
224
|
+
"ADDRESSES_PROVIDER",
|
|
225
|
+
"VITE_ADDRESSES_PROVIDER",
|
|
226
|
+
"NEXT_PUBLIC_ADDRESSES_PROVIDER",
|
|
227
|
+
]),
|
|
228
|
+
dataProvider: envAddr(["DATA_PROVIDER", "VITE_DATA_PROVIDER", "NEXT_PUBLIC_DATA_PROVIDER"]),
|
|
229
|
+
uiPoolDataProvider: envAddr([
|
|
230
|
+
"UI_POOL_DATA_PROVIDER",
|
|
231
|
+
"VITE_UI_POOL_DATA_PROVIDER",
|
|
232
|
+
"NEXT_PUBLIC_UI_POOL_DATA_PROVIDER",
|
|
233
|
+
]),
|
|
234
|
+
walletBalanceProvider: envAddr([
|
|
235
|
+
"WALLET_BALANCE_PROVIDER",
|
|
236
|
+
"VITE_WALLET_BALANCE_PROVIDER",
|
|
237
|
+
"NEXT_PUBLIC_WALLET_BALANCE_PROVIDER",
|
|
238
|
+
]),
|
|
239
|
+
aaveOracle: envAddr(["AAVE_ORACLE", "VITE_AAVE_ORACLE", "NEXT_PUBLIC_AAVE_ORACLE"]),
|
|
240
|
+
liquidationExecutor: envAddr([
|
|
241
|
+
"LIQUIDATION_EXECUTOR",
|
|
242
|
+
"VITE_LIQUIDATION_EXECUTOR",
|
|
243
|
+
"NEXT_PUBLIC_LIQUIDATION_EXECUTOR",
|
|
244
|
+
]),
|
|
245
|
+
protocolVault: envAddr(["PROTOCOL_VAULT", "VITE_PROTOCOL_VAULT", "NEXT_PUBLIC_PROTOCOL_VAULT"]),
|
|
246
|
+
ethUsdFeed: envAddr(["ETH_USD_FEED", "VITE_ETH_USD_FEED", "NEXT_PUBLIC_ETH_USD_FEED"]),
|
|
247
|
+
weth: envAddr(["WETH", "VITE_WETH", "NEXT_PUBLIC_WETH"]),
|
|
248
|
+
wethGateway: envAddr(["WETH_GATEWAY", "VITE_WETH_GATEWAY", "NEXT_PUBLIC_WETH_GATEWAY"]),
|
|
249
|
+
lens: envAddr(["LENS", "VITE_LENS", "NEXT_PUBLIC_LENS"]),
|
|
250
|
+
tokenVesting: envAddr(["TOKEN_VESTING", "VITE_TOKEN_VESTING", "NEXT_PUBLIC_TOKEN_VESTING"]),
|
|
251
|
+
faucet: envAddr(["FAUCET", "VITE_FAUCET", "NEXT_PUBLIC_FAUCET"]),
|
|
252
|
+
},
|
|
253
|
+
/** Captured replacement launch defaults; environment variables may override them. */
|
|
254
|
+
4663: {
|
|
255
|
+
...robinhoodAbyssInfrastructure,
|
|
256
|
+
...launchApplicationFromEnv(robinhoodLaunchApplication),
|
|
257
|
+
lendingPool: "0x5b8F732A4F7a62D642070bb49255d6C434A76766",
|
|
258
|
+
addressesProvider: "0xaaD329d0Da03C8c00E8460b5b208D0A21A48C9df",
|
|
259
|
+
dataProvider: "0x3B097A7899DF433552B8428E774964661b53C193",
|
|
260
|
+
uiPoolDataProvider: "0x2F35A64c7E7cBc0c05A1A1C3e2F3952E103fD5b8",
|
|
261
|
+
walletBalanceProvider: "0x833BB152212DD5d2d6C7b0501aB38efb9602AD8B",
|
|
262
|
+
aaveOracle: "0xb9441f8D3Eda65Ac7cbb6b542b5345c98067e5Fb",
|
|
263
|
+
liquidationExecutor: envAddr([
|
|
264
|
+
"LIQUIDATION_EXECUTOR",
|
|
265
|
+
"VITE_LIQUIDATION_EXECUTOR",
|
|
266
|
+
"NEXT_PUBLIC_LIQUIDATION_EXECUTOR",
|
|
267
|
+
]),
|
|
268
|
+
protocolVault: "0x961981916AB6575C3af3eeCecbf6A3b7Fad7C9e1",
|
|
269
|
+
ethUsdFeed: ROBINHOOD_ETH_USD,
|
|
270
|
+
weth: ROBINHOOD_WETH,
|
|
271
|
+
wethGateway: "0xAbc9E3B20e8773536BDCa5ba28C619762C8e0570",
|
|
272
|
+
lens: "0x82FA6e601F48d64b4f163Eb47D6001f2d5040f9B",
|
|
273
|
+
tokenVesting: zero,
|
|
274
|
+
faucet: zero,
|
|
275
|
+
},
|
|
276
|
+
46631: {
|
|
277
|
+
...workbenchDefaults,
|
|
278
|
+
...abyssInfrastructureFromEnv(robinhoodAbyssInfrastructure),
|
|
279
|
+
...launchApplicationFromEnv(zeroLaunchApplication),
|
|
280
|
+
lendingPool: envAddr(
|
|
281
|
+
["VITE_LENDING_POOL", "NEXT_PUBLIC_LENDING_POOL"],
|
|
282
|
+
workbenchDefaults.lendingPool,
|
|
283
|
+
),
|
|
284
|
+
addressesProvider: envAddr(
|
|
285
|
+
["VITE_ADDRESSES_PROVIDER", "NEXT_PUBLIC_ADDRESSES_PROVIDER"],
|
|
286
|
+
workbenchDefaults.addressesProvider,
|
|
287
|
+
),
|
|
288
|
+
dataProvider: envAddr(
|
|
289
|
+
["VITE_DATA_PROVIDER", "NEXT_PUBLIC_DATA_PROVIDER"],
|
|
290
|
+
workbenchDefaults.dataProvider,
|
|
291
|
+
),
|
|
292
|
+
uiPoolDataProvider: envAddr(
|
|
293
|
+
["VITE_UI_POOL_DATA_PROVIDER", "NEXT_PUBLIC_UI_POOL_DATA_PROVIDER"],
|
|
294
|
+
workbenchDefaults.uiPoolDataProvider,
|
|
295
|
+
),
|
|
296
|
+
walletBalanceProvider: envAddr(
|
|
297
|
+
["VITE_WALLET_BALANCE_PROVIDER", "NEXT_PUBLIC_WALLET_BALANCE_PROVIDER"],
|
|
298
|
+
workbenchDefaults.walletBalanceProvider,
|
|
299
|
+
),
|
|
300
|
+
aaveOracle: envAddr(
|
|
301
|
+
["VITE_AAVE_ORACLE", "NEXT_PUBLIC_AAVE_ORACLE"],
|
|
302
|
+
workbenchDefaults.aaveOracle,
|
|
303
|
+
),
|
|
304
|
+
liquidationExecutor: envAddr(
|
|
305
|
+
["LIQUIDATION_EXECUTOR", "VITE_LIQUIDATION_EXECUTOR", "NEXT_PUBLIC_LIQUIDATION_EXECUTOR"],
|
|
306
|
+
workbenchDefaults.liquidationExecutor,
|
|
307
|
+
),
|
|
308
|
+
protocolVault: envAddr(
|
|
309
|
+
["VITE_PROTOCOL_VAULT", "NEXT_PUBLIC_PROTOCOL_VAULT"],
|
|
310
|
+
workbenchDefaults.protocolVault,
|
|
311
|
+
),
|
|
312
|
+
ethUsdFeed: envAddr(
|
|
313
|
+
["VITE_ETH_USD_FEED", "NEXT_PUBLIC_ETH_USD_FEED"],
|
|
314
|
+
workbenchDefaults.ethUsdFeed,
|
|
315
|
+
),
|
|
316
|
+
weth: envAddr(["VITE_WETH", "NEXT_PUBLIC_WETH"], workbenchDefaults.weth),
|
|
317
|
+
wethGateway: envAddr(
|
|
318
|
+
["VITE_WETH_GATEWAY", "NEXT_PUBLIC_WETH_GATEWAY"],
|
|
319
|
+
workbenchDefaults.wethGateway,
|
|
320
|
+
),
|
|
321
|
+
lens: envAddr(["VITE_LENS", "NEXT_PUBLIC_LENS"], workbenchDefaults.lens),
|
|
322
|
+
tokenVesting: envAddr(
|
|
323
|
+
["VITE_TOKEN_VESTING", "NEXT_PUBLIC_TOKEN_VESTING"],
|
|
324
|
+
workbenchDefaults.tokenVesting,
|
|
325
|
+
),
|
|
326
|
+
faucet: envAddr(["VITE_FAUCET", "NEXT_PUBLIC_FAUCET"], workbenchDefaults.faucet),
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export const chains: Record<SupportedChainId, Chain> = {
|
|
331
|
+
31337: anvilLocal,
|
|
332
|
+
4663: robinhoodMainnet,
|
|
333
|
+
46631: workbenchChain,
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export function getAddresses(chainId: SupportedChainId = 46631): ProtocolAddresses {
|
|
337
|
+
return addresses[chainId];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export function isSupportedChainId(id: number): id is SupportedChainId {
|
|
341
|
+
return id === 31337 || id === 4663 || id === 46631;
|
|
342
|
+
}
|
package/src/auction.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type Address, zeroAddress } from "viem";
|
|
2
|
+
|
|
3
|
+
/** Fixed supply used by Atomic launches. */
|
|
4
|
+
export const AUCTION_SUPPLY = 1_000_000_000n * 10n ** 18n;
|
|
5
|
+
export const AUCTION_SUPPLY_WHOLE = 1_000_000_000;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const ROBINHOOD_USDG = "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168" as Address;
|
|
9
|
+
export const ROBINHOOD_WETH = "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73" as Address;
|
|
10
|
+
export const ROBINHOOD_ABYSS = "0x15f3385625D7e364C5a6216FBbceadf10fa90e7d" as Address;
|
|
11
|
+
export const ROBINHOOD_AAPL = "0xaF3D76f1834A1d425780943C99Ea8A608f8a93f9" as Address;
|
|
12
|
+
export const ROBINHOOD_AMD = "0x86923f96303D656E4aa86D9d42D1e57ad2023fdC" as Address;
|
|
13
|
+
export const ROBINHOOD_AMZN = "0x12f190a9F9d7D37a250758b26824B97CE941bF54" as Address;
|
|
14
|
+
export const ROBINHOOD_ASML = "0x47F93d52cBeC7C6D2CfC080e154002370a60dAEA" as Address;
|
|
15
|
+
export const ROBINHOOD_BABA = "0xad25Ac6C84D497db898fa1E8387bf6Af3532a1c4" as Address;
|
|
16
|
+
export const ROBINHOOD_CLSK = "0xcBB95BBF36099d34dA091dc6Fa6F49EfA257Cee3" as Address;
|
|
17
|
+
export const ROBINHOOD_COIN = "0x6330D8C3178a418788dF01a47479c0ce7CCF450b" as Address;
|
|
18
|
+
export const ROBINHOOD_CRCL = "0xdF0992E440dD0be65BD8439b609d6D4366bf1CB5" as Address;
|
|
19
|
+
export const ROBINHOOD_CRWV = "0x5f10A1C971B69e47e059e1dC91901B59b3fB49C3" as Address;
|
|
20
|
+
export const ROBINHOOD_DELL = "0x941AE714EC6D8130c7B75d67160Ca08f1e7d11Dd" as Address;
|
|
21
|
+
export const ROBINHOOD_EWY = "0x7f0aBeF0C07280F82c6a08ead09dEd6BAE2C13Fc" as Address;
|
|
22
|
+
export const ROBINHOOD_GME = "0x1b0E319c6A659F002271B69dB8A7df2F911c153E" as Address;
|
|
23
|
+
export const ROBINHOOD_GOOGL = "0x2e0847E8910a9732eB3fb1bb4b70a580ADAD4FE3" as Address;
|
|
24
|
+
export const ROBINHOOD_INTC = "0xc72b96e0E48ecd4DC75E1e45396e26300BC39681" as Address;
|
|
25
|
+
export const ROBINHOOD_IONQ = "0x558378E000D634A36593E338eBacdd6207640EfE" as Address;
|
|
26
|
+
export const ROBINHOOD_META = "0xc0D6457C16Cc70d6790Dd43521C899C87ce02f35" as Address;
|
|
27
|
+
export const ROBINHOOD_MSFT = "0xe93237C50D904957Cf27E7B1133b510C669c2e74" as Address;
|
|
28
|
+
export const ROBINHOOD_MSTR = "0xec262a75e413fAfD0dF80480274532C79D42da09" as Address;
|
|
29
|
+
export const ROBINHOOD_MU = "0xfF080c8ce2E5feadaCa0Da81314Ae59D232d4afD" as Address;
|
|
30
|
+
export const ROBINHOOD_NBIS = "0x9D9c6684F596F66a64C030B93A886D51Fd4D7931" as Address;
|
|
31
|
+
export const ROBINHOOD_NVDA = "0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC" as Address;
|
|
32
|
+
export const ROBINHOOD_ORCL = "0xb0992820E760d836549ba69BC7598b4af75dEE03" as Address;
|
|
33
|
+
export const ROBINHOOD_PLTR = "0x894E1EC2D74FFE5AEF8Dc8A9e84686acCB964F2A" as Address;
|
|
34
|
+
export const ROBINHOOD_QQQ = "0xD5f3879160bc7c32ebb4dC785F8a4F505888de68" as Address;
|
|
35
|
+
export const ROBINHOOD_RGTI = "0x284358abc07F9359f19f4b5b4aC91901Be2597Ba" as Address;
|
|
36
|
+
export const ROBINHOOD_RKLB = "0x3b14C39E89D60D627b42a1A4CA45b5bb45Fc12e2" as Address;
|
|
37
|
+
export const ROBINHOOD_SGOV = "0x92FD66527192E3e61d4DDd13322Aa222DE86F9B5" as Address;
|
|
38
|
+
export const ROBINHOOD_SLV = "0x411eFb0E7f985935DAec3D4C3ebaEa0d0AD7D89f" as Address;
|
|
39
|
+
export const ROBINHOOD_SNDK = "0xB90A19fF0Af67f7779afF50A882A9CfF42446400" as Address;
|
|
40
|
+
export const ROBINHOOD_SPCX = "0x4a0E65A3EcceC6dBe60AE065F2e7bb85Fae35eEa" as Address;
|
|
41
|
+
export const ROBINHOOD_SPY = "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C" as Address;
|
|
42
|
+
export const ROBINHOOD_TSLA = "0x322F0929c4625eD5bAd873c95208D54E1c003b2d" as Address;
|
|
43
|
+
export const ROBINHOOD_TSM = "0x58FfE4a942d3885bAa22D7520691F611EF09e7AA" as Address;
|
|
44
|
+
export const ROBINHOOD_USAR = "0xd917B029C761D264c6A312BBbcDA868658eF86a6" as Address;
|
|
45
|
+
export const ROBINHOOD_USO = "0xa30FA36Db767ad9eD3f7a60fC79526fB4d56D344" as Address;
|
|
46
|
+
|
|
47
|
+
export type AuctionQuoteId = string;
|
|
48
|
+
|
|
49
|
+
export type AuctionQuoteOption = {
|
|
50
|
+
id: AuctionQuoteId;
|
|
51
|
+
symbol: string;
|
|
52
|
+
/** Contract address; native ETH is represented by the zero address. */
|
|
53
|
+
address: Address;
|
|
54
|
+
decimals: number;
|
|
55
|
+
/** UI-only: treat quote as $1 when labeling opening FDV. Not an on-chain flag. */
|
|
56
|
+
/** Human-readable asset name used for search and display. */
|
|
57
|
+
name: string;
|
|
58
|
+
usdPeg: boolean;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function rwa(id: AuctionQuoteId, name: string, address: Address): AuctionQuoteOption {
|
|
62
|
+
return { id, symbol: id, name, address, decimals: 18, usdPeg: false };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Supported paired assets for Atomic launches: native ETH, wrapped WETH, USDG, then catalog stocks. */
|
|
66
|
+
export const AUCTION_QUOTE_OPTIONS: AuctionQuoteOption[] = [
|
|
67
|
+
{ id: "ETH", symbol: "ETH", name: "Ether", address: zeroAddress, decimals: 18, usdPeg: false },
|
|
68
|
+
{ id: "WETH", symbol: "WETH", name: "Wrapped Ether", address: ROBINHOOD_WETH, decimals: 18, usdPeg: false },
|
|
69
|
+
{ id: "USDG", symbol: "USDG", name: "Global Dollar", address: ROBINHOOD_USDG, decimals: 6, usdPeg: true },
|
|
70
|
+
{ id: "ABYSS", symbol: "ABYSS", name: "Abyss", address: ROBINHOOD_ABYSS, decimals: 18, usdPeg: false },
|
|
71
|
+
rwa("AAPL", "Apple", ROBINHOOD_AAPL),
|
|
72
|
+
rwa("AMD", "Advanced Micro Devices", ROBINHOOD_AMD),
|
|
73
|
+
rwa("AMZN", "Amazon", ROBINHOOD_AMZN),
|
|
74
|
+
rwa("ASML", "ASML Holding", ROBINHOOD_ASML),
|
|
75
|
+
rwa("BABA", "Alibaba", ROBINHOOD_BABA),
|
|
76
|
+
rwa("CLSK", "CleanSpark", ROBINHOOD_CLSK),
|
|
77
|
+
rwa("COIN", "Coinbase", ROBINHOOD_COIN),
|
|
78
|
+
rwa("CRCL", "Circle", ROBINHOOD_CRCL),
|
|
79
|
+
rwa("CRWV", "CoreWeave", ROBINHOOD_CRWV),
|
|
80
|
+
rwa("DELL", "Dell", ROBINHOOD_DELL),
|
|
81
|
+
rwa("EWY", "MSCI South Korea", ROBINHOOD_EWY),
|
|
82
|
+
rwa("GME", "GameStop", ROBINHOOD_GME),
|
|
83
|
+
rwa("GOOGL", "Alphabet", ROBINHOOD_GOOGL),
|
|
84
|
+
rwa("INTC", "Intel", ROBINHOOD_INTC),
|
|
85
|
+
rwa("IONQ", "IonQ", ROBINHOOD_IONQ),
|
|
86
|
+
rwa("META", "Meta", ROBINHOOD_META),
|
|
87
|
+
rwa("MSFT", "Microsoft", ROBINHOOD_MSFT),
|
|
88
|
+
rwa("MSTR", "Strategy", ROBINHOOD_MSTR),
|
|
89
|
+
rwa("MU", "Micron", ROBINHOOD_MU),
|
|
90
|
+
rwa("NBIS", "Nebius", ROBINHOOD_NBIS),
|
|
91
|
+
rwa("NVDA", "NVIDIA", ROBINHOOD_NVDA),
|
|
92
|
+
rwa("ORCL", "Oracle", ROBINHOOD_ORCL),
|
|
93
|
+
rwa("PLTR", "Palantir", ROBINHOOD_PLTR),
|
|
94
|
+
rwa("QQQ", "Nasdaq-100", ROBINHOOD_QQQ),
|
|
95
|
+
rwa("RGTI", "Rigetti", ROBINHOOD_RGTI),
|
|
96
|
+
rwa("RKLB", "Rocket Lab", ROBINHOOD_RKLB),
|
|
97
|
+
rwa("SGOV", "T-Bills", ROBINHOOD_SGOV),
|
|
98
|
+
rwa("SLV", "Silver", ROBINHOOD_SLV),
|
|
99
|
+
rwa("SNDK", "Sandisk", ROBINHOOD_SNDK),
|
|
100
|
+
rwa("SPCX", "SPACs", ROBINHOOD_SPCX),
|
|
101
|
+
rwa("SPY", "S&P 500", ROBINHOOD_SPY),
|
|
102
|
+
rwa("TSLA", "Tesla", ROBINHOOD_TSLA),
|
|
103
|
+
rwa("TSM", "TSMC", ROBINHOOD_TSM),
|
|
104
|
+
rwa("USAR", "USA Rare Earth", ROBINHOOD_USAR),
|
|
105
|
+
rwa("USO", "Oil", ROBINHOOD_USO),
|
|
106
|
+
];
|
|
107
|
+
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Account,
|
|
3
|
+
type Chain,
|
|
4
|
+
createPublicClient,
|
|
5
|
+
createWalletClient,
|
|
6
|
+
type Hex,
|
|
7
|
+
http,
|
|
8
|
+
type PublicClient,
|
|
9
|
+
type Transport,
|
|
10
|
+
type WalletClient,
|
|
11
|
+
} from "viem";
|
|
12
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
13
|
+
import { foundry } from "viem/chains";
|
|
14
|
+
import type { SupportedChainId } from "./addresses.js";
|
|
15
|
+
import { chains } from "./addresses.js";
|
|
16
|
+
|
|
17
|
+
export function createProtocolPublicClient(opts?: {
|
|
18
|
+
chainId?: SupportedChainId;
|
|
19
|
+
rpcUrl?: string;
|
|
20
|
+
}): PublicClient {
|
|
21
|
+
const chainId = opts?.chainId ?? 31337;
|
|
22
|
+
const chain = chains[chainId] ?? foundry;
|
|
23
|
+
const transport = http(opts?.rpcUrl ?? process.env.RPC_URL ?? "http://127.0.0.1:8545");
|
|
24
|
+
return createPublicClient({ chain, transport });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function createProtocolWalletClient(opts: {
|
|
28
|
+
privateKey: Hex;
|
|
29
|
+
chainId?: SupportedChainId;
|
|
30
|
+
rpcUrl?: string;
|
|
31
|
+
}): WalletClient {
|
|
32
|
+
const chainId = opts.chainId ?? 31337;
|
|
33
|
+
const chain: Chain = chains[chainId] ?? foundry;
|
|
34
|
+
const transport: Transport = http(opts.rpcUrl ?? process.env.RPC_URL ?? "http://127.0.0.1:8545");
|
|
35
|
+
const account: Account = privateKeyToAccount(opts.privateKey);
|
|
36
|
+
return createWalletClient({ account, chain, transport });
|
|
37
|
+
}
|
package/src/format.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** Ray = 1e27 (Aave interest rates). */
|
|
2
|
+
export const RAY = 10n ** 27n;
|
|
3
|
+
export const WAD = 10n ** 18n;
|
|
4
|
+
export const BPS = 10_000n;
|
|
5
|
+
|
|
6
|
+
export function rayToPercent(ray: bigint, digits = 2): number {
|
|
7
|
+
if (ray === 0n) return 0;
|
|
8
|
+
// (ray / 1e27) * 100
|
|
9
|
+
const scaled = (ray * 10_000n) / RAY; // bps-ish * 100
|
|
10
|
+
return Number(scaled) / 100 / 100;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Convert Aave liquidity/variable borrow rate (ray) to APY % display number. */
|
|
14
|
+
export function rayAprToApyPercent(ray: bigint): number {
|
|
15
|
+
// Simple APR display (not compounded) — matches most Aave UI rate tooltips at a glance.
|
|
16
|
+
return Number((ray * 10_000n) / RAY) / 100;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function formatHealthFactor(hfRayOrWad: bigint): string {
|
|
20
|
+
if (hfRayOrWad === 0n) return "—";
|
|
21
|
+
// getUserAccountData returns HF in wad (1e18)
|
|
22
|
+
const value = Number(hfRayOrWad) / 1e18;
|
|
23
|
+
if (!Number.isFinite(value) || value > 1e6) return "∞";
|
|
24
|
+
return value.toFixed(2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function healthFactorStatus(hfWad: bigint): "safe" | "watch" | "danger" | "none" {
|
|
28
|
+
if (hfWad === 0n) return "none";
|
|
29
|
+
const value = Number(hfWad) / 1e18;
|
|
30
|
+
if (!Number.isFinite(value) || value > 1e6) return "safe";
|
|
31
|
+
if (value < 1.05) return "danger";
|
|
32
|
+
if (value < 1.5) return "watch";
|
|
33
|
+
return "safe";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Parse a decimal health factor ("1.25") to wad. */
|
|
37
|
+
export function parseHealthFactorToWad(raw: string): bigint | undefined {
|
|
38
|
+
const cleaned = raw.trim();
|
|
39
|
+
if (!cleaned) return undefined;
|
|
40
|
+
const n = Number(cleaned);
|
|
41
|
+
if (!Number.isFinite(n) || n <= 0) return undefined;
|
|
42
|
+
const [whole, frac = ""] = cleaned.split(".");
|
|
43
|
+
const fracPadded = (frac + "0".repeat(18)).slice(0, 18);
|
|
44
|
+
return BigInt(whole || "0") * WAD + BigInt(fracPadded || "0");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function parseAmountToUnits(amount: string, decimals: number): bigint {
|
|
48
|
+
const cleaned = amount.trim();
|
|
49
|
+
if (!cleaned || cleaned === ".") return 0n;
|
|
50
|
+
const [whole, frac = ""] = cleaned.split(".");
|
|
51
|
+
const fracPadded = (frac + "0".repeat(decimals)).slice(0, decimals);
|
|
52
|
+
const wholePart = BigInt(whole || "0") * 10n ** BigInt(decimals);
|
|
53
|
+
const fracPart = BigInt(fracPadded || "0");
|
|
54
|
+
return wholePart + fracPart;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function formatUnitsDisplay(value: bigint, decimals: number, digits = 4): string {
|
|
58
|
+
if (value === 0n) return "0";
|
|
59
|
+
const neg = value < 0n;
|
|
60
|
+
const v = neg ? -value : value;
|
|
61
|
+
const base = 10n ** BigInt(decimals);
|
|
62
|
+
const whole = v / base;
|
|
63
|
+
const frac = v % base;
|
|
64
|
+
const fracStr = frac.toString().padStart(decimals, "0").slice(0, digits).replace(/0+$/, "");
|
|
65
|
+
const body = fracStr ? `${whole}.${fracStr}` : whole.toString();
|
|
66
|
+
return neg ? `-${body}` : body;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function utilizationFromReserve(availableLiquidity: bigint, totalDebt: bigint): number {
|
|
70
|
+
const total = availableLiquidity + totalDebt;
|
|
71
|
+
if (total === 0n) return 0;
|
|
72
|
+
return Number((totalDebt * 10_000n) / total) / 100;
|
|
73
|
+
}
|
package/src/index.ts
ADDED