mantle-agent-kit-sdk 1.0.2 → 1.0.4

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
@@ -1,6 +1,6 @@
1
1
  # Mantle Agent Kit SDK
2
2
 
3
- TypeScript SDK for seamless integration with DeFi protocols on Mantle Network. Provides unified interfaces for swaps, lending, liquid staking, and cross-chain operations.
3
+ TypeScript SDK for seamless integration with DeFi protocols on Mantle Network. Provides unified interfaces for swaps, lending, liquid staking, perpetual trading, and cross-chain operations.
4
4
 
5
5
  Part of [Mantle DevKit](https://mantle-devkit.vercel.app) - the complete developer suite for Mantle.
6
6
 
@@ -32,31 +32,23 @@ const txHash = await agent.sendTransaction(
32
32
 
33
33
  ## Supported Protocols
34
34
 
35
- ### DEX Aggregators
36
- - **OKX DEX Aggregator** - Multi-source liquidity aggregation with HMAC authentication
37
- - **1inch** - Pathfinder algorithm for optimal swap routes (optional API key)
38
- - **OpenOcean** - Cross-DEX aggregation for best execution prices
39
-
40
- ### Native Mantle DEXs
41
- - **Agni Finance** - Leading DEX on Mantle with concentrated liquidity (Uniswap V3 architecture)
42
- - **Merchant Moe** - Liquidity Book DEX with dynamic fee tiers (TraderJoe V2.1 architecture)
43
- - **Uniswap V3** - Direct integration with canonical Uniswap V3 contracts
44
-
45
- ### Lending Protocols
46
- - **Lendle** - Mantle's primary lending market with supply, borrow, and collateralization (Aave V2 architecture)
47
-
48
- ### Liquid Staking
49
- - **mETH Protocol** - Mantle's native liquid staking derivative for Ethereum
50
-
51
- ### Cross-Chain Infrastructure
52
- - **Squid Router** - Seamless cross-chain swaps via Axelar network
35
+ | Protocol | Network | Description |
36
+ |----------|---------|-------------|
37
+ | **OKX DEX** | Mainnet | Multi-source liquidity aggregation |
38
+ | **1inch** | Mainnet | Pathfinder algorithm for optimal routes |
39
+ | **OpenOcean** | Mainnet | Cross-DEX aggregation |
40
+ | **Agni Finance** | Mainnet | Concentrated liquidity DEX (Uniswap V3) |
41
+ | **Merchant Moe** | Mainnet | Liquidity Book DEX (TraderJoe V2.1) |
42
+ | **Uniswap V3** | Mainnet | Canonical Uniswap V3 contracts |
43
+ | **Lendle** | Mainnet | Lending market (Aave V2 fork) |
44
+ | **mETH Protocol** | Mainnet | Liquid staking token |
45
+ | **PikePerps** | Testnet | Perpetual futures trading (up to 100x) |
46
+ | **Squid Router** | Mainnet | Cross-chain swaps via Axelar |
53
47
 
54
48
  ## API Reference
55
49
 
56
50
  ### Token Transfers
57
51
 
58
- Send native MNT tokens to any address.
59
-
60
52
  ```typescript
61
53
  await agent.sendTransaction(
62
54
  recipientAddress: Address,
@@ -64,6 +56,8 @@ await agent.sendTransaction(
64
56
  ): Promise<Address>
65
57
  ```
66
58
 
59
+ ---
60
+
67
61
  ### DEX Operations
68
62
 
69
63
  #### OKX DEX Aggregator
@@ -160,12 +154,12 @@ const txHash = await agent.merchantMoeSwap(
160
154
  );
161
155
  ```
162
156
 
157
+ ---
158
+
163
159
  ### Lendle Lending Protocol
164
160
 
165
161
  #### Supply Assets
166
162
 
167
- Deposit tokens to earn yield and use as collateral.
168
-
169
163
  ```typescript
170
164
  const txHash = await agent.lendleSupply(
171
165
  tokenAddress: Address,
@@ -175,8 +169,6 @@ const txHash = await agent.lendleSupply(
175
169
 
176
170
  #### Withdraw Assets
177
171
 
178
- Withdraw previously supplied tokens.
179
-
180
172
  ```typescript
181
173
  const txHash = await agent.lendleWithdraw(
182
174
  tokenAddress: Address,
@@ -187,46 +179,158 @@ const txHash = await agent.lendleWithdraw(
187
179
 
188
180
  #### Borrow Assets
189
181
 
190
- Borrow against supplied collateral.
191
-
192
182
  ```typescript
193
183
  const txHash = await agent.lendleBorrow(
194
184
  tokenAddress: Address,
195
185
  amount: string,
196
186
  interestRateMode?: 1 | 2, // 1 = stable, 2 = variable (default)
197
- onBehalfOf?: Address // optional
187
+ onBehalfOf?: Address
198
188
  );
199
189
  ```
200
190
 
201
191
  #### Repay Debt
202
192
 
203
- Repay borrowed assets.
204
-
205
193
  ```typescript
206
194
  const txHash = await agent.lendleRepay(
207
195
  tokenAddress: Address,
208
196
  amount: string,
209
197
  rateMode?: 1 | 2, // 1 = stable, 2 = variable (default)
210
- onBehalfOf?: Address // optional
198
+ onBehalfOf?: Address
199
+ );
200
+ ```
201
+
202
+ #### View Account Data
203
+
204
+ ```typescript
205
+ const accountData = await agent.lendleGetUserAccountData(
206
+ userAddress?: Address // optional, defaults to agent account
207
+ );
208
+ // Returns: {
209
+ // totalCollateralETH: bigint,
210
+ // totalDebtETH: bigint,
211
+ // availableBorrowsETH: bigint,
212
+ // currentLiquidationThreshold: bigint,
213
+ // ltv: bigint,
214
+ // healthFactor: bigint
215
+ // }
216
+ ```
217
+
218
+ #### View All Positions
219
+
220
+ ```typescript
221
+ const positions = await agent.lendleGetPositions(
222
+ userAddress?: Address // optional, defaults to agent account
211
223
  );
224
+ // Returns: {
225
+ // positions: LendlePosition[],
226
+ // totalSupplied: bigint,
227
+ // totalDebt: bigint
228
+ // }
212
229
  ```
213
230
 
214
- ### mETH Protocol
231
+ ---
215
232
 
216
- Access Mantle's liquid staking token address.
233
+ ### mETH Protocol (Liquid Staking)
217
234
 
218
235
  ```typescript
236
+ // Get mETH token address
219
237
  const methAddress = agent.getMethTokenAddress();
220
238
  // Returns: 0xcDA86A272531e8640cD7F1a92c01839911B90bb0 (mainnet)
239
+
240
+ // View mETH position (balances)
241
+ const position = await agent.methGetPosition(
242
+ userAddress?: Address // optional, defaults to agent account
243
+ );
244
+ // Returns: {
245
+ // methBalance: bigint,
246
+ // wethBalance: bigint,
247
+ // wmntBalance: bigint,
248
+ // methTokenAddress: Address,
249
+ // wethTokenAddress: Address,
250
+ // wmntTokenAddress: Address
251
+ // }
252
+
253
+ // Swap WETH to mETH via DEX
254
+ const txHash = await agent.swapToMeth(
255
+ amount: string, // WETH amount in wei
256
+ slippage?: number // default: 0.5
257
+ );
258
+
259
+ // Swap mETH to WETH via DEX
260
+ const txHash = await agent.swapFromMeth(
261
+ amount: string, // mETH amount in wei
262
+ slippage?: number // default: 0.5
263
+ );
221
264
  ```
222
265
 
223
- Note: To stake ETH for mETH, use the [official mETH interface](https://www.mantle-meth.xyz/).
266
+ > **Note**: Actual ETH staking happens on Ethereum L1. On Mantle L2, you can swap to/from mETH via DEX or use it in DeFi protocols. To stake ETH for mETH on L1, use the [official mETH interface](https://www.mantle-meth.xyz/).
267
+
268
+ ---
269
+
270
+ ### PikePerps - Perpetual Trading
224
271
 
225
- ### Cross-Chain Operations
272
+ Trade perpetual futures with up to 100x leverage on meme tokens.
226
273
 
227
- #### Squid Router
274
+ > **Network**: Mantle Sepolia Testnet only
228
275
 
229
- Execute cross-chain swaps via Axelar network.
276
+ #### Open Long Position
277
+
278
+ ```typescript
279
+ const result = await agent.pikeperpsOpenLong(
280
+ tokenAddress: Address, // Meme token to trade
281
+ margin: string, // Margin in wei
282
+ leverage?: number // 1-100, default: 10
283
+ );
284
+ // Returns: { positionId: bigint, txHash: Hex }
285
+ ```
286
+
287
+ #### Open Short Position
288
+
289
+ ```typescript
290
+ const result = await agent.pikeperpsOpenShort(
291
+ tokenAddress: Address,
292
+ margin: string,
293
+ leverage?: number // 1-100, default: 10
294
+ );
295
+ // Returns: { positionId: bigint, txHash: Hex }
296
+ ```
297
+
298
+ #### Close Position
299
+
300
+ ```typescript
301
+ const txHash = await agent.pikeperpsClosePosition(
302
+ positionId: bigint
303
+ );
304
+ ```
305
+
306
+ #### View Positions
307
+
308
+ ```typescript
309
+ const positions = await agent.pikeperpsGetPositions(
310
+ userAddress?: Address // optional, defaults to agent account
311
+ );
312
+ // Returns: PikePerpsPosition[] with:
313
+ // positionId, token, isLong, size, margin, leverage,
314
+ // entryPrice, currentPrice, pnl, isProfit,
315
+ // liquidationPrice, isOpen
316
+ ```
317
+
318
+ #### Get Market Data
319
+
320
+ ```typescript
321
+ const marketData = await agent.pikeperpsGetMarketData(
322
+ tokenAddress: Address,
323
+ limit?: number // default: 20
324
+ );
325
+ // Returns: {
326
+ // token, currentPrice, hasPrice, isListed, curveProgress,
327
+ // recentTrades: PikePerpsTrade[]
328
+ // }
329
+ ```
330
+
331
+ ---
332
+
333
+ ### Cross-Chain Operations (Squid Router)
230
334
 
231
335
  ```typescript
232
336
  // Get cross-chain route
@@ -250,14 +354,14 @@ const txHash = await agent.crossChainSwapViaSquid(
250
354
  );
251
355
  ```
252
356
 
357
+ ---
358
+
253
359
  ## Configuration
254
360
 
255
361
  ### Environment Variables
256
362
 
257
363
  #### Platform Configuration (Required)
258
364
 
259
- The Mantle Agent Kit requires an APP_ID for platform validation and authentication.
260
-
261
365
  ```env
262
366
  APP_ID=your_app_id_here
263
367
 
@@ -265,10 +369,6 @@ APP_ID=your_app_id_here
265
369
  PLATFORM_URL=https://mantle-devkit.vercel.app
266
370
  ```
267
371
 
268
- **What is APP_ID?**
269
-
270
- APP_ID is a unique identifier that authenticates your application and validates access to the Mantle Agent Kit. When you call `agent.initialize()`, it validates your APP_ID with the platform API and returns your project configuration (name, payout address, network, status).
271
-
272
372
  #### OKX DEX (Required for OKX methods)
273
373
 
274
374
  ```env
@@ -286,49 +386,60 @@ ONEINCH_API_KEY=your_api_key
286
386
 
287
387
  ### Network Configuration
288
388
 
289
- The SDK supports both Mantle mainnet and testnet:
290
-
291
- - **Mainnet**: Chain ID 5000
292
- - **Testnet**: Chain ID 5003 (Sepolia)
389
+ | Network | Chain ID | Usage |
390
+ |---------|----------|-------|
391
+ | Mainnet | 5000 | Production (DEX, Lendle, mETH) |
392
+ | Testnet (Sepolia) | 5003 | Development, PikePerps |
293
393
 
294
394
  ```typescript
295
395
  const mainnetAgent = new MNTAgentKit(privateKey, "mainnet");
296
396
  const testnetAgent = new MNTAgentKit(privateKey, "testnet");
297
397
  ```
298
398
 
299
- ## Contract Addresses
399
+ ### Demo/Simulation Mode
400
+
401
+ ```typescript
402
+ // Initialize agent in demo mode
403
+ const demoAgent = new MNTAgentKit(privateKey, "testnet-demo");
404
+
405
+ // All operations return mock responses
406
+ const result = await demoAgent.swapOnUniswap(tokenA, tokenB, amount);
407
+ // Returns: { txHash: "0xdemo...", demo: true, message: "..." }
408
+ ```
300
409
 
301
- All protocol contract addresses are pre-configured for Mantle Mainnet:
410
+ ---
411
+
412
+ ## Contract Addresses
302
413
 
303
- **Lendle Protocol**
304
- - LendingPool: `0xCFa5aE7c2CE8Fadc6426C1ff872cA45378Fb7cF3`
305
- - DataProvider: `0xD0E0b5e99c8a36f4c5234cd1E90CFc5C2Bb58A69`
414
+ ### Mainnet (Chain ID: 5000)
306
415
 
307
- **Agni Finance**
308
- - Factory: `0x25780dc8Fc3cfBD75F33bFDAB65e969b603b2035`
309
- - SwapRouter: `0x319B69888b0d11cEC22caA5034e25FfFBDc88421`
310
- - NonfungiblePositionManager: `0x9C9e335A3BC0EF6F66F44390c383D0bB7a0A34f0`
416
+ | Protocol | Contract | Address |
417
+ |----------|----------|---------|
418
+ | **mETH** | Token | `0xcDA86A272531e8640cD7F1a92c01839911B90bb0` |
419
+ | **WETH** | Token | `0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111` |
420
+ | **WMNT** | Token | `0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8` |
421
+ | **Lendle** | LendingPool | `0xCFa5aE7c2CE8Fadc6426C1ff872cA45378Fb7cF3` |
422
+ | **Lendle** | DataProvider | `0x552b9e4bae485C4B7F540777d7D25614CdB84773` |
423
+ | **Agni** | Factory | `0x25780dc8Fc3cfBD75F33bFDAB65e969b603b2035` |
424
+ | **Agni** | SwapRouter | `0x319B69888b0d11cEC22caA5034e25FfFBDc88421` |
425
+ | **Merchant Moe** | LBRouter | `0x013e138EF6008ae5FDFDE29700e3f2Bc61d21E3a` |
426
+ | **Uniswap V3** | SwapRouter | `0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45` |
311
427
 
312
- **Merchant Moe**
313
- - LBRouter: `0x013e138EF6008ae5FDFDE29700e3f2Bc61d21E3a`
314
- - LBFactory: `0xa6630671775c4EA2743840F9A5016dCf2A104054`
315
- - LBQuoter: `0xFa1ec885c522Ee2c06aFCfBC66E88a88ca09EEED`
428
+ ### Testnet (Chain ID: 5003)
316
429
 
317
- **mETH Protocol**
318
- - mETH Token: `0xcDA86A272531e8640cD7F1a92c01839911B90bb0`
430
+ | Protocol | Contract | Address |
431
+ |----------|----------|---------|
432
+ | **PikePerps** | PerpetualTrading | `0x8081b646f349c049f2d5e8a400057d411dd657bd` |
433
+ | **PikePerps** | BondingCurveMarket | `0x93b268325A9862645c82b32229f3B52264750Ca2` |
319
434
 
320
- **Uniswap V3**
321
- - SwapRouter: `0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45`
322
- - QuoterV2: `0x61fFE014bA17989E743c5F6cB21bF9697530B21e`
435
+ Verify addresses on [Mantlescan](https://mantlescan.xyz).
323
436
 
324
- Verify current addresses on [Mantlescan](https://mantlescan.xyz).
437
+ ---
325
438
 
326
439
  ## Advanced Usage
327
440
 
328
441
  ### Accessing Protocol Constants
329
442
 
330
- Import protocol-specific constants for advanced integrations:
331
-
332
443
  ```typescript
333
444
  import {
334
445
  AgniConstants,
@@ -336,26 +447,37 @@ import {
336
447
  MerchantMoeConstants,
337
448
  MethConstants,
338
449
  UniswapConstants,
450
+ PikePerpsConstants,
339
451
  } from "mantle-agent-kit-sdk";
340
452
 
341
453
  // Example: Get Lendle pool address
342
454
  const poolAddress = LendleConstants.LENDING_POOL.mainnet;
455
+
456
+ // Example: Get PikePerps contract
457
+ const perpsAddress = PikePerpsConstants.PERPETUAL_TRADING.testnet;
458
+
459
+ // Example: Get mETH/WETH/WMNT addresses
460
+ const methToken = MethConstants.METH_TOKEN.mainnet;
461
+ const wethToken = MethConstants.WETH_TOKEN.mainnet;
462
+ const wmntToken = MethConstants.WMNT_TOKEN.mainnet;
343
463
  ```
344
464
 
345
465
  ### Type Definitions
346
466
 
347
- Import utility types for type-safe development:
348
-
349
467
  ```typescript
350
- import type { UserAccountData, ProjectConfig } from "mantle-agent-kit-sdk";
351
-
352
- // UserAccountData returned from Lendle user queries
353
- // ProjectConfig returned from platform validation
468
+ import type {
469
+ UserAccountData,
470
+ ProjectConfig,
471
+ LendlePosition,
472
+ LendlePositionsResult,
473
+ MethPosition,
474
+ PikePerpsPosition,
475
+ PikePerpsMarketData,
476
+ PikePerpsTrade,
477
+ } from "mantle-agent-kit-sdk";
354
478
  ```
355
479
 
356
- ### Accessing Project Configuration
357
-
358
- After initializing the agent, you can access the validated project configuration:
480
+ ### Project Configuration
359
481
 
360
482
  ```typescript
361
483
  const agent = new MNTAgentKit(privateKey, "mainnet");
@@ -368,6 +490,8 @@ console.log("Network:", agent.projectConfig?.network);
368
490
  console.log("Status:", agent.projectConfig?.status);
369
491
  ```
370
492
 
493
+ ---
494
+
371
495
  ## Development
372
496
 
373
497
  ### Build from Source
@@ -393,6 +517,8 @@ dist/
393
517
  └── *.map # Source maps
394
518
  ```
395
519
 
520
+ ---
521
+
396
522
  ## License
397
523
 
398
524
  MIT