@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.d.ts CHANGED
@@ -411,6 +411,15 @@ declare class ManiaSDK {
411
411
  * @param token - Token address
412
412
  */
413
413
  getTokenInfo(token: Address): Promise<TokenInfo>;
414
+ /**
415
+ * Get token name and symbol
416
+ *
417
+ * @param token - Token address
418
+ */
419
+ getTokenMetadata(token: Address): Promise<{
420
+ name: string;
421
+ symbol: string;
422
+ }>;
414
423
  /**
415
424
  * Get buy quote from contract
416
425
  *
@@ -548,6 +557,36 @@ declare class ManiaSDK {
548
557
  * Get the wallet client
549
558
  */
550
559
  getWalletClient(): WalletClient | null;
560
+ /**
561
+ * Get chain config or throw if not found
562
+ */
563
+ private getChainConfigOrThrow;
564
+ /**
565
+ * Get quote for buying tokens with ETH on Kumbaya DEX (Uniswap V3)
566
+ * Use this for tokens that have migrated from the bonding curve
567
+ *
568
+ * @param token - Token address
569
+ * @param ethAmount - ETH amount in wei
570
+ * @returns Token amount out
571
+ */
572
+ getMigratedBuyQuote(token: Address, ethAmount: bigint): Promise<bigint>;
573
+ /**
574
+ * Get quote for selling tokens for ETH on Kumbaya DEX (Uniswap V3)
575
+ * Use this for tokens that have migrated from the bonding curve
576
+ *
577
+ * @param token - Token address
578
+ * @param tokenAmount - Token amount to sell
579
+ * @returns ETH amount out in wei
580
+ */
581
+ getMigratedSellQuote(token: Address, tokenAmount: bigint): Promise<bigint>;
582
+ /**
583
+ * Get the Uniswap V3 pool address for a token/WETH pair
584
+ *
585
+ * @param token - Token address
586
+ * @returns Pool address
587
+ * @throws Error if pool not found
588
+ */
589
+ getPoolAddress(token: Address): Promise<Address>;
551
590
  }
552
591
 
553
592
  /**
@@ -587,6 +626,7 @@ interface ChainConfig {
587
626
  wethAddress: Address;
588
627
  nonfungiblePositionManager: Address;
589
628
  uniswapV3Factory: Address;
629
+ quoterV2: Address;
590
630
  blockExplorer: string;
591
631
  }
592
632
  /**
@@ -1026,6 +1066,238 @@ declare const MANIA_FACTORY_ABI: readonly [{
1026
1066
  }];
1027
1067
  readonly anonymous: false;
1028
1068
  }];
1069
+ declare const QUOTER_V2_ABI: readonly [{
1070
+ readonly inputs: readonly [{
1071
+ readonly internalType: "address";
1072
+ readonly name: "_factory";
1073
+ readonly type: "address";
1074
+ }, {
1075
+ readonly internalType: "address";
1076
+ readonly name: "_WETH9";
1077
+ readonly type: "address";
1078
+ }];
1079
+ readonly stateMutability: "nonpayable";
1080
+ readonly type: "constructor";
1081
+ }, {
1082
+ readonly inputs: readonly [];
1083
+ readonly name: "WETH9";
1084
+ readonly outputs: readonly [{
1085
+ readonly internalType: "address";
1086
+ readonly name: "";
1087
+ readonly type: "address";
1088
+ }];
1089
+ readonly stateMutability: "view";
1090
+ readonly type: "function";
1091
+ }, {
1092
+ readonly inputs: readonly [];
1093
+ readonly name: "factory";
1094
+ readonly outputs: readonly [{
1095
+ readonly internalType: "address";
1096
+ readonly name: "";
1097
+ readonly type: "address";
1098
+ }];
1099
+ readonly stateMutability: "view";
1100
+ readonly type: "function";
1101
+ }, {
1102
+ readonly inputs: readonly [{
1103
+ readonly internalType: "bytes";
1104
+ readonly name: "path";
1105
+ readonly type: "bytes";
1106
+ }, {
1107
+ readonly internalType: "uint256";
1108
+ readonly name: "amountIn";
1109
+ readonly type: "uint256";
1110
+ }];
1111
+ readonly name: "quoteExactInput";
1112
+ readonly outputs: readonly [{
1113
+ readonly internalType: "uint256";
1114
+ readonly name: "amountOut";
1115
+ readonly type: "uint256";
1116
+ }, {
1117
+ readonly internalType: "uint160[]";
1118
+ readonly name: "sqrtPriceX96AfterList";
1119
+ readonly type: "uint160[]";
1120
+ }, {
1121
+ readonly internalType: "uint32[]";
1122
+ readonly name: "initializedTicksCrossedList";
1123
+ readonly type: "uint32[]";
1124
+ }, {
1125
+ readonly internalType: "uint256";
1126
+ readonly name: "gasEstimate";
1127
+ readonly type: "uint256";
1128
+ }];
1129
+ readonly stateMutability: "nonpayable";
1130
+ readonly type: "function";
1131
+ }, {
1132
+ readonly inputs: readonly [{
1133
+ readonly components: readonly [{
1134
+ readonly internalType: "address";
1135
+ readonly name: "tokenIn";
1136
+ readonly type: "address";
1137
+ }, {
1138
+ readonly internalType: "address";
1139
+ readonly name: "tokenOut";
1140
+ readonly type: "address";
1141
+ }, {
1142
+ readonly internalType: "uint256";
1143
+ readonly name: "amountIn";
1144
+ readonly type: "uint256";
1145
+ }, {
1146
+ readonly internalType: "uint24";
1147
+ readonly name: "fee";
1148
+ readonly type: "uint24";
1149
+ }, {
1150
+ readonly internalType: "uint160";
1151
+ readonly name: "sqrtPriceLimitX96";
1152
+ readonly type: "uint160";
1153
+ }];
1154
+ readonly internalType: "struct IQuoterV2.QuoteExactInputSingleParams";
1155
+ readonly name: "params";
1156
+ readonly type: "tuple";
1157
+ }];
1158
+ readonly name: "quoteExactInputSingle";
1159
+ readonly outputs: readonly [{
1160
+ readonly internalType: "uint256";
1161
+ readonly name: "amountOut";
1162
+ readonly type: "uint256";
1163
+ }, {
1164
+ readonly internalType: "uint160";
1165
+ readonly name: "sqrtPriceX96After";
1166
+ readonly type: "uint160";
1167
+ }, {
1168
+ readonly internalType: "uint32";
1169
+ readonly name: "initializedTicksCrossed";
1170
+ readonly type: "uint32";
1171
+ }, {
1172
+ readonly internalType: "uint256";
1173
+ readonly name: "gasEstimate";
1174
+ readonly type: "uint256";
1175
+ }];
1176
+ readonly stateMutability: "nonpayable";
1177
+ readonly type: "function";
1178
+ }, {
1179
+ readonly inputs: readonly [{
1180
+ readonly internalType: "bytes";
1181
+ readonly name: "path";
1182
+ readonly type: "bytes";
1183
+ }, {
1184
+ readonly internalType: "uint256";
1185
+ readonly name: "amountOut";
1186
+ readonly type: "uint256";
1187
+ }];
1188
+ readonly name: "quoteExactOutput";
1189
+ readonly outputs: readonly [{
1190
+ readonly internalType: "uint256";
1191
+ readonly name: "amountIn";
1192
+ readonly type: "uint256";
1193
+ }, {
1194
+ readonly internalType: "uint160[]";
1195
+ readonly name: "sqrtPriceX96AfterList";
1196
+ readonly type: "uint160[]";
1197
+ }, {
1198
+ readonly internalType: "uint32[]";
1199
+ readonly name: "initializedTicksCrossedList";
1200
+ readonly type: "uint32[]";
1201
+ }, {
1202
+ readonly internalType: "uint256";
1203
+ readonly name: "gasEstimate";
1204
+ readonly type: "uint256";
1205
+ }];
1206
+ readonly stateMutability: "nonpayable";
1207
+ readonly type: "function";
1208
+ }, {
1209
+ readonly inputs: readonly [{
1210
+ readonly components: readonly [{
1211
+ readonly internalType: "address";
1212
+ readonly name: "tokenIn";
1213
+ readonly type: "address";
1214
+ }, {
1215
+ readonly internalType: "address";
1216
+ readonly name: "tokenOut";
1217
+ readonly type: "address";
1218
+ }, {
1219
+ readonly internalType: "uint256";
1220
+ readonly name: "amount";
1221
+ readonly type: "uint256";
1222
+ }, {
1223
+ readonly internalType: "uint24";
1224
+ readonly name: "fee";
1225
+ readonly type: "uint24";
1226
+ }, {
1227
+ readonly internalType: "uint160";
1228
+ readonly name: "sqrtPriceLimitX96";
1229
+ readonly type: "uint160";
1230
+ }];
1231
+ readonly internalType: "struct IQuoterV2.QuoteExactOutputSingleParams";
1232
+ readonly name: "params";
1233
+ readonly type: "tuple";
1234
+ }];
1235
+ readonly name: "quoteExactOutputSingle";
1236
+ readonly outputs: readonly [{
1237
+ readonly internalType: "uint256";
1238
+ readonly name: "amountIn";
1239
+ readonly type: "uint256";
1240
+ }, {
1241
+ readonly internalType: "uint160";
1242
+ readonly name: "sqrtPriceX96After";
1243
+ readonly type: "uint160";
1244
+ }, {
1245
+ readonly internalType: "uint32";
1246
+ readonly name: "initializedTicksCrossed";
1247
+ readonly type: "uint32";
1248
+ }, {
1249
+ readonly internalType: "uint256";
1250
+ readonly name: "gasEstimate";
1251
+ readonly type: "uint256";
1252
+ }];
1253
+ readonly stateMutability: "nonpayable";
1254
+ readonly type: "function";
1255
+ }, {
1256
+ readonly inputs: readonly [{
1257
+ readonly internalType: "int256";
1258
+ readonly name: "amount0Delta";
1259
+ readonly type: "int256";
1260
+ }, {
1261
+ readonly internalType: "int256";
1262
+ readonly name: "amount1Delta";
1263
+ readonly type: "int256";
1264
+ }, {
1265
+ readonly internalType: "bytes";
1266
+ readonly name: "path";
1267
+ readonly type: "bytes";
1268
+ }];
1269
+ readonly name: "uniswapV3SwapCallback";
1270
+ readonly outputs: readonly [];
1271
+ readonly stateMutability: "view";
1272
+ readonly type: "function";
1273
+ }];
1274
+ declare const UNISWAP_V3_FACTORY_ABI: readonly [{
1275
+ readonly inputs: readonly [];
1276
+ readonly stateMutability: "nonpayable";
1277
+ readonly type: "constructor";
1278
+ }, {
1279
+ readonly inputs: readonly [{
1280
+ readonly internalType: "address";
1281
+ readonly name: "tokenA";
1282
+ readonly type: "address";
1283
+ }, {
1284
+ readonly internalType: "address";
1285
+ readonly name: "tokenB";
1286
+ readonly type: "address";
1287
+ }, {
1288
+ readonly internalType: "uint24";
1289
+ readonly name: "fee";
1290
+ readonly type: "uint24";
1291
+ }];
1292
+ readonly name: "getPool";
1293
+ readonly outputs: readonly [{
1294
+ readonly internalType: "address";
1295
+ readonly name: "";
1296
+ readonly type: "address";
1297
+ }];
1298
+ readonly stateMutability: "view";
1299
+ readonly type: "function";
1300
+ }];
1029
1301
  declare const ERC20_ABI: readonly [{
1030
1302
  readonly type: "function";
1031
1303
  readonly name: "name";
@@ -1113,4 +1385,4 @@ declare const ERC20_ABI: readonly [{
1113
1385
  readonly stateMutability: "nonpayable";
1114
1386
  }];
1115
1387
 
1116
- export { BPS_DENOMINATOR, BondingCurve, type BondingCurveState, type BuyParams, type BuyQuote, CHAIN_CONFIGS, CREATOR_FEE_BASIS_POINTS, type ChainConfig, type CompleteEvent, type CreateAndBuyParams, type CreateEvent, type CreateTokenParams, DEFAULT_SLIPPAGE_BPS, ERC20_ABI, type GlobalState, MANIA_FACTORY_ABI, MAX_FEE_BASIS_POINTS, MAX_MIGRATE_FEES, MIGRATION_THRESHOLD, ManiaSDK, type ManiaSDKConfig, type MigrateParams, type MigrationEvent, PROTOCOL_FEE_BASIS_POINTS, type SellParams, type SellQuote, type SetParamsInput, type SlippageConfig, TICK_LOWER, TICK_UPPER, TOKENS_FOR_LP, TOTAL_FEE_BASIS_POINTS, type TokenInfo, type TradeEvent, type TransactionResult, UNISWAP_FEE_TIER, bpsToPercent, calculateBuyAmount, calculateMigrationProgress, calculatePriceImpact, calculateSellAmount, calculateWithSlippage, formatEthValue, formatMarketCap, formatPrice, formatTokenAmount, getChainConfig, isValidAddress, parseEthValue, percentToBps, sleep, truncateAddress, withRetry };
1388
+ export { BPS_DENOMINATOR, BondingCurve, type BondingCurveState, type BuyParams, type BuyQuote, CHAIN_CONFIGS, CREATOR_FEE_BASIS_POINTS, type ChainConfig, type CompleteEvent, type CreateAndBuyParams, type CreateEvent, type CreateTokenParams, DEFAULT_SLIPPAGE_BPS, ERC20_ABI, type GlobalState, MANIA_FACTORY_ABI, MAX_FEE_BASIS_POINTS, MAX_MIGRATE_FEES, MIGRATION_THRESHOLD, ManiaSDK, type ManiaSDKConfig, type MigrateParams, type MigrationEvent, PROTOCOL_FEE_BASIS_POINTS, QUOTER_V2_ABI, type SellParams, type SellQuote, type SetParamsInput, type SlippageConfig, TICK_LOWER, TICK_UPPER, TOKENS_FOR_LP, TOTAL_FEE_BASIS_POINTS, type TokenInfo, type TradeEvent, type TransactionResult, UNISWAP_FEE_TIER, UNISWAP_V3_FACTORY_ABI, bpsToPercent, calculateBuyAmount, calculateMigrationProgress, calculatePriceImpact, calculateSellAmount, calculateWithSlippage, formatEthValue, formatMarketCap, formatPrice, formatTokenAmount, getChainConfig, isValidAddress, parseEthValue, percentToBps, sleep, truncateAddress, withRetry };
package/dist/index.js CHANGED
@@ -32,11 +32,13 @@ __export(index_exports, {
32
32
  MIGRATION_THRESHOLD: () => MIGRATION_THRESHOLD,
33
33
  ManiaSDK: () => ManiaSDK,
34
34
  PROTOCOL_FEE_BASIS_POINTS: () => PROTOCOL_FEE_BASIS_POINTS,
35
+ QUOTER_V2_ABI: () => QUOTER_V2_ABI,
35
36
  TICK_LOWER: () => TICK_LOWER,
36
37
  TICK_UPPER: () => TICK_UPPER,
37
38
  TOKENS_FOR_LP: () => TOKENS_FOR_LP,
38
39
  TOTAL_FEE_BASIS_POINTS: () => TOTAL_FEE_BASIS_POINTS,
39
40
  UNISWAP_FEE_TIER: () => UNISWAP_FEE_TIER,
41
+ UNISWAP_V3_FACTORY_ABI: () => UNISWAP_V3_FACTORY_ABI,
40
42
  bpsToPercent: () => bpsToPercent,
41
43
  calculateBuyAmount: () => calculateBuyAmount,
42
44
  calculateMigrationProgress: () => calculateMigrationProgress,
@@ -83,7 +85,19 @@ var CHAIN_CONFIGS = {
83
85
  wethAddress: "0x4200000000000000000000000000000000000006",
84
86
  nonfungiblePositionManager: "0xa204A97EF8Bd2E3198f19EB5a804680467BD85f5",
85
87
  uniswapV3Factory: "0x619fb6C12c36b57a8bAb05e98F42C43745DCf69f",
88
+ quoterV2: "0xfb230b93803F90238cB03f254452bA3a3b0Ec38d",
86
89
  blockExplorer: "https://megaeth-testnet-v2.blockscout.com"
90
+ },
91
+ // Mega Eth Mainnet
92
+ 4326: {
93
+ chainId: 4326,
94
+ name: "Mega Eth Mainnet",
95
+ factoryAddress: "0xb2f6344Cb0Ee13e027759166770198f4d8B3106d",
96
+ wethAddress: "0x4200000000000000000000000000000000000006",
97
+ nonfungiblePositionManager: "0x2b781C57e6358f64864Ff8EC464a03Fdaf9974bA",
98
+ uniswapV3Factory: "0x68b34591f662508076927803c567Cc8006988a09",
99
+ quoterV2: "0x1F1a8dC7E138C34b503Ca080962aC10B75384a27",
100
+ blockExplorer: "https://megaeth.blockscout.com/"
87
101
  }
88
102
  };
89
103
  function getChainConfig(chainId) {
@@ -508,6 +522,139 @@ var MANIA_FACTORY_ABI = [
508
522
  anonymous: false
509
523
  }
510
524
  ];
525
+ var QUOTER_V2_ABI = [
526
+ {
527
+ inputs: [
528
+ { internalType: "address", name: "_factory", type: "address" },
529
+ { internalType: "address", name: "_WETH9", type: "address" }
530
+ ],
531
+ stateMutability: "nonpayable",
532
+ type: "constructor"
533
+ },
534
+ {
535
+ inputs: [],
536
+ name: "WETH9",
537
+ outputs: [{ internalType: "address", name: "", type: "address" }],
538
+ stateMutability: "view",
539
+ type: "function"
540
+ },
541
+ {
542
+ inputs: [],
543
+ name: "factory",
544
+ outputs: [{ internalType: "address", name: "", type: "address" }],
545
+ stateMutability: "view",
546
+ type: "function"
547
+ },
548
+ {
549
+ inputs: [
550
+ { internalType: "bytes", name: "path", type: "bytes" },
551
+ { internalType: "uint256", name: "amountIn", type: "uint256" }
552
+ ],
553
+ name: "quoteExactInput",
554
+ outputs: [
555
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
556
+ { internalType: "uint160[]", name: "sqrtPriceX96AfterList", type: "uint160[]" },
557
+ { internalType: "uint32[]", name: "initializedTicksCrossedList", type: "uint32[]" },
558
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
559
+ ],
560
+ stateMutability: "nonpayable",
561
+ type: "function"
562
+ },
563
+ {
564
+ inputs: [
565
+ {
566
+ components: [
567
+ { internalType: "address", name: "tokenIn", type: "address" },
568
+ { internalType: "address", name: "tokenOut", type: "address" },
569
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
570
+ { internalType: "uint24", name: "fee", type: "uint24" },
571
+ { internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" }
572
+ ],
573
+ internalType: "struct IQuoterV2.QuoteExactInputSingleParams",
574
+ name: "params",
575
+ type: "tuple"
576
+ }
577
+ ],
578
+ name: "quoteExactInputSingle",
579
+ outputs: [
580
+ { internalType: "uint256", name: "amountOut", type: "uint256" },
581
+ { internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" },
582
+ { internalType: "uint32", name: "initializedTicksCrossed", type: "uint32" },
583
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
584
+ ],
585
+ stateMutability: "nonpayable",
586
+ type: "function"
587
+ },
588
+ {
589
+ inputs: [
590
+ { internalType: "bytes", name: "path", type: "bytes" },
591
+ { internalType: "uint256", name: "amountOut", type: "uint256" }
592
+ ],
593
+ name: "quoteExactOutput",
594
+ outputs: [
595
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
596
+ { internalType: "uint160[]", name: "sqrtPriceX96AfterList", type: "uint160[]" },
597
+ { internalType: "uint32[]", name: "initializedTicksCrossedList", type: "uint32[]" },
598
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
599
+ ],
600
+ stateMutability: "nonpayable",
601
+ type: "function"
602
+ },
603
+ {
604
+ inputs: [
605
+ {
606
+ components: [
607
+ { internalType: "address", name: "tokenIn", type: "address" },
608
+ { internalType: "address", name: "tokenOut", type: "address" },
609
+ { internalType: "uint256", name: "amount", type: "uint256" },
610
+ { internalType: "uint24", name: "fee", type: "uint24" },
611
+ { internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" }
612
+ ],
613
+ internalType: "struct IQuoterV2.QuoteExactOutputSingleParams",
614
+ name: "params",
615
+ type: "tuple"
616
+ }
617
+ ],
618
+ name: "quoteExactOutputSingle",
619
+ outputs: [
620
+ { internalType: "uint256", name: "amountIn", type: "uint256" },
621
+ { internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" },
622
+ { internalType: "uint32", name: "initializedTicksCrossed", type: "uint32" },
623
+ { internalType: "uint256", name: "gasEstimate", type: "uint256" }
624
+ ],
625
+ stateMutability: "nonpayable",
626
+ type: "function"
627
+ },
628
+ {
629
+ inputs: [
630
+ { internalType: "int256", name: "amount0Delta", type: "int256" },
631
+ { internalType: "int256", name: "amount1Delta", type: "int256" },
632
+ { internalType: "bytes", name: "path", type: "bytes" }
633
+ ],
634
+ name: "uniswapV3SwapCallback",
635
+ outputs: [],
636
+ stateMutability: "view",
637
+ type: "function"
638
+ }
639
+ ];
640
+ var UNISWAP_V3_FACTORY_ABI = [
641
+ {
642
+ inputs: [],
643
+ stateMutability: "nonpayable",
644
+ type: "constructor"
645
+ },
646
+ {
647
+ inputs: [
648
+ { internalType: "address", name: "tokenA", type: "address" },
649
+ { internalType: "address", name: "tokenB", type: "address" },
650
+ { internalType: "uint24", name: "fee", type: "uint24" }
651
+ ],
652
+ name: "getPool",
653
+ outputs: [{ internalType: "address", name: "", type: "address" }],
654
+ stateMutability: "view",
655
+ type: "function"
656
+ }
657
+ ];
511
658
  var ERC20_ABI = [
512
659
  {
513
660
  type: "function",
@@ -727,7 +874,7 @@ var ManiaSDK = class _ManiaSDK {
727
874
  }
728
875
  /**
729
876
  * Get comprehensive token information
730
- *
877
+ *
731
878
  * @param token - Token address
732
879
  */
733
880
  async getTokenInfo(token) {
@@ -741,6 +888,18 @@ var ManiaSDK = class _ManiaSDK {
741
888
  migrationProgress: curve.getMigrationProgress()
742
889
  };
743
890
  }
891
+ /**
892
+ * Get token name and symbol
893
+ *
894
+ * @param token - Token address
895
+ */
896
+ async getTokenMetadata(token) {
897
+ const [name, symbol] = await Promise.all([
898
+ this.publicClient.readContract({ address: token, abi: ERC20_ABI, functionName: "name" }),
899
+ this.publicClient.readContract({ address: token, abi: ERC20_ABI, functionName: "symbol" })
900
+ ]);
901
+ return { name, symbol };
902
+ }
744
903
  /**
745
904
  * Get buy quote from contract
746
905
  *
@@ -1095,6 +1254,85 @@ var ManiaSDK = class _ManiaSDK {
1095
1254
  getWalletClient() {
1096
1255
  return this.walletClient;
1097
1256
  }
1257
+ // ========== MIGRATED TOKEN METHODS ==========
1258
+ /**
1259
+ * Get chain config or throw if not found
1260
+ */
1261
+ getChainConfigOrThrow() {
1262
+ const config = getChainConfig(this.chainId);
1263
+ if (!config) {
1264
+ throw new Error(`Chain config not found for chain ID: ${this.chainId}`);
1265
+ }
1266
+ return config;
1267
+ }
1268
+ /**
1269
+ * Get quote for buying tokens with ETH on Kumbaya DEX (Uniswap V3)
1270
+ * Use this for tokens that have migrated from the bonding curve
1271
+ *
1272
+ * @param token - Token address
1273
+ * @param ethAmount - ETH amount in wei
1274
+ * @returns Token amount out
1275
+ */
1276
+ async getMigratedBuyQuote(token, ethAmount) {
1277
+ const chainConfig = this.getChainConfigOrThrow();
1278
+ const { result } = await this.publicClient.simulateContract({
1279
+ address: chainConfig.quoterV2,
1280
+ abi: QUOTER_V2_ABI,
1281
+ functionName: "quoteExactInputSingle",
1282
+ args: [{
1283
+ tokenIn: chainConfig.wethAddress,
1284
+ tokenOut: token,
1285
+ amountIn: ethAmount,
1286
+ fee: UNISWAP_FEE_TIER,
1287
+ sqrtPriceLimitX96: 0n
1288
+ }]
1289
+ });
1290
+ return result[0];
1291
+ }
1292
+ /**
1293
+ * Get quote for selling tokens for ETH on Kumbaya DEX (Uniswap V3)
1294
+ * Use this for tokens that have migrated from the bonding curve
1295
+ *
1296
+ * @param token - Token address
1297
+ * @param tokenAmount - Token amount to sell
1298
+ * @returns ETH amount out in wei
1299
+ */
1300
+ async getMigratedSellQuote(token, tokenAmount) {
1301
+ const chainConfig = this.getChainConfigOrThrow();
1302
+ const { result } = await this.publicClient.simulateContract({
1303
+ address: chainConfig.quoterV2,
1304
+ abi: QUOTER_V2_ABI,
1305
+ functionName: "quoteExactInputSingle",
1306
+ args: [{
1307
+ tokenIn: token,
1308
+ tokenOut: chainConfig.wethAddress,
1309
+ amountIn: tokenAmount,
1310
+ fee: UNISWAP_FEE_TIER,
1311
+ sqrtPriceLimitX96: 0n
1312
+ }]
1313
+ });
1314
+ return result[0];
1315
+ }
1316
+ /**
1317
+ * Get the Uniswap V3 pool address for a token/WETH pair
1318
+ *
1319
+ * @param token - Token address
1320
+ * @returns Pool address
1321
+ * @throws Error if pool not found
1322
+ */
1323
+ async getPoolAddress(token) {
1324
+ const chainConfig = this.getChainConfigOrThrow();
1325
+ const poolAddress = await this.publicClient.readContract({
1326
+ address: chainConfig.uniswapV3Factory,
1327
+ abi: UNISWAP_V3_FACTORY_ABI,
1328
+ functionName: "getPool",
1329
+ args: [token, chainConfig.wethAddress, UNISWAP_FEE_TIER]
1330
+ });
1331
+ if (poolAddress === "0x0000000000000000000000000000000000000000") {
1332
+ throw new Error(`Pool not found for token ${token}`);
1333
+ }
1334
+ return poolAddress;
1335
+ }
1098
1336
  };
1099
1337
 
1100
1338
  // src/utils.ts
@@ -1200,11 +1438,13 @@ async function withRetry(fn, maxRetries = 3, baseDelayMs = 1e3) {
1200
1438
  MIGRATION_THRESHOLD,
1201
1439
  ManiaSDK,
1202
1440
  PROTOCOL_FEE_BASIS_POINTS,
1441
+ QUOTER_V2_ABI,
1203
1442
  TICK_LOWER,
1204
1443
  TICK_UPPER,
1205
1444
  TOKENS_FOR_LP,
1206
1445
  TOTAL_FEE_BASIS_POINTS,
1207
1446
  UNISWAP_FEE_TIER,
1447
+ UNISWAP_V3_FACTORY_ABI,
1208
1448
  bpsToPercent,
1209
1449
  calculateBuyAmount,
1210
1450
  calculateMigrationProgress,