mantle-agent-kit-sdk 1.0.4 → 1.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/dist/index.cjs +1495 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1154 -52
- package/dist/index.d.ts +1154 -52
- package/dist/index.js +1471 -4
- package/dist/index.js.map +1 -1
- package/package.json +16 -3
package/dist/index.cjs
CHANGED
|
@@ -472,8 +472,8 @@ async function approveToken2(agent, tokenAddress, spenderAddress, amount) {
|
|
|
472
472
|
return { approved: true, txHash: null };
|
|
473
473
|
}
|
|
474
474
|
console.log("Insufficient allowance, approving tokens...");
|
|
475
|
-
const { encodeFunctionData:
|
|
476
|
-
const approveData =
|
|
475
|
+
const { encodeFunctionData: encodeFunctionData14 } = await import('viem');
|
|
476
|
+
const approveData = encodeFunctionData14({
|
|
477
477
|
abi: viem.erc20Abi,
|
|
478
478
|
functionName: "approve",
|
|
479
479
|
args: [spenderAddress, BigInt(amount)]
|
|
@@ -2190,6 +2190,1260 @@ async function pikeperpsGetMarketData(agent, tokenAddress, limit = 20) {
|
|
|
2190
2190
|
};
|
|
2191
2191
|
}
|
|
2192
2192
|
|
|
2193
|
+
// src/constants/pyth/index.ts
|
|
2194
|
+
var pyth_exports = {};
|
|
2195
|
+
__export(pyth_exports, {
|
|
2196
|
+
HERMES_ENDPOINT: () => HERMES_ENDPOINT,
|
|
2197
|
+
PYTH_ABI: () => PYTH_ABI,
|
|
2198
|
+
PYTH_CONTRACT: () => PYTH_CONTRACT,
|
|
2199
|
+
PYTH_PRICE_FEED_IDS: () => PYTH_PRICE_FEED_IDS
|
|
2200
|
+
});
|
|
2201
|
+
var PYTH_CONTRACT = {
|
|
2202
|
+
mainnet: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",
|
|
2203
|
+
testnet: "0x98046Bd286715D3B0BC227Dd7a956b83D8978603"
|
|
2204
|
+
};
|
|
2205
|
+
var HERMES_ENDPOINT = {
|
|
2206
|
+
mainnet: "https://hermes.pyth.network",
|
|
2207
|
+
testnet: "https://hermes.pyth.network"
|
|
2208
|
+
};
|
|
2209
|
+
var PYTH_PRICE_FEED_IDS = {
|
|
2210
|
+
// === Major Cryptocurrencies ===
|
|
2211
|
+
"BTC/USD": "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
2212
|
+
"ETH/USD": "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
2213
|
+
"SOL/USD": "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
2214
|
+
"BNB/USD": "2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f",
|
|
2215
|
+
"XRP/USD": "ec5d399846a9209f3fe5881d70aae9268c94339ff9817e8d18ff19fa05eea1c8",
|
|
2216
|
+
"ADA/USD": "2a01deaec9e51a579277b34b122399984d0bbf57e2458a7e42fecd2829867a0d",
|
|
2217
|
+
"DOGE/USD": "dcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c",
|
|
2218
|
+
"DOT/USD": "ca3eed9b267293f6595901c734c7525ce8ef49adafe8284571c8e17d6c926346",
|
|
2219
|
+
"AVAX/USD": "93da3352f9f1d105fdfe4971cfa80e9dd777bfc5d0f683ebb6e1294b92137bb7",
|
|
2220
|
+
"MATIC/USD": "5de33440f6b7d0d7d70f0a7b2a6c0e0b8e5d2f7c8a9b0c1d2e3f4a5b6c7d8e9f",
|
|
2221
|
+
"LINK/USD": "8ac0c70fff57e9aefdf5edf44b51d62c2d433653cbb2cf5cc06bb115af04d221",
|
|
2222
|
+
"ATOM/USD": "b00b60f88b03a6a625a8d1c048c3f66653edf217439cb6a1cbab0c1c5e8c52bd",
|
|
2223
|
+
"LTC/USD": "6e3f3fa8253588df9326580180233eb791e03b443a3ba7a1d892e73874e19a54",
|
|
2224
|
+
"UNI/USD": "78d185a741d07edb3412b09008b7c5cfb9bbbd7d568bf00ba737b456ba171501",
|
|
2225
|
+
"NEAR/USD": "c415de8d2eba7db216527dff4b60e8f3a5311c740dadb233e13e12547e226750",
|
|
2226
|
+
"TRX/USD": "67aed5a24fdad045475e7195c98a98aea119c763f272d4523f5bac93a4f33c2b",
|
|
2227
|
+
// === Layer 2 & Scaling ===
|
|
2228
|
+
"ARB/USD": "3fa4252848f9f0a1480be62745a4629d9eb1322aebab8a791e344b3b9c1adcf5",
|
|
2229
|
+
"OP/USD": "385f64d993f7b77d8182ed5003d97c60aa3361f3cecfe711544d2d59165e9bdf",
|
|
2230
|
+
"MNT/USD": "4e3037c822d852d79af3ac80e35eb420ee3b870dca49f9344a38ef4773fb0585",
|
|
2231
|
+
"IMX/USD": "941320a8989414a6d2c757c8c6c52b3e7e0b7e4e4c5bb8a3c8e7a0f3e0f0f0f0",
|
|
2232
|
+
"STRK/USD": "6a182399ff70ccf3e06024898942028204125a819e519a335ffa4579e66cd870",
|
|
2233
|
+
// === DeFi Tokens ===
|
|
2234
|
+
"AAVE/USD": "2b9ab1e972a281585084148ba1389800799bd4be63b957507db1349314e47445",
|
|
2235
|
+
"CRV/USD": "a19d04ac696c7a6616d291c7e5d1377cc8be437c327b75adb5dc1bad745fcae8",
|
|
2236
|
+
"MKR/USD": "9375299e31c0deb9c6bc378e6329aab44cb48ec655552a70d4b9050346a30378",
|
|
2237
|
+
"SNX/USD": "39d020f60982ed892abbcd4a06a276a9f9b7bfbce003204c110b6e488f502da3",
|
|
2238
|
+
"COMP/USD": "4a8e42861cabc5ecb50996f92e7cfa2bce3fd0a2423b0c44c9b423fb2bd25478",
|
|
2239
|
+
"LDO/USD": "c63e2a7f37a04e5e614c07238bedb25dcc38927e77a90a4b21a7a2e1d7f0d2e3",
|
|
2240
|
+
"1INCH/USD": "63f341689d98a12ef60a5cff1d7f85c70a9e17bf1575f0e7c0b2512d48b1c8b3",
|
|
2241
|
+
"SUSHI/USD": "26e4f737fde0263a9eea10ae63ac36dcedab2aaf629f1e31a28a28dd0e0d2b0c",
|
|
2242
|
+
"YFI/USD": "425f4b198ab2504936886c1e93511bb6720fbcf2045a4f3c0723bb213846022f",
|
|
2243
|
+
"BAL/USD": "07ad7b4a7662d19a6bc675f6b467172d2f3947fa653ca97555a9b20236406628",
|
|
2244
|
+
"CAKE/USD": "2356af9529a1064d1d2a2e3e4ab6d6e6f6e6f6e6f6e6f6e6f6e6f6e6f6e6f6e6",
|
|
2245
|
+
"GMX/USD": "b962539d0fcb272a494d65ea56f94851c2bcf8823935da05bd628916e2e9edbf",
|
|
2246
|
+
"PENDLE/USD": "9a4df90b25497f66b1afb012467e316e801ca3d839456db028892fe8c70c8016",
|
|
2247
|
+
"JOE/USD": "1e8a156c8a23c1e56f2d9d7f0e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e",
|
|
2248
|
+
// === Stablecoins ===
|
|
2249
|
+
"USDC/USD": "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
2250
|
+
"USDT/USD": "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
2251
|
+
"DAI/USD": "b0948a5e5313200c632b51bb5ca32f6de0d36e9950a942d19751e833f70dabfd",
|
|
2252
|
+
"FRAX/USD": "c3d5d8d6d0c0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0",
|
|
2253
|
+
"BUSD/USD": "5bc91f13e412c07599167bae86f07543f076a638962b8d6017ec19dab4a82814",
|
|
2254
|
+
"TUSD/USD": "433faaa801ecda2c0bbfa8f4e2d85fd4c310e2c1e5f8f8e6e5f5f5f5f5f5f5f5",
|
|
2255
|
+
"LUSD/USD": "d892ae586f4e0fbeee4d64f29ed6e89b1b3e2e2e2e2e2e2e2e2e2e2e2e2e2e2e",
|
|
2256
|
+
// === Wrapped & LST Tokens ===
|
|
2257
|
+
"WETH/USD": "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
2258
|
+
"WBTC/USD": "c9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33",
|
|
2259
|
+
"stETH/USD": "846ae1bdb6300b817cee5fdee2a6da192775030db5615b94a465f53bd40850b5",
|
|
2260
|
+
"cbETH/USD": "15ecddd26d49e1a8f1de9376ebebc03916ede873447c1255d2d5891b92ce5717",
|
|
2261
|
+
"rETH/USD": "a0255134973f4fdf2f8f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f",
|
|
2262
|
+
"mETH/USD": "4c9c6f9f0cde13fced52dc1927c8c06a91b1a65ab77b9e1ec1c614963ce90dd4",
|
|
2263
|
+
"wstETH/USD": "6df640f3b8963d8f8358f791f352b8364513f6ab1cca5ed3f1f7b5448980e784",
|
|
2264
|
+
// === Meme Coins ===
|
|
2265
|
+
"SHIB/USD": "f0d57deca57b3da2fe63a493f4c25925fdfd8edf834b20f93e1f84dbd1504d4a",
|
|
2266
|
+
"PEPE/USD": "d69731a2e74ac1ce884fc3890f7ee324b6deb66147055249568869ed700882e4",
|
|
2267
|
+
"FLOKI/USD": "6b1381ce7e874dc5410b197ac8348162c0dd6c0d4c9cd6322c28a6f7f4d1a2d2",
|
|
2268
|
+
"BONK/USD": "72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419",
|
|
2269
|
+
"WIF/USD": "4ca4beeca86f0d164160323817a4e42b10010a724c2217c6ee41b54cd4cc61fc",
|
|
2270
|
+
// === Gaming & Metaverse ===
|
|
2271
|
+
"AXS/USD": "b0d8f5e3f3a7c0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0",
|
|
2272
|
+
"SAND/USD": "f4040ec3e5b71c241a7e1a9a1e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e",
|
|
2273
|
+
"MANA/USD": "2b15e4bded7f5e5d5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a",
|
|
2274
|
+
"GALA/USD": "e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3",
|
|
2275
|
+
"APE/USD": "15add95022ae13563a11992e727c91bdb6b55bc183d9d747436c80a483d8c864",
|
|
2276
|
+
"ENJ/USD": "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a",
|
|
2277
|
+
// === Infrastructure & Oracles ===
|
|
2278
|
+
"FIL/USD": "150ac9b959aee0051e4091f0ef5216d941f590e1c5e7f91cf7635b5c11628c0e",
|
|
2279
|
+
"GRT/USD": "4d1f8dae0d96236fb98e8f47571a70f41c8b8f2f6d6c0e0e0e0e0e0e0e0e0e0e",
|
|
2280
|
+
"RNDR/USD": "ab7347771135fc733f8f38db462ba085ed3309955f42554a14fa13e855ac0e2f",
|
|
2281
|
+
"INJ/USD": "7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592",
|
|
2282
|
+
"AR/USD": "8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c",
|
|
2283
|
+
"THETA/USD": "4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a",
|
|
2284
|
+
"PYTH/USD": "0bbf28e9a841a1cc788f6a361b17ca072d0ea3098a1e5df1c3922d06719579ff",
|
|
2285
|
+
// === AI & Data ===
|
|
2286
|
+
"FET/USD": "b49ee9d8ccf9b6e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0",
|
|
2287
|
+
"OCEAN/USD": "2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d",
|
|
2288
|
+
"TAO/USD": "410f41de235f2dbdf41f1a808c1e15f6a9e7d6a7b8c9d0e1f2a3b4c5d6e7f8a9",
|
|
2289
|
+
// === Exchange Tokens ===
|
|
2290
|
+
"FTT/USD": "6c75e52531ec5fd3ef253f6062956a8508a2f03fa0a209fb7dbc0d0f3d6f6f6f",
|
|
2291
|
+
"CRO/USD": "b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7",
|
|
2292
|
+
"OKB/USD": "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
2293
|
+
// === Forex Pairs ===
|
|
2294
|
+
"EUR/USD": "a995d00bb36a63cef7fd2c287dc105fc8f3d93779f062f09551b0af3e81ec30b",
|
|
2295
|
+
"GBP/USD": "84c2dde9633d93d1bcad84e7dc41c9d56578b7ec52fabedc1f335d673df0a7c1",
|
|
2296
|
+
"JPY/USD": "ef2c98c804ba503c6a707e38be4dfbb16683775f195b091252bf24693042fd52",
|
|
2297
|
+
"AUD/USD": "67a6f93030f4217f2e8f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f",
|
|
2298
|
+
"CAD/USD": "9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a",
|
|
2299
|
+
// === Commodities ===
|
|
2300
|
+
"XAU/USD": "765d2ba906dbc32ca17cc11f5310a89e9ee1f6420508c63861f2f8ba4ee34bb2",
|
|
2301
|
+
"XAG/USD": "f2fb02c32b055c805e7238d628e5e9dadef274376114eb1f012337cabe93871e",
|
|
2302
|
+
"WTI/USD": "c9c8e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9",
|
|
2303
|
+
"BRENT/USD": "d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8d8",
|
|
2304
|
+
// === US Equities ===
|
|
2305
|
+
"AAPL/USD": "49f6b65cb1de6b10eaf75e7c03ca029c306d0357e91b5311b175084a5ad55688",
|
|
2306
|
+
"NVDA/USD": "b1073854ed24cbc755dc527418f52b7d271f6cc967bbf8d8129112b18860a593",
|
|
2307
|
+
"TSLA/USD": "16dad506d7db8da01c87581c87ca897a012a153557d4d578c3b9c9e1bc0632f1",
|
|
2308
|
+
"GOOGL/USD": "b7e3904c08ddd9c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0",
|
|
2309
|
+
"AMZN/USD": "c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6c6",
|
|
2310
|
+
"MSFT/USD": "d0ca23c1cc005e004ccf1db5bf76aeb6a49218f43dac3d4b275e92de12ea4b77",
|
|
2311
|
+
"META/USD": "a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4",
|
|
2312
|
+
"COIN/USD": "9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b",
|
|
2313
|
+
"SPY/USD": "19e09bb805456ada3979a7d1cbb4b6d63babc3a0f8e8a9b3c4d5e6f7a8b9c0d1",
|
|
2314
|
+
"QQQ/USD": "2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e"
|
|
2315
|
+
};
|
|
2316
|
+
var PYTH_ABI = [
|
|
2317
|
+
{
|
|
2318
|
+
inputs: [{ name: "id", type: "bytes32" }],
|
|
2319
|
+
name: "getPrice",
|
|
2320
|
+
outputs: [
|
|
2321
|
+
{
|
|
2322
|
+
components: [
|
|
2323
|
+
{ name: "price", type: "int64" },
|
|
2324
|
+
{ name: "conf", type: "uint64" },
|
|
2325
|
+
{ name: "expo", type: "int32" },
|
|
2326
|
+
{ name: "publishTime", type: "uint256" }
|
|
2327
|
+
],
|
|
2328
|
+
name: "",
|
|
2329
|
+
type: "tuple"
|
|
2330
|
+
}
|
|
2331
|
+
],
|
|
2332
|
+
stateMutability: "view",
|
|
2333
|
+
type: "function"
|
|
2334
|
+
},
|
|
2335
|
+
{
|
|
2336
|
+
inputs: [{ name: "id", type: "bytes32" }],
|
|
2337
|
+
name: "getPriceNoOlderThan",
|
|
2338
|
+
outputs: [
|
|
2339
|
+
{
|
|
2340
|
+
components: [
|
|
2341
|
+
{ name: "price", type: "int64" },
|
|
2342
|
+
{ name: "conf", type: "uint64" },
|
|
2343
|
+
{ name: "expo", type: "int32" },
|
|
2344
|
+
{ name: "publishTime", type: "uint256" }
|
|
2345
|
+
],
|
|
2346
|
+
name: "",
|
|
2347
|
+
type: "tuple"
|
|
2348
|
+
}
|
|
2349
|
+
],
|
|
2350
|
+
stateMutability: "view",
|
|
2351
|
+
type: "function"
|
|
2352
|
+
},
|
|
2353
|
+
{
|
|
2354
|
+
inputs: [
|
|
2355
|
+
{ name: "id", type: "bytes32" },
|
|
2356
|
+
{ name: "age", type: "uint256" }
|
|
2357
|
+
],
|
|
2358
|
+
name: "getPriceNoOlderThan",
|
|
2359
|
+
outputs: [
|
|
2360
|
+
{
|
|
2361
|
+
components: [
|
|
2362
|
+
{ name: "price", type: "int64" },
|
|
2363
|
+
{ name: "conf", type: "uint64" },
|
|
2364
|
+
{ name: "expo", type: "int32" },
|
|
2365
|
+
{ name: "publishTime", type: "uint256" }
|
|
2366
|
+
],
|
|
2367
|
+
name: "",
|
|
2368
|
+
type: "tuple"
|
|
2369
|
+
}
|
|
2370
|
+
],
|
|
2371
|
+
stateMutability: "view",
|
|
2372
|
+
type: "function"
|
|
2373
|
+
},
|
|
2374
|
+
{
|
|
2375
|
+
inputs: [{ name: "id", type: "bytes32" }],
|
|
2376
|
+
name: "getPriceUnsafe",
|
|
2377
|
+
outputs: [
|
|
2378
|
+
{
|
|
2379
|
+
components: [
|
|
2380
|
+
{ name: "price", type: "int64" },
|
|
2381
|
+
{ name: "conf", type: "uint64" },
|
|
2382
|
+
{ name: "expo", type: "int32" },
|
|
2383
|
+
{ name: "publishTime", type: "uint256" }
|
|
2384
|
+
],
|
|
2385
|
+
name: "",
|
|
2386
|
+
type: "tuple"
|
|
2387
|
+
}
|
|
2388
|
+
],
|
|
2389
|
+
stateMutability: "view",
|
|
2390
|
+
type: "function"
|
|
2391
|
+
},
|
|
2392
|
+
{
|
|
2393
|
+
inputs: [{ name: "id", type: "bytes32" }],
|
|
2394
|
+
name: "getEmaPrice",
|
|
2395
|
+
outputs: [
|
|
2396
|
+
{
|
|
2397
|
+
components: [
|
|
2398
|
+
{ name: "price", type: "int64" },
|
|
2399
|
+
{ name: "conf", type: "uint64" },
|
|
2400
|
+
{ name: "expo", type: "int32" },
|
|
2401
|
+
{ name: "publishTime", type: "uint256" }
|
|
2402
|
+
],
|
|
2403
|
+
name: "",
|
|
2404
|
+
type: "tuple"
|
|
2405
|
+
}
|
|
2406
|
+
],
|
|
2407
|
+
stateMutability: "view",
|
|
2408
|
+
type: "function"
|
|
2409
|
+
},
|
|
2410
|
+
{
|
|
2411
|
+
inputs: [{ name: "updateData", type: "bytes[]" }],
|
|
2412
|
+
name: "updatePriceFeeds",
|
|
2413
|
+
outputs: [],
|
|
2414
|
+
stateMutability: "payable",
|
|
2415
|
+
type: "function"
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
inputs: [{ name: "updateData", type: "bytes[]" }],
|
|
2419
|
+
name: "getUpdateFee",
|
|
2420
|
+
outputs: [{ name: "feeAmount", type: "uint256" }],
|
|
2421
|
+
stateMutability: "view",
|
|
2422
|
+
type: "function"
|
|
2423
|
+
},
|
|
2424
|
+
{
|
|
2425
|
+
inputs: [{ name: "id", type: "bytes32" }],
|
|
2426
|
+
name: "priceFeedExists",
|
|
2427
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2428
|
+
stateMutability: "view",
|
|
2429
|
+
type: "function"
|
|
2430
|
+
},
|
|
2431
|
+
{
|
|
2432
|
+
inputs: [
|
|
2433
|
+
{ name: "updateData", type: "bytes[]" },
|
|
2434
|
+
{ name: "priceIds", type: "bytes32[]" },
|
|
2435
|
+
{ name: "minPublishTime", type: "uint64" },
|
|
2436
|
+
{ name: "maxPublishTime", type: "uint64" }
|
|
2437
|
+
],
|
|
2438
|
+
name: "parsePriceFeedUpdates",
|
|
2439
|
+
outputs: [
|
|
2440
|
+
{
|
|
2441
|
+
components: [
|
|
2442
|
+
{ name: "id", type: "bytes32" },
|
|
2443
|
+
{
|
|
2444
|
+
components: [
|
|
2445
|
+
{ name: "price", type: "int64" },
|
|
2446
|
+
{ name: "conf", type: "uint64" },
|
|
2447
|
+
{ name: "expo", type: "int32" },
|
|
2448
|
+
{ name: "publishTime", type: "uint256" }
|
|
2449
|
+
],
|
|
2450
|
+
name: "price",
|
|
2451
|
+
type: "tuple"
|
|
2452
|
+
},
|
|
2453
|
+
{
|
|
2454
|
+
components: [
|
|
2455
|
+
{ name: "price", type: "int64" },
|
|
2456
|
+
{ name: "conf", type: "uint64" },
|
|
2457
|
+
{ name: "expo", type: "int32" },
|
|
2458
|
+
{ name: "publishTime", type: "uint256" }
|
|
2459
|
+
],
|
|
2460
|
+
name: "emaPrice",
|
|
2461
|
+
type: "tuple"
|
|
2462
|
+
}
|
|
2463
|
+
],
|
|
2464
|
+
name: "",
|
|
2465
|
+
type: "tuple[]"
|
|
2466
|
+
}
|
|
2467
|
+
],
|
|
2468
|
+
stateMutability: "payable",
|
|
2469
|
+
type: "function"
|
|
2470
|
+
}
|
|
2471
|
+
];
|
|
2472
|
+
|
|
2473
|
+
// src/tools/pyth/getPrice.ts
|
|
2474
|
+
async function pythGetPrice(agent, priceFeedIdOrPair) {
|
|
2475
|
+
const pythAddress = PYTH_CONTRACT[agent.chain];
|
|
2476
|
+
let priceFeedId = priceFeedIdOrPair;
|
|
2477
|
+
let pair = priceFeedIdOrPair;
|
|
2478
|
+
if (priceFeedIdOrPair in PYTH_PRICE_FEED_IDS) {
|
|
2479
|
+
priceFeedId = PYTH_PRICE_FEED_IDS[priceFeedIdOrPair];
|
|
2480
|
+
pair = priceFeedIdOrPair;
|
|
2481
|
+
} else {
|
|
2482
|
+
const foundPair = Object.entries(PYTH_PRICE_FEED_IDS).find(
|
|
2483
|
+
([, id]) => id === priceFeedIdOrPair.replace("0x", "")
|
|
2484
|
+
);
|
|
2485
|
+
if (foundPair) {
|
|
2486
|
+
pair = foundPair[0];
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
const feedId = priceFeedId.startsWith("0x") ? priceFeedId : `0x${priceFeedId}`;
|
|
2490
|
+
if (agent.demo) {
|
|
2491
|
+
return createMockPythResponse(pair, feedId);
|
|
2492
|
+
}
|
|
2493
|
+
try {
|
|
2494
|
+
const priceData = await agent.client.readContract({
|
|
2495
|
+
address: pythAddress,
|
|
2496
|
+
abi: PYTH_ABI,
|
|
2497
|
+
functionName: "getPriceUnsafe",
|
|
2498
|
+
args: [feedId]
|
|
2499
|
+
});
|
|
2500
|
+
const price = Number(priceData.price);
|
|
2501
|
+
const confidence = Number(priceData.conf);
|
|
2502
|
+
const exponent = priceData.expo;
|
|
2503
|
+
const publishTime = Number(priceData.publishTime);
|
|
2504
|
+
const formattedPrice = formatPythPrice(price, exponent);
|
|
2505
|
+
return {
|
|
2506
|
+
priceFeedId: feedId,
|
|
2507
|
+
pair,
|
|
2508
|
+
price: priceData.price.toString(),
|
|
2509
|
+
confidence: priceData.conf.toString(),
|
|
2510
|
+
exponent,
|
|
2511
|
+
publishTime,
|
|
2512
|
+
formattedPrice
|
|
2513
|
+
};
|
|
2514
|
+
} catch (error) {
|
|
2515
|
+
throw new Error(
|
|
2516
|
+
`Failed to fetch price from Pyth: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
async function pythGetEmaPrice(agent, priceFeedIdOrPair) {
|
|
2521
|
+
const pythAddress = PYTH_CONTRACT[agent.chain];
|
|
2522
|
+
let priceFeedId = priceFeedIdOrPair;
|
|
2523
|
+
let pair = priceFeedIdOrPair;
|
|
2524
|
+
if (priceFeedIdOrPair in PYTH_PRICE_FEED_IDS) {
|
|
2525
|
+
priceFeedId = PYTH_PRICE_FEED_IDS[priceFeedIdOrPair];
|
|
2526
|
+
pair = priceFeedIdOrPair;
|
|
2527
|
+
}
|
|
2528
|
+
const feedId = priceFeedId.startsWith("0x") ? priceFeedId : `0x${priceFeedId}`;
|
|
2529
|
+
if (agent.demo) {
|
|
2530
|
+
return createMockPythResponse(pair, feedId);
|
|
2531
|
+
}
|
|
2532
|
+
try {
|
|
2533
|
+
const priceData = await agent.client.readContract({
|
|
2534
|
+
address: pythAddress,
|
|
2535
|
+
abi: PYTH_ABI,
|
|
2536
|
+
functionName: "getEmaPrice",
|
|
2537
|
+
args: [feedId]
|
|
2538
|
+
});
|
|
2539
|
+
const formattedPrice = formatPythPrice(
|
|
2540
|
+
Number(priceData.price),
|
|
2541
|
+
priceData.expo
|
|
2542
|
+
);
|
|
2543
|
+
return {
|
|
2544
|
+
priceFeedId: feedId,
|
|
2545
|
+
pair,
|
|
2546
|
+
price: priceData.price.toString(),
|
|
2547
|
+
confidence: priceData.conf.toString(),
|
|
2548
|
+
exponent: priceData.expo,
|
|
2549
|
+
publishTime: Number(priceData.publishTime),
|
|
2550
|
+
formattedPrice
|
|
2551
|
+
};
|
|
2552
|
+
} catch (error) {
|
|
2553
|
+
throw new Error(
|
|
2554
|
+
`Failed to fetch EMA price from Pyth: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
2555
|
+
);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
function formatPythPrice(price, exponent) {
|
|
2559
|
+
const adjustedPrice = price * Math.pow(10, exponent);
|
|
2560
|
+
if (adjustedPrice >= 1) {
|
|
2561
|
+
return adjustedPrice.toFixed(2);
|
|
2562
|
+
} else {
|
|
2563
|
+
return adjustedPrice.toFixed(8);
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
function createMockPythResponse(pair, feedId) {
|
|
2567
|
+
const mockPrices = {
|
|
2568
|
+
// Major Crypto
|
|
2569
|
+
"BTC/USD": 97500,
|
|
2570
|
+
"ETH/USD": 3450,
|
|
2571
|
+
"SOL/USD": 185,
|
|
2572
|
+
"BNB/USD": 680,
|
|
2573
|
+
"XRP/USD": 2.35,
|
|
2574
|
+
"ADA/USD": 0.95,
|
|
2575
|
+
"DOGE/USD": 0.32,
|
|
2576
|
+
"DOT/USD": 7.2,
|
|
2577
|
+
"AVAX/USD": 38,
|
|
2578
|
+
"MATIC/USD": 0.48,
|
|
2579
|
+
"LINK/USD": 22,
|
|
2580
|
+
"ATOM/USD": 9.5,
|
|
2581
|
+
"LTC/USD": 105,
|
|
2582
|
+
"UNI/USD": 13.5,
|
|
2583
|
+
"NEAR/USD": 5.2,
|
|
2584
|
+
"TRX/USD": 0.25,
|
|
2585
|
+
// L2
|
|
2586
|
+
"ARB/USD": 0.85,
|
|
2587
|
+
"OP/USD": 1.95,
|
|
2588
|
+
"MNT/USD": 0.85,
|
|
2589
|
+
"STRK/USD": 0.45,
|
|
2590
|
+
// DeFi
|
|
2591
|
+
"AAVE/USD": 285,
|
|
2592
|
+
"CRV/USD": 0.52,
|
|
2593
|
+
"MKR/USD": 1850,
|
|
2594
|
+
"SNX/USD": 2.8,
|
|
2595
|
+
"LDO/USD": 1.85,
|
|
2596
|
+
"GMX/USD": 28,
|
|
2597
|
+
"PENDLE/USD": 4.2,
|
|
2598
|
+
// Stablecoins
|
|
2599
|
+
"USDC/USD": 1,
|
|
2600
|
+
"USDT/USD": 1,
|
|
2601
|
+
"DAI/USD": 1,
|
|
2602
|
+
// LST
|
|
2603
|
+
"mETH/USD": 3500,
|
|
2604
|
+
"stETH/USD": 3450,
|
|
2605
|
+
"wstETH/USD": 4100,
|
|
2606
|
+
// Meme
|
|
2607
|
+
"SHIB/USD": 22e-6,
|
|
2608
|
+
"PEPE/USD": 18e-6,
|
|
2609
|
+
"BONK/USD": 28e-6,
|
|
2610
|
+
"WIF/USD": 1.85,
|
|
2611
|
+
// Commodities
|
|
2612
|
+
"XAU/USD": 2650,
|
|
2613
|
+
"XAG/USD": 31,
|
|
2614
|
+
// Forex
|
|
2615
|
+
"EUR/USD": 1.08,
|
|
2616
|
+
"GBP/USD": 1.27,
|
|
2617
|
+
"JPY/USD": 67e-4,
|
|
2618
|
+
// Equities
|
|
2619
|
+
"AAPL/USD": 248,
|
|
2620
|
+
"NVDA/USD": 138,
|
|
2621
|
+
"TSLA/USD": 385,
|
|
2622
|
+
"MSFT/USD": 425
|
|
2623
|
+
};
|
|
2624
|
+
const price = mockPrices[pair] || 100;
|
|
2625
|
+
const decimals = price < 0.01 ? 8 : price < 1 ? 4 : 2;
|
|
2626
|
+
return {
|
|
2627
|
+
priceFeedId: feedId,
|
|
2628
|
+
pair,
|
|
2629
|
+
price: Math.floor(price * 1e8).toString(),
|
|
2630
|
+
confidence: "50000",
|
|
2631
|
+
exponent: -8,
|
|
2632
|
+
publishTime: Math.floor(Date.now() / 1e3),
|
|
2633
|
+
formattedPrice: price.toFixed(decimals)
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
// src/tools/pyth/getMultiplePrices.ts
|
|
2638
|
+
async function pythGetMultiplePrices(agent, pairs) {
|
|
2639
|
+
const pythAddress = PYTH_CONTRACT[agent.chain];
|
|
2640
|
+
const results = [];
|
|
2641
|
+
for (const pairOrId of pairs) {
|
|
2642
|
+
let priceFeedId = pairOrId;
|
|
2643
|
+
let pair = pairOrId;
|
|
2644
|
+
if (pairOrId in PYTH_PRICE_FEED_IDS) {
|
|
2645
|
+
priceFeedId = PYTH_PRICE_FEED_IDS[pairOrId];
|
|
2646
|
+
pair = pairOrId;
|
|
2647
|
+
} else {
|
|
2648
|
+
const foundPair = Object.entries(PYTH_PRICE_FEED_IDS).find(
|
|
2649
|
+
([, id]) => id === pairOrId.replace("0x", "")
|
|
2650
|
+
);
|
|
2651
|
+
if (foundPair) {
|
|
2652
|
+
pair = foundPair[0];
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
const feedId = priceFeedId.startsWith("0x") ? priceFeedId : `0x${priceFeedId}`;
|
|
2656
|
+
if (agent.demo) {
|
|
2657
|
+
results.push(createMockPythResponse2(pair, feedId));
|
|
2658
|
+
continue;
|
|
2659
|
+
}
|
|
2660
|
+
try {
|
|
2661
|
+
const priceData = await agent.client.readContract({
|
|
2662
|
+
address: pythAddress,
|
|
2663
|
+
abi: PYTH_ABI,
|
|
2664
|
+
functionName: "getPriceUnsafe",
|
|
2665
|
+
args: [feedId]
|
|
2666
|
+
});
|
|
2667
|
+
const formattedPrice = formatPythPrice2(
|
|
2668
|
+
Number(priceData.price),
|
|
2669
|
+
priceData.expo
|
|
2670
|
+
);
|
|
2671
|
+
results.push({
|
|
2672
|
+
priceFeedId: feedId,
|
|
2673
|
+
pair,
|
|
2674
|
+
price: priceData.price.toString(),
|
|
2675
|
+
confidence: priceData.conf.toString(),
|
|
2676
|
+
exponent: priceData.expo,
|
|
2677
|
+
publishTime: Number(priceData.publishTime),
|
|
2678
|
+
formattedPrice
|
|
2679
|
+
});
|
|
2680
|
+
} catch (error) {
|
|
2681
|
+
results.push({
|
|
2682
|
+
priceFeedId: feedId,
|
|
2683
|
+
pair,
|
|
2684
|
+
price: "0",
|
|
2685
|
+
confidence: "0",
|
|
2686
|
+
exponent: 0,
|
|
2687
|
+
publishTime: 0,
|
|
2688
|
+
formattedPrice: "Error fetching price"
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
return results;
|
|
2693
|
+
}
|
|
2694
|
+
function pythGetSupportedPriceFeeds() {
|
|
2695
|
+
return { ...PYTH_PRICE_FEED_IDS };
|
|
2696
|
+
}
|
|
2697
|
+
async function pythPriceFeedExists(agent, priceFeedIdOrPair) {
|
|
2698
|
+
const pythAddress = PYTH_CONTRACT[agent.chain];
|
|
2699
|
+
let priceFeedId = priceFeedIdOrPair;
|
|
2700
|
+
if (priceFeedIdOrPair in PYTH_PRICE_FEED_IDS) {
|
|
2701
|
+
priceFeedId = PYTH_PRICE_FEED_IDS[priceFeedIdOrPair];
|
|
2702
|
+
}
|
|
2703
|
+
const feedId = priceFeedId.startsWith("0x") ? priceFeedId : `0x${priceFeedId}`;
|
|
2704
|
+
if (agent.demo) {
|
|
2705
|
+
return priceFeedIdOrPair in PYTH_PRICE_FEED_IDS;
|
|
2706
|
+
}
|
|
2707
|
+
try {
|
|
2708
|
+
const exists = await agent.client.readContract({
|
|
2709
|
+
address: pythAddress,
|
|
2710
|
+
abi: PYTH_ABI,
|
|
2711
|
+
functionName: "priceFeedExists",
|
|
2712
|
+
args: [feedId]
|
|
2713
|
+
});
|
|
2714
|
+
return exists;
|
|
2715
|
+
} catch {
|
|
2716
|
+
return false;
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
function formatPythPrice2(price, exponent) {
|
|
2720
|
+
const adjustedPrice = price * Math.pow(10, exponent);
|
|
2721
|
+
if (adjustedPrice >= 1) {
|
|
2722
|
+
return adjustedPrice.toFixed(2);
|
|
2723
|
+
}
|
|
2724
|
+
return adjustedPrice.toFixed(8);
|
|
2725
|
+
}
|
|
2726
|
+
function createMockPythResponse2(pair, feedId) {
|
|
2727
|
+
const mockPrices = {
|
|
2728
|
+
// Major Crypto
|
|
2729
|
+
"BTC/USD": 97500,
|
|
2730
|
+
"ETH/USD": 3450,
|
|
2731
|
+
"SOL/USD": 185,
|
|
2732
|
+
"BNB/USD": 680,
|
|
2733
|
+
"XRP/USD": 2.35,
|
|
2734
|
+
"ADA/USD": 0.95,
|
|
2735
|
+
"DOGE/USD": 0.32,
|
|
2736
|
+
"DOT/USD": 7.2,
|
|
2737
|
+
"AVAX/USD": 38,
|
|
2738
|
+
"MATIC/USD": 0.48,
|
|
2739
|
+
"LINK/USD": 22,
|
|
2740
|
+
"ATOM/USD": 9.5,
|
|
2741
|
+
"LTC/USD": 105,
|
|
2742
|
+
"UNI/USD": 13.5,
|
|
2743
|
+
"NEAR/USD": 5.2,
|
|
2744
|
+
"TRX/USD": 0.25,
|
|
2745
|
+
// L2
|
|
2746
|
+
"ARB/USD": 0.85,
|
|
2747
|
+
"OP/USD": 1.95,
|
|
2748
|
+
"MNT/USD": 0.85,
|
|
2749
|
+
"STRK/USD": 0.45,
|
|
2750
|
+
// DeFi
|
|
2751
|
+
"AAVE/USD": 285,
|
|
2752
|
+
"CRV/USD": 0.52,
|
|
2753
|
+
"MKR/USD": 1850,
|
|
2754
|
+
"SNX/USD": 2.8,
|
|
2755
|
+
"LDO/USD": 1.85,
|
|
2756
|
+
"GMX/USD": 28,
|
|
2757
|
+
"PENDLE/USD": 4.2,
|
|
2758
|
+
// Stablecoins
|
|
2759
|
+
"USDC/USD": 1,
|
|
2760
|
+
"USDT/USD": 1,
|
|
2761
|
+
"DAI/USD": 1,
|
|
2762
|
+
// LST
|
|
2763
|
+
"mETH/USD": 3500,
|
|
2764
|
+
"stETH/USD": 3450,
|
|
2765
|
+
"wstETH/USD": 4100,
|
|
2766
|
+
// Meme
|
|
2767
|
+
"SHIB/USD": 22e-6,
|
|
2768
|
+
"PEPE/USD": 18e-6,
|
|
2769
|
+
"BONK/USD": 28e-6,
|
|
2770
|
+
"WIF/USD": 1.85,
|
|
2771
|
+
// Commodities
|
|
2772
|
+
"XAU/USD": 2650,
|
|
2773
|
+
"XAG/USD": 31,
|
|
2774
|
+
// Forex
|
|
2775
|
+
"EUR/USD": 1.08,
|
|
2776
|
+
"GBP/USD": 1.27,
|
|
2777
|
+
"JPY/USD": 67e-4,
|
|
2778
|
+
// Equities
|
|
2779
|
+
"AAPL/USD": 248,
|
|
2780
|
+
"NVDA/USD": 138,
|
|
2781
|
+
"TSLA/USD": 385,
|
|
2782
|
+
"MSFT/USD": 425
|
|
2783
|
+
};
|
|
2784
|
+
const price = mockPrices[pair] || 100;
|
|
2785
|
+
const decimals = price < 0.01 ? 8 : price < 1 ? 4 : 2;
|
|
2786
|
+
return {
|
|
2787
|
+
priceFeedId: feedId,
|
|
2788
|
+
pair,
|
|
2789
|
+
price: Math.floor(price * 1e8).toString(),
|
|
2790
|
+
confidence: "50000",
|
|
2791
|
+
exponent: -8,
|
|
2792
|
+
publishTime: Math.floor(Date.now() / 1e3),
|
|
2793
|
+
formattedPrice: price.toFixed(decimals)
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
// src/constants/token-launchpad/index.ts
|
|
2798
|
+
var token_launchpad_exports = {};
|
|
2799
|
+
__export(token_launchpad_exports, {
|
|
2800
|
+
ERC20_ABI: () => ERC20_ABI
|
|
2801
|
+
});
|
|
2802
|
+
var ERC20_ABI = [
|
|
2803
|
+
{
|
|
2804
|
+
inputs: [],
|
|
2805
|
+
name: "name",
|
|
2806
|
+
outputs: [{ name: "", type: "string" }],
|
|
2807
|
+
stateMutability: "view",
|
|
2808
|
+
type: "function"
|
|
2809
|
+
},
|
|
2810
|
+
{
|
|
2811
|
+
inputs: [],
|
|
2812
|
+
name: "symbol",
|
|
2813
|
+
outputs: [{ name: "", type: "string" }],
|
|
2814
|
+
stateMutability: "view",
|
|
2815
|
+
type: "function"
|
|
2816
|
+
},
|
|
2817
|
+
{
|
|
2818
|
+
inputs: [],
|
|
2819
|
+
name: "decimals",
|
|
2820
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
2821
|
+
stateMutability: "view",
|
|
2822
|
+
type: "function"
|
|
2823
|
+
},
|
|
2824
|
+
{
|
|
2825
|
+
inputs: [],
|
|
2826
|
+
name: "totalSupply",
|
|
2827
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2828
|
+
stateMutability: "view",
|
|
2829
|
+
type: "function"
|
|
2830
|
+
},
|
|
2831
|
+
{
|
|
2832
|
+
inputs: [{ name: "account", type: "address" }],
|
|
2833
|
+
name: "balanceOf",
|
|
2834
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2835
|
+
stateMutability: "view",
|
|
2836
|
+
type: "function"
|
|
2837
|
+
},
|
|
2838
|
+
{
|
|
2839
|
+
inputs: [
|
|
2840
|
+
{ name: "to", type: "address" },
|
|
2841
|
+
{ name: "amount", type: "uint256" }
|
|
2842
|
+
],
|
|
2843
|
+
name: "transfer",
|
|
2844
|
+
outputs: [{ name: "", type: "bool" }],
|
|
2845
|
+
stateMutability: "nonpayable",
|
|
2846
|
+
type: "function"
|
|
2847
|
+
}
|
|
2848
|
+
];
|
|
2849
|
+
|
|
2850
|
+
// src/tools/token-launchpad/deployToken.ts
|
|
2851
|
+
var ERC20_BYTECODE = "0x608060405234801561001057600080fd5b5060405161089a38038061089a833981016040819052610032916101db565b8251839083906100499060039060208501906100b4565b50805161005d9060049060208401906100b4565b50505061007a33826100756012600a6102eb565b610081565b5050610359565b6001600160a01b0382166100ab5760405163ec442f0560e01b815260006004820152602401604051809103906000fd5b6100b760008383610140565b5050565b8280546100c09061030c565b90600052602060002090601f0160209004810192826100e2576000855561012e565b82601f106100f357805160ff191683800117855561012e565b8280016001018555821561012e579182015b8281111561012e578251825591602001919060010190610105565b5061013a92915061013e565b5090565b5b8082111561013a576000815560010161013f565b6001600160a01b038316610174578060026000828254610160919061034b565b9091555061019f9050565b6001600160a01b0383166000908152602081905260408120805483929061019c908490610346565b90915550505b6001600160a01b0382166101c1576002805482900390556101e6565b6001600160a01b03821660009081526020819052604081208054839290610169908490610346565b816001600160a01b0316836001600160a01b03166000805160206108228339815191528360405161021991815260200190565b60405180910390a3505050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025757818101518382015260200161023f565b83811115610268576000848401525b50505050565b600082601f83011261027e578081fd5b81516001600160401b038082111561029857610298610226565b604051601f8301601f19908116603f011681019082821181831017156102c0576102c0610226565b816040528381528660208588010111156102d8578485fd5b6102e9846020830160208901610240565b9695505050505050565b60008060006060848603121561030757600080fd5b83516001600160401b038082111561031d578586fd5b6103298783880161026e565b9450602086015191508082111561033e578384fd5b5061034b8682870161026e565b925050604084015190509250925092565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156103ad57816000190482111561039357610393610372565b808516156103a057918102915b93841c939080029061037c565b509250929050565b6000826103c457506001610460565b816103d157506000610460565b81600181146103e757600281146103f15761040d565b6001915050610460565b60ff84111561040257610402610372565b50506001821b610460565b5060208310610133831016604e8410600b8410161715610430575081810a610460565b61043a8383610377565b806000190482111561044e5761044e610372565b029392505050565b600061046283836103b5565b9392505050565b61046b610482565b600082821015610479576104796103a2565b50039056fe";
|
|
2852
|
+
var RWA_BYTECODE = "0x608060405234801561001057600080fd5b5060405161089a38038061089a833981016040819052610032916101db565b8251839083906100499060039060208501906100b4565b50805161005d9060049060208401906100b4565b50505061007a33826100756012600a6102eb565b610081565b5050610359565b6001600160a01b0382166100ab5760405163ec442f0560e01b815260006004820152602401604051809103906000fd5b6100b760008383610140565b5050565b8280546100c09061030c565b90600052602060002090601f0160209004810192826100e2576000855561012e565b82601f106100f357805160ff191683800117855561012e565b8280016001018555821561012e579182015b8281111561012e578251825591602001919060010190610105565b5061013a92915061013e565b5090565b5b8082111561013a576000815560010161013f565b6001600160a01b038316610174578060026000828254610160919061034b565b9091555061019f9050565b6001600160a01b0383166000908152602081905260408120805483929061019c908490610346565b90915550505b6001600160a01b0382166101c1576002805482900390556101e6565b6001600160a01b03821660009081526020819052604081208054839290610169908490610346565b816001600160a01b0316836001600160a01b03166000805160206108228339815191528360405161021991815260200190565b60405180910390a3505050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025757818101518382015260200161023f565b83811115610268576000848401525b50505050565b600082601f83011261027e578081fd5b81516001600160401b038082111561029857610298610226565b604051601f8301601f19908116603f011681019082821181831017156102c0576102c0610226565b816040528381528660208588010111156102d8578485fd5b6102e9846020830160208901610240565b9695505050505050565b60008060006060848603121561030757600080fd5b83516001600160401b038082111561031d578586fd5b6103298783880161026e565b9450602086015191508082111561033e578384fd5b5061034b8682870161026e565b925050604084015190509250925092565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156103ad57816000190482111561039357610393610372565b808516156103a057918102915b93841c939080029061037c565b509250929050565b6000826103c457506001610460565b816103d157506000610460565b81600181146103e757600281146103f15761040d565b6001915050610460565b60ff84111561040257610402610372565b50506001821b610460565b5060208310610133831016604e8410600b8410161715610430575081810a610460565b61043a8383610377565b806000190482111561044e5761044e610372565b029392505050565b600061046283836103b5565b9392505050565b61046b610482565b600082821015610479576104796103a2565b50039056fe";
|
|
2853
|
+
async function deployToken(agent, name, symbol, supply, tokenType = "standard", assetType, assetId) {
|
|
2854
|
+
const decimals = 18;
|
|
2855
|
+
const supplyInWei = viem.parseUnits(supply, decimals).toString();
|
|
2856
|
+
if (agent.demo) {
|
|
2857
|
+
return {
|
|
2858
|
+
tokenAddress: `0xDEMO${tokenType === "rwa" ? "RWA" : "TKN"}00000000000000000001`,
|
|
2859
|
+
txHash: DEMO_TX_HASH,
|
|
2860
|
+
name,
|
|
2861
|
+
symbol,
|
|
2862
|
+
decimals,
|
|
2863
|
+
totalSupply: supplyInWei,
|
|
2864
|
+
mintedTo: agent.account.address,
|
|
2865
|
+
tokenType,
|
|
2866
|
+
assetType,
|
|
2867
|
+
assetId
|
|
2868
|
+
};
|
|
2869
|
+
}
|
|
2870
|
+
if (!name?.trim()) throw new Error("Token name required");
|
|
2871
|
+
if (!symbol?.trim()) throw new Error("Token symbol required");
|
|
2872
|
+
if (!supply || Number(supply) <= 0) throw new Error("Supply must be > 0");
|
|
2873
|
+
const args = viem.encodeAbiParameters(
|
|
2874
|
+
viem.parseAbiParameters("string, string, uint256"),
|
|
2875
|
+
[name, symbol, BigInt(supplyInWei)]
|
|
2876
|
+
);
|
|
2877
|
+
const bytecode = tokenType === "rwa" ? RWA_BYTECODE : ERC20_BYTECODE;
|
|
2878
|
+
const deployData = bytecode + args.slice(2);
|
|
2879
|
+
const txHash = await agent.client.sendTransaction({ data: deployData });
|
|
2880
|
+
const receipt = await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
2881
|
+
if (!receipt.contractAddress) {
|
|
2882
|
+
throw new Error("Deployment failed - no contract address");
|
|
2883
|
+
}
|
|
2884
|
+
return {
|
|
2885
|
+
tokenAddress: receipt.contractAddress,
|
|
2886
|
+
txHash,
|
|
2887
|
+
name,
|
|
2888
|
+
symbol,
|
|
2889
|
+
decimals,
|
|
2890
|
+
totalSupply: supplyInWei,
|
|
2891
|
+
mintedTo: agent.account.address,
|
|
2892
|
+
tokenType,
|
|
2893
|
+
assetType,
|
|
2894
|
+
assetId
|
|
2895
|
+
};
|
|
2896
|
+
}
|
|
2897
|
+
async function deployStandardToken(agent, name, symbol, supply) {
|
|
2898
|
+
return deployToken(agent, name, symbol, supply, "standard");
|
|
2899
|
+
}
|
|
2900
|
+
async function deployRWAToken(agent, name, symbol, supply, assetType, assetId) {
|
|
2901
|
+
return deployToken(agent, name, symbol, supply, "rwa", assetType, assetId);
|
|
2902
|
+
}
|
|
2903
|
+
async function getTokenInfo(agent, tokenAddress, holder) {
|
|
2904
|
+
if (agent.demo) {
|
|
2905
|
+
return {
|
|
2906
|
+
address: tokenAddress,
|
|
2907
|
+
name: "Demo Token",
|
|
2908
|
+
symbol: "DEMO",
|
|
2909
|
+
decimals: 18,
|
|
2910
|
+
totalSupply: "1000000000000000000000000",
|
|
2911
|
+
balance: holder ? "1000000000000000000000" : void 0
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
const [name, symbol, decimals, totalSupply] = await Promise.all([
|
|
2915
|
+
agent.client.readContract({ address: tokenAddress, abi: viem.erc20Abi, functionName: "name" }),
|
|
2916
|
+
agent.client.readContract({ address: tokenAddress, abi: viem.erc20Abi, functionName: "symbol" }),
|
|
2917
|
+
agent.client.readContract({ address: tokenAddress, abi: viem.erc20Abi, functionName: "decimals" }),
|
|
2918
|
+
agent.client.readContract({ address: tokenAddress, abi: viem.erc20Abi, functionName: "totalSupply" })
|
|
2919
|
+
]);
|
|
2920
|
+
const result = {
|
|
2921
|
+
address: tokenAddress,
|
|
2922
|
+
name,
|
|
2923
|
+
symbol,
|
|
2924
|
+
decimals,
|
|
2925
|
+
totalSupply: totalSupply.toString()
|
|
2926
|
+
};
|
|
2927
|
+
if (holder) {
|
|
2928
|
+
const balance = await agent.client.readContract({
|
|
2929
|
+
address: tokenAddress,
|
|
2930
|
+
abi: viem.erc20Abi,
|
|
2931
|
+
functionName: "balanceOf",
|
|
2932
|
+
args: [holder]
|
|
2933
|
+
});
|
|
2934
|
+
result.balance = balance.toString();
|
|
2935
|
+
}
|
|
2936
|
+
return result;
|
|
2937
|
+
}
|
|
2938
|
+
async function getTokenBalance(agent, tokenAddress, holder) {
|
|
2939
|
+
if (agent.demo) return "1000000000000000000000";
|
|
2940
|
+
const balance = await agent.client.readContract({
|
|
2941
|
+
address: tokenAddress,
|
|
2942
|
+
abi: viem.erc20Abi,
|
|
2943
|
+
functionName: "balanceOf",
|
|
2944
|
+
args: [holder || agent.account.address]
|
|
2945
|
+
});
|
|
2946
|
+
return balance.toString();
|
|
2947
|
+
}
|
|
2948
|
+
async function transferToken(agent, tokenAddress, to, amount) {
|
|
2949
|
+
if (agent.demo) return DEMO_TX_HASH;
|
|
2950
|
+
const data = viem.encodeFunctionData({
|
|
2951
|
+
abi: viem.erc20Abi,
|
|
2952
|
+
functionName: "transfer",
|
|
2953
|
+
args: [to, BigInt(amount)]
|
|
2954
|
+
});
|
|
2955
|
+
const txHash = await agent.client.sendTransaction({ to: tokenAddress, data });
|
|
2956
|
+
await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
2957
|
+
return txHash;
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
// src/constants/nft-launchpad/index.ts
|
|
2961
|
+
var nft_launchpad_exports = {};
|
|
2962
|
+
__export(nft_launchpad_exports, {
|
|
2963
|
+
ERC721_ABI: () => ERC721_ABI
|
|
2964
|
+
});
|
|
2965
|
+
var ERC721_ABI = [
|
|
2966
|
+
// Constructor-related
|
|
2967
|
+
{
|
|
2968
|
+
inputs: [
|
|
2969
|
+
{ name: "name", type: "string" },
|
|
2970
|
+
{ name: "symbol", type: "string" },
|
|
2971
|
+
{ name: "baseURI", type: "string" },
|
|
2972
|
+
{ name: "maxSupply", type: "uint256" }
|
|
2973
|
+
],
|
|
2974
|
+
stateMutability: "nonpayable",
|
|
2975
|
+
type: "constructor"
|
|
2976
|
+
},
|
|
2977
|
+
// View functions
|
|
2978
|
+
{
|
|
2979
|
+
inputs: [],
|
|
2980
|
+
name: "name",
|
|
2981
|
+
outputs: [{ name: "", type: "string" }],
|
|
2982
|
+
stateMutability: "view",
|
|
2983
|
+
type: "function"
|
|
2984
|
+
},
|
|
2985
|
+
{
|
|
2986
|
+
inputs: [],
|
|
2987
|
+
name: "symbol",
|
|
2988
|
+
outputs: [{ name: "", type: "string" }],
|
|
2989
|
+
stateMutability: "view",
|
|
2990
|
+
type: "function"
|
|
2991
|
+
},
|
|
2992
|
+
{
|
|
2993
|
+
inputs: [],
|
|
2994
|
+
name: "totalSupply",
|
|
2995
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2996
|
+
stateMutability: "view",
|
|
2997
|
+
type: "function"
|
|
2998
|
+
},
|
|
2999
|
+
{
|
|
3000
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
3001
|
+
name: "tokenURI",
|
|
3002
|
+
outputs: [{ name: "", type: "string" }],
|
|
3003
|
+
stateMutability: "view",
|
|
3004
|
+
type: "function"
|
|
3005
|
+
},
|
|
3006
|
+
{
|
|
3007
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
3008
|
+
name: "ownerOf",
|
|
3009
|
+
outputs: [{ name: "", type: "address" }],
|
|
3010
|
+
stateMutability: "view",
|
|
3011
|
+
type: "function"
|
|
3012
|
+
},
|
|
3013
|
+
{
|
|
3014
|
+
inputs: [{ name: "owner", type: "address" }],
|
|
3015
|
+
name: "balanceOf",
|
|
3016
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
3017
|
+
stateMutability: "view",
|
|
3018
|
+
type: "function"
|
|
3019
|
+
},
|
|
3020
|
+
{
|
|
3021
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
3022
|
+
name: "getApproved",
|
|
3023
|
+
outputs: [{ name: "", type: "address" }],
|
|
3024
|
+
stateMutability: "view",
|
|
3025
|
+
type: "function"
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
inputs: [
|
|
3029
|
+
{ name: "owner", type: "address" },
|
|
3030
|
+
{ name: "operator", type: "address" }
|
|
3031
|
+
],
|
|
3032
|
+
name: "isApprovedForAll",
|
|
3033
|
+
outputs: [{ name: "", type: "bool" }],
|
|
3034
|
+
stateMutability: "view",
|
|
3035
|
+
type: "function"
|
|
3036
|
+
},
|
|
3037
|
+
// State changing functions
|
|
3038
|
+
{
|
|
3039
|
+
inputs: [{ name: "to", type: "address" }],
|
|
3040
|
+
name: "mint",
|
|
3041
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
3042
|
+
stateMutability: "nonpayable",
|
|
3043
|
+
type: "function"
|
|
3044
|
+
},
|
|
3045
|
+
{
|
|
3046
|
+
inputs: [
|
|
3047
|
+
{ name: "to", type: "address" },
|
|
3048
|
+
{ name: "quantity", type: "uint256" }
|
|
3049
|
+
],
|
|
3050
|
+
name: "batchMint",
|
|
3051
|
+
outputs: [{ name: "startTokenId", type: "uint256" }],
|
|
3052
|
+
stateMutability: "nonpayable",
|
|
3053
|
+
type: "function"
|
|
3054
|
+
},
|
|
3055
|
+
{
|
|
3056
|
+
inputs: [
|
|
3057
|
+
{ name: "to", type: "address" },
|
|
3058
|
+
{ name: "tokenId", type: "uint256" }
|
|
3059
|
+
],
|
|
3060
|
+
name: "approve",
|
|
3061
|
+
outputs: [],
|
|
3062
|
+
stateMutability: "nonpayable",
|
|
3063
|
+
type: "function"
|
|
3064
|
+
},
|
|
3065
|
+
{
|
|
3066
|
+
inputs: [
|
|
3067
|
+
{ name: "operator", type: "address" },
|
|
3068
|
+
{ name: "approved", type: "bool" }
|
|
3069
|
+
],
|
|
3070
|
+
name: "setApprovalForAll",
|
|
3071
|
+
outputs: [],
|
|
3072
|
+
stateMutability: "nonpayable",
|
|
3073
|
+
type: "function"
|
|
3074
|
+
},
|
|
3075
|
+
{
|
|
3076
|
+
inputs: [
|
|
3077
|
+
{ name: "from", type: "address" },
|
|
3078
|
+
{ name: "to", type: "address" },
|
|
3079
|
+
{ name: "tokenId", type: "uint256" }
|
|
3080
|
+
],
|
|
3081
|
+
name: "transferFrom",
|
|
3082
|
+
outputs: [],
|
|
3083
|
+
stateMutability: "nonpayable",
|
|
3084
|
+
type: "function"
|
|
3085
|
+
},
|
|
3086
|
+
{
|
|
3087
|
+
inputs: [
|
|
3088
|
+
{ name: "from", type: "address" },
|
|
3089
|
+
{ name: "to", type: "address" },
|
|
3090
|
+
{ name: "tokenId", type: "uint256" }
|
|
3091
|
+
],
|
|
3092
|
+
name: "safeTransferFrom",
|
|
3093
|
+
outputs: [],
|
|
3094
|
+
stateMutability: "nonpayable",
|
|
3095
|
+
type: "function"
|
|
3096
|
+
},
|
|
3097
|
+
{
|
|
3098
|
+
inputs: [
|
|
3099
|
+
{ name: "from", type: "address" },
|
|
3100
|
+
{ name: "to", type: "address" },
|
|
3101
|
+
{ name: "tokenId", type: "uint256" },
|
|
3102
|
+
{ name: "data", type: "bytes" }
|
|
3103
|
+
],
|
|
3104
|
+
name: "safeTransferFrom",
|
|
3105
|
+
outputs: [],
|
|
3106
|
+
stateMutability: "nonpayable",
|
|
3107
|
+
type: "function"
|
|
3108
|
+
},
|
|
3109
|
+
// Events
|
|
3110
|
+
{
|
|
3111
|
+
anonymous: false,
|
|
3112
|
+
inputs: [
|
|
3113
|
+
{ indexed: true, name: "from", type: "address" },
|
|
3114
|
+
{ indexed: true, name: "to", type: "address" },
|
|
3115
|
+
{ indexed: true, name: "tokenId", type: "uint256" }
|
|
3116
|
+
],
|
|
3117
|
+
name: "Transfer",
|
|
3118
|
+
type: "event"
|
|
3119
|
+
},
|
|
3120
|
+
{
|
|
3121
|
+
anonymous: false,
|
|
3122
|
+
inputs: [
|
|
3123
|
+
{ indexed: true, name: "owner", type: "address" },
|
|
3124
|
+
{ indexed: true, name: "approved", type: "address" },
|
|
3125
|
+
{ indexed: true, name: "tokenId", type: "uint256" }
|
|
3126
|
+
],
|
|
3127
|
+
name: "Approval",
|
|
3128
|
+
type: "event"
|
|
3129
|
+
},
|
|
3130
|
+
{
|
|
3131
|
+
anonymous: false,
|
|
3132
|
+
inputs: [
|
|
3133
|
+
{ indexed: true, name: "owner", type: "address" },
|
|
3134
|
+
{ indexed: true, name: "operator", type: "address" },
|
|
3135
|
+
{ indexed: false, name: "approved", type: "bool" }
|
|
3136
|
+
],
|
|
3137
|
+
name: "ApprovalForAll",
|
|
3138
|
+
type: "event"
|
|
3139
|
+
}
|
|
3140
|
+
];
|
|
3141
|
+
|
|
3142
|
+
// src/tools/nft-launchpad/deployCollection.ts
|
|
3143
|
+
var ERC721_CREATION_CODE = `0x608060405234801561001057600080fd5b506040516112a03803806112a0833981016040819052610032916101e5565b83838383600061004283826102f4565b50600161004f82826102f4565b5050600680546001600160a01b0319163317905550600782905560088190555050505050506103b3565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009f57600080fd5b81516001600160401b03808211156100b9576100b9610079565b604051601f8301601f19908116603f011681019082821181831017156100e1576100e1610079565b816040528381526020925086838588010111156100fd57600080fd5b600091505b8382101561011f5785820183015181830184015290820190610102565b6000928101909201929092529392505050565b60008060008060808587031215610148578384fd5b84516001600160401b038082111561015e578586fd5b61016a8883890161008f565b9550602087015191508082111561017f578485fd5b5061018c8782880161008f565b9350506040850151915060608501519050929550929550929292909250565b600181811c908216806101bf57607f821691505b6020821081036101df57634e487b7160e01b600052602260045260246000fd5b50919050565b600080600080608085870312156101fa578384fd5b84516001600160401b0380821115610210578586fd5b61021c8883890161008f565b95506020870151915080821115610231578485fd5b5061023e8782880161008f565b935050604085015191506060850151905092959194509250565b601f82111561029f57600081815260208120601f850160051c8101602086101561027f5750805b601f850160051c820191505b8181101561029e5782815560010161028b565b505050505050565b81516001600160401b038111156102bf576102bf610079565b6102d3816102cd84546101ab565b84610258565b602080601f83116001811461030857600084156102f05750858301515b600019600386901b1c1916600185901b17855561029e565b600085815260208120601f198616915b8281101561033757888601518255948401946001909101908401610318565b50858210156103555787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082601f83011261037657600080fd5b81356001600160401b0381111561038f5761038f610079565b6040516020601f19601f85011681018181106001600160401b03821117156103b9576103b9610079565b6040528281528484830111156103ce57600080fd5b8282602083013760009201829052509392505050565b600080600080608085870312156103f9578384fd5b84356001600160401b038082111561040f578586fd5b61041b88838901610365565b95506020870135915080821115610430578485fd5b5061043d87828801610365565b935050604085013591506060850135905092959194509250565b610ede806103c26000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80636352211e11610097578063a22cb46511610066578063a22cb465146101f3578063b88d4fde14610206578063c87b56dd14610219578063e985e9c51461022c57600080fd5b80636352211e146101a75780636a627842146101ba57806370a08231146101cd57806395d89b41146101eb57600080fd5b8063095ea7b3116100d3578063095ea7b31461016257806318160ddd1461017757806323b872dd1461018157806342842e0e1461019457600080fd5b806301ffc9a7146100fa57806306fdde0314610122578063081812fc14610137575b600080fd5b61010d610108366004610b4a565b610268565b60405190151581526020015b60405180910390f35b61012a6102ba565b6040516101199190610bb7565b61014a610145366004610bca565b61034c565b6040516001600160a01b039091168152602001610119565b610175610170366004610bff565b610373565b005b6005545b604051908152602001610119565b61017561018f366004610c29565b61048d565b6101756101a2366004610c29565b6104be565b61014a6101b5366004610bca565b6104d9565b61017b6101c8366004610c65565b610539565b61017b6101db366004610c65565b6001600160a01b031660009081526003602052604090205490565b61012a6105d6565b610175610201366004610c80565b6105e5565b610175610214366004610cd2565b6105f4565b61012a610227366004610bca565b61062c565b61010d61023a366004610dae565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b60006001600160e01b031982166380ac58cd60e01b148061029957506001600160e01b03198216635b5e139f60e01b145b806102b457506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546102c990610de1565b80601f01602080910402602001604051908101604052809291908181526020018280546102f590610de1565b80156103425780601f1061031757610100808354040283529160200191610342565b820191906000526020600020905b81548152906001019060200180831161032557829003601f168201915b5050505050905090565b600061035782610697565b506000908152600260205260409020546001600160a01b031690565b600061037e826104d9565b9050806001600160a01b0316836001600160a01b0316036103f05760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061040c575061040c813361023a565b61047e5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016103e7565b61048883836106f6565b505050565b6104973382610764565b6104b35760405162461bcd60e51b81526004016103e790610e1b565b6104888383836107c3565b61048883838360405180602001604052806000815250610930565b6000818152600260205260408120546001600160a01b0316806102b45760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016103e7565b6006546000906001600160a01b031633146105965760405162461bcd60e51b815260206004820152601960248201527f4f6e6c79206f776e65722063616e206d696e7420746f6b656e730000000000006044820152606401610e7565b600580549060006105a683610e68565b91905055905060075460001480156105bf575060075481115b156105c957600080fd5b6105d38382610944565b50919050565b6060600180546102c990610de1565b6105f033838361095e565b5050565b6105fe3383610764565b61061a5760405162461bcd60e51b81526004016103e790610e1b565b61062684848484610a2c565b50505050565b606061063782610697565b600061064e60408051602081019091526000815290565b9050600081511161066e5760405180602001604052806000815250610690565b8061067884610a5f565b604051602001610689929190610e81565b6040519091905056fe60005b838110156106ae578181015183820152602001610696565b50506000910152565b60006102b4826001600160a01b03163b151590565b806001600160a01b0316826001600160a01b0316036107225760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f76616c20746f2073656c660000000000000000604482015260640160405180910390fd5b6001600160a01b03838116600081815260046020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0382166107b25760405162461bcd60e51b815260206004820152601160248201527045524337323: 696e76616c6964206164647260781b604482015260640160405180910390fd5b6000818152600260205260408120546001600160a01b0316906107d490610aff565b6001600160a01b0384166000908152600360205260408120805460019290610807908490610eb0565b909155505060008281526002602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000818152600260205260408120546001600160a01b031661092c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840160405180910390fd5b6000610937836104d9565b9050806001600160a01b0316846001600160a01b031614806109725750836001600160a01b03166109678461034c565b6001600160a01b0316145b8061098257506109828185610b23565b949350505050565b61098d8484846107c3565b61099984848484610b4c565b6106265760405162461bcd60e51b81526004016103e790610ec3565b6105f08282604051806020016040528060008152506109d3836109b5565b6109bf8383610a2c565b6109cc6000848484610b4c565b5050505050565b816001600160a01b0316836001600160a01b0316036109fe5760405162461bcd60e51b81526004016103e790610f0c565b6001600160a01b0382811660008181526004602090815260408083209487168084529482529182902080548615157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909116179055905190825290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3191015b60405180910390a3505050565b610a376107c3565b610a4384848484610c25565b5050505050565b60606000610a5783610c58565b600101905060008167ffffffffffffffff811115610a7757610a77610cbc565b6040519080825280601f01601f191660200182016040528015610aa1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610aab57509392505050565b600060001982015b6000838152600260205260409020546001600160a01b0316610b085750919050565b8015610b145792915050565b82610b1e81610f4f565b935050610b07565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b60006001600160a01b0384163b15610c1a57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290610b90903390899088908890600401610f66565b6020604051808303816000875af1925050508015610bcb575060408051601f3d908101601f19168201909252610bc891810190610f99565b60015b610c00573d808015610bf9576040519150601f19603f3d011682016040523d82523d6000602084013e610bfe565b606091505b505080515f03610c185760405162461bcd60e51b81526004016103e790610ec3565b505b6001600160e01b031916630a85bd0160e11b149050610982565b506001949350505050565b610c318484846107c3565b610c3d84848484610b4c565b6106265760405162461bcd60e51b81526004016103e790610ec3565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610c975772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610cc3576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610ce157662386f26fc10000830492506010015b6305f5e1008310610cf9576305f5e100830492506008015b6127108310610d0d57612710830492506004015b60648310610d1f576064830492506002015b600a83106102b45760010192915050565b6001600160e01b031981168114610d4657600080fd5b50565b600060208284031215610d5a578081fd5b8135610d6581610d30565b9392505050565b60005b83811015610d87578181015183820152602001610d6f565b50506000910152565b60008151808452610da8816020860160208601610d6c565b601f01601f19169290920160200192915050565b602081526000610d656020830184610d90565b600060208284031215610de0578081fd5b5035919050565b80356001600160a01b0381168114610dfe57600080fd5b919050565b60008060408385031215610e15578081fd5b610e1e83610de7565b946020939093013593505050565b600080600060608486031215610e40578081fd5b610e4984610de7565b9250610e5760208501610de7565b9150604084013590509250925092565b600060208284031215610e78578081fd5b610d6582610de7565b60008060408385031215610e93578182fd5b610e9c83610de7565b915060208301358015158114610eb0578182fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112610ee1578081fd5b813567ffffffffffffffff80821115610efc57610efc610ebb565b604051601f8301601f19908116603f01168101908282118183101715610f2457610f24610ebb565b81604052838152866020858801011115610f3c578485fd5b83602087016020830137600060208583010152809450505050509291505056fea264697066735822122000000000000000000000000000000000000000000000000000000000000000064736f6c63430008150033`;
|
|
3144
|
+
async function deployNFTCollection(agent, config) {
|
|
3145
|
+
const { name, symbol, baseURI, maxSupply = 0 } = config;
|
|
3146
|
+
if (agent.demo) {
|
|
3147
|
+
return {
|
|
3148
|
+
collectionAddress: "0xDEMO000000000000000000000000000000000002",
|
|
3149
|
+
txHash: DEMO_TX_HASH,
|
|
3150
|
+
name,
|
|
3151
|
+
symbol,
|
|
3152
|
+
baseURI,
|
|
3153
|
+
maxSupply,
|
|
3154
|
+
deployer: agent.account.address
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
if (!name || name.length === 0) {
|
|
3158
|
+
throw new Error("Collection name is required");
|
|
3159
|
+
}
|
|
3160
|
+
if (!symbol || symbol.length === 0) {
|
|
3161
|
+
throw new Error("Collection symbol is required");
|
|
3162
|
+
}
|
|
3163
|
+
if (!baseURI) {
|
|
3164
|
+
throw new Error("Base URI is required for token metadata");
|
|
3165
|
+
}
|
|
3166
|
+
const constructorArgs = viem.encodeAbiParameters(
|
|
3167
|
+
viem.parseAbiParameters(
|
|
3168
|
+
"string name, string symbol, string baseURI, uint256 maxSupply"
|
|
3169
|
+
),
|
|
3170
|
+
[name, symbol, baseURI, BigInt(maxSupply)]
|
|
3171
|
+
);
|
|
3172
|
+
const deploymentBytecode = ERC721_CREATION_CODE + constructorArgs.slice(2);
|
|
3173
|
+
const txHash = await agent.client.sendTransaction({
|
|
3174
|
+
data: deploymentBytecode
|
|
3175
|
+
});
|
|
3176
|
+
const receipt = await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
3177
|
+
if (!receipt.contractAddress) {
|
|
3178
|
+
throw new Error(
|
|
3179
|
+
"NFT Collection deployment failed - no contract address returned"
|
|
3180
|
+
);
|
|
3181
|
+
}
|
|
3182
|
+
return {
|
|
3183
|
+
collectionAddress: receipt.contractAddress,
|
|
3184
|
+
txHash,
|
|
3185
|
+
name,
|
|
3186
|
+
symbol,
|
|
3187
|
+
baseURI,
|
|
3188
|
+
maxSupply,
|
|
3189
|
+
deployer: agent.account.address
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
async function deployNFTCollectionWithPreset(agent, preset, name, symbol, baseURI) {
|
|
3193
|
+
const presetConfigs = {
|
|
3194
|
+
pfp: 1e4,
|
|
3195
|
+
// Profile picture collections
|
|
3196
|
+
art: 1e3,
|
|
3197
|
+
// Art collections
|
|
3198
|
+
membership: 100,
|
|
3199
|
+
// Membership/pass collections
|
|
3200
|
+
unlimited: 0
|
|
3201
|
+
// Unlimited supply
|
|
3202
|
+
};
|
|
3203
|
+
return deployNFTCollection(agent, {
|
|
3204
|
+
name,
|
|
3205
|
+
symbol,
|
|
3206
|
+
baseURI,
|
|
3207
|
+
maxSupply: presetConfigs[preset]
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
async function mintNFT(agent, collectionAddress, to) {
|
|
3211
|
+
const recipient = to || agent.account.address;
|
|
3212
|
+
if (agent.demo) {
|
|
3213
|
+
return {
|
|
3214
|
+
txHash: DEMO_TX_HASH,
|
|
3215
|
+
tokenId: "1",
|
|
3216
|
+
collectionAddress,
|
|
3217
|
+
to: recipient
|
|
3218
|
+
};
|
|
3219
|
+
}
|
|
3220
|
+
const data = viem.encodeFunctionData({
|
|
3221
|
+
abi: ERC721_ABI,
|
|
3222
|
+
functionName: "mint",
|
|
3223
|
+
args: [recipient]
|
|
3224
|
+
});
|
|
3225
|
+
const txHash = await agent.client.sendTransaction({
|
|
3226
|
+
to: collectionAddress,
|
|
3227
|
+
data
|
|
3228
|
+
});
|
|
3229
|
+
const receipt = await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
3230
|
+
let tokenId = "0";
|
|
3231
|
+
for (const log of receipt.logs) {
|
|
3232
|
+
if (log.topics[0] === "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") {
|
|
3233
|
+
if (log.topics[3]) {
|
|
3234
|
+
tokenId = BigInt(log.topics[3]).toString();
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
return {
|
|
3239
|
+
txHash,
|
|
3240
|
+
tokenId,
|
|
3241
|
+
collectionAddress,
|
|
3242
|
+
to: recipient
|
|
3243
|
+
};
|
|
3244
|
+
}
|
|
3245
|
+
async function batchMintNFT(agent, collectionAddress, to, quantity) {
|
|
3246
|
+
if (agent.demo) {
|
|
3247
|
+
return {
|
|
3248
|
+
txHash: DEMO_TX_HASH,
|
|
3249
|
+
startTokenId: "1",
|
|
3250
|
+
quantity
|
|
3251
|
+
};
|
|
3252
|
+
}
|
|
3253
|
+
const data = viem.encodeFunctionData({
|
|
3254
|
+
abi: ERC721_ABI,
|
|
3255
|
+
functionName: "batchMint",
|
|
3256
|
+
args: [to, BigInt(quantity)]
|
|
3257
|
+
});
|
|
3258
|
+
const txHash = await agent.client.sendTransaction({
|
|
3259
|
+
to: collectionAddress,
|
|
3260
|
+
data
|
|
3261
|
+
});
|
|
3262
|
+
const receipt = await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
3263
|
+
let startTokenId = "1";
|
|
3264
|
+
for (const log of receipt.logs) {
|
|
3265
|
+
if (log.topics[0] === "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") {
|
|
3266
|
+
if (log.topics[3]) {
|
|
3267
|
+
startTokenId = BigInt(log.topics[3]).toString();
|
|
3268
|
+
break;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
return {
|
|
3273
|
+
txHash,
|
|
3274
|
+
startTokenId,
|
|
3275
|
+
quantity
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
async function getNFTCollectionInfo(agent, collectionAddress, holderAddress) {
|
|
3279
|
+
if (agent.demo) {
|
|
3280
|
+
return {
|
|
3281
|
+
address: collectionAddress,
|
|
3282
|
+
name: "Demo NFT Collection",
|
|
3283
|
+
symbol: "DEMO",
|
|
3284
|
+
totalSupply: "100",
|
|
3285
|
+
balanceOf: holderAddress ? "5" : void 0
|
|
3286
|
+
};
|
|
3287
|
+
}
|
|
3288
|
+
const [name, symbol, totalSupply] = await Promise.all([
|
|
3289
|
+
agent.client.readContract({
|
|
3290
|
+
address: collectionAddress,
|
|
3291
|
+
abi: ERC721_ABI,
|
|
3292
|
+
functionName: "name"
|
|
3293
|
+
}),
|
|
3294
|
+
agent.client.readContract({
|
|
3295
|
+
address: collectionAddress,
|
|
3296
|
+
abi: ERC721_ABI,
|
|
3297
|
+
functionName: "symbol"
|
|
3298
|
+
}),
|
|
3299
|
+
agent.client.readContract({
|
|
3300
|
+
address: collectionAddress,
|
|
3301
|
+
abi: ERC721_ABI,
|
|
3302
|
+
functionName: "totalSupply"
|
|
3303
|
+
})
|
|
3304
|
+
]);
|
|
3305
|
+
const result = {
|
|
3306
|
+
address: collectionAddress,
|
|
3307
|
+
name,
|
|
3308
|
+
symbol,
|
|
3309
|
+
totalSupply: totalSupply.toString()
|
|
3310
|
+
};
|
|
3311
|
+
if (holderAddress) {
|
|
3312
|
+
const balance = await agent.client.readContract({
|
|
3313
|
+
address: collectionAddress,
|
|
3314
|
+
abi: ERC721_ABI,
|
|
3315
|
+
functionName: "balanceOf",
|
|
3316
|
+
args: [holderAddress]
|
|
3317
|
+
});
|
|
3318
|
+
result.balanceOf = balance.toString();
|
|
3319
|
+
}
|
|
3320
|
+
return result;
|
|
3321
|
+
}
|
|
3322
|
+
async function getNFTTokenInfo(agent, collectionAddress, tokenId) {
|
|
3323
|
+
if (agent.demo) {
|
|
3324
|
+
return {
|
|
3325
|
+
collectionAddress,
|
|
3326
|
+
tokenId,
|
|
3327
|
+
owner: agent.account.address,
|
|
3328
|
+
tokenURI: `https://example.com/metadata/${tokenId}.json`
|
|
3329
|
+
};
|
|
3330
|
+
}
|
|
3331
|
+
const [owner, tokenURI] = await Promise.all([
|
|
3332
|
+
agent.client.readContract({
|
|
3333
|
+
address: collectionAddress,
|
|
3334
|
+
abi: ERC721_ABI,
|
|
3335
|
+
functionName: "ownerOf",
|
|
3336
|
+
args: [BigInt(tokenId)]
|
|
3337
|
+
}),
|
|
3338
|
+
agent.client.readContract({
|
|
3339
|
+
address: collectionAddress,
|
|
3340
|
+
abi: ERC721_ABI,
|
|
3341
|
+
functionName: "tokenURI",
|
|
3342
|
+
args: [BigInt(tokenId)]
|
|
3343
|
+
})
|
|
3344
|
+
]);
|
|
3345
|
+
return {
|
|
3346
|
+
collectionAddress,
|
|
3347
|
+
tokenId,
|
|
3348
|
+
owner,
|
|
3349
|
+
tokenURI
|
|
3350
|
+
};
|
|
3351
|
+
}
|
|
3352
|
+
async function getNFTBalance(agent, collectionAddress, holderAddress) {
|
|
3353
|
+
const address = holderAddress || agent.account.address;
|
|
3354
|
+
if (agent.demo) {
|
|
3355
|
+
return "5";
|
|
3356
|
+
}
|
|
3357
|
+
const balance = await agent.client.readContract({
|
|
3358
|
+
address: collectionAddress,
|
|
3359
|
+
abi: ERC721_ABI,
|
|
3360
|
+
functionName: "balanceOf",
|
|
3361
|
+
args: [address]
|
|
3362
|
+
});
|
|
3363
|
+
return balance.toString();
|
|
3364
|
+
}
|
|
3365
|
+
async function isNFTOwner(agent, collectionAddress, tokenId, ownerAddress) {
|
|
3366
|
+
const address = ownerAddress || agent.account.address;
|
|
3367
|
+
if (agent.demo) {
|
|
3368
|
+
return true;
|
|
3369
|
+
}
|
|
3370
|
+
try {
|
|
3371
|
+
const owner = await agent.client.readContract({
|
|
3372
|
+
address: collectionAddress,
|
|
3373
|
+
abi: ERC721_ABI,
|
|
3374
|
+
functionName: "ownerOf",
|
|
3375
|
+
args: [BigInt(tokenId)]
|
|
3376
|
+
});
|
|
3377
|
+
return owner.toLowerCase() === address.toLowerCase();
|
|
3378
|
+
} catch {
|
|
3379
|
+
return false;
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
async function transferNFT(agent, collectionAddress, to, tokenId) {
|
|
3383
|
+
if (agent.demo) {
|
|
3384
|
+
return DEMO_TX_HASH;
|
|
3385
|
+
}
|
|
3386
|
+
const data = viem.encodeFunctionData({
|
|
3387
|
+
abi: ERC721_ABI,
|
|
3388
|
+
functionName: "transferFrom",
|
|
3389
|
+
args: [agent.account.address, to, BigInt(tokenId)]
|
|
3390
|
+
});
|
|
3391
|
+
const txHash = await agent.client.sendTransaction({
|
|
3392
|
+
to: collectionAddress,
|
|
3393
|
+
data
|
|
3394
|
+
});
|
|
3395
|
+
await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
3396
|
+
return txHash;
|
|
3397
|
+
}
|
|
3398
|
+
async function safeTransferNFT(agent, collectionAddress, to, tokenId) {
|
|
3399
|
+
if (agent.demo) {
|
|
3400
|
+
return DEMO_TX_HASH;
|
|
3401
|
+
}
|
|
3402
|
+
const data = viem.encodeFunctionData({
|
|
3403
|
+
abi: ERC721_ABI,
|
|
3404
|
+
functionName: "safeTransferFrom",
|
|
3405
|
+
args: [agent.account.address, to, BigInt(tokenId)]
|
|
3406
|
+
});
|
|
3407
|
+
const txHash = await agent.client.sendTransaction({
|
|
3408
|
+
to: collectionAddress,
|
|
3409
|
+
data
|
|
3410
|
+
});
|
|
3411
|
+
await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
3412
|
+
return txHash;
|
|
3413
|
+
}
|
|
3414
|
+
async function approveNFT(agent, collectionAddress, approved, tokenId) {
|
|
3415
|
+
if (agent.demo) {
|
|
3416
|
+
return DEMO_TX_HASH;
|
|
3417
|
+
}
|
|
3418
|
+
const data = viem.encodeFunctionData({
|
|
3419
|
+
abi: ERC721_ABI,
|
|
3420
|
+
functionName: "approve",
|
|
3421
|
+
args: [approved, BigInt(tokenId)]
|
|
3422
|
+
});
|
|
3423
|
+
const txHash = await agent.client.sendTransaction({
|
|
3424
|
+
to: collectionAddress,
|
|
3425
|
+
data
|
|
3426
|
+
});
|
|
3427
|
+
await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
3428
|
+
return txHash;
|
|
3429
|
+
}
|
|
3430
|
+
async function setApprovalForAllNFT(agent, collectionAddress, operator, approved) {
|
|
3431
|
+
if (agent.demo) {
|
|
3432
|
+
return DEMO_TX_HASH;
|
|
3433
|
+
}
|
|
3434
|
+
const data = viem.encodeFunctionData({
|
|
3435
|
+
abi: ERC721_ABI,
|
|
3436
|
+
functionName: "setApprovalForAll",
|
|
3437
|
+
args: [operator, approved]
|
|
3438
|
+
});
|
|
3439
|
+
const txHash = await agent.client.sendTransaction({
|
|
3440
|
+
to: collectionAddress,
|
|
3441
|
+
data
|
|
3442
|
+
});
|
|
3443
|
+
await agent.client.waitForTransactionReceipt({ hash: txHash });
|
|
3444
|
+
return txHash;
|
|
3445
|
+
}
|
|
3446
|
+
|
|
2193
3447
|
// src/tools/okx/getSwapQuote.ts
|
|
2194
3448
|
var getSwapQuote = async (agent, from, to, amount, slippagePercentage) => {
|
|
2195
3449
|
if (agent.demo) {
|
|
@@ -2563,6 +3817,219 @@ var MNTAgentKit = class {
|
|
|
2563
3817
|
async pikeperpsGetMarketData(tokenAddress, limit = 20) {
|
|
2564
3818
|
return await pikeperpsGetMarketData(this, tokenAddress, limit);
|
|
2565
3819
|
}
|
|
3820
|
+
// ===== Pyth Network Price Feeds =====
|
|
3821
|
+
/**
|
|
3822
|
+
* Get real-time price from Pyth Network
|
|
3823
|
+
* @param priceFeedIdOrPair - Price feed ID or pair name (e.g., "ETH/USD", "BTC/USD", "MNT/USD")
|
|
3824
|
+
* @returns Price data with formatted price
|
|
3825
|
+
*/
|
|
3826
|
+
async pythGetPrice(priceFeedIdOrPair) {
|
|
3827
|
+
return await pythGetPrice(this, priceFeedIdOrPair);
|
|
3828
|
+
}
|
|
3829
|
+
/**
|
|
3830
|
+
* Get EMA (Exponential Moving Average) price from Pyth
|
|
3831
|
+
* @param priceFeedIdOrPair - Price feed ID or pair name
|
|
3832
|
+
* @returns EMA price data
|
|
3833
|
+
*/
|
|
3834
|
+
async pythGetEmaPrice(priceFeedIdOrPair) {
|
|
3835
|
+
return await pythGetEmaPrice(this, priceFeedIdOrPair);
|
|
3836
|
+
}
|
|
3837
|
+
/**
|
|
3838
|
+
* Get multiple prices from Pyth in a single call
|
|
3839
|
+
* @param pairs - Array of pair names or price feed IDs
|
|
3840
|
+
* @returns Array of price responses
|
|
3841
|
+
*/
|
|
3842
|
+
async pythGetMultiplePrices(pairs) {
|
|
3843
|
+
return await pythGetMultiplePrices(this, pairs);
|
|
3844
|
+
}
|
|
3845
|
+
/**
|
|
3846
|
+
* Get all supported Pyth price feed IDs
|
|
3847
|
+
* @returns Object mapping pair names to price feed IDs
|
|
3848
|
+
*/
|
|
3849
|
+
pythGetSupportedPriceFeeds() {
|
|
3850
|
+
return pythGetSupportedPriceFeeds();
|
|
3851
|
+
}
|
|
3852
|
+
/**
|
|
3853
|
+
* Check if a price feed exists on Pyth
|
|
3854
|
+
* @param priceFeedIdOrPair - Price feed ID or pair name
|
|
3855
|
+
* @returns Boolean indicating if feed exists
|
|
3856
|
+
*/
|
|
3857
|
+
async pythPriceFeedExists(priceFeedIdOrPair) {
|
|
3858
|
+
return await pythPriceFeedExists(this, priceFeedIdOrPair);
|
|
3859
|
+
}
|
|
3860
|
+
// ===== Token Launchpad =====
|
|
3861
|
+
/**
|
|
3862
|
+
* Deploy a new token (ERC20 or RWA) - supply minted to your address
|
|
3863
|
+
* @param name - Token name
|
|
3864
|
+
* @param symbol - Token symbol
|
|
3865
|
+
* @param supply - Total supply (human readable, e.g., "1000000")
|
|
3866
|
+
* @param tokenType - "standard" or "rwa"
|
|
3867
|
+
* @param assetType - For RWA: asset category
|
|
3868
|
+
* @param assetId - For RWA: external asset ID
|
|
3869
|
+
*/
|
|
3870
|
+
async deployToken(name, symbol, supply, tokenType = "standard", assetType, assetId) {
|
|
3871
|
+
return await deployToken(this, name, symbol, supply, tokenType, assetType, assetId);
|
|
3872
|
+
}
|
|
3873
|
+
/**
|
|
3874
|
+
* Deploy a standard ERC20 token
|
|
3875
|
+
* @param name - Token name
|
|
3876
|
+
* @param symbol - Token symbol
|
|
3877
|
+
* @param supply - Total supply (e.g., "1000000" for 1M tokens)
|
|
3878
|
+
*/
|
|
3879
|
+
async deployStandardToken(name, symbol, supply) {
|
|
3880
|
+
return await deployStandardToken(this, name, symbol, supply);
|
|
3881
|
+
}
|
|
3882
|
+
/**
|
|
3883
|
+
* Deploy an RWA (Real World Asset) token
|
|
3884
|
+
* @param name - Token name (e.g., "Manhattan Property Token")
|
|
3885
|
+
* @param symbol - Token symbol (e.g., "MPT")
|
|
3886
|
+
* @param supply - Total supply for fractional ownership
|
|
3887
|
+
* @param assetType - Asset category: "Real Estate", "Commodities", "Securities", "Art"
|
|
3888
|
+
* @param assetId - External reference ID for the underlying asset
|
|
3889
|
+
*/
|
|
3890
|
+
async deployRWAToken(name, symbol, supply, assetType, assetId) {
|
|
3891
|
+
return await deployRWAToken(this, name, symbol, supply, assetType, assetId);
|
|
3892
|
+
}
|
|
3893
|
+
/**
|
|
3894
|
+
* Get token information
|
|
3895
|
+
*/
|
|
3896
|
+
async getTokenInfo(tokenAddress, holder) {
|
|
3897
|
+
return await getTokenInfo(this, tokenAddress, holder);
|
|
3898
|
+
}
|
|
3899
|
+
/**
|
|
3900
|
+
* Get token balance
|
|
3901
|
+
*/
|
|
3902
|
+
async getTokenBalance(tokenAddress, holder) {
|
|
3903
|
+
return await getTokenBalance(this, tokenAddress, holder);
|
|
3904
|
+
}
|
|
3905
|
+
/**
|
|
3906
|
+
* Transfer tokens
|
|
3907
|
+
*/
|
|
3908
|
+
async transferToken(tokenAddress, to, amount) {
|
|
3909
|
+
return await transferToken(this, tokenAddress, to, amount);
|
|
3910
|
+
}
|
|
3911
|
+
// ===== NFT Launchpad =====
|
|
3912
|
+
/**
|
|
3913
|
+
* Deploy a new ERC721 NFT collection on Mantle Network
|
|
3914
|
+
* @param config - Collection configuration (name, symbol, baseURI, maxSupply)
|
|
3915
|
+
* @returns Collection deployment result with contract address
|
|
3916
|
+
*/
|
|
3917
|
+
async deployNFTCollection(config) {
|
|
3918
|
+
return await deployNFTCollection(this, config);
|
|
3919
|
+
}
|
|
3920
|
+
/**
|
|
3921
|
+
* Deploy an NFT collection with preset configurations
|
|
3922
|
+
* @param preset - Preset type: "pfp" (10000), "art" (1000), "membership" (100), "unlimited"
|
|
3923
|
+
* @param name - Collection name
|
|
3924
|
+
* @param symbol - Collection symbol
|
|
3925
|
+
* @param baseURI - Base URI for metadata
|
|
3926
|
+
* @returns Collection deployment result
|
|
3927
|
+
*/
|
|
3928
|
+
async deployNFTCollectionWithPreset(preset, name, symbol, baseURI) {
|
|
3929
|
+
return await deployNFTCollectionWithPreset(
|
|
3930
|
+
this,
|
|
3931
|
+
preset,
|
|
3932
|
+
name,
|
|
3933
|
+
symbol,
|
|
3934
|
+
baseURI
|
|
3935
|
+
);
|
|
3936
|
+
}
|
|
3937
|
+
/**
|
|
3938
|
+
* Mint a single NFT from a collection
|
|
3939
|
+
* @param collectionAddress - NFT collection contract address
|
|
3940
|
+
* @param to - Recipient address (defaults to agent address)
|
|
3941
|
+
* @returns Mint result with token ID
|
|
3942
|
+
*/
|
|
3943
|
+
async mintNFT(collectionAddress, to) {
|
|
3944
|
+
return await mintNFT(this, collectionAddress, to);
|
|
3945
|
+
}
|
|
3946
|
+
/**
|
|
3947
|
+
* Batch mint multiple NFTs from a collection
|
|
3948
|
+
* @param collectionAddress - NFT collection contract address
|
|
3949
|
+
* @param to - Recipient address
|
|
3950
|
+
* @param quantity - Number of NFTs to mint
|
|
3951
|
+
* @returns Mint result with starting token ID
|
|
3952
|
+
*/
|
|
3953
|
+
async batchMintNFT(collectionAddress, to, quantity) {
|
|
3954
|
+
return await batchMintNFT(this, collectionAddress, to, quantity);
|
|
3955
|
+
}
|
|
3956
|
+
/**
|
|
3957
|
+
* Get information about an NFT collection
|
|
3958
|
+
* @param collectionAddress - NFT collection contract address
|
|
3959
|
+
* @param holderAddress - Optional address to get balance for
|
|
3960
|
+
* @returns Collection information
|
|
3961
|
+
*/
|
|
3962
|
+
async getNFTCollectionInfo(collectionAddress, holderAddress) {
|
|
3963
|
+
return await getNFTCollectionInfo(this, collectionAddress, holderAddress);
|
|
3964
|
+
}
|
|
3965
|
+
/**
|
|
3966
|
+
* Get information about a specific NFT token
|
|
3967
|
+
* @param collectionAddress - NFT collection contract address
|
|
3968
|
+
* @param tokenId - Token ID
|
|
3969
|
+
* @returns Token information
|
|
3970
|
+
*/
|
|
3971
|
+
async getNFTTokenInfo(collectionAddress, tokenId) {
|
|
3972
|
+
return await getNFTTokenInfo(this, collectionAddress, tokenId);
|
|
3973
|
+
}
|
|
3974
|
+
/**
|
|
3975
|
+
* Get NFT balance for an address
|
|
3976
|
+
* @param collectionAddress - NFT collection contract address
|
|
3977
|
+
* @param holderAddress - Address to check (defaults to agent address)
|
|
3978
|
+
* @returns Balance as string
|
|
3979
|
+
*/
|
|
3980
|
+
async getNFTBalance(collectionAddress, holderAddress) {
|
|
3981
|
+
return await getNFTBalance(this, collectionAddress, holderAddress);
|
|
3982
|
+
}
|
|
3983
|
+
/**
|
|
3984
|
+
* Check if an address owns a specific NFT
|
|
3985
|
+
* @param collectionAddress - NFT collection contract address
|
|
3986
|
+
* @param tokenId - Token ID to check
|
|
3987
|
+
* @param ownerAddress - Address to verify ownership
|
|
3988
|
+
* @returns Boolean indicating ownership
|
|
3989
|
+
*/
|
|
3990
|
+
async isNFTOwner(collectionAddress, tokenId, ownerAddress) {
|
|
3991
|
+
return await isNFTOwner(this, collectionAddress, tokenId, ownerAddress);
|
|
3992
|
+
}
|
|
3993
|
+
/**
|
|
3994
|
+
* Transfer an NFT to another address
|
|
3995
|
+
* @param collectionAddress - NFT collection contract address
|
|
3996
|
+
* @param to - Recipient address
|
|
3997
|
+
* @param tokenId - Token ID to transfer
|
|
3998
|
+
* @returns Transaction hash
|
|
3999
|
+
*/
|
|
4000
|
+
async transferNFT(collectionAddress, to, tokenId) {
|
|
4001
|
+
return await transferNFT(this, collectionAddress, to, tokenId);
|
|
4002
|
+
}
|
|
4003
|
+
/**
|
|
4004
|
+
* Safe transfer an NFT (checks if recipient can receive)
|
|
4005
|
+
* @param collectionAddress - NFT collection contract address
|
|
4006
|
+
* @param to - Recipient address
|
|
4007
|
+
* @param tokenId - Token ID to transfer
|
|
4008
|
+
* @returns Transaction hash
|
|
4009
|
+
*/
|
|
4010
|
+
async safeTransferNFT(collectionAddress, to, tokenId) {
|
|
4011
|
+
return await safeTransferNFT(this, collectionAddress, to, tokenId);
|
|
4012
|
+
}
|
|
4013
|
+
/**
|
|
4014
|
+
* Approve an address to transfer a specific NFT
|
|
4015
|
+
* @param collectionAddress - NFT collection contract address
|
|
4016
|
+
* @param approved - Address to approve
|
|
4017
|
+
* @param tokenId - Token ID to approve
|
|
4018
|
+
* @returns Transaction hash
|
|
4019
|
+
*/
|
|
4020
|
+
async approveNFT(collectionAddress, approved, tokenId) {
|
|
4021
|
+
return await approveNFT(this, collectionAddress, approved, tokenId);
|
|
4022
|
+
}
|
|
4023
|
+
/**
|
|
4024
|
+
* Set approval for all NFTs in a collection
|
|
4025
|
+
* @param collectionAddress - NFT collection contract address
|
|
4026
|
+
* @param operator - Operator address
|
|
4027
|
+
* @param approved - Whether to approve or revoke
|
|
4028
|
+
* @returns Transaction hash
|
|
4029
|
+
*/
|
|
4030
|
+
async setApprovalForAllNFT(collectionAddress, operator, approved) {
|
|
4031
|
+
return await setApprovalForAllNFT(this, collectionAddress, operator, approved);
|
|
4032
|
+
}
|
|
2566
4033
|
};
|
|
2567
4034
|
|
|
2568
4035
|
exports.AgniConstants = agni_exports;
|
|
@@ -2571,22 +4038,38 @@ exports.METH_TOKEN = METH_TOKEN;
|
|
|
2571
4038
|
exports.MNTAgentKit = MNTAgentKit;
|
|
2572
4039
|
exports.MerchantMoeConstants = merchantmoe_exports;
|
|
2573
4040
|
exports.MethConstants = meth_exports;
|
|
4041
|
+
exports.NFTLaunchpadConstants = nft_launchpad_exports;
|
|
2574
4042
|
exports.OKXConstants = okx_exports;
|
|
2575
4043
|
exports.OneInchConstants = oneinch_exports;
|
|
2576
4044
|
exports.OpenOceanConstants = openocean_exports;
|
|
2577
4045
|
exports.PikePerpsConstants = pikeperps_exports;
|
|
4046
|
+
exports.PythConstants = pyth_exports;
|
|
2578
4047
|
exports.SquidConstants = squid_exports;
|
|
4048
|
+
exports.TokenLaunchpadConstants = token_launchpad_exports;
|
|
2579
4049
|
exports.UniswapConstants = uniswap_exports;
|
|
2580
4050
|
exports.agniSwap = agniSwap;
|
|
4051
|
+
exports.approveNFT = approveNFT;
|
|
2581
4052
|
exports.approveToken = approveToken;
|
|
4053
|
+
exports.batchMintNFT = batchMintNFT;
|
|
2582
4054
|
exports.crossChainSwapViaSquid = crossChainSwapViaSquid;
|
|
4055
|
+
exports.deployNFTCollection = deployNFTCollection;
|
|
4056
|
+
exports.deployNFTCollectionWithPreset = deployNFTCollectionWithPreset;
|
|
4057
|
+
exports.deployRWAToken = deployRWAToken;
|
|
4058
|
+
exports.deployStandardToken = deployStandardToken;
|
|
4059
|
+
exports.deployToken = deployToken;
|
|
2583
4060
|
exports.executeSwap = executeSwap;
|
|
2584
4061
|
exports.get1inchQuote = get1inchQuote;
|
|
4062
|
+
exports.getNFTBalance = getNFTBalance;
|
|
4063
|
+
exports.getNFTCollectionInfo = getNFTCollectionInfo;
|
|
4064
|
+
exports.getNFTTokenInfo = getNFTTokenInfo;
|
|
2585
4065
|
exports.getOpenOceanQuote = getOpenOceanQuote;
|
|
2586
4066
|
exports.getProjectConfig = getProjectConfig;
|
|
2587
4067
|
exports.getSquidRoute = getSquidRoute;
|
|
4068
|
+
exports.getTokenBalance = getTokenBalance;
|
|
4069
|
+
exports.getTokenInfo = getTokenInfo;
|
|
2588
4070
|
exports.getUniswapQuote = getUniswapQuote;
|
|
2589
4071
|
exports.initializePlatform = initializePlatform;
|
|
4072
|
+
exports.isNFTOwner = isNFTOwner;
|
|
2590
4073
|
exports.lendleBorrow = lendleBorrow;
|
|
2591
4074
|
exports.lendleGetPositions = lendleGetPositions;
|
|
2592
4075
|
exports.lendleRepay = lendleRepay;
|
|
@@ -2594,16 +4077,26 @@ exports.lendleSupply = lendleSupply;
|
|
|
2594
4077
|
exports.lendleWithdraw = lendleWithdraw;
|
|
2595
4078
|
exports.merchantMoeSwap = merchantMoeSwap;
|
|
2596
4079
|
exports.methGetPosition = methGetPosition;
|
|
4080
|
+
exports.mintNFT = mintNFT;
|
|
2597
4081
|
exports.pikeperpsClosePosition = pikeperpsClosePosition;
|
|
2598
4082
|
exports.pikeperpsGetMarketData = pikeperpsGetMarketData;
|
|
2599
4083
|
exports.pikeperpsGetPositions = pikeperpsGetPositions;
|
|
2600
4084
|
exports.pikeperpsOpenLong = pikeperpsOpenLong;
|
|
2601
4085
|
exports.pikeperpsOpenShort = pikeperpsOpenShort;
|
|
4086
|
+
exports.pythGetEmaPrice = pythGetEmaPrice;
|
|
4087
|
+
exports.pythGetMultiplePrices = pythGetMultiplePrices;
|
|
4088
|
+
exports.pythGetPrice = pythGetPrice;
|
|
4089
|
+
exports.pythGetSupportedPriceFeeds = pythGetSupportedPriceFeeds;
|
|
4090
|
+
exports.pythPriceFeedExists = pythPriceFeedExists;
|
|
4091
|
+
exports.safeTransferNFT = safeTransferNFT;
|
|
2602
4092
|
exports.sendTransaction = sendTransaction;
|
|
4093
|
+
exports.setApprovalForAllNFT = setApprovalForAllNFT;
|
|
2603
4094
|
exports.swapFromMeth = swapFromMeth;
|
|
2604
4095
|
exports.swapOn1inch = swapOn1inch;
|
|
2605
4096
|
exports.swapOnOpenOcean = swapOnOpenOcean;
|
|
2606
4097
|
exports.swapOnUniswap = swapOnUniswap;
|
|
2607
4098
|
exports.swapToMeth = swapToMeth;
|
|
4099
|
+
exports.transferNFT = transferNFT;
|
|
4100
|
+
exports.transferToken = transferToken;
|
|
2608
4101
|
//# sourceMappingURL=index.cjs.map
|
|
2609
4102
|
//# sourceMappingURL=index.cjs.map
|