@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/README.md CHANGED
@@ -61,7 +61,7 @@ console.log("Migration Progress:", tokenInfo.migrationProgress, "%");
61
61
  const result = await sdk.create({
62
62
  name: "My Token",
63
63
  symbol: "MTK",
64
- uri: "ipfs://...", // Metadata URI
64
+ uri: "ipfs://...", // Metadata URI (see Token Metadata below)
65
65
  creator: "0x...", // Creator address (receives fees)
66
66
  });
67
67
 
@@ -69,6 +69,60 @@ console.log("Token created:", result.tokenAddress);
69
69
  console.log("Transaction:", result.hash);
70
70
  ```
71
71
 
72
+ ### Token Metadata
73
+
74
+ The `uri` parameter should point to an IPFS URL containing a JSON metadata file. You must upload your metadata JSON to IPFS first, then pass the resulting IPFS URL to the `uri` field.
75
+
76
+ **Metadata Structure:**
77
+
78
+ ```json
79
+ {
80
+ "name": "HOMER",
81
+ "symbol": "HOMER",
82
+ "description": "A description of your token",
83
+ "image": "ipfs://bafybeigpul3iw2yok735e7ozc5siwg7l3gcmuovcsawkzelsq7kwbtexxu",
84
+ "attributes": {
85
+ "twitter": "https://x.com/yourproject",
86
+ "website": "https://yourproject.com",
87
+ "github": "https://github.com/yourproject",
88
+ "discord": "https://discord.gg/yourproject"
89
+ }
90
+ }
91
+ ```
92
+
93
+ **Fields:**
94
+
95
+ | Field | Required | Description |
96
+ |-------|----------|-------------|
97
+ | `name` | Yes | Token display name |
98
+ | `symbol` | Yes | Token symbol (ticker) |
99
+ | `description` | No | Description of the token |
100
+ | `image` | No | IPFS URL to token image (e.g., `ipfs://bafy...`) |
101
+ | `attributes` | No | Social links and additional metadata |
102
+
103
+ **Adding an Image:**
104
+
105
+ 1. Upload your image to IPFS (using Pinata, NFT.Storage, or any IPFS pinning service)
106
+ 2. Get the resulting CID (e.g., `bafybeigpul3iw2yok735e7ozc5siwg7l3gcmuovcsawkzelsq7kwbtexxu`)
107
+ 3. Use the `ipfs://` protocol prefix: `ipfs://<CID>`
108
+ 4. Include this URL in the `image` field of your metadata JSON
109
+ 5. Upload the complete metadata JSON to IPFS
110
+ 6. Pass the metadata IPFS URL as the `uri` parameter when creating the token
111
+
112
+ **Example:**
113
+
114
+ ```typescript
115
+ // After uploading metadata.json to IPFS and getting the CID
116
+ const metadataUri = "ipfs://bafkreihdwdcef3fksy7ygjxwfxjfujdi4mfg6rn4m5jqnz3gyvhqorvnrm";
117
+
118
+ const result = await sdk.create({
119
+ name: "HOMER",
120
+ symbol: "HOMER",
121
+ uri: metadataUri,
122
+ creator: "0x...",
123
+ });
124
+ ```
125
+
72
126
  ### Create and Buy in One Transaction
73
127
 
74
128
  ```typescript
@@ -204,6 +258,15 @@ sdk.watchMigrationEvents((event) => {
204
258
  unwatch();
205
259
  ```
206
260
 
261
+ ### Reading Token Metadata
262
+
263
+ ```typescript
264
+ // Get token name and symbol
265
+ const { name, symbol } = await sdk.getTokenMetadata(tokenAddress);
266
+ console.log("Name:", name);
267
+ console.log("Symbol:", symbol);
268
+ ```
269
+
207
270
  ### Reading Global State
208
271
 
209
272
  ```typescript
@@ -215,6 +278,31 @@ console.log("Pool Migration Fee:", globalState.poolMigrationFee);
215
278
  console.log("Token Total Supply:", globalState.tokenTotalSupply);
216
279
  ```
217
280
 
281
+ ### Trading Migrated Tokens
282
+
283
+ After a token migrates to Uniswap V3, use these methods to get quotes:
284
+
285
+ ```typescript
286
+ import { parseEther } from "viem";
287
+
288
+ // Check if token has migrated
289
+ const isMigrated = await sdk.isMigrated(tokenAddress);
290
+
291
+ if (isMigrated) {
292
+ // Get Uniswap V3 pool address
293
+ const poolAddress = await sdk.getPoolAddress(tokenAddress);
294
+ console.log("Pool:", poolAddress);
295
+
296
+ // Get buy quote (ETH -> Token)
297
+ const tokensOut = await sdk.getMigratedBuyQuote(tokenAddress, parseEther("1"));
298
+ console.log("Tokens for 1 ETH:", tokensOut);
299
+
300
+ // Get sell quote (Token -> ETH)
301
+ const ethOut = await sdk.getMigratedSellQuote(tokenAddress, parseEther("1000"));
302
+ console.log("ETH for 1000 tokens:", ethOut);
303
+ }
304
+ ```
305
+
218
306
  ## Utility Functions
219
307
 
220
308
  ```typescript
package/dist/index.d.mts 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 };