@continuumdao/ctm-mpc-defi 0.2.34 → 0.2.36
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/agent/catalog.cjs +1562 -45
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +5995 -2960
- package/dist/agent/catalog.js +1502 -46
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/aave-v4/SKILL.md +19 -4
- package/dist/agent/skills/aerodrome/SKILL.md +2 -2
- package/dist/agent/skills/compound-v3/SKILL.md +2 -2
- package/dist/agent/skills/curve-dao/SKILL.md +14 -0
- package/dist/agent/skills/ethena/SKILL.md +3 -1
- package/dist/agent/skills/euler-v2/SKILL.md +1 -1
- package/dist/agent/skills/gmx/SKILL.md +1 -1
- package/dist/agent/skills/hyperliquid/SKILL.md +7 -5
- package/dist/agent/skills/lido/SKILL.md +3 -0
- package/dist/agent/skills/maple-syrup/SKILL.md +35 -3
- package/dist/agent/skills/morpho/SKILL.md +1 -1
- package/dist/agent/skills/pendle/SKILL.md +63 -0
- package/dist/agent/skills/sky/SKILL.md +2 -0
- package/dist/agent/skills/yield-compare/SKILL.md +81 -0
- package/dist/core/index.cjs +2 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +257 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +257 -28
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +170 -0
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.d.ts +59 -1
- package/dist/protocols/evm/aave-v4/index.js +164 -1
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/aerodrome/index.cjs +1308 -901
- package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
- package/dist/protocols/evm/aerodrome/index.d.ts +69 -2
- package/dist/protocols/evm/aerodrome/index.js +1217 -807
- package/dist/protocols/evm/aerodrome/index.js.map +1 -1
- package/dist/protocols/evm/compound-v3/index.cjs +82 -6
- package/dist/protocols/evm/compound-v3/index.cjs.map +1 -1
- package/dist/protocols/evm/compound-v3/index.d.ts +89 -1
- package/dist/protocols/evm/compound-v3/index.js +80 -7
- package/dist/protocols/evm/compound-v3/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +447 -18
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.d.ts +108 -1
- package/dist/protocols/evm/curve-dao/index.js +440 -19
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/ethena/index.cjs +89 -0
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +17 -1
- package/dist/protocols/evm/ethena/index.js +89 -2
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +29 -0
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +21 -1
- package/dist/protocols/evm/euler-v2/index.js +29 -1
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/gmx/index.cjs +83 -1
- package/dist/protocols/evm/gmx/index.cjs.map +1 -1
- package/dist/protocols/evm/gmx/index.d.ts +22 -2
- package/dist/protocols/evm/gmx/index.js +80 -2
- package/dist/protocols/evm/gmx/index.js.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.cjs +67 -11
- package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.d.ts +39 -2
- package/dist/protocols/evm/hyperliquid/index.js +64 -12
- package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +13 -0
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +9 -1
- package/dist/protocols/evm/lido/index.js +13 -1
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +129 -1
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.d.ts +45 -1
- package/dist/protocols/evm/maple/index.js +124 -3
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs +34 -7
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.d.ts +23 -1
- package/dist/protocols/evm/morpho/index.js +34 -8
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/pendle/index.cjs +1530 -0
- package/dist/protocols/evm/pendle/index.cjs.map +1 -0
- package/dist/protocols/evm/pendle/index.d.ts +463 -0
- package/dist/protocols/evm/pendle/index.js +1463 -0
- package/dist/protocols/evm/pendle/index.js.map +1 -0
- package/dist/protocols/evm/sky/index.cjs +52 -0
- package/dist/protocols/evm/sky/index.cjs.map +1 -1
- package/dist/protocols/evm/sky/index.d.ts +16 -1
- package/dist/protocols/evm/sky/index.js +50 -1
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,5 +12,6 @@ export { NEAR_CHAIN_CATEGORY, nearChainCategoryModule } from './chains/near/inde
|
|
|
12
12
|
export { uniswapV4, uniswapV4ProtocolModule } from './protocols/evm/uniswap-v4/index.js';
|
|
13
13
|
export { curveDao, curveDaoProtocolModule } from './protocols/evm/curve-dao/index.js';
|
|
14
14
|
export { aerodromeProtocolModule } from './protocols/evm/aerodrome/index.js';
|
|
15
|
+
export { pendleProtocolModule } from './protocols/evm/pendle/index.js';
|
|
15
16
|
import 'viem';
|
|
16
17
|
import 'abitype';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,112 @@
|
|
|
1
|
+
import { parseAbi, parseAbiItem, hashTypedData, getAddress, zeroAddress, defineChain, createPublicClient, http, parseGwei, serializeTransaction, keccak256, parseUnits, formatUnits, encodeFunctionData, stringToHex, decodeFunctionData, erc20Abi, isAddress } from 'viem';
|
|
1
2
|
import { getClientIdFromKeyGenResult, gasLimitFromEstimateAndChainConfig, fetchChainFeeParams, gweiToDecimalString, proposalTxParamsToFeeSnapshot, alignEip1559FeesWithLatestBase, nodeFetchWithReadAuth } from '@continuumdao/continuum-node-sdk';
|
|
2
3
|
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
3
|
-
import { parseAbi, parseAbiItem, hashTypedData, getAddress, zeroAddress, defineChain, createPublicClient, http, parseGwei, serializeTransaction, keccak256, parseUnits, formatUnits, encodeFunctionData, stringToHex, decodeFunctionData, erc20Abi, isAddress } from 'viem';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __esm = (fn, res) => function __init() {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/core/expiry.ts
|
|
11
|
+
function defiMultisignExpiryUnixSeconds(protocolId, explicitExpiryDate) {
|
|
12
|
+
if (typeof explicitExpiryDate === "number" && Number.isFinite(explicitExpiryDate) && explicitExpiryDate > 0) {
|
|
13
|
+
return Math.floor(explicitExpiryDate);
|
|
14
|
+
}
|
|
15
|
+
if (protocolId && DEFI_PROTOCOLS_WITH_30MIN_EXPIRY.has(protocolId)) {
|
|
16
|
+
return Math.floor(Date.now() / 1e3) + DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS;
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
var DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS, DEFI_PROTOCOLS_WITH_30MIN_EXPIRY;
|
|
21
|
+
var init_expiry = __esm({
|
|
22
|
+
"src/core/expiry.ts"() {
|
|
23
|
+
DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS = 30 * 60;
|
|
24
|
+
DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = /* @__PURE__ */ new Set([
|
|
25
|
+
"uniswap-v4",
|
|
26
|
+
"gmx",
|
|
27
|
+
"hyperliquid",
|
|
28
|
+
"arcus",
|
|
29
|
+
"curve-dao",
|
|
30
|
+
"aerodrome",
|
|
31
|
+
"pendle"
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
function isAerodromeChainSupported(chainId) {
|
|
36
|
+
const n = typeof chainId === "number" ? chainId : Number.parseInt(String(chainId), 10);
|
|
37
|
+
return n === AERODROME_CHAIN_ID;
|
|
38
|
+
}
|
|
39
|
+
var AERODROME_PROTOCOL_ID, AERODROME_CHAIN_ID, AERODROME_WETH_BASE, AERODROME_USDC_BASE;
|
|
40
|
+
var init_support = __esm({
|
|
41
|
+
"src/protocols/evm/aerodrome/support.ts"() {
|
|
42
|
+
AERODROME_PROTOCOL_ID = "aerodrome";
|
|
43
|
+
AERODROME_CHAIN_ID = 8453;
|
|
44
|
+
AERODROME_WETH_BASE = "0x4200000000000000000000000000000000000006";
|
|
45
|
+
AERODROME_USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var AERODROME_BASE_ADDRESSES_FALLBACK;
|
|
49
|
+
var init_addresses = __esm({
|
|
50
|
+
"src/protocols/evm/aerodrome/addresses.ts"() {
|
|
51
|
+
init_support();
|
|
52
|
+
AERODROME_BASE_ADDRESSES_FALLBACK = {
|
|
53
|
+
chainId: AERODROME_CHAIN_ID,
|
|
54
|
+
aero: "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
|
|
55
|
+
router: "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43",
|
|
56
|
+
poolFactory: "0x420DD381b31aEf6683db6B902084cB0FFECe40Da",
|
|
57
|
+
factoryRegistry: "0x5C3F18F06CC09CA1910767A34a20F771039E37C0",
|
|
58
|
+
voter: "0x16613524e02ad97eDfeF371bC883F2F5d6C480A5",
|
|
59
|
+
votingEscrow: "0xeBf418Fe2512e7E6bd9b87a8F0f294aCDC67e6B4",
|
|
60
|
+
rewardsDistributor: "0x227f65131A261548b057215bB1D5Ab2997964C7d",
|
|
61
|
+
mixedQuoter: "0x0A5aA5D3a4d28014f967Bf0f29EAA3FF9807D5c6",
|
|
62
|
+
/** MixedRouteQuoterV3 — v2 + all three CL factories (bitmask path encoding). */
|
|
63
|
+
mixedQuoterV3: "0xCd2A7D98e82D6107eac1828ce8DeAA6acB65b555",
|
|
64
|
+
nfpm: "0x827922686190790b37229fd06084350E74485b72",
|
|
65
|
+
/** Oldest Slipstream CL factory (Gauges V1). Path bit 1<<20. */
|
|
66
|
+
clFactory: "0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A",
|
|
67
|
+
/** Slipstream CL factory 2 (gauge caps). Raw tickSpacing in MixedQuoterV3. */
|
|
68
|
+
clFactory2: "0xaDe65c38CD4849aDBA595a4323a8C7DdfE89716a",
|
|
69
|
+
/** Newest Slipstream CL factory (Gauges V3) — Coinbase B20 stock pools. Path bit 1<<19. */
|
|
70
|
+
clFactory3: "0xf8f2eB4940CFE7d13603DDDD87f123820Fc061Ef",
|
|
71
|
+
universalRouter: "0x6Cb442acF35158D5eDa88fe602221b67B400Be3E",
|
|
72
|
+
swapRouter: "0xBE6D8f0d05cC4be24d5167a3eF062215bE6D18a5",
|
|
73
|
+
swapRouter2: "0xcbBb8035cAc7D4B3Ca7aBb74cF7BdF900215Ce0D",
|
|
74
|
+
swapRouter3: "0x698Cb2b6dd822994581fEa6eA4Fc755d1363A92F",
|
|
75
|
+
pricesOracle: "0xee717411f6E44F9feE011835C8E6FAaC5dEfF166",
|
|
76
|
+
slipstreamHelper: "0x0AD09A66af0154a84e86F761313d02d0abB6edd5",
|
|
77
|
+
lpSugar: "0x69dD9db6d8f8E7d83887A704f447b1a584b599A1",
|
|
78
|
+
sugarSlipstreamHelper: "0x9c62ab10577fB3C20A22E231b7703Ed6D456CC7a",
|
|
79
|
+
swapper: "0x91616a7B9CF6D23f8C17845581051EBdC4BcB916",
|
|
80
|
+
weth: AERODROME_WETH_BASE
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var init_stockTokens = __esm({
|
|
85
|
+
"src/protocols/evm/aerodrome/stockTokens.ts"() {
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
var init_discover = __esm({
|
|
89
|
+
"src/protocols/evm/aerodrome/discover.ts"() {
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
var init_yields = __esm({
|
|
93
|
+
"src/protocols/evm/aerodrome/yields.ts"() {
|
|
94
|
+
init_addresses();
|
|
95
|
+
init_support();
|
|
96
|
+
new Set(
|
|
97
|
+
[
|
|
98
|
+
AERODROME_WETH_BASE,
|
|
99
|
+
AERODROME_USDC_BASE,
|
|
100
|
+
AERODROME_BASE_ADDRESSES_FALLBACK.aero,
|
|
101
|
+
"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
102
|
+
"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
|
|
103
|
+
"0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34",
|
|
104
|
+
"0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
|
|
105
|
+
"0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452"
|
|
106
|
+
].map((a) => a.toLowerCase())
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
6
110
|
|
|
7
111
|
// src/core/purpose.ts
|
|
8
112
|
function mergePurposeText(purposeText, purposeSuffix) {
|
|
@@ -297,25 +401,8 @@ function buildPayloadSignEd25519MultisignBody(args) {
|
|
|
297
401
|
});
|
|
298
402
|
}
|
|
299
403
|
|
|
300
|
-
// src/core/
|
|
301
|
-
|
|
302
|
-
var DEFI_PROTOCOLS_WITH_30MIN_EXPIRY = /* @__PURE__ */ new Set([
|
|
303
|
-
"uniswap-v4",
|
|
304
|
-
"gmx",
|
|
305
|
-
"hyperliquid",
|
|
306
|
-
"arcus",
|
|
307
|
-
"curve-dao",
|
|
308
|
-
"aerodrome"
|
|
309
|
-
]);
|
|
310
|
-
function defiMultisignExpiryUnixSeconds(protocolId, explicitExpiryDate) {
|
|
311
|
-
if (typeof explicitExpiryDate === "number" && Number.isFinite(explicitExpiryDate) && explicitExpiryDate > 0) {
|
|
312
|
-
return Math.floor(explicitExpiryDate);
|
|
313
|
-
}
|
|
314
|
-
if (protocolId && DEFI_PROTOCOLS_WITH_30MIN_EXPIRY.has(protocolId)) {
|
|
315
|
-
return Math.floor(Date.now() / 1e3) + DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS;
|
|
316
|
-
}
|
|
317
|
-
return void 0;
|
|
318
|
-
}
|
|
404
|
+
// src/core/index.ts
|
|
405
|
+
init_expiry();
|
|
319
406
|
function isEvmNativeToken(address) {
|
|
320
407
|
try {
|
|
321
408
|
return getAddress(address) === zeroAddress;
|
|
@@ -3429,6 +3516,22 @@ var curveDaoProtocolModule = {
|
|
|
3429
3516
|
amountHuman: { type: "string", required: true, description: "Human-readable input amount" },
|
|
3430
3517
|
slippagePercent: { type: "number", required: true, description: "Slippage percent (0\u2013100 exclusive)" }
|
|
3431
3518
|
}
|
|
3519
|
+
},
|
|
3520
|
+
{
|
|
3521
|
+
id: "curve-dao.add-liquidity",
|
|
3522
|
+
protocolId: CURVE_DAO_PROTOCOL_ID,
|
|
3523
|
+
chainCategory: "evm",
|
|
3524
|
+
description: "Add liquidity to an important Curve pool (optional gauge stake)",
|
|
3525
|
+
commonParams: ["keyGen", "purposeText", "useCustomGas"],
|
|
3526
|
+
params: {}
|
|
3527
|
+
},
|
|
3528
|
+
{
|
|
3529
|
+
id: "curve-dao.remove-liquidity",
|
|
3530
|
+
protocolId: CURVE_DAO_PROTOCOL_ID,
|
|
3531
|
+
chainCategory: "evm",
|
|
3532
|
+
description: "Remove liquidity from an important Curve pool",
|
|
3533
|
+
commonParams: ["keyGen", "purposeText", "useCustomGas"],
|
|
3534
|
+
params: {}
|
|
3432
3535
|
}
|
|
3433
3536
|
]
|
|
3434
3537
|
};
|
|
@@ -3438,14 +3541,14 @@ var curveDao = {
|
|
|
3438
3541
|
isChainSupported: isCurveApiChainSupported,
|
|
3439
3542
|
loadSession: loadFullCurveSessionForRpc
|
|
3440
3543
|
};
|
|
3441
|
-
var AERODROME_PROTOCOL_ID = "aerodrome";
|
|
3442
|
-
var AERODROME_CHAIN_ID = 8453;
|
|
3443
|
-
function isAerodromeChainSupported(chainId) {
|
|
3444
|
-
const n = typeof chainId === "number" ? chainId : Number.parseInt(String(chainId), 10);
|
|
3445
|
-
return n === AERODROME_CHAIN_ID;
|
|
3446
|
-
}
|
|
3447
3544
|
|
|
3448
3545
|
// src/protocols/evm/aerodrome/index.ts
|
|
3546
|
+
init_support();
|
|
3547
|
+
init_support();
|
|
3548
|
+
init_addresses();
|
|
3549
|
+
init_stockTokens();
|
|
3550
|
+
init_discover();
|
|
3551
|
+
init_yields();
|
|
3449
3552
|
var aerodromeProtocolModule = {
|
|
3450
3553
|
id: AERODROME_PROTOCOL_ID,
|
|
3451
3554
|
chainCategory: "evm",
|
|
@@ -3554,11 +3657,137 @@ var aerodromeProtocolModule = {
|
|
|
3554
3657
|
};
|
|
3555
3658
|
registerProtocolModule(aerodromeProtocolModule);
|
|
3556
3659
|
|
|
3660
|
+
// src/protocols/evm/pendle/support.ts
|
|
3661
|
+
var PENDLE_PROTOCOL_ID = "pendle";
|
|
3662
|
+
var PENDLE_CORE_API_BASE = "https://api-v2.pendle.finance/core";
|
|
3663
|
+
var PENDLE_CHAIN_CACHE_MS = 30 * 60 * 1e3;
|
|
3664
|
+
|
|
3665
|
+
// src/protocols/evm/pendle/api.ts
|
|
3666
|
+
var FETCH_TIMEOUT_MS = 12e4;
|
|
3667
|
+
var PendleApiError = class extends Error {
|
|
3668
|
+
status;
|
|
3669
|
+
path;
|
|
3670
|
+
constructor(message, status, path) {
|
|
3671
|
+
super(message);
|
|
3672
|
+
this.name = "PendleApiError";
|
|
3673
|
+
this.status = status;
|
|
3674
|
+
this.path = path;
|
|
3675
|
+
}
|
|
3676
|
+
};
|
|
3677
|
+
function sleep(ms) {
|
|
3678
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3679
|
+
}
|
|
3680
|
+
function queryString(params) {
|
|
3681
|
+
const q = new URLSearchParams();
|
|
3682
|
+
for (const [k, v] of Object.entries(params)) {
|
|
3683
|
+
if (v === void 0 || v === "") continue;
|
|
3684
|
+
q.set(k, String(v));
|
|
3685
|
+
}
|
|
3686
|
+
const s = q.toString();
|
|
3687
|
+
return s ? `?${s}` : "";
|
|
3688
|
+
}
|
|
3689
|
+
async function pendleCoreFetch(args) {
|
|
3690
|
+
const path = args.path.startsWith("/") ? args.path : `/${args.path}`;
|
|
3691
|
+
const url = `${PENDLE_CORE_API_BASE}${path}${queryString(args.query ?? {})}`;
|
|
3692
|
+
const headers = { Accept: "application/json" };
|
|
3693
|
+
if (args.apiKey?.trim()) headers.Authorization = `Bearer ${args.apiKey.trim()}`;
|
|
3694
|
+
if (args.body !== void 0) headers["Content-Type"] = "application/json";
|
|
3695
|
+
let lastError;
|
|
3696
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
3697
|
+
const ac = new AbortController();
|
|
3698
|
+
const timer = setTimeout(() => ac.abort(), FETCH_TIMEOUT_MS);
|
|
3699
|
+
try {
|
|
3700
|
+
const res = await fetch(url, {
|
|
3701
|
+
method: args.method ?? "GET",
|
|
3702
|
+
headers,
|
|
3703
|
+
body: args.body === void 0 ? void 0 : JSON.stringify(args.body),
|
|
3704
|
+
signal: ac.signal
|
|
3705
|
+
});
|
|
3706
|
+
if (res.status === 429) {
|
|
3707
|
+
const wait = Math.min(8e3, 500 * 2 ** attempt);
|
|
3708
|
+
await sleep(wait);
|
|
3709
|
+
lastError = new PendleApiError(`Pendle API rate limited (429) on ${path}`, 429, path);
|
|
3710
|
+
continue;
|
|
3711
|
+
}
|
|
3712
|
+
const text = await res.text();
|
|
3713
|
+
if (!res.ok) {
|
|
3714
|
+
throw new PendleApiError(
|
|
3715
|
+
`Pendle API ${res.status} ${path}: ${text.slice(0, 400)}`,
|
|
3716
|
+
res.status,
|
|
3717
|
+
path
|
|
3718
|
+
);
|
|
3719
|
+
}
|
|
3720
|
+
if (!text.trim()) return {};
|
|
3721
|
+
return JSON.parse(text);
|
|
3722
|
+
} catch (err) {
|
|
3723
|
+
lastError = err;
|
|
3724
|
+
if (err instanceof PendleApiError && err.status !== 429) throw err;
|
|
3725
|
+
if (attempt < 3 && (err instanceof PendleApiError || err?.name === "AbortError")) {
|
|
3726
|
+
await sleep(Math.min(8e3, 400 * 2 ** attempt));
|
|
3727
|
+
continue;
|
|
3728
|
+
}
|
|
3729
|
+
throw err;
|
|
3730
|
+
} finally {
|
|
3731
|
+
clearTimeout(timer);
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3737
|
+
// src/protocols/evm/pendle/discover.ts
|
|
3738
|
+
var chainIdsCache = null;
|
|
3739
|
+
async function pendleFetchSupportedChainIds() {
|
|
3740
|
+
const now = Date.now();
|
|
3741
|
+
if (chainIdsCache && now - chainIdsCache.at < PENDLE_CHAIN_CACHE_MS) return chainIdsCache.chainIds;
|
|
3742
|
+
const json = await pendleCoreFetch({ path: "/v1/chains" });
|
|
3743
|
+
const ids = Array.isArray(json.chainIds) ? json.chainIds.map((n) => Number(n)).filter((n) => Number.isFinite(n) && n > 0) : [];
|
|
3744
|
+
chainIdsCache = { at: now, chainIds: ids };
|
|
3745
|
+
return ids;
|
|
3746
|
+
}
|
|
3747
|
+
async function isPendleChainSupported(chainId) {
|
|
3748
|
+
try {
|
|
3749
|
+
const ids = await pendleFetchSupportedChainIds();
|
|
3750
|
+
if (ids.length === 0) return true;
|
|
3751
|
+
return ids.includes(chainId);
|
|
3752
|
+
} catch {
|
|
3753
|
+
return true;
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3757
|
+
// src/protocols/evm/pendle/index.ts
|
|
3758
|
+
var pendleProtocolModule = {
|
|
3759
|
+
id: PENDLE_PROTOCOL_ID,
|
|
3760
|
+
chainCategory: "evm",
|
|
3761
|
+
isChainSupported(ctx) {
|
|
3762
|
+
if (ctx.chainCategory !== "evm") return false;
|
|
3763
|
+
const n = typeof ctx.chainId === "number" ? ctx.chainId : Number.parseInt(String(ctx.chainId), 10);
|
|
3764
|
+
if (!Number.isFinite(n)) return false;
|
|
3765
|
+
return isPendleChainSupported(n);
|
|
3766
|
+
},
|
|
3767
|
+
isTokenSupported(token) {
|
|
3768
|
+
if (token.category !== "evm") return false;
|
|
3769
|
+
return token.kind === "native" || token.kind === "erc20";
|
|
3770
|
+
},
|
|
3771
|
+
actions: [
|
|
3772
|
+
{ id: "pendle.fetch-markets", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "List live Pendle markets (TVL-ranked, cap 100, matured omitted)", commonParams: [], params: {} },
|
|
3773
|
+
{ id: "pendle.search-assets", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "Search live PT/YT/SY/underlying (matured only if address-pinned)", commonParams: [], params: {} },
|
|
3774
|
+
{ id: "pendle.swap", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "Swap token \u2194 PT/YT via Hosted SDK convert", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
3775
|
+
{ id: "pendle.mint-py", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "Mint PT + YT", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
3776
|
+
{ id: "pendle.redeem-py", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "Redeem PT + YT (PT only after expiry)", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
3777
|
+
{ id: "pendle.add-liquidity", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "Add Pendle AMM liquidity", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
3778
|
+
{ id: "pendle.fetch-positions", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "List this wallet\u2019s Pendle LP (including matured)", commonParams: [], params: {} },
|
|
3779
|
+
{ id: "pendle.remove-liquidity", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "Remove Pendle AMM liquidity", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} },
|
|
3780
|
+
{ id: "pendle.redeem-rewards", protocolId: PENDLE_PROTOCOL_ID, chainCategory: "evm", description: "Redeem on-chain SY/YT/LP interest and incentives (not merkle airdrops)", commonParams: ["keyGen", "purposeText", "useCustomGas"], params: {} }
|
|
3781
|
+
]
|
|
3782
|
+
};
|
|
3783
|
+
registerProtocolModule(pendleProtocolModule);
|
|
3784
|
+
|
|
3557
3785
|
// src/index.ts
|
|
3558
3786
|
registerProtocolModule(uniswapV4ProtocolModule);
|
|
3559
3787
|
registerProtocolModule(curveDaoProtocolModule);
|
|
3560
3788
|
registerProtocolModule(aerodromeProtocolModule);
|
|
3789
|
+
registerProtocolModule(pendleProtocolModule);
|
|
3561
3790
|
|
|
3562
|
-
export { COINGECKO_PLATFORM_BY_CHAIN_ID, DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS, DEFI_PROTOCOLS_WITH_30MIN_EXPIRY, EIP712_SIGN_REQUEST_KIND, NEAR_CHAIN_CATEGORY, PAYLOAD_SIGN_ED25519_REQUEST_KIND, SOLANA_CHAIN_CATEGORY, aerodromeProtocolModule, approveStepsToEvmTxSteps, buildConditionalErc20ApproveSteps, buildEip712Multisign, buildEvmMultisignBatch, buildPayloadSignEd25519MultisignBody, coingeckoPlatformForChainId, coreChainCategoryModule, curveDao, curveDaoProtocolModule, defiMultisignExpiryUnixSeconds, evmChainCategoryModule, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getEulerV3ApiProxyBase, getJsonViaOptionalProxy, getMapleGraphqlProxyUrl, getMorphoGraphqlProxyUrl, getMorphoMidnightRestProxyUrl, getProtocolModule, getProtocolModules, isEvmNativeToken, matchEvmTokenKind, mergePurposeText, nearChainCategoryModule, normalizeCurveRouterAmountString, normalizeHumanDecimalAmount, parseEvmChainIdToNumber, postJsonViaOptionalProxy, publicClientForRpc, registerProtocolModule, resolveErc20Decimals, routerSwapGasLimitFromEstimate, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setEulerV3ApiProxyBase, setMapleGraphqlProxyUrl, setMorphoGraphqlProxyUrl, setMorphoMidnightRestProxyUrl, solanaChainCategoryModule, uniswapV4, uniswapV4ProtocolModule };
|
|
3791
|
+
export { COINGECKO_PLATFORM_BY_CHAIN_ID, DEFAULT_DEFI_MULTISIGN_EXPIRY_SECONDS, DEFI_PROTOCOLS_WITH_30MIN_EXPIRY, EIP712_SIGN_REQUEST_KIND, NEAR_CHAIN_CATEGORY, PAYLOAD_SIGN_ED25519_REQUEST_KIND, SOLANA_CHAIN_CATEGORY, aerodromeProtocolModule, approveStepsToEvmTxSteps, buildConditionalErc20ApproveSteps, buildEip712Multisign, buildEvmMultisignBatch, buildPayloadSignEd25519MultisignBody, coingeckoPlatformForChainId, coreChainCategoryModule, curveDao, curveDaoProtocolModule, defiMultisignExpiryUnixSeconds, evmChainCategoryModule, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getEulerV3ApiProxyBase, getJsonViaOptionalProxy, getMapleGraphqlProxyUrl, getMorphoGraphqlProxyUrl, getMorphoMidnightRestProxyUrl, getProtocolModule, getProtocolModules, isEvmNativeToken, matchEvmTokenKind, mergePurposeText, nearChainCategoryModule, normalizeCurveRouterAmountString, normalizeHumanDecimalAmount, parseEvmChainIdToNumber, pendleProtocolModule, postJsonViaOptionalProxy, publicClientForRpc, registerProtocolModule, resolveErc20Decimals, routerSwapGasLimitFromEstimate, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setEulerV3ApiProxyBase, setMapleGraphqlProxyUrl, setMorphoGraphqlProxyUrl, setMorphoMidnightRestProxyUrl, solanaChainCategoryModule, uniswapV4, uniswapV4ProtocolModule };
|
|
3563
3792
|
//# sourceMappingURL=index.js.map
|
|
3564
3793
|
//# sourceMappingURL=index.js.map
|