@mania-labs/mania-sdk 1.0.2 → 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,6 +29,7 @@ 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"
33
34
  },
34
35
  // Mega Eth Mainnet
@@ -39,6 +40,7 @@ var CHAIN_CONFIGS = {
39
40
  wethAddress: "0x4200000000000000000000000000000000000006",
40
41
  nonfungiblePositionManager: "0x2b781C57e6358f64864Ff8EC464a03Fdaf9974bA",
41
42
  uniswapV3Factory: "0x68b34591f662508076927803c567Cc8006988a09",
43
+ quoterV2: "0x1F1a8dC7E138C34b503Ca080962aC10B75384a27",
42
44
  blockExplorer: "https://megaeth.blockscout.com/"
43
45
  }
44
46
  };
@@ -464,6 +466,139 @@ var MANIA_FACTORY_ABI = [
464
466
  anonymous: false
465
467
  }
466
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
+ ];
467
602
  var ERC20_ABI = [
468
603
  {
469
604
  type: "function",
@@ -683,7 +818,7 @@ var ManiaSDK = class _ManiaSDK {
683
818
  }
684
819
  /**
685
820
  * Get comprehensive token information
686
- *
821
+ *
687
822
  * @param token - Token address
688
823
  */
689
824
  async getTokenInfo(token) {
@@ -697,6 +832,18 @@ var ManiaSDK = class _ManiaSDK {
697
832
  migrationProgress: curve.getMigrationProgress()
698
833
  };
699
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
+ }
700
847
  /**
701
848
  * Get buy quote from contract
702
849
  *
@@ -1051,6 +1198,85 @@ var ManiaSDK = class _ManiaSDK {
1051
1198
  getWalletClient() {
1052
1199
  return this.walletClient;
1053
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
+ }
1054
1280
  };
1055
1281
 
1056
1282
  // src/utils.ts
@@ -1155,11 +1381,13 @@ export {
1155
1381
  MIGRATION_THRESHOLD,
1156
1382
  ManiaSDK,
1157
1383
  PROTOCOL_FEE_BASIS_POINTS,
1384
+ QUOTER_V2_ABI,
1158
1385
  TICK_LOWER,
1159
1386
  TICK_UPPER,
1160
1387
  TOKENS_FOR_LP,
1161
1388
  TOTAL_FEE_BASIS_POINTS,
1162
1389
  UNISWAP_FEE_TIER,
1390
+ UNISWAP_V3_FACTORY_ABI,
1163
1391
  bpsToPercent,
1164
1392
  calculateBuyAmount,
1165
1393
  calculateMigrationProgress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mania-labs/mania-sdk",
3
- "version": "1.0.2",
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",