mantle-agent-kit-sdk 1.0.3 → 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 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: encodeFunctionData8 } = await import('viem');
476
- const approveData = encodeFunctionData8({
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)]
@@ -502,6 +502,9 @@ async function swapOnOpenOcean(agent, fromToken, toToken, amount, slippage = "1"
502
502
  if (agent.demo) {
503
503
  return createMockOpenOceanSwapResponse(amount);
504
504
  }
505
+ if (!agent.demo && agent.chain != "mainnet") {
506
+ throw new Error("Openocean swaps happen only on mainnet");
507
+ }
505
508
  const walletAddress = agent.account.address;
506
509
  if (fromToken.toLowerCase() !== NATIVE_TOKEN_ADDRESS.toLowerCase()) {
507
510
  await approveToken2(agent, fromToken, OPENOCEAN_EXCHANGE_PROXY, amount);
@@ -951,8 +954,10 @@ __export(lendle_exports, {
951
954
  LENDING_POOL: () => LENDING_POOL,
952
955
  LENDING_POOL_ABI: () => LENDING_POOL_ABI,
953
956
  LENDING_POOL_ADDRESSES_PROVIDER: () => LENDING_POOL_ADDRESSES_PROVIDER,
957
+ LENDLE_SUPPORTED_ASSETS: () => LENDLE_SUPPORTED_ASSETS,
954
958
  ORACLE: () => ORACLE,
955
959
  PROTOCOL_DATA_PROVIDER: () => PROTOCOL_DATA_PROVIDER,
960
+ PROTOCOL_DATA_PROVIDER_ABI: () => PROTOCOL_DATA_PROVIDER_ABI,
956
961
  WMNT_ADDRESS: () => WMNT_ADDRESS2
957
962
  });
958
963
  var LENDING_POOL = {
@@ -1067,6 +1072,65 @@ var LENDING_POOL_ABI = [
1067
1072
  type: "function"
1068
1073
  }
1069
1074
  ];
1075
+ var PROTOCOL_DATA_PROVIDER_ABI = [
1076
+ {
1077
+ inputs: [],
1078
+ name: "getAllReservesTokens",
1079
+ outputs: [
1080
+ {
1081
+ components: [
1082
+ { name: "symbol", type: "string" },
1083
+ { name: "tokenAddress", type: "address" }
1084
+ ],
1085
+ name: "",
1086
+ type: "tuple[]"
1087
+ }
1088
+ ],
1089
+ stateMutability: "view",
1090
+ type: "function"
1091
+ },
1092
+ {
1093
+ inputs: [
1094
+ { name: "asset", type: "address" },
1095
+ { name: "user", type: "address" }
1096
+ ],
1097
+ name: "getUserReserveData",
1098
+ outputs: [
1099
+ { name: "currentATokenBalance", type: "uint256" },
1100
+ { name: "currentStableDebt", type: "uint256" },
1101
+ { name: "currentVariableDebt", type: "uint256" },
1102
+ { name: "principalStableDebt", type: "uint256" },
1103
+ { name: "scaledVariableDebt", type: "uint256" },
1104
+ { name: "stableBorrowRate", type: "uint256" },
1105
+ { name: "liquidityRate", type: "uint256" },
1106
+ { name: "stableRateLastUpdated", type: "uint40" },
1107
+ { name: "usageAsCollateralEnabled", type: "bool" }
1108
+ ],
1109
+ stateMutability: "view",
1110
+ type: "function"
1111
+ },
1112
+ {
1113
+ inputs: [{ name: "asset", type: "address" }],
1114
+ name: "getReserveTokensAddresses",
1115
+ outputs: [
1116
+ { name: "aTokenAddress", type: "address" },
1117
+ { name: "stableDebtTokenAddress", type: "address" },
1118
+ { name: "variableDebtTokenAddress", type: "address" }
1119
+ ],
1120
+ stateMutability: "view",
1121
+ type: "function"
1122
+ }
1123
+ ];
1124
+ var LENDLE_SUPPORTED_ASSETS = {
1125
+ mainnet: [
1126
+ { symbol: "WMNT", address: "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8" },
1127
+ { symbol: "WETH", address: "0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111" },
1128
+ { symbol: "USDC", address: "0x09Bc4E0D10C81b3a3766c49F0f98a8aaa7adA8D2" },
1129
+ { symbol: "USDT", address: "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE" },
1130
+ { symbol: "mETH", address: "0xcDA86A272531e8640cD7F1a92c01839911B90bb0" }
1131
+ ],
1132
+ testnet: []
1133
+ };
1070
1134
 
1071
1135
  // src/tools/lendle/supply.ts
1072
1136
  async function lendleSupply(agent, tokenAddress, amount) {
@@ -1172,6 +1236,67 @@ async function lendleRepay(agent, tokenAddress, amount, rateMode = INTEREST_RATE
1172
1236
  await agent.client.waitForTransactionReceipt({ hash });
1173
1237
  return hash;
1174
1238
  }
1239
+ async function lendleGetPositions(agent, userAddress) {
1240
+ const dataProviderAddress = PROTOCOL_DATA_PROVIDER[agent.chain];
1241
+ const address = userAddress || agent.account.address;
1242
+ if (dataProviderAddress === "0x0000000000000000000000000000000000000000") {
1243
+ throw new Error(
1244
+ `Lendle ProtocolDataProvider not configured for ${agent.chain}. Only available on mainnet.`
1245
+ );
1246
+ }
1247
+ const supportedAssets = LENDLE_SUPPORTED_ASSETS[agent.chain];
1248
+ if (!supportedAssets || supportedAssets.length === 0) {
1249
+ throw new Error(`No supported assets configured for ${agent.chain}`);
1250
+ }
1251
+ const positions = [];
1252
+ let totalSupplied = 0n;
1253
+ let totalDebt = 0n;
1254
+ for (const asset of supportedAssets) {
1255
+ try {
1256
+ const assetAddress = viem.getAddress(asset.address);
1257
+ const result = await agent.client.readContract({
1258
+ address: dataProviderAddress,
1259
+ abi: PROTOCOL_DATA_PROVIDER_ABI,
1260
+ functionName: "getUserReserveData",
1261
+ args: [assetAddress, address]
1262
+ });
1263
+ const [
1264
+ currentATokenBalance,
1265
+ currentStableDebt,
1266
+ currentVariableDebt,
1267
+ _principalStableDebt,
1268
+ _scaledVariableDebt,
1269
+ stableBorrowRate,
1270
+ liquidityRate,
1271
+ _stableRateLastUpdated,
1272
+ usageAsCollateralEnabled
1273
+ ] = result;
1274
+ if (currentATokenBalance > 0n || currentStableDebt > 0n || currentVariableDebt > 0n) {
1275
+ const assetTotalDebt = currentStableDebt + currentVariableDebt;
1276
+ positions.push({
1277
+ asset: assetAddress,
1278
+ symbol: asset.symbol,
1279
+ supplied: currentATokenBalance,
1280
+ stableDebt: currentStableDebt,
1281
+ variableDebt: currentVariableDebt,
1282
+ totalDebt: assetTotalDebt,
1283
+ liquidityRate,
1284
+ stableBorrowRate,
1285
+ usageAsCollateralEnabled
1286
+ });
1287
+ totalSupplied += currentATokenBalance;
1288
+ totalDebt += assetTotalDebt;
1289
+ }
1290
+ } catch (error) {
1291
+ console.warn(`Failed to get position for ${asset.symbol}:`, error);
1292
+ }
1293
+ }
1294
+ return {
1295
+ positions,
1296
+ totalSupplied,
1297
+ totalDebt
1298
+ };
1299
+ }
1175
1300
 
1176
1301
  // src/constants/agni/index.ts
1177
1302
  var agni_exports = {};
@@ -1334,196 +1459,2197 @@ async function merchantMoeSwap(agent, tokenIn, tokenOut, amountIn, slippagePerce
1334
1459
  // src/constants/meth/index.ts
1335
1460
  var meth_exports = {};
1336
1461
  __export(meth_exports, {
1337
- METH_TOKEN: () => METH_TOKEN
1462
+ METH_ABI: () => METH_ABI,
1463
+ METH_TOKEN: () => METH_TOKEN,
1464
+ NATIVE_MNT_ADDRESS: () => NATIVE_MNT_ADDRESS,
1465
+ WETH_TOKEN: () => WETH_TOKEN,
1466
+ WMNT_TOKEN: () => WMNT_TOKEN
1338
1467
  });
1339
1468
  var METH_TOKEN = {
1340
1469
  mainnet: "0xcDA86A272531e8640cD7F1a92c01839911B90bb0",
1341
1470
  testnet: "0x0000000000000000000000000000000000000000"
1342
1471
  };
1343
-
1344
- // src/tools/okx/getSwapQuote.ts
1345
- var getSwapQuote = async (agent, from, to, amount, slippagePercentage) => {
1346
- if (agent.demo) {
1347
- return createMockQuoteResponse("OKX", amount);
1348
- }
1349
- const chainIndex = agent.chain === "mainnet" ? "5000" : "5003";
1350
- return getSwapTransaction(from, to, amount, chainIndex, slippagePercentage);
1472
+ var WETH_TOKEN = {
1473
+ mainnet: "0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111",
1474
+ testnet: "0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111"
1351
1475
  };
1352
-
1353
- // src/utils/x402/index.ts
1354
- var DEFAULT_PLATFORM_URL = "https://mantle-devkit.vercel.app";
1355
- var cachedConfig = null;
1356
- var validationPromise = null;
1357
- function getPlatformBaseUrl() {
1358
- if (typeof process !== "undefined" && process.env) {
1359
- return process.env.PLATFORM_URL || process.env.NEXT_PUBLIC_PLATFORM_URL || DEFAULT_PLATFORM_URL;
1476
+ var WMNT_TOKEN = {
1477
+ mainnet: "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8",
1478
+ testnet: "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8"
1479
+ };
1480
+ var NATIVE_MNT_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
1481
+ var METH_ABI = [
1482
+ {
1483
+ inputs: [{ name: "account", type: "address" }],
1484
+ name: "balanceOf",
1485
+ outputs: [{ name: "", type: "uint256" }],
1486
+ stateMutability: "view",
1487
+ type: "function"
1488
+ },
1489
+ {
1490
+ inputs: [],
1491
+ name: "totalSupply",
1492
+ outputs: [{ name: "", type: "uint256" }],
1493
+ stateMutability: "view",
1494
+ type: "function"
1495
+ },
1496
+ {
1497
+ inputs: [],
1498
+ name: "decimals",
1499
+ outputs: [{ name: "", type: "uint8" }],
1500
+ stateMutability: "view",
1501
+ type: "function"
1502
+ },
1503
+ {
1504
+ inputs: [],
1505
+ name: "symbol",
1506
+ outputs: [{ name: "", type: "string" }],
1507
+ stateMutability: "view",
1508
+ type: "function"
1509
+ },
1510
+ {
1511
+ inputs: [
1512
+ { name: "spender", type: "address" },
1513
+ { name: "amount", type: "uint256" }
1514
+ ],
1515
+ name: "approve",
1516
+ outputs: [{ name: "", type: "bool" }],
1517
+ stateMutability: "nonpayable",
1518
+ type: "function"
1519
+ },
1520
+ {
1521
+ inputs: [
1522
+ { name: "owner", type: "address" },
1523
+ { name: "spender", type: "address" }
1524
+ ],
1525
+ name: "allowance",
1526
+ outputs: [{ name: "", type: "uint256" }],
1527
+ stateMutability: "view",
1528
+ type: "function"
1360
1529
  }
1361
- return DEFAULT_PLATFORM_URL;
1362
- }
1363
- async function validateAppId(appId) {
1364
- const baseUrl2 = getPlatformBaseUrl();
1365
- const url = `${baseUrl2}/api/v1/validate?appId=${encodeURIComponent(appId)}`;
1366
- const response = await fetch(url, {
1367
- method: "GET",
1368
- headers: { "Content-Type": "application/json" }
1369
- });
1370
- if (!response.ok) {
1371
- if (response.status === 404) {
1372
- throw new Error(
1373
- "Platform: Project not found. Invalid APP_ID. Please check your APP_ID configuration."
1374
- );
1375
- }
1376
- if (response.status === 401) {
1377
- throw new Error(
1378
- "Platform: Unauthorized. Invalid APP_ID. Please verify your APP_ID."
1379
- );
1380
- }
1530
+ ];
1531
+ async function methGetPosition(agent, userAddress) {
1532
+ const methTokenAddress = METH_TOKEN[agent.chain];
1533
+ const wethTokenAddress = WETH_TOKEN[agent.chain];
1534
+ const wmntTokenAddress = WMNT_TOKEN[agent.chain];
1535
+ const address = userAddress || agent.account.address;
1536
+ if (methTokenAddress === "0x0000000000000000000000000000000000000000") {
1381
1537
  throw new Error(
1382
- `Platform: Validation failed: ${response.status} ${response.statusText}`
1538
+ `mETH not available on ${agent.chain}. Only available on mainnet.`
1383
1539
  );
1384
1540
  }
1385
- const data = await response.json();
1386
- if (!data.appId || !data.payTo || !data.network) {
1387
- throw new Error("Platform: Invalid response - missing required fields");
1541
+ const methBalance = await agent.client.readContract({
1542
+ address: methTokenAddress,
1543
+ abi: METH_ABI,
1544
+ functionName: "balanceOf",
1545
+ args: [address]
1546
+ });
1547
+ let wethBalance = 0n;
1548
+ try {
1549
+ wethBalance = await agent.client.readContract({
1550
+ address: wethTokenAddress,
1551
+ abi: METH_ABI,
1552
+ // Same ERC20 ABI works for WETH
1553
+ functionName: "balanceOf",
1554
+ args: [address]
1555
+ });
1556
+ } catch {
1388
1557
  }
1389
- if (data.status !== "ACTIVE") {
1390
- throw new Error(
1391
- `Platform: Project is not active. Current status: ${data.status}`
1392
- );
1558
+ let wmntBalance = 0n;
1559
+ try {
1560
+ wmntBalance = await agent.client.readContract({
1561
+ address: wmntTokenAddress,
1562
+ abi: METH_ABI,
1563
+ // Same ERC20 ABI works for WMNT
1564
+ functionName: "balanceOf",
1565
+ args: [address]
1566
+ });
1567
+ } catch {
1393
1568
  }
1394
1569
  return {
1395
- appId: data.appId,
1396
- name: data.name,
1397
- payTo: data.payTo,
1398
- network: data.network,
1399
- status: data.status
1570
+ methBalance,
1571
+ wethBalance,
1572
+ wmntBalance,
1573
+ methTokenAddress,
1574
+ wethTokenAddress,
1575
+ wmntTokenAddress
1400
1576
  };
1401
1577
  }
1402
- async function initializePlatform() {
1403
- if (cachedConfig) {
1404
- return cachedConfig;
1405
- }
1406
- if (validationPromise) {
1407
- return validationPromise;
1408
- }
1409
- let appId;
1410
- if (typeof process !== "undefined" && process.env) {
1411
- appId = process.env.APP_ID || process.env.NEXT_PUBLIC_APP_ID;
1412
- }
1413
- if (!appId || typeof appId !== "string" || appId.trim().length === 0) {
1578
+ async function swapToMeth(agent, amount, slippage = 0.5) {
1579
+ const methTokenAddress = METH_TOKEN[agent.chain];
1580
+ const wethTokenAddress = WETH_TOKEN[agent.chain];
1581
+ if (methTokenAddress === "0x0000000000000000000000000000000000000000") {
1414
1582
  throw new Error(
1415
- "APP_ID is required. Set it in your .env file:\nAPP_ID=your_app_id_here"
1583
+ `mETH not available on ${agent.chain}. Only available on mainnet.`
1416
1584
  );
1417
1585
  }
1418
- validationPromise = validateAppId(appId.trim());
1419
- try {
1420
- cachedConfig = await validationPromise;
1421
- return cachedConfig;
1422
- } catch (error) {
1423
- validationPromise = null;
1424
- throw error;
1425
- }
1586
+ const result = await swapOnOpenOcean(
1587
+ agent,
1588
+ wethTokenAddress,
1589
+ methTokenAddress,
1590
+ amount,
1591
+ slippage.toString()
1592
+ );
1593
+ return result.txHash;
1426
1594
  }
1427
- function getProjectConfig() {
1428
- if (!cachedConfig) {
1595
+ async function swapFromMeth(agent, amount, slippage = 0.5) {
1596
+ const methTokenAddress = METH_TOKEN[agent.chain];
1597
+ const wethTokenAddress = WETH_TOKEN[agent.chain];
1598
+ if (methTokenAddress === "0x0000000000000000000000000000000000000000") {
1429
1599
  throw new Error(
1430
- "Platform not initialized. Call initializePlatform() first."
1600
+ `mETH not available on ${agent.chain}. Only available on mainnet.`
1431
1601
  );
1432
1602
  }
1433
- return cachedConfig;
1603
+ const result = await swapOnOpenOcean(
1604
+ agent,
1605
+ methTokenAddress,
1606
+ wethTokenAddress,
1607
+ amount,
1608
+ slippage.toString()
1609
+ );
1610
+ return result.txHash;
1434
1611
  }
1435
- var MNTAgentKit = class {
1436
- account;
1437
- client;
1438
- chain;
1439
- demo;
1440
- projectConfig;
1441
- constructor(privateKey, chain) {
1442
- this.account = accounts.privateKeyToAccount(privateKey);
1443
- this.demo = chain === "testnet-demo";
1444
- this.chain = chain === "testnet-demo" ? "testnet" : chain;
1445
- this.client = viem.createWalletClient({
1446
- chain: this.chain == "mainnet" ? chains.mantle : chains.mantleSepoliaTestnet,
1447
- transport: viem.http(),
1448
- account: this.account
1449
- }).extend(viem.publicActions).extend(experimental.erc7811Actions());
1450
- }
1451
- /**
1452
- * Initialize the agent with platform validation
1453
- *
1454
- * Validates APP_ID with the platform API.
1455
- * Must be called after creating the agent instance.
1456
- *
1457
- * @returns The initialized agent instance
1458
- * @throws Error if APP_ID is not set or validation fails
1459
- *
1460
- * @example
1461
- * ```typescript
1462
- * const agent = new MNTAgentKit(privateKey, "mainnet");
1463
- * await agent.initialize(); // Validates APP_ID
1464
- * ```
1465
- */
1466
- async initialize() {
1467
- this.projectConfig = await initializePlatform();
1468
- return this;
1469
- }
1470
- async sendTransaction(to, amount) {
1471
- return await sendTransaction(this, to, amount);
1472
- }
1473
- // OKX DEX Aggregator
1474
- async getSwapQuote(fromTokenAddress, toTokenAddress, amount, slippagePercentage = "0.5") {
1475
- return await getSwapQuote(
1476
- this,
1477
- fromTokenAddress,
1478
- toTokenAddress,
1479
- amount,
1480
- slippagePercentage
1481
- );
1482
- }
1483
- async executeSwap(fromTokenAddress, toTokenAddress, amount, slippagePercentage = "0.5") {
1484
- return await executeSwap(
1485
- this,
1486
- fromTokenAddress,
1487
- toTokenAddress,
1488
- amount,
1489
- slippagePercentage
1490
- );
1491
- }
1492
- // OpenOcean DEX Aggregator
1493
- async getOpenOceanQuote(fromToken, toToken, amount) {
1494
- return await getOpenOceanQuote(this, fromToken, toToken, amount);
1495
- }
1496
- async swapOnOpenOcean(fromToken, toToken, amount, slippage = 0.5) {
1497
- return await swapOnOpenOcean(
1498
- this,
1499
- fromToken,
1500
- toToken,
1501
- amount,
1502
- slippage.toString()
1503
- );
1504
- }
1505
- // 1inch DEX Aggregator
1506
- async get1inchQuote(fromToken, toToken, amount) {
1507
- return await get1inchQuote(this, fromToken, toToken, amount);
1508
- }
1509
- async swapOn1inch(fromToken, toToken, amount, slippage = 0.5) {
1510
- return await swapOn1inch(
1511
- this,
1512
- fromToken,
1513
- toToken,
1514
- amount,
1515
- slippage.toString()
1516
- );
1517
- }
1518
- // Uniswap V3 DEX
1519
- async getUniswapQuote(fromToken, toToken, amount) {
1520
- return await getUniswapQuote(this, fromToken, toToken, amount);
1521
- }
1522
- async swapOnUniswap(fromToken, toToken, amount, slippage = 0.5) {
1523
- return await swapOnUniswap(
1524
- this,
1525
- fromToken,
1526
- toToken,
1612
+
1613
+ // src/constants/pikeperps/index.ts
1614
+ var pikeperps_exports = {};
1615
+ __export(pikeperps_exports, {
1616
+ BONDING_CURVE_MARKET: () => BONDING_CURVE_MARKET,
1617
+ BONDING_CURVE_MARKET_ABI: () => BONDING_CURVE_MARKET_ABI,
1618
+ PERPETUAL_TRADING: () => PERPETUAL_TRADING,
1619
+ PERPETUAL_TRADING_ABI: () => PERPETUAL_TRADING_ABI,
1620
+ PIKE_PERPS_CONFIG: () => PIKE_PERPS_CONFIG
1621
+ });
1622
+ var PERPETUAL_TRADING = {
1623
+ mainnet: "0x0000000000000000000000000000000000000000",
1624
+ // Not deployed yet
1625
+ testnet: "0x8081b646f349c049f2d5e8a400057d411dd657bd"
1626
+ };
1627
+ var BONDING_CURVE_MARKET = {
1628
+ mainnet: "0x0000000000000000000000000000000000000000",
1629
+ testnet: "0x93b268325A9862645c82b32229f3B52264750Ca2"
1630
+ };
1631
+ var PIKE_PERPS_CONFIG = {
1632
+ MAX_LEVERAGE: 100,
1633
+ DEFAULT_LEVERAGE: 10,
1634
+ MIN_LEVERAGE: 1,
1635
+ TRADING_FEE_BPS: 5,
1636
+ // 0.05%
1637
+ LIQUIDATION_REWARD_BPS: 500,
1638
+ // 5%
1639
+ PRICE_DECIMALS: 8
1640
+ // Prices are scaled by 1e8
1641
+ };
1642
+ var PERPETUAL_TRADING_ABI = [
1643
+ {
1644
+ inputs: [
1645
+ { internalType: "address", name: "_pyth", type: "address" }
1646
+ ],
1647
+ stateMutability: "nonpayable",
1648
+ type: "constructor"
1649
+ },
1650
+ {
1651
+ anonymous: false,
1652
+ inputs: [
1653
+ { indexed: true, internalType: "uint256", name: "positionId", type: "uint256" },
1654
+ { indexed: true, internalType: "address", name: "user", type: "address" },
1655
+ { indexed: false, internalType: "uint256", name: "pnl", type: "uint256" },
1656
+ { indexed: false, internalType: "uint256", name: "exitPrice", type: "uint256" }
1657
+ ],
1658
+ name: "PositionClosed",
1659
+ type: "event"
1660
+ },
1661
+ {
1662
+ anonymous: false,
1663
+ inputs: [
1664
+ { indexed: true, internalType: "uint256", name: "positionId", type: "uint256" },
1665
+ { indexed: true, internalType: "address", name: "user", type: "address" },
1666
+ { indexed: false, internalType: "uint256", name: "liquidationPrice", type: "uint256" }
1667
+ ],
1668
+ name: "PositionLiquidated",
1669
+ type: "event"
1670
+ },
1671
+ {
1672
+ anonymous: false,
1673
+ inputs: [
1674
+ { indexed: true, internalType: "uint256", name: "positionId", type: "uint256" },
1675
+ { indexed: true, internalType: "address", name: "user", type: "address" },
1676
+ { indexed: true, internalType: "address", name: "token", type: "address" },
1677
+ { indexed: false, internalType: "bool", name: "isLong", type: "bool" },
1678
+ { indexed: false, internalType: "uint256", name: "size", type: "uint256" },
1679
+ { indexed: false, internalType: "uint256", name: "margin", type: "uint256" },
1680
+ { indexed: false, internalType: "uint256", name: "leverage", type: "uint256" },
1681
+ { indexed: false, internalType: "uint256", name: "entryPrice", type: "uint256" }
1682
+ ],
1683
+ name: "PositionOpened",
1684
+ type: "event"
1685
+ },
1686
+ {
1687
+ inputs: [{ internalType: "uint256", name: "_positionId", type: "uint256" }],
1688
+ name: "closePosition",
1689
+ outputs: [],
1690
+ stateMutability: "nonpayable",
1691
+ type: "function"
1692
+ },
1693
+ {
1694
+ inputs: [{ internalType: "address", name: "_token", type: "address" }],
1695
+ name: "getCurrentPrice",
1696
+ outputs: [
1697
+ { internalType: "uint256", name: "currentPrice", type: "uint256" },
1698
+ { internalType: "bool", name: "hasPrice", type: "bool" }
1699
+ ],
1700
+ stateMutability: "view",
1701
+ type: "function"
1702
+ },
1703
+ {
1704
+ inputs: [{ internalType: "uint256", name: "_positionId", type: "uint256" }],
1705
+ name: "getLiquidationPrice",
1706
+ outputs: [{ internalType: "uint256", name: "liquidationPrice", type: "uint256" }],
1707
+ stateMutability: "view",
1708
+ type: "function"
1709
+ },
1710
+ {
1711
+ inputs: [{ internalType: "uint256", name: "_positionId", type: "uint256" }],
1712
+ name: "getPosition",
1713
+ outputs: [
1714
+ {
1715
+ components: [
1716
+ { internalType: "address", name: "user", type: "address" },
1717
+ { internalType: "address", name: "token", type: "address" },
1718
+ { internalType: "bool", name: "isLong", type: "bool" },
1719
+ { internalType: "uint256", name: "size", type: "uint256" },
1720
+ { internalType: "uint256", name: "margin", type: "uint256" },
1721
+ { internalType: "uint256", name: "leverage", type: "uint256" },
1722
+ { internalType: "uint256", name: "entryPrice", type: "uint256" },
1723
+ { internalType: "uint256", name: "entryTime", type: "uint256" },
1724
+ { internalType: "uint256", name: "lastFundingTime", type: "uint256" },
1725
+ { internalType: "bool", name: "isOpen", type: "bool" }
1726
+ ],
1727
+ internalType: "struct PerpetualTrading.Position",
1728
+ name: "",
1729
+ type: "tuple"
1730
+ }
1731
+ ],
1732
+ stateMutability: "view",
1733
+ type: "function"
1734
+ },
1735
+ {
1736
+ inputs: [{ internalType: "uint256", name: "_positionId", type: "uint256" }],
1737
+ name: "getPositionPnL",
1738
+ outputs: [
1739
+ { internalType: "uint256", name: "pnl", type: "uint256" },
1740
+ { internalType: "bool", name: "isProfit", type: "bool" }
1741
+ ],
1742
+ stateMutability: "view",
1743
+ type: "function"
1744
+ },
1745
+ {
1746
+ inputs: [{ internalType: "address", name: "_user", type: "address" }],
1747
+ name: "getUserPositions",
1748
+ outputs: [{ internalType: "uint256[]", name: "", type: "uint256[]" }],
1749
+ stateMutability: "view",
1750
+ type: "function"
1751
+ },
1752
+ {
1753
+ inputs: [{ internalType: "uint256", name: "_positionId", type: "uint256" }],
1754
+ name: "liquidatePosition",
1755
+ outputs: [],
1756
+ stateMutability: "nonpayable",
1757
+ type: "function"
1758
+ },
1759
+ {
1760
+ inputs: [],
1761
+ name: "maxLeverage",
1762
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1763
+ stateMutability: "view",
1764
+ type: "function"
1765
+ },
1766
+ {
1767
+ inputs: [],
1768
+ name: "minMarginBps",
1769
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1770
+ stateMutability: "view",
1771
+ type: "function"
1772
+ },
1773
+ {
1774
+ inputs: [],
1775
+ name: "nextPositionId",
1776
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1777
+ stateMutability: "view",
1778
+ type: "function"
1779
+ },
1780
+ {
1781
+ inputs: [
1782
+ { internalType: "address", name: "_token", type: "address" },
1783
+ { internalType: "bool", name: "_isLong", type: "bool" },
1784
+ { internalType: "uint256", name: "_margin", type: "uint256" },
1785
+ { internalType: "uint256", name: "_leverage", type: "uint256" }
1786
+ ],
1787
+ name: "openPosition",
1788
+ outputs: [{ internalType: "uint256", name: "positionId", type: "uint256" }],
1789
+ stateMutability: "payable",
1790
+ type: "function"
1791
+ },
1792
+ {
1793
+ inputs: [{ internalType: "uint256", name: "_positionId", type: "uint256" }],
1794
+ name: "shouldLiquidate",
1795
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
1796
+ stateMutability: "view",
1797
+ type: "function"
1798
+ },
1799
+ {
1800
+ inputs: [],
1801
+ name: "tradingFeeBps",
1802
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1803
+ stateMutability: "view",
1804
+ type: "function"
1805
+ }
1806
+ ];
1807
+ var BONDING_CURVE_MARKET_ABI = [
1808
+ {
1809
+ inputs: [{ internalType: "address", name: "_token", type: "address" }],
1810
+ name: "getCurrentPrice",
1811
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1812
+ stateMutability: "view",
1813
+ type: "function"
1814
+ },
1815
+ {
1816
+ inputs: [{ internalType: "address", name: "_token", type: "address" }],
1817
+ name: "isListed",
1818
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
1819
+ stateMutability: "view",
1820
+ type: "function"
1821
+ },
1822
+ {
1823
+ inputs: [{ internalType: "address", name: "_token", type: "address" }],
1824
+ name: "getCurveProgress",
1825
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1826
+ stateMutability: "view",
1827
+ type: "function"
1828
+ }
1829
+ ];
1830
+
1831
+ // src/tools/pikeperps/openLong.ts
1832
+ async function pikeperpsOpenLong(agent, tokenAddress, margin, leverage = PIKE_PERPS_CONFIG.DEFAULT_LEVERAGE) {
1833
+ const perpetualTradingAddress = PERPETUAL_TRADING[agent.chain];
1834
+ if (perpetualTradingAddress === "0x0000000000000000000000000000000000000000") {
1835
+ throw new Error(
1836
+ `PikePerps not available on ${agent.chain}. Only available on testnet.`
1837
+ );
1838
+ }
1839
+ if (leverage < PIKE_PERPS_CONFIG.MIN_LEVERAGE || leverage > PIKE_PERPS_CONFIG.MAX_LEVERAGE) {
1840
+ throw new Error(
1841
+ `Leverage must be between ${PIKE_PERPS_CONFIG.MIN_LEVERAGE} and ${PIKE_PERPS_CONFIG.MAX_LEVERAGE}`
1842
+ );
1843
+ }
1844
+ if (agent.demo) {
1845
+ return {
1846
+ positionId: BigInt(Math.floor(Math.random() * 1e3)),
1847
+ txHash: "0xdemo_open_long_tx_hash"
1848
+ };
1849
+ }
1850
+ const marginBigInt = BigInt(margin);
1851
+ const data = viem.encodeFunctionData({
1852
+ abi: PERPETUAL_TRADING_ABI,
1853
+ functionName: "openPosition",
1854
+ args: [tokenAddress, true, marginBigInt, BigInt(leverage)]
1855
+ });
1856
+ const txHash = await agent.client.sendTransaction({
1857
+ to: perpetualTradingAddress,
1858
+ data,
1859
+ value: marginBigInt
1860
+ });
1861
+ const receipt = await agent.client.waitForTransactionReceipt({ hash: txHash });
1862
+ let positionId = 0n;
1863
+ for (const log of receipt.logs) {
1864
+ try {
1865
+ if (log.topics[0] === "0x2e5b0e8c5f5d55d89e89f5b5d5e5f5d55d89e89f5b5d5e5f5d55d89e89f5b5d5") {
1866
+ positionId = BigInt(log.topics[1] || "0");
1867
+ break;
1868
+ }
1869
+ } catch {
1870
+ }
1871
+ }
1872
+ if (positionId === 0n) {
1873
+ try {
1874
+ const nextId = await agent.client.readContract({
1875
+ address: perpetualTradingAddress,
1876
+ abi: PERPETUAL_TRADING_ABI,
1877
+ functionName: "nextPositionId"
1878
+ });
1879
+ positionId = nextId - 1n;
1880
+ } catch {
1881
+ }
1882
+ }
1883
+ return {
1884
+ positionId,
1885
+ txHash
1886
+ };
1887
+ }
1888
+ async function pikeperpsOpenShort(agent, tokenAddress, margin, leverage = PIKE_PERPS_CONFIG.DEFAULT_LEVERAGE) {
1889
+ const perpetualTradingAddress = PERPETUAL_TRADING[agent.chain];
1890
+ if (perpetualTradingAddress === "0x0000000000000000000000000000000000000000") {
1891
+ throw new Error(
1892
+ `PikePerps not available on ${agent.chain}. Only available on testnet.`
1893
+ );
1894
+ }
1895
+ if (leverage < PIKE_PERPS_CONFIG.MIN_LEVERAGE || leverage > PIKE_PERPS_CONFIG.MAX_LEVERAGE) {
1896
+ throw new Error(
1897
+ `Leverage must be between ${PIKE_PERPS_CONFIG.MIN_LEVERAGE} and ${PIKE_PERPS_CONFIG.MAX_LEVERAGE}`
1898
+ );
1899
+ }
1900
+ if (agent.demo) {
1901
+ return {
1902
+ positionId: BigInt(Math.floor(Math.random() * 1e3)),
1903
+ txHash: "0xdemo_open_short_tx_hash"
1904
+ };
1905
+ }
1906
+ const marginBigInt = BigInt(margin);
1907
+ const data = viem.encodeFunctionData({
1908
+ abi: PERPETUAL_TRADING_ABI,
1909
+ functionName: "openPosition",
1910
+ args: [tokenAddress, false, marginBigInt, BigInt(leverage)]
1911
+ });
1912
+ const txHash = await agent.client.sendTransaction({
1913
+ to: perpetualTradingAddress,
1914
+ data,
1915
+ value: marginBigInt
1916
+ });
1917
+ const receipt = await agent.client.waitForTransactionReceipt({ hash: txHash });
1918
+ let positionId = 0n;
1919
+ for (const log of receipt.logs) {
1920
+ try {
1921
+ if (log.topics[0] === "0x2e5b0e8c5f5d55d89e89f5b5d5e5f5d55d89e89f5b5d5e5f5d55d89e89f5b5d5") {
1922
+ positionId = BigInt(log.topics[1] || "0");
1923
+ break;
1924
+ }
1925
+ } catch {
1926
+ }
1927
+ }
1928
+ if (positionId === 0n) {
1929
+ try {
1930
+ const nextId = await agent.client.readContract({
1931
+ address: perpetualTradingAddress,
1932
+ abi: PERPETUAL_TRADING_ABI,
1933
+ functionName: "nextPositionId"
1934
+ });
1935
+ positionId = nextId - 1n;
1936
+ } catch {
1937
+ }
1938
+ }
1939
+ return {
1940
+ positionId,
1941
+ txHash
1942
+ };
1943
+ }
1944
+ async function pikeperpsClosePosition(agent, positionId) {
1945
+ const perpetualTradingAddress = PERPETUAL_TRADING[agent.chain];
1946
+ if (perpetualTradingAddress === "0x0000000000000000000000000000000000000000") {
1947
+ throw new Error(
1948
+ `PikePerps not available on ${agent.chain}. Only available on testnet.`
1949
+ );
1950
+ }
1951
+ if (agent.demo) {
1952
+ return "0xdemo_close_position_tx_hash";
1953
+ }
1954
+ const data = viem.encodeFunctionData({
1955
+ abi: PERPETUAL_TRADING_ABI,
1956
+ functionName: "closePosition",
1957
+ args: [positionId]
1958
+ });
1959
+ const txHash = await agent.client.sendTransaction({
1960
+ to: perpetualTradingAddress,
1961
+ data
1962
+ });
1963
+ await agent.client.waitForTransactionReceipt({ hash: txHash });
1964
+ return txHash;
1965
+ }
1966
+ async function pikeperpsGetPositions(agent, userAddress) {
1967
+ const perpetualTradingAddress = PERPETUAL_TRADING[agent.chain];
1968
+ const address = userAddress || agent.account.address;
1969
+ if (perpetualTradingAddress === "0x0000000000000000000000000000000000000000") {
1970
+ throw new Error(
1971
+ `PikePerps not available on ${agent.chain}. Only available on testnet.`
1972
+ );
1973
+ }
1974
+ if (agent.demo) {
1975
+ return [
1976
+ {
1977
+ positionId: 1n,
1978
+ token: "0x0000000000000000000000000000000000000001",
1979
+ isLong: true,
1980
+ size: BigInt("1000000000000000000"),
1981
+ // 1 ETH equivalent
1982
+ margin: BigInt("100000000000000000"),
1983
+ // 0.1 ETH
1984
+ leverage: 10,
1985
+ entryPrice: BigInt("100000000"),
1986
+ // $1.00 scaled by 1e8
1987
+ entryTime: BigInt(Math.floor(Date.now() / 1e3) - 3600),
1988
+ currentPrice: BigInt("110000000"),
1989
+ // $1.10
1990
+ pnl: BigInt("10000000000000000"),
1991
+ // 0.01 ETH profit
1992
+ isProfit: true,
1993
+ liquidationPrice: BigInt("90000000"),
1994
+ // $0.90
1995
+ isOpen: true
1996
+ }
1997
+ ];
1998
+ }
1999
+ const positionIds = await agent.client.readContract({
2000
+ address: perpetualTradingAddress,
2001
+ abi: PERPETUAL_TRADING_ABI,
2002
+ functionName: "getUserPositions",
2003
+ args: [address]
2004
+ });
2005
+ if (positionIds.length === 0) {
2006
+ return [];
2007
+ }
2008
+ const positions = [];
2009
+ for (const positionId of positionIds) {
2010
+ try {
2011
+ const rawPosition = await agent.client.readContract({
2012
+ address: perpetualTradingAddress,
2013
+ abi: PERPETUAL_TRADING_ABI,
2014
+ functionName: "getPosition",
2015
+ args: [positionId]
2016
+ });
2017
+ if (!rawPosition.isOpen) {
2018
+ continue;
2019
+ }
2020
+ const [pnl, isProfit] = await agent.client.readContract({
2021
+ address: perpetualTradingAddress,
2022
+ abi: PERPETUAL_TRADING_ABI,
2023
+ functionName: "getPositionPnL",
2024
+ args: [positionId]
2025
+ });
2026
+ const liquidationPrice = await agent.client.readContract({
2027
+ address: perpetualTradingAddress,
2028
+ abi: PERPETUAL_TRADING_ABI,
2029
+ functionName: "getLiquidationPrice",
2030
+ args: [positionId]
2031
+ });
2032
+ let currentPrice = 0n;
2033
+ try {
2034
+ const [price, hasPrice] = await agent.client.readContract({
2035
+ address: perpetualTradingAddress,
2036
+ abi: PERPETUAL_TRADING_ABI,
2037
+ functionName: "getCurrentPrice",
2038
+ args: [rawPosition.token]
2039
+ });
2040
+ if (hasPrice) {
2041
+ currentPrice = price;
2042
+ }
2043
+ } catch {
2044
+ currentPrice = rawPosition.entryPrice;
2045
+ }
2046
+ positions.push({
2047
+ positionId,
2048
+ token: rawPosition.token,
2049
+ isLong: rawPosition.isLong,
2050
+ size: rawPosition.size,
2051
+ margin: rawPosition.margin,
2052
+ leverage: Number(rawPosition.leverage),
2053
+ entryPrice: rawPosition.entryPrice,
2054
+ entryTime: rawPosition.entryTime,
2055
+ currentPrice,
2056
+ pnl,
2057
+ isProfit,
2058
+ liquidationPrice,
2059
+ isOpen: rawPosition.isOpen
2060
+ });
2061
+ } catch (error) {
2062
+ console.warn(`Failed to fetch position ${positionId}:`, error);
2063
+ }
2064
+ }
2065
+ return positions;
2066
+ }
2067
+ async function pikeperpsGetMarketData(agent, tokenAddress, limit = 20) {
2068
+ const perpetualTradingAddress = PERPETUAL_TRADING[agent.chain];
2069
+ const bondingCurveAddress = BONDING_CURVE_MARKET[agent.chain];
2070
+ if (perpetualTradingAddress === "0x0000000000000000000000000000000000000000") {
2071
+ throw new Error(
2072
+ `PikePerps not available on ${agent.chain}. Only available on testnet.`
2073
+ );
2074
+ }
2075
+ if (agent.demo) {
2076
+ return {
2077
+ token: tokenAddress,
2078
+ currentPrice: BigInt("100000000"),
2079
+ // $1.00 scaled by 1e8
2080
+ hasPrice: true,
2081
+ isListed: true,
2082
+ curveProgress: BigInt("5000"),
2083
+ // 50%
2084
+ recentTrades: [
2085
+ {
2086
+ positionId: 1n,
2087
+ trader: "0x0000000000000000000000000000000000000001",
2088
+ token: tokenAddress,
2089
+ isLong: true,
2090
+ size: BigInt("1000000000000000000"),
2091
+ margin: BigInt("100000000000000000"),
2092
+ leverage: 10n,
2093
+ entryPrice: BigInt("100000000"),
2094
+ timestamp: Math.floor(Date.now() / 1e3) - 300,
2095
+ txHash: "0xdemo_trade_hash",
2096
+ blockNumber: 1000n
2097
+ }
2098
+ ]
2099
+ };
2100
+ }
2101
+ let currentPrice = 0n;
2102
+ let hasPrice = false;
2103
+ try {
2104
+ const [price, hasPriceResult] = await agent.client.readContract({
2105
+ address: perpetualTradingAddress,
2106
+ abi: PERPETUAL_TRADING_ABI,
2107
+ functionName: "getCurrentPrice",
2108
+ args: [tokenAddress]
2109
+ });
2110
+ currentPrice = price;
2111
+ hasPrice = hasPriceResult;
2112
+ } catch {
2113
+ }
2114
+ let isListed = false;
2115
+ let curveProgress = 0n;
2116
+ if (bondingCurveAddress !== "0x0000000000000000000000000000000000000000") {
2117
+ try {
2118
+ isListed = await agent.client.readContract({
2119
+ address: bondingCurveAddress,
2120
+ abi: BONDING_CURVE_MARKET_ABI,
2121
+ functionName: "isListed",
2122
+ args: [tokenAddress]
2123
+ });
2124
+ if (isListed) {
2125
+ curveProgress = await agent.client.readContract({
2126
+ address: bondingCurveAddress,
2127
+ abi: BONDING_CURVE_MARKET_ABI,
2128
+ functionName: "getCurveProgress",
2129
+ args: [tokenAddress]
2130
+ });
2131
+ }
2132
+ } catch {
2133
+ }
2134
+ }
2135
+ const recentTrades = [];
2136
+ try {
2137
+ const currentBlock = await agent.client.getBlockNumber();
2138
+ const fromBlock = currentBlock > 1000n ? currentBlock - 1000n : 0n;
2139
+ const logs = await agent.client.getLogs({
2140
+ address: perpetualTradingAddress,
2141
+ event: viem.parseAbiItem(
2142
+ "event PositionOpened(uint256 indexed positionId, address indexed user, address indexed token, bool isLong, uint256 size, uint256 margin, uint256 leverage, uint256 entryPrice)"
2143
+ ),
2144
+ args: {
2145
+ token: tokenAddress
2146
+ },
2147
+ fromBlock,
2148
+ toBlock: currentBlock
2149
+ });
2150
+ const blockCache = /* @__PURE__ */ new Map();
2151
+ for (const log of logs.slice(-limit)) {
2152
+ let timestamp = 0;
2153
+ if (!blockCache.has(log.blockNumber)) {
2154
+ try {
2155
+ const block = await agent.client.getBlock({
2156
+ blockNumber: log.blockNumber
2157
+ });
2158
+ timestamp = Number(block.timestamp);
2159
+ blockCache.set(log.blockNumber, timestamp);
2160
+ } catch {
2161
+ timestamp = Math.floor(Date.now() / 1e3);
2162
+ }
2163
+ } else {
2164
+ timestamp = blockCache.get(log.blockNumber) || 0;
2165
+ }
2166
+ recentTrades.push({
2167
+ positionId: BigInt(log.topics[1] || "0"),
2168
+ trader: log.topics[2],
2169
+ token: tokenAddress,
2170
+ isLong: log.args.isLong || false,
2171
+ size: log.args.size || 0n,
2172
+ margin: log.args.margin || 0n,
2173
+ leverage: log.args.leverage || 0n,
2174
+ entryPrice: log.args.entryPrice || 0n,
2175
+ timestamp,
2176
+ txHash: log.transactionHash,
2177
+ blockNumber: log.blockNumber
2178
+ });
2179
+ }
2180
+ } catch (error) {
2181
+ console.warn("Failed to fetch recent trades:", error);
2182
+ }
2183
+ return {
2184
+ token: tokenAddress,
2185
+ currentPrice,
2186
+ hasPrice,
2187
+ isListed,
2188
+ curveProgress,
2189
+ recentTrades
2190
+ };
2191
+ }
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
+
3447
+ // src/tools/okx/getSwapQuote.ts
3448
+ var getSwapQuote = async (agent, from, to, amount, slippagePercentage) => {
3449
+ if (agent.demo) {
3450
+ return createMockQuoteResponse("OKX", amount);
3451
+ }
3452
+ const chainIndex = agent.chain === "mainnet" ? "5000" : "5003";
3453
+ return getSwapTransaction(from, to, amount, chainIndex, slippagePercentage);
3454
+ };
3455
+
3456
+ // src/utils/x402/index.ts
3457
+ var DEFAULT_PLATFORM_URL = "https://mantle-devkit.vercel.app";
3458
+ var cachedConfig = null;
3459
+ var validationPromise = null;
3460
+ function getPlatformBaseUrl() {
3461
+ if (typeof process !== "undefined" && process.env) {
3462
+ return process.env.PLATFORM_URL || process.env.NEXT_PUBLIC_PLATFORM_URL || DEFAULT_PLATFORM_URL;
3463
+ }
3464
+ return DEFAULT_PLATFORM_URL;
3465
+ }
3466
+ async function validateAppId(appId) {
3467
+ const baseUrl2 = getPlatformBaseUrl();
3468
+ const url = `${baseUrl2}/api/v1/validate?appId=${encodeURIComponent(appId)}`;
3469
+ const response = await fetch(url, {
3470
+ method: "GET",
3471
+ headers: { "Content-Type": "application/json" }
3472
+ });
3473
+ if (!response.ok) {
3474
+ if (response.status === 404) {
3475
+ throw new Error(
3476
+ "Platform: Project not found. Invalid APP_ID. Please check your APP_ID configuration."
3477
+ );
3478
+ }
3479
+ if (response.status === 401) {
3480
+ throw new Error(
3481
+ "Platform: Unauthorized. Invalid APP_ID. Please verify your APP_ID."
3482
+ );
3483
+ }
3484
+ throw new Error(
3485
+ `Platform: Validation failed: ${response.status} ${response.statusText}`
3486
+ );
3487
+ }
3488
+ const data = await response.json();
3489
+ if (!data.appId || !data.payTo || !data.network) {
3490
+ throw new Error("Platform: Invalid response - missing required fields");
3491
+ }
3492
+ if (data.status !== "ACTIVE") {
3493
+ throw new Error(
3494
+ `Platform: Project is not active. Current status: ${data.status}`
3495
+ );
3496
+ }
3497
+ return {
3498
+ appId: data.appId,
3499
+ name: data.name,
3500
+ payTo: data.payTo,
3501
+ network: data.network,
3502
+ status: data.status
3503
+ };
3504
+ }
3505
+ async function initializePlatform() {
3506
+ if (cachedConfig) {
3507
+ return cachedConfig;
3508
+ }
3509
+ if (validationPromise) {
3510
+ return validationPromise;
3511
+ }
3512
+ let appId;
3513
+ if (typeof process !== "undefined" && process.env) {
3514
+ appId = process.env.APP_ID || process.env.NEXT_PUBLIC_APP_ID;
3515
+ }
3516
+ if (!appId || typeof appId !== "string" || appId.trim().length === 0) {
3517
+ throw new Error(
3518
+ "APP_ID is required. Set it in your .env file:\nAPP_ID=your_app_id_here"
3519
+ );
3520
+ }
3521
+ validationPromise = validateAppId(appId.trim());
3522
+ try {
3523
+ cachedConfig = await validationPromise;
3524
+ return cachedConfig;
3525
+ } catch (error) {
3526
+ validationPromise = null;
3527
+ throw error;
3528
+ }
3529
+ }
3530
+ function getProjectConfig() {
3531
+ if (!cachedConfig) {
3532
+ throw new Error(
3533
+ "Platform not initialized. Call initializePlatform() first."
3534
+ );
3535
+ }
3536
+ return cachedConfig;
3537
+ }
3538
+ async function getUserAccountData(agent, userAddress) {
3539
+ const lendingPoolAddress = LENDING_POOL[agent.chain];
3540
+ const address = userAddress || agent.account.address;
3541
+ if (lendingPoolAddress === "0x0000000000000000000000000000000000000000") {
3542
+ throw new Error(
3543
+ `Lendle LendingPool not configured for ${agent.chain}. Only available on mainnet.`
3544
+ );
3545
+ }
3546
+ const result = await agent.client.readContract({
3547
+ address: lendingPoolAddress,
3548
+ abi: LENDING_POOL_ABI,
3549
+ functionName: "getUserAccountData",
3550
+ args: [address]
3551
+ });
3552
+ return {
3553
+ totalCollateralETH: result[0],
3554
+ totalDebtETH: result[1],
3555
+ availableBorrowsETH: result[2],
3556
+ currentLiquidationThreshold: result[3],
3557
+ ltv: result[4],
3558
+ healthFactor: result[5]
3559
+ };
3560
+ }
3561
+ var MNTAgentKit = class {
3562
+ account;
3563
+ client;
3564
+ chain;
3565
+ demo;
3566
+ projectConfig;
3567
+ constructor(privateKey, chain) {
3568
+ this.account = accounts.privateKeyToAccount(privateKey);
3569
+ this.demo = chain === "testnet-demo";
3570
+ this.chain = chain === "testnet-demo" ? "testnet" : chain;
3571
+ this.client = viem.createWalletClient({
3572
+ chain: this.chain == "mainnet" ? chains.mantle : chains.mantleSepoliaTestnet,
3573
+ transport: viem.http(),
3574
+ account: this.account
3575
+ }).extend(viem.publicActions).extend(experimental.erc7811Actions());
3576
+ }
3577
+ /**
3578
+ * Initialize the agent with platform validation
3579
+ *
3580
+ * Validates APP_ID with the platform API.
3581
+ * Must be called after creating the agent instance.
3582
+ *
3583
+ * @returns The initialized agent instance
3584
+ * @throws Error if APP_ID is not set or validation fails
3585
+ *
3586
+ * @example
3587
+ * ```typescript
3588
+ * const agent = new MNTAgentKit(privateKey, "mainnet");
3589
+ * await agent.initialize(); // Validates APP_ID
3590
+ * ```
3591
+ */
3592
+ async initialize() {
3593
+ this.projectConfig = await initializePlatform();
3594
+ return this;
3595
+ }
3596
+ async sendTransaction(to, amount) {
3597
+ return await sendTransaction(this, to, amount);
3598
+ }
3599
+ // OKX DEX Aggregator
3600
+ async getSwapQuote(fromTokenAddress, toTokenAddress, amount, slippagePercentage = "0.5") {
3601
+ return await getSwapQuote(
3602
+ this,
3603
+ fromTokenAddress,
3604
+ toTokenAddress,
3605
+ amount,
3606
+ slippagePercentage
3607
+ );
3608
+ }
3609
+ async executeSwap(fromTokenAddress, toTokenAddress, amount, slippagePercentage = "0.5") {
3610
+ return await executeSwap(
3611
+ this,
3612
+ fromTokenAddress,
3613
+ toTokenAddress,
3614
+ amount,
3615
+ slippagePercentage
3616
+ );
3617
+ }
3618
+ // OpenOcean DEX Aggregator
3619
+ async getOpenOceanQuote(fromToken, toToken, amount) {
3620
+ return await getOpenOceanQuote(this, fromToken, toToken, amount);
3621
+ }
3622
+ async swapOnOpenOcean(fromToken, toToken, amount, slippage = 0.5) {
3623
+ return await swapOnOpenOcean(
3624
+ this,
3625
+ fromToken,
3626
+ toToken,
3627
+ amount,
3628
+ slippage.toString()
3629
+ );
3630
+ }
3631
+ // 1inch DEX Aggregator
3632
+ async get1inchQuote(fromToken, toToken, amount) {
3633
+ return await get1inchQuote(this, fromToken, toToken, amount);
3634
+ }
3635
+ async swapOn1inch(fromToken, toToken, amount, slippage = 0.5) {
3636
+ return await swapOn1inch(
3637
+ this,
3638
+ fromToken,
3639
+ toToken,
3640
+ amount,
3641
+ slippage.toString()
3642
+ );
3643
+ }
3644
+ // Uniswap V3 DEX
3645
+ async getUniswapQuote(fromToken, toToken, amount) {
3646
+ return await getUniswapQuote(this, fromToken, toToken, amount);
3647
+ }
3648
+ async swapOnUniswap(fromToken, toToken, amount, slippage = 0.5) {
3649
+ return await swapOnUniswap(
3650
+ this,
3651
+ fromToken,
3652
+ toToken,
1527
3653
  amount,
1528
3654
  slippage.toString()
1529
3655
  );
@@ -1547,6 +3673,24 @@ var MNTAgentKit = class {
1547
3673
  async lendleRepay(tokenAddress, amount, rateMode = 2, onBehalfOf) {
1548
3674
  return await lendleRepay(this, tokenAddress, amount, rateMode, onBehalfOf);
1549
3675
  }
3676
+ /**
3677
+ * Get user account data from Lendle LendingPool
3678
+ * Returns overall position including total collateral, debt, and health factor
3679
+ * @param userAddress - User wallet address (optional, defaults to agent account)
3680
+ * @returns User account data with collateral, debt, available borrows, and health factor
3681
+ */
3682
+ async lendleGetUserAccountData(userAddress) {
3683
+ return await getUserAccountData(this, userAddress);
3684
+ }
3685
+ /**
3686
+ * Get all Lendle positions for a user (per-token breakdown)
3687
+ * Returns detailed supply and borrow amounts for each asset
3688
+ * @param userAddress - User wallet address (optional, defaults to agent account)
3689
+ * @returns Array of positions with supply/borrow amounts per asset
3690
+ */
3691
+ async lendleGetPositions(userAddress) {
3692
+ return await lendleGetPositions(this, userAddress);
3693
+ }
1550
3694
  // Agni Finance DEX (#1 on Mantle)
1551
3695
  async agniSwap(tokenIn, tokenOut, amountIn, slippagePercent = 0.5, feeTier) {
1552
3696
  return await agniSwap(
@@ -1575,6 +3719,33 @@ var MNTAgentKit = class {
1575
3719
  }
1576
3720
  return METH_TOKEN[this.chain];
1577
3721
  }
3722
+ /**
3723
+ * Get mETH staking position for a user
3724
+ * Returns mETH balance and WETH balance for comparison
3725
+ * @param userAddress - User wallet address (optional, defaults to agent account)
3726
+ * @returns mETH position with balances
3727
+ */
3728
+ async methGetPosition(userAddress) {
3729
+ return await methGetPosition(this, userAddress);
3730
+ }
3731
+ /**
3732
+ * Swap WETH to mETH using DEX aggregator
3733
+ * @param amount - Amount of WETH to swap (in wei as string)
3734
+ * @param slippage - Slippage tolerance percentage (default 0.5%)
3735
+ * @returns Transaction hash
3736
+ */
3737
+ async swapToMeth(amount, slippage = 0.5) {
3738
+ return await swapToMeth(this, amount, slippage);
3739
+ }
3740
+ /**
3741
+ * Swap mETH to WETH using DEX aggregator
3742
+ * @param amount - Amount of mETH to swap (in wei as string)
3743
+ * @param slippage - Slippage tolerance percentage (default 0.5%)
3744
+ * @returns Transaction hash
3745
+ */
3746
+ async swapFromMeth(amount, slippage = 0.5) {
3747
+ return await swapFromMeth(this, amount, slippage);
3748
+ }
1578
3749
  // Squid Router Cross-chain
1579
3750
  async getSquidRoute(fromToken, toToken, fromChain, toChain, amount, slippage = 1) {
1580
3751
  return await getSquidRoute(
@@ -1598,6 +3769,267 @@ var MNTAgentKit = class {
1598
3769
  slippage
1599
3770
  );
1600
3771
  }
3772
+ // PikePerps - Perpetual Trading
3773
+ /**
3774
+ * Open a long position on PikePerps
3775
+ * @param tokenAddress - Token to trade (meme token address)
3776
+ * @param margin - Margin amount in wei (as string)
3777
+ * @param leverage - Leverage multiplier (1-100, default 10)
3778
+ * @returns Position ID and transaction hash
3779
+ */
3780
+ async pikeperpsOpenLong(tokenAddress, margin, leverage = 10) {
3781
+ return await pikeperpsOpenLong(this, tokenAddress, margin, leverage);
3782
+ }
3783
+ /**
3784
+ * Open a short position on PikePerps
3785
+ * @param tokenAddress - Token to trade (meme token address)
3786
+ * @param margin - Margin amount in wei (as string)
3787
+ * @param leverage - Leverage multiplier (1-100, default 10)
3788
+ * @returns Position ID and transaction hash
3789
+ */
3790
+ async pikeperpsOpenShort(tokenAddress, margin, leverage = 10) {
3791
+ return await pikeperpsOpenShort(this, tokenAddress, margin, leverage);
3792
+ }
3793
+ /**
3794
+ * Close an existing position on PikePerps
3795
+ * @param positionId - Position ID to close
3796
+ * @returns Transaction hash
3797
+ */
3798
+ async pikeperpsClosePosition(positionId) {
3799
+ return await pikeperpsClosePosition(this, positionId);
3800
+ }
3801
+ /**
3802
+ * Get all positions for a user on PikePerps
3803
+ * Returns detailed position data including PnL and liquidation prices
3804
+ * @param userAddress - User wallet address (optional, defaults to agent account)
3805
+ * @returns Array of positions with PnL and liquidation data
3806
+ */
3807
+ async pikeperpsGetPositions(userAddress) {
3808
+ return await pikeperpsGetPositions(this, userAddress);
3809
+ }
3810
+ /**
3811
+ * Get market data for a token on PikePerps
3812
+ * Returns current price and recent trades
3813
+ * @param tokenAddress - Token address to get market data for
3814
+ * @param limit - Maximum number of recent trades to return (default 20)
3815
+ * @returns Market data with price and recent trades
3816
+ */
3817
+ async pikeperpsGetMarketData(tokenAddress, limit = 20) {
3818
+ return await pikeperpsGetMarketData(this, tokenAddress, limit);
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
+ }
1601
4033
  };
1602
4034
 
1603
4035
  exports.AgniConstants = agni_exports;
@@ -1606,29 +4038,65 @@ exports.METH_TOKEN = METH_TOKEN;
1606
4038
  exports.MNTAgentKit = MNTAgentKit;
1607
4039
  exports.MerchantMoeConstants = merchantmoe_exports;
1608
4040
  exports.MethConstants = meth_exports;
4041
+ exports.NFTLaunchpadConstants = nft_launchpad_exports;
1609
4042
  exports.OKXConstants = okx_exports;
1610
4043
  exports.OneInchConstants = oneinch_exports;
1611
4044
  exports.OpenOceanConstants = openocean_exports;
4045
+ exports.PikePerpsConstants = pikeperps_exports;
4046
+ exports.PythConstants = pyth_exports;
1612
4047
  exports.SquidConstants = squid_exports;
4048
+ exports.TokenLaunchpadConstants = token_launchpad_exports;
1613
4049
  exports.UniswapConstants = uniswap_exports;
1614
4050
  exports.agniSwap = agniSwap;
4051
+ exports.approveNFT = approveNFT;
1615
4052
  exports.approveToken = approveToken;
4053
+ exports.batchMintNFT = batchMintNFT;
1616
4054
  exports.crossChainSwapViaSquid = crossChainSwapViaSquid;
4055
+ exports.deployNFTCollection = deployNFTCollection;
4056
+ exports.deployNFTCollectionWithPreset = deployNFTCollectionWithPreset;
4057
+ exports.deployRWAToken = deployRWAToken;
4058
+ exports.deployStandardToken = deployStandardToken;
4059
+ exports.deployToken = deployToken;
1617
4060
  exports.executeSwap = executeSwap;
1618
4061
  exports.get1inchQuote = get1inchQuote;
4062
+ exports.getNFTBalance = getNFTBalance;
4063
+ exports.getNFTCollectionInfo = getNFTCollectionInfo;
4064
+ exports.getNFTTokenInfo = getNFTTokenInfo;
1619
4065
  exports.getOpenOceanQuote = getOpenOceanQuote;
1620
4066
  exports.getProjectConfig = getProjectConfig;
1621
4067
  exports.getSquidRoute = getSquidRoute;
4068
+ exports.getTokenBalance = getTokenBalance;
4069
+ exports.getTokenInfo = getTokenInfo;
1622
4070
  exports.getUniswapQuote = getUniswapQuote;
1623
4071
  exports.initializePlatform = initializePlatform;
4072
+ exports.isNFTOwner = isNFTOwner;
1624
4073
  exports.lendleBorrow = lendleBorrow;
4074
+ exports.lendleGetPositions = lendleGetPositions;
1625
4075
  exports.lendleRepay = lendleRepay;
1626
4076
  exports.lendleSupply = lendleSupply;
1627
4077
  exports.lendleWithdraw = lendleWithdraw;
1628
4078
  exports.merchantMoeSwap = merchantMoeSwap;
4079
+ exports.methGetPosition = methGetPosition;
4080
+ exports.mintNFT = mintNFT;
4081
+ exports.pikeperpsClosePosition = pikeperpsClosePosition;
4082
+ exports.pikeperpsGetMarketData = pikeperpsGetMarketData;
4083
+ exports.pikeperpsGetPositions = pikeperpsGetPositions;
4084
+ exports.pikeperpsOpenLong = pikeperpsOpenLong;
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;
1629
4092
  exports.sendTransaction = sendTransaction;
4093
+ exports.setApprovalForAllNFT = setApprovalForAllNFT;
4094
+ exports.swapFromMeth = swapFromMeth;
1630
4095
  exports.swapOn1inch = swapOn1inch;
1631
4096
  exports.swapOnOpenOcean = swapOnOpenOcean;
1632
4097
  exports.swapOnUniswap = swapOnUniswap;
4098
+ exports.swapToMeth = swapToMeth;
4099
+ exports.transferNFT = transferNFT;
4100
+ exports.transferToken = transferToken;
1633
4101
  //# sourceMappingURL=index.cjs.map
1634
4102
  //# sourceMappingURL=index.cjs.map