@mania-labs/mania-sdk 1.0.1 → 1.0.3

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.mjs CHANGED
@@ -29,7 +29,19 @@ var CHAIN_CONFIGS = {
29
29
  wethAddress: "0x4200000000000000000000000000000000000006",
30
30
  nonfungiblePositionManager: "0xa204A97EF8Bd2E3198f19EB5a804680467BD85f5",
31
31
  uniswapV3Factory: "0x619fb6C12c36b57a8bAb05e98F42C43745DCf69f",
32
+ quoterV2: "0xfb230b93803F90238cB03f254452bA3a3b0Ec38d",
32
33
  blockExplorer: "https://megaeth-testnet-v2.blockscout.com"
34
+ },
35
+ // Mega Eth Mainnet
36
+ 4326: {
37
+ chainId: 4326,
38
+ name: "Mega Eth Mainnet",
39
+ factoryAddress: "0xb2f6344Cb0Ee13e027759166770198f4d8B3106d",
40
+ wethAddress: "0x4200000000000000000000000000000000000006",
41
+ nonfungiblePositionManager: "0x2b781C57e6358f64864Ff8EC464a03Fdaf9974bA",
42
+ uniswapV3Factory: "0x68b34591f662508076927803c567Cc8006988a09",
43
+ quoterV2: "0x1F1a8dC7E138C34b503Ca080962aC10B75384a27",
44
+ blockExplorer: "https://megaeth.blockscout.com/"
33
45
  }
34
46
  };
35
47
  function getChainConfig(chainId) {
@@ -454,6 +466,139 @@ var MANIA_FACTORY_ABI = [
454
466
  anonymous: false
455
467
  }
456
468
  ];
469
+ var QUOTER_V2_ABI = [
470
+ {
471
+ inputs: [
472
+ { internalType: "address", name: "_factory", type: "address" },
473
+ { internalType: "address", name: "_WETH9", type: "address" }
474
+ ],
475
+ stateMutability: "nonpayable",
476
+ type: "constructor"
477
+ },
478
+ {
479
+ inputs: [],
480
+ name: "WETH9",
481
+ outputs: [{ internalType: "address", name: "", type: "address" }],
482
+ stateMutability: "view",
483
+ type: "function"
484
+ },
485
+ {
486
+ inputs: [],
487
+ name: "factory",
488
+ outputs: [{ internalType: "address", name: "", type: "address" }],
489
+ stateMutability: "view",
490
+ type: "function"
491
+ },
492
+ {
493
+ inputs: [
494
+ { internalType: "bytes", name: "path", type: "bytes" },
495
+ { internalType: "uint256", name: "amountIn", type: "uint256" }
496
+ ],
497
+ name: "quoteExactInput",
498
+ outputs: [
499
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
500
+ { internalType: "uint160[]", name: "sqrtPriceX96AfterList", type: "uint160[]" },
501
+ { internalType: "uint32[]", name: "initializedTicksCrossedList", type: "uint32[]" },
502
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
503
+ ],
504
+ stateMutability: "nonpayable",
505
+ type: "function"
506
+ },
507
+ {
508
+ inputs: [
509
+ {
510
+ components: [
511
+ { internalType: "address", name: "tokenIn", type: "address" },
512
+ { internalType: "address", name: "tokenOut", type: "address" },
513
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
514
+ { internalType: "uint24", name: "fee", type: "uint24" },
515
+ { internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" }
516
+ ],
517
+ internalType: "struct IQuoterV2.QuoteExactInputSingleParams",
518
+ name: "params",
519
+ type: "tuple"
520
+ }
521
+ ],
522
+ name: "quoteExactInputSingle",
523
+ outputs: [
524
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
525
+ { internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" },
526
+ { internalType: "uint32", name: "initializedTicksCrossed", type: "uint32" },
527
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
528
+ ],
529
+ stateMutability: "nonpayable",
530
+ type: "function"
531
+ },
532
+ {
533
+ inputs: [
534
+ { internalType: "bytes", name: "path", type: "bytes" },
535
+ { internalType: "uint256", name: "amountOut", type: "uint256" }
536
+ ],
537
+ name: "quoteExactOutput",
538
+ outputs: [
539
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
540
+ { internalType: "uint160[]", name: "sqrtPriceX96AfterList", type: "uint160[]" },
541
+ { internalType: "uint32[]", name: "initializedTicksCrossedList", type: "uint32[]" },
542
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
543
+ ],
544
+ stateMutability: "nonpayable",
545
+ type: "function"
546
+ },
547
+ {
548
+ inputs: [
549
+ {
550
+ components: [
551
+ { internalType: "address", name: "tokenIn", type: "address" },
552
+ { internalType: "address", name: "tokenOut", type: "address" },
553
+ { internalType: "uint256", name: "amount", type: "uint256" },
554
+ { internalType: "uint24", name: "fee", type: "uint24" },
555
+ { internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" }
556
+ ],
557
+ internalType: "struct IQuoterV2.QuoteExactOutputSingleParams",
558
+ name: "params",
559
+ type: "tuple"
560
+ }
561
+ ],
562
+ name: "quoteExactOutputSingle",
563
+ outputs: [
564
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
565
+ { internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" },
566
+ { internalType: "uint32", name: "initializedTicksCrossed", type: "uint32" },
567
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
568
+ ],
569
+ stateMutability: "nonpayable",
570
+ type: "function"
571
+ },
572
+ {
573
+ inputs: [
574
+ { internalType: "int256", name: "amount0Delta", type: "int256" },
575
+ { internalType: "int256", name: "amount1Delta", type: "int256" },
576
+ { internalType: "bytes", name: "path", type: "bytes" }
577
+ ],
578
+ name: "uniswapV3SwapCallback",
579
+ outputs: [],
580
+ stateMutability: "view",
581
+ type: "function"
582
+ }
583
+ ];
584
+ var UNISWAP_V3_FACTORY_ABI = [
585
+ {
586
+ inputs: [],
587
+ stateMutability: "nonpayable",
588
+ type: "constructor"
589
+ },
590
+ {
591
+ inputs: [
592
+ { internalType: "address", name: "tokenA", type: "address" },
593
+ { internalType: "address", name: "tokenB", type: "address" },
594
+ { internalType: "uint24", name: "fee", type: "uint24" }
595
+ ],
596
+ name: "getPool",
597
+ outputs: [{ internalType: "address", name: "", type: "address" }],
598
+ stateMutability: "view",
599
+ type: "function"
600
+ }
601
+ ];
457
602
  var ERC20_ABI = [
458
603
  {
459
604
  type: "function",
@@ -673,7 +818,7 @@ var ManiaSDK = class _ManiaSDK {
673
818
  }
674
819
  /**
675
820
  * Get comprehensive token information
676
- *
821
+ *
677
822
  * @param token - Token address
678
823
  */
679
824
  async getTokenInfo(token) {
@@ -687,6 +832,18 @@ var ManiaSDK = class _ManiaSDK {
687
832
  migrationProgress: curve.getMigrationProgress()
688
833
  };
689
834
  }
835
+ /**
836
+ * Get token name and symbol
837
+ *
838
+ * @param token - Token address
839
+ */
840
+ async getTokenMetadata(token) {
841
+ const [name, symbol] = await Promise.all([
842
+ this.publicClient.readContract({ address: token, abi: ERC20_ABI, functionName: "name" }),
843
+ this.publicClient.readContract({ address: token, abi: ERC20_ABI, functionName: "symbol" })
844
+ ]);
845
+ return { name, symbol };
846
+ }
690
847
  /**
691
848
  * Get buy quote from contract
692
849
  *
@@ -1041,6 +1198,85 @@ var ManiaSDK = class _ManiaSDK {
1041
1198
  getWalletClient() {
1042
1199
  return this.walletClient;
1043
1200
  }
1201
+ // ========== MIGRATED TOKEN METHODS ==========
1202
+ /**
1203
+ * Get chain config or throw if not found
1204
+ */
1205
+ getChainConfigOrThrow() {
1206
+ const config = getChainConfig(this.chainId);
1207
+ if (!config) {
1208
+ throw new Error(`Chain config not found for chain ID: ${this.chainId}`);
1209
+ }
1210
+ return config;
1211
+ }
1212
+ /**
1213
+ * Get quote for buying tokens with ETH on Kumbaya DEX (Uniswap V3)
1214
+ * Use this for tokens that have migrated from the bonding curve
1215
+ *
1216
+ * @param token - Token address
1217
+ * @param ethAmount - ETH amount in wei
1218
+ * @returns Token amount out
1219
+ */
1220
+ async getMigratedBuyQuote(token, ethAmount) {
1221
+ const chainConfig = this.getChainConfigOrThrow();
1222
+ const { result } = await this.publicClient.simulateContract({
1223
+ address: chainConfig.quoterV2,
1224
+ abi: QUOTER_V2_ABI,
1225
+ functionName: "quoteExactInputSingle",
1226
+ args: [{
1227
+ tokenIn: chainConfig.wethAddress,
1228
+ tokenOut: token,
1229
+ amountIn: ethAmount,
1230
+ fee: UNISWAP_FEE_TIER,
1231
+ sqrtPriceLimitX96: 0n
1232
+ }]
1233
+ });
1234
+ return result[0];
1235
+ }
1236
+ /**
1237
+ * Get quote for selling tokens for ETH on Kumbaya DEX (Uniswap V3)
1238
+ * Use this for tokens that have migrated from the bonding curve
1239
+ *
1240
+ * @param token - Token address
1241
+ * @param tokenAmount - Token amount to sell
1242
+ * @returns ETH amount out in wei
1243
+ */
1244
+ async getMigratedSellQuote(token, tokenAmount) {
1245
+ const chainConfig = this.getChainConfigOrThrow();
1246
+ const { result } = await this.publicClient.simulateContract({
1247
+ address: chainConfig.quoterV2,
1248
+ abi: QUOTER_V2_ABI,
1249
+ functionName: "quoteExactInputSingle",
1250
+ args: [{
1251
+ tokenIn: token,
1252
+ tokenOut: chainConfig.wethAddress,
1253
+ amountIn: tokenAmount,
1254
+ fee: UNISWAP_FEE_TIER,
1255
+ sqrtPriceLimitX96: 0n
1256
+ }]
1257
+ });
1258
+ return result[0];
1259
+ }
1260
+ /**
1261
+ * Get the Uniswap V3 pool address for a token/WETH pair
1262
+ *
1263
+ * @param token - Token address
1264
+ * @returns Pool address
1265
+ * @throws Error if pool not found
1266
+ */
1267
+ async getPoolAddress(token) {
1268
+ const chainConfig = this.getChainConfigOrThrow();
1269
+ const poolAddress = await this.publicClient.readContract({
1270
+ address: chainConfig.uniswapV3Factory,
1271
+ abi: UNISWAP_V3_FACTORY_ABI,
1272
+ functionName: "getPool",
1273
+ args: [token, chainConfig.wethAddress, UNISWAP_FEE_TIER]
1274
+ });
1275
+ if (poolAddress === "0x0000000000000000000000000000000000000000") {
1276
+ throw new Error(`Pool not found for token ${token}`);
1277
+ }
1278
+ return poolAddress;
1279
+ }
1044
1280
  };
1045
1281
 
1046
1282
  // src/utils.ts
@@ -1145,11 +1381,13 @@ export {
1145
1381
  MIGRATION_THRESHOLD,
1146
1382
  ManiaSDK,
1147
1383
  PROTOCOL_FEE_BASIS_POINTS,
1384
+ QUOTER_V2_ABI,
1148
1385
  TICK_LOWER,
1149
1386
  TICK_UPPER,
1150
1387
  TOKENS_FOR_LP,
1151
1388
  TOTAL_FEE_BASIS_POINTS,
1152
1389
  UNISWAP_FEE_TIER,
1390
+ UNISWAP_V3_FACTORY_ABI,
1153
1391
  bpsToPercent,
1154
1392
  calculateBuyAmount,
1155
1393
  calculateMigrationProgress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mania-labs/mania-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Official SDK for interacting with the Mania Protocol - EVM Bonding Curve Token Launchpad",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",