@paraswap/dex-lib 4.3.11 → 4.3.12
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/build/abi/PendleOracle.json +413 -0
- package/build/abi/algebra-integral/AlgebraFactory.abi.json +947 -0
- package/build/abi/algebra-integral/Quoter.abi.json +231 -0
- package/build/abi/algebra-integral/SwapRouter.abi.json +810 -0
- package/build/abi/ekubo/twamm-data-fetcher.json +216 -0
- package/build/abi/ekubo/twamm.json +720 -0
- package/build/abi/ring-v2/few-wrapped-token.json +587 -0
- package/build/abi/ring-v2/ring-v2-factory.json +125 -0
- package/build/abi/ring-v2/ring-v2-pool.json +461 -0
- package/build/abi/ring-v2/ring-v2-router.json +332 -0
- package/build/abi/usdc-transmuter/usdc-transmuter.abi.json +156 -0
- package/build/dex/aave-v3-pt-roll-over/aave-v3-pt-roll-over.d.ts +58 -0
- package/build/dex/aave-v3-pt-roll-over/aave-v3-pt-roll-over.js +363 -0
- package/build/dex/aave-v3-pt-roll-over/aave-v3-pt-roll-over.js.map +1 -0
- package/build/dex/aave-v3-pt-roll-over/config.d.ts +3 -0
- package/build/dex/aave-v3-pt-roll-over/config.js +42 -0
- package/build/dex/aave-v3-pt-roll-over/config.js.map +1 -0
- package/build/dex/aave-v3-pt-roll-over/constants.d.ts +3 -0
- package/build/dex/aave-v3-pt-roll-over/constants.js +7 -0
- package/build/dex/aave-v3-pt-roll-over/constants.js.map +1 -0
- package/build/dex/aave-v3-pt-roll-over/types.d.ts +30 -0
- package/build/dex/aave-v3-pt-roll-over/types.js +3 -0
- package/build/dex/aave-v3-pt-roll-over/types.js.map +1 -0
- package/build/dex/aave-v3-pt-roll-over/utils.d.ts +4 -0
- package/build/dex/aave-v3-pt-roll-over/utils.js +12 -0
- package/build/dex/aave-v3-pt-roll-over/utils.js.map +1 -0
- package/build/dex/algebra-integral/algebra-integral-factory.d.ts +29 -0
- package/build/dex/algebra-integral/algebra-integral-factory.js +159 -0
- package/build/dex/algebra-integral/algebra-integral-factory.js.map +1 -0
- package/build/dex/algebra-integral/algebra-integral.d.ts +43 -0
- package/build/dex/algebra-integral/algebra-integral.js +425 -0
- package/build/dex/algebra-integral/algebra-integral.js.map +1 -0
- package/build/dex/algebra-integral/config.d.ts +3 -0
- package/build/dex/algebra-integral/config.js +17 -0
- package/build/dex/algebra-integral/config.js.map +1 -0
- package/build/dex/algebra-integral/types.d.ts +35 -0
- package/build/dex/algebra-integral/types.js +10 -0
- package/build/dex/algebra-integral/types.js.map +1 -0
- package/build/dex/balancer-v1/balancer-v1.js +18 -1
- package/build/dex/balancer-v1/balancer-v1.js.map +1 -1
- package/build/dex/balancer-v3/reClammPool.d.ts +23 -0
- package/build/dex/balancer-v3/reClammPool.js +82 -0
- package/build/dex/balancer-v3/reClammPool.js.map +1 -0
- package/build/dex/ekubo/pools/base.d.ts +36 -0
- package/build/dex/ekubo/pools/base.js +289 -0
- package/build/dex/ekubo/pools/base.js.map +1 -0
- package/build/dex/ekubo/pools/full-range.d.ts +23 -0
- package/build/dex/ekubo/pools/full-range.js +99 -0
- package/build/dex/ekubo/pools/full-range.js.map +1 -0
- package/build/dex/ekubo/pools/iface.d.ts +46 -0
- package/build/dex/ekubo/pools/iface.js +75 -0
- package/build/dex/ekubo/pools/iface.js.map +1 -0
- package/build/dex/ekubo/pools/math/twamm/exp2.d.ts +1 -0
- package/build/dex/ekubo/pools/math/twamm/exp2.js +86 -0
- package/build/dex/ekubo/pools/math/twamm/exp2.js.map +1 -0
- package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.d.ts +1 -0
- package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.js +56 -0
- package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.js.map +1 -0
- package/build/dex/ekubo/pools/oracle.d.ts +8 -0
- package/build/dex/ekubo/pools/oracle.js +19 -0
- package/build/dex/ekubo/pools/oracle.js.map +1 -0
- package/build/dex/ekubo/pools/twamm.d.ts +38 -0
- package/build/dex/ekubo/pools/twamm.js +253 -0
- package/build/dex/ekubo/pools/twamm.js.map +1 -0
- package/build/dex/ekubo/pools/utils.d.ts +28 -0
- package/build/dex/ekubo/pools/utils.js +80 -0
- package/build/dex/ekubo/pools/utils.js.map +1 -0
- package/build/dex/miro-migrator/constants.d.ts +1 -1
- package/build/dex/miro-migrator/constants.js +1 -1
- package/build/dex/miro-migrator/miro-migrator-pool.d.ts +5 -5
- package/build/dex/miro-migrator/miro-migrator-pool.js +13 -22
- package/build/dex/miro-migrator/miro-migrator-pool.js.map +1 -1
- package/build/dex/miro-migrator/miro-migrator-state.d.ts +27 -0
- package/build/dex/miro-migrator/miro-migrator-state.js +89 -0
- package/build/dex/miro-migrator/miro-migrator-state.js.map +1 -0
- package/build/dex/miro-migrator/miro-migrator.js +4 -2
- package/build/dex/miro-migrator/miro-migrator.js.map +1 -1
- package/build/dex/sky-converter/config.js +0 -1
- package/build/dex/sky-converter/config.js.map +1 -1
- package/build/dex/sky-converter/sky-converter.js +22 -11
- package/build/dex/sky-converter/sky-converter.js.map +1 -1
- package/build/dex/sky-converter/types.d.ts +1 -1
- package/build/dex/usdc-transmuter/config.d.ts +3 -0
- package/build/dex/usdc-transmuter/config.js +20 -0
- package/build/dex/usdc-transmuter/config.js.map +1 -0
- package/build/dex/usdc-transmuter/constants.d.ts +1 -0
- package/build/dex/usdc-transmuter/constants.js +5 -0
- package/build/dex/usdc-transmuter/constants.js.map +1 -0
- package/build/dex/usdc-transmuter/types.d.ts +20 -0
- package/build/dex/usdc-transmuter/types.js +9 -0
- package/build/dex/usdc-transmuter/types.js.map +1 -0
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +26 -0
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +75 -0
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +1 -0
- package/build/dex/usdc-transmuter/usdc-transmuter.d.ts +37 -0
- package/build/dex/usdc-transmuter/usdc-transmuter.js +148 -0
- package/build/dex/usdc-transmuter/usdc-transmuter.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.AaveV3PtRollOver = void 0;
|
|
40
|
+
const constants_1 = require("../../constants");
|
|
41
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
42
|
+
const utils_1 = require("../../utils");
|
|
43
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
44
|
+
const config_1 = require("./config");
|
|
45
|
+
const abi_1 = require("@ethersproject/abi");
|
|
46
|
+
const PendleOracle_json_1 = __importDefault(require("../../abi/PendleOracle.json"));
|
|
47
|
+
const constants_2 = require("./constants");
|
|
48
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
49
|
+
const utils_2 = require("./utils");
|
|
50
|
+
class AaveV3PtRollOver extends simple_exchange_1.SimpleExchange {
|
|
51
|
+
network;
|
|
52
|
+
dexKey;
|
|
53
|
+
dexHelper;
|
|
54
|
+
unitPrice;
|
|
55
|
+
hasConstantPriceLargeAmounts = false;
|
|
56
|
+
needWrapNative = false;
|
|
57
|
+
isFeeOnTransferSupported = false;
|
|
58
|
+
config;
|
|
59
|
+
marketsCache = new Map();
|
|
60
|
+
oracleInterface;
|
|
61
|
+
logger;
|
|
62
|
+
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.AaveV3PtRollOverConfig);
|
|
63
|
+
constructor(network, dexKey, dexHelper, unitPrice = bigint_constants_1.BI_POWS[18]) {
|
|
64
|
+
super(dexHelper, dexKey);
|
|
65
|
+
this.network = network;
|
|
66
|
+
this.dexKey = dexKey;
|
|
67
|
+
this.dexHelper = dexHelper;
|
|
68
|
+
this.unitPrice = unitPrice;
|
|
69
|
+
this.config = config_1.AaveV3PtRollOverConfig[dexKey][network];
|
|
70
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
71
|
+
this.oracleInterface = new abi_1.Interface(PendleOracle_json_1.default);
|
|
72
|
+
}
|
|
73
|
+
getAdapters() {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
async initializePricing(blockNumber) {
|
|
77
|
+
// Try to fetch real market data from Pendle API
|
|
78
|
+
await this.fetchRealMarketData();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Fetch real market data from Pendle API - Use static configuration for now
|
|
82
|
+
* Note: Market discovery endpoints may require authentication
|
|
83
|
+
*/
|
|
84
|
+
async fetchRealMarketData() {
|
|
85
|
+
// For now, use static configuration since market discovery endpoints
|
|
86
|
+
// may require authentication or different API structure
|
|
87
|
+
this.populateFallbackMarkets();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Populate markets from static configuration when API is unavailable
|
|
91
|
+
* This uses the actual market addresses from the configuration, not mock data
|
|
92
|
+
*/
|
|
93
|
+
populateFallbackMarkets() {
|
|
94
|
+
const configuredMarkets = [
|
|
95
|
+
{
|
|
96
|
+
address: this.config.oldMarketAddress,
|
|
97
|
+
ptAddress: this.config.oldPendleToken.address,
|
|
98
|
+
ptDecimals: this.config.oldPendleToken.decimals,
|
|
99
|
+
ytAddress: constants_1.NULL_ADDRESS, // YT address not needed for rollover
|
|
100
|
+
underlyingAssetAddress: this.config.underlyingAssetAddress.toLowerCase(),
|
|
101
|
+
name: this.config.oldPendleToken.name,
|
|
102
|
+
expiry: this.config.oldPendleToken.expiry,
|
|
103
|
+
chainId: this.network,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
address: this.config.newMarketAddress,
|
|
107
|
+
ptAddress: this.config.newPendleToken.address,
|
|
108
|
+
ptDecimals: this.config.newPendleToken.decimals,
|
|
109
|
+
ytAddress: constants_1.NULL_ADDRESS, // YT address not needed for rollover
|
|
110
|
+
underlyingAssetAddress: this.config.underlyingAssetAddress.toLowerCase(),
|
|
111
|
+
name: this.config.newPendleToken.name,
|
|
112
|
+
expiry: this.config.newPendleToken.expiry,
|
|
113
|
+
chainId: this.network,
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
configuredMarkets.forEach(market => {
|
|
117
|
+
this.marketsCache.set(market.ptAddress.toLowerCase(), market);
|
|
118
|
+
});
|
|
119
|
+
this.logger.info(`${this.dexKey}-${this.network}: Populated ${this.marketsCache.size} markets from static configuration`);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get market details for a given PT address
|
|
123
|
+
*/
|
|
124
|
+
getMarketForPt(ptAddress) {
|
|
125
|
+
const normalizedAddress = ptAddress.toLowerCase();
|
|
126
|
+
// Check cache first
|
|
127
|
+
if (this.marketsCache.has(normalizedAddress)) {
|
|
128
|
+
return this.marketsCache.get(normalizedAddress);
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Batch all oracle calls using multicall for better performance
|
|
134
|
+
*/
|
|
135
|
+
async batchOracleCallsMulticall(srcMarketAddress, destMarketAddress, blockNumber, duration = 1800) {
|
|
136
|
+
// Prepare all calls
|
|
137
|
+
const calls = [
|
|
138
|
+
// Source market oracle state check
|
|
139
|
+
{
|
|
140
|
+
target: this.config.oracleAddress,
|
|
141
|
+
callData: this.oracleInterface.encodeFunctionData('getOracleState', [
|
|
142
|
+
srcMarketAddress,
|
|
143
|
+
duration,
|
|
144
|
+
]),
|
|
145
|
+
decodeFunction: utils_2.oracleStateDecoder,
|
|
146
|
+
},
|
|
147
|
+
// Destination market oracle state check
|
|
148
|
+
{
|
|
149
|
+
target: this.config.oracleAddress,
|
|
150
|
+
callData: this.oracleInterface.encodeFunctionData('getOracleState', [
|
|
151
|
+
destMarketAddress,
|
|
152
|
+
duration,
|
|
153
|
+
]),
|
|
154
|
+
decodeFunction: utils_2.oracleStateDecoder,
|
|
155
|
+
},
|
|
156
|
+
// Source market PT to asset rate
|
|
157
|
+
{
|
|
158
|
+
target: this.config.oracleAddress,
|
|
159
|
+
callData: this.oracleInterface.encodeFunctionData('getPtToAssetRate', [
|
|
160
|
+
srcMarketAddress,
|
|
161
|
+
duration,
|
|
162
|
+
]),
|
|
163
|
+
decodeFunction: utils_2.ptToAssetRateDecoder,
|
|
164
|
+
},
|
|
165
|
+
// Destination market PT to asset rate
|
|
166
|
+
{
|
|
167
|
+
target: this.config.oracleAddress,
|
|
168
|
+
callData: this.oracleInterface.encodeFunctionData('getPtToAssetRate', [
|
|
169
|
+
destMarketAddress,
|
|
170
|
+
duration,
|
|
171
|
+
]),
|
|
172
|
+
decodeFunction: utils_2.ptToAssetRateDecoder,
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
// Execute all calls in one multicall
|
|
176
|
+
const [srcOracleReady, destOracleReady, srcPtToAssetRate, destPtToAssetRate,] = await this.dexHelper.multiWrapper.tryAggregate(true, calls, blockNumber);
|
|
177
|
+
return [
|
|
178
|
+
srcOracleReady.returnData,
|
|
179
|
+
destOracleReady.returnData,
|
|
180
|
+
srcPtToAssetRate.returnData,
|
|
181
|
+
destPtToAssetRate.returnData,
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
185
|
+
if (side === constants_1.SwapSide.BUY) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
189
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
190
|
+
if (srcTokenAddress === destTokenAddress) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
// Check if this is a valid PT-to-PT rollover
|
|
194
|
+
const srcMarket = this.getMarketForPt(srcTokenAddress);
|
|
195
|
+
const destMarket = this.getMarketForPt(destTokenAddress);
|
|
196
|
+
if (!srcMarket || !destMarket) {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
// Ensure both PTs are for the same underlying asset
|
|
200
|
+
if (srcMarket.underlyingAssetAddress !== destMarket.underlyingAssetAddress) {
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
return [`${this.dexKey}_${srcMarket.address}_${destMarket.address}`];
|
|
204
|
+
}
|
|
205
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
206
|
+
if (side === constants_1.SwapSide.BUY) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const _srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
210
|
+
const _destToken = this.dexHelper.config.wrapETH(destToken);
|
|
211
|
+
const srcTokenAddress = _srcToken.address;
|
|
212
|
+
const destTokenAddress = _destToken.address;
|
|
213
|
+
// Get market details
|
|
214
|
+
const srcMarket = this.getMarketForPt(srcTokenAddress);
|
|
215
|
+
const destMarket = this.getMarketForPt(destTokenAddress);
|
|
216
|
+
if (!srcMarket || !destMarket) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
// Batch all oracle calls using multicall for better performance
|
|
220
|
+
const [srcOracleReady, destOracleReady, srcPtToAssetRate, destPtToAssetRate,] = await this.batchOracleCallsMulticall(srcMarket.address, destMarket.address, blockNumber);
|
|
221
|
+
if (!srcOracleReady || !destOracleReady) {
|
|
222
|
+
this.logger.error(`${this.dexKey}-${this.network}: ${srcOracleReady ? '' : 'src'}${destOracleReady ? '' : 'dest'} oracle not ready`);
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
const prices = [];
|
|
226
|
+
// Calculate exchange rate: srcPT -> asset -> destPT
|
|
227
|
+
// srcPtAmount * srcPtToAssetRate / destPtToAssetRate = destPtAmount
|
|
228
|
+
const exchangeRate = (srcPtToAssetRate * this.unitPrice) / destPtToAssetRate;
|
|
229
|
+
for (const amount of amounts) {
|
|
230
|
+
if (amount === 0n) {
|
|
231
|
+
prices.push(0n);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
// Calculate output amount
|
|
235
|
+
const outputAmount = (amount * exchangeRate) / BigInt(this.unitPrice);
|
|
236
|
+
// Price is output/input ratio
|
|
237
|
+
const effectivePrice = (outputAmount * BigInt(this.unitPrice)) / amount;
|
|
238
|
+
prices.push(effectivePrice);
|
|
239
|
+
}
|
|
240
|
+
const data = {
|
|
241
|
+
srcMarketAddress: srcMarket.address,
|
|
242
|
+
destMarketAddress: destMarket.address,
|
|
243
|
+
};
|
|
244
|
+
return [
|
|
245
|
+
{
|
|
246
|
+
prices,
|
|
247
|
+
unit: this.unitPrice,
|
|
248
|
+
data,
|
|
249
|
+
poolAddresses: [srcMarket.address],
|
|
250
|
+
exchange: this.dexKey,
|
|
251
|
+
gasCost: constants_2.AAVE_V3_PT_ROLL_OVER_GAS_COST,
|
|
252
|
+
poolIdentifier: `${srcMarket.address}:${destMarket.address}`,
|
|
253
|
+
},
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
getCalldataGasCost() {
|
|
257
|
+
// Based on Pendle transaction complexity - simpler since we're using oracle
|
|
258
|
+
return (CALLDATA_GAS_COST.ZERO_BYTE * 500 + CALLDATA_GAS_COST.NONZERO_BYTE * 200);
|
|
259
|
+
}
|
|
260
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
261
|
+
const payload = '0x';
|
|
262
|
+
return {
|
|
263
|
+
targetExchange: this.config.pendleRouterAddress,
|
|
264
|
+
payload,
|
|
265
|
+
networkFee: '0',
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
269
|
+
const market = this.getMarketForPt(tokenAddress);
|
|
270
|
+
if (!market) {
|
|
271
|
+
// If it's not a PT token we support, return empty
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
// Find other AAVE PT markets for rollover opportunities
|
|
275
|
+
const rolloverOpportunities = [];
|
|
276
|
+
for (const [ptAddress, cachedMarket] of this.marketsCache) {
|
|
277
|
+
if (ptAddress !== tokenAddress.toLowerCase() &&
|
|
278
|
+
cachedMarket.underlyingAssetAddress.toLowerCase() ===
|
|
279
|
+
market.underlyingAssetAddress.toLowerCase()) {
|
|
280
|
+
rolloverOpportunities.push({
|
|
281
|
+
exchange: this.dexKey,
|
|
282
|
+
address: cachedMarket.address,
|
|
283
|
+
connectorTokens: [
|
|
284
|
+
{
|
|
285
|
+
address: cachedMarket.ptAddress,
|
|
286
|
+
decimals: cachedMarket.ptDecimals,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return rolloverOpportunities.slice(0, limit);
|
|
294
|
+
}
|
|
295
|
+
async updatePoolState() {
|
|
296
|
+
// If cache is empty, try to fetch real market data
|
|
297
|
+
if (this.marketsCache.size === 0) {
|
|
298
|
+
await this.fetchRealMarketData();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
async getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side, context, executorAddress) {
|
|
302
|
+
if (side === constants_1.SwapSide.BUY) {
|
|
303
|
+
throw new Error('Buy side not supported for PT rollover');
|
|
304
|
+
}
|
|
305
|
+
// Call Pendle SDK roll-over-pt endpoint for PT rollover
|
|
306
|
+
const rollOverParams = {
|
|
307
|
+
receiver: recipient,
|
|
308
|
+
slippage: constants_2.DEFAULT_SLIPPAGE_FOR_QUOTTING,
|
|
309
|
+
dstMarket: data.destMarketAddress,
|
|
310
|
+
ptAmount: srcAmount,
|
|
311
|
+
};
|
|
312
|
+
const response = await this.callPendleSdkApi(`/v1/sdk/${this.network}/markets/${data.srcMarketAddress}/roll-over-pt`, rollOverParams);
|
|
313
|
+
if (!response.success) {
|
|
314
|
+
throw new Error(`Pendle SDK roll-over-pt endpoint failed: ${response.error || 'No transaction data returned'}`);
|
|
315
|
+
}
|
|
316
|
+
// Extract transaction data from response
|
|
317
|
+
const txData = response.tx || response.data?.tx || response.data;
|
|
318
|
+
if (!txData || !txData.to || !txData.data) {
|
|
319
|
+
throw new Error(`Pendle SDK response missing transaction data. Response: ${JSON.stringify(response)}`);
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
targetExchange: txData.to, // This should be the Pendle Router address
|
|
323
|
+
exchangeData: txData.data, // The actual encoded transaction data
|
|
324
|
+
needWrapNative: false,
|
|
325
|
+
dexFuncHasRecipient: true,
|
|
326
|
+
returnAmountPos: 0,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Call Pendle SDK API for transaction construction
|
|
331
|
+
*/
|
|
332
|
+
async callPendleSdkApi(endpoint, params) {
|
|
333
|
+
try {
|
|
334
|
+
// Build URL with query parameters for GET requests
|
|
335
|
+
const url = new URL(`${constants_2.PENDLE_API_URL}${endpoint}`);
|
|
336
|
+
Object.keys(params).forEach(key => {
|
|
337
|
+
if (params[key] !== undefined && params[key] !== null) {
|
|
338
|
+
url.searchParams.append(key, params[key].toString());
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
const response = await this.dexHelper.httpRequest.get(url.toString(), 30000, // 30 second timeout
|
|
342
|
+
{
|
|
343
|
+
Accept: 'application/json',
|
|
344
|
+
});
|
|
345
|
+
const responseData = response;
|
|
346
|
+
return {
|
|
347
|
+
success: true,
|
|
348
|
+
data: responseData.data || responseData, // Handle different response structures
|
|
349
|
+
tx: responseData.tx || responseData.data?.tx, // Extract transaction data
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
this.logger.error(`${this.dexKey}-${this.network}: Pendle SDK API call failed for ${endpoint}:`, error);
|
|
354
|
+
return {
|
|
355
|
+
success: false,
|
|
356
|
+
error: error?.message || 'Unknown error',
|
|
357
|
+
data: null,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
exports.AaveV3PtRollOver = AaveV3PtRollOver;
|
|
363
|
+
//# sourceMappingURL=aave-v3-pt-roll-over.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aave-v3-pt-roll-over.js","sourceRoot":"","sources":["../../../src/dex/aave-v3-pt-roll-over/aave-v3-pt-roll-over.ts"],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AM,IAAI,IAAI,CAAC,OAAO,oCAAoC,QAAQ,GAAG,EAC7E,KAAK,CACN,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,EAAE,OAAO,IAAI,eAAe;gBACxC,IAAI,EAAE,IAAI;aACX,CAAC;QACJ,CAAC;IACH,CAAC;;AAtcH,4CAucC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AaveV3PtRollOverConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
// Pendle V4 Router https://etherscan.io/address/0x888888888889758f76e7103c6cbf23abbf58f946#code
|
|
6
|
+
const PENDLE_ROUTER_ADDRESS = '0x888888888889758f76e7103c6cbf23abbf58f946';
|
|
7
|
+
// sUSDe PT 29 May 2025 https://etherscan.io/address/0xb7de5dfcb74d25c2f21841fbd6230355c50d9308
|
|
8
|
+
const OLD_PT_ADDRESS = '0xb7de5dfcb74d25c2f21841fbd6230355c50d9308';
|
|
9
|
+
// sUSDe PT 31 Jul 2025 https://etherscan.io/address/0x3b3fb9c57858ef816833dc91565efcd85d96f634
|
|
10
|
+
const NEW_PT_ADDRESS = '0x3b3fb9c57858ef816833dc91565efcd85d96f634';
|
|
11
|
+
// sUSDe Market 29 May 2025 https://etherscan.io/address/0xb162b764044697cf03617c2efbcb1f42e31e4766
|
|
12
|
+
const OLD_MARKET_ADDRESS = '0xb162b764044697cf03617c2efbcb1f42e31e4766';
|
|
13
|
+
// sUSDe Market 31 Jul 2025 https://etherscan.io/address/0x4339ffe2b7592dc783ed13cce310531ab366deac
|
|
14
|
+
const NEW_MARKET_ADDRESS = '0x4339ffe2b7592dc783ed13cce310531ab366deac';
|
|
15
|
+
// Pendle Oracle https://etherscan.io/address/0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2
|
|
16
|
+
const ORACLE_ADDRESS = '0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2';
|
|
17
|
+
// sUSDe Token https://etherscan.io/address/0x9D39A5DE30e57443BfF2A8307A4256c8797A3497
|
|
18
|
+
const UNDERLYING_TOKEN_ADDRESS = '0x9D39A5DE30e57443BfF2A8307A4256c8797A3497';
|
|
19
|
+
exports.AaveV3PtRollOverConfig = {
|
|
20
|
+
AaveV3PtRollOver: {
|
|
21
|
+
[constants_1.Network.MAINNET]: {
|
|
22
|
+
pendleRouterAddress: PENDLE_ROUTER_ADDRESS,
|
|
23
|
+
oldPendleToken: {
|
|
24
|
+
address: OLD_PT_ADDRESS,
|
|
25
|
+
decimals: 18,
|
|
26
|
+
name: 'PT-sUSDe-29MAY2025',
|
|
27
|
+
expiry: 1748476800, // May 29, 2025
|
|
28
|
+
},
|
|
29
|
+
newPendleToken: {
|
|
30
|
+
address: NEW_PT_ADDRESS,
|
|
31
|
+
decimals: 18,
|
|
32
|
+
name: 'PT-sUSDe-31JUL2025',
|
|
33
|
+
expiry: 1753574400, // July 31, 2025
|
|
34
|
+
},
|
|
35
|
+
oldMarketAddress: OLD_MARKET_ADDRESS,
|
|
36
|
+
newMarketAddress: NEW_MARKET_ADDRESS,
|
|
37
|
+
oracleAddress: ORACLE_ADDRESS,
|
|
38
|
+
underlyingAssetAddress: UNDERLYING_TOKEN_ADDRESS,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/aave-v3-pt-roll-over/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE1C,gGAAgG;AAChG,MAAM,qBAAqB,GAAG,4CAA4C,CAAC;AAC3E,+FAA+F;AAC/F,MAAM,cAAc,GAAG,4CAA4C,CAAC;AACpE,+FAA+F;AAC/F,MAAM,cAAc,GAAG,4CAA4C,CAAC;AACpE,mGAAmG;AACnG,MAAM,kBAAkB,GAAG,4CAA4C,CAAC;AACxE,mGAAmG;AACnG,MAAM,kBAAkB,GAAG,4CAA4C,CAAC;AACxE,wFAAwF;AACxF,MAAM,cAAc,GAAG,4CAA4C,CAAC;AACpE,sFAAsF;AACtF,MAAM,wBAAwB,GAAG,4CAA4C,CAAC;AAEjE,QAAA,sBAAsB,GAA4B;IAC7D,gBAAgB,EAAE;QAChB,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,mBAAmB,EAAE,qBAAqB;YAC1C,cAAc,EAAE;gBACd,OAAO,EAAE,cAAc;gBACvB,QAAQ,EAAE,EAAE;gBACZ,IAAI,EAAE,oBAAoB;gBAC1B,MAAM,EAAE,UAAU,EAAE,eAAe;aACpC;YACD,cAAc,EAAE;gBACd,OAAO,EAAE,cAAc;gBACvB,QAAQ,EAAE,EAAE;gBACZ,IAAI,EAAE,oBAAoB;gBAC1B,MAAM,EAAE,UAAU,EAAE,gBAAgB;aACrC;YACD,gBAAgB,EAAE,kBAAkB;YACpC,gBAAgB,EAAE,kBAAkB;YACpC,aAAa,EAAE,cAAc;YAC7B,sBAAsB,EAAE,wBAAwB;SACjD;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AAVE_V3_PT_ROLL_OVER_GAS_COST = exports.DEFAULT_SLIPPAGE_FOR_QUOTTING = exports.PENDLE_API_URL = void 0;
|
|
4
|
+
exports.PENDLE_API_URL = 'https://api-v2.pendle.finance/core';
|
|
5
|
+
exports.DEFAULT_SLIPPAGE_FOR_QUOTTING = 0.01; // 1%
|
|
6
|
+
exports.AAVE_V3_PT_ROLL_OVER_GAS_COST = 200_000; // https://www.tdly.co/shared/simulation/24e4be25-96fc-4011-82af-53065f6140bb
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/aave-v3-pt-roll-over/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,oCAAoC,CAAC;AAEtD,QAAA,6BAA6B,GAAG,IAAI,CAAC,CAAC,KAAK;AAE3C,QAAA,6BAA6B,GAAG,OAAO,CAAC,CAAC,6EAA6E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
export type PendleSDKMarket = {
|
|
3
|
+
address: string;
|
|
4
|
+
ptAddress: string;
|
|
5
|
+
ptDecimals: number;
|
|
6
|
+
ytAddress: string;
|
|
7
|
+
underlyingAssetAddress: string;
|
|
8
|
+
name: string;
|
|
9
|
+
expiry: number;
|
|
10
|
+
chainId: number;
|
|
11
|
+
};
|
|
12
|
+
export type AaveV3PtRollOverData = {
|
|
13
|
+
srcMarketAddress: Address;
|
|
14
|
+
destMarketAddress: Address;
|
|
15
|
+
};
|
|
16
|
+
export type PendleToken = {
|
|
17
|
+
address: Address;
|
|
18
|
+
decimals: number;
|
|
19
|
+
name: string;
|
|
20
|
+
expiry: number;
|
|
21
|
+
};
|
|
22
|
+
export type DexParams = {
|
|
23
|
+
pendleRouterAddress: Address;
|
|
24
|
+
oldPendleToken: PendleToken;
|
|
25
|
+
newPendleToken: PendleToken;
|
|
26
|
+
oldMarketAddress: Address;
|
|
27
|
+
newMarketAddress: Address;
|
|
28
|
+
oracleAddress: Address;
|
|
29
|
+
underlyingAssetAddress: Address;
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/aave-v3-pt-roll-over/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BytesLike } from 'ethers';
|
|
2
|
+
import { MultiResult } from '../../lib/multi-wrapper';
|
|
3
|
+
export declare function oracleStateDecoder(result: MultiResult<BytesLike> | BytesLike): boolean;
|
|
4
|
+
export declare function ptToAssetRateDecoder(result: MultiResult<BytesLike> | BytesLike): bigint;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.oracleStateDecoder = oracleStateDecoder;
|
|
4
|
+
exports.ptToAssetRateDecoder = ptToAssetRateDecoder;
|
|
5
|
+
const decoders_1 = require("../../lib/decoders");
|
|
6
|
+
function oracleStateDecoder(result) {
|
|
7
|
+
return (0, decoders_1.generalDecoder)(result, ['bool', 'uint16', 'bool'], false, value => Boolean(value[2]) && !Boolean(value[0]));
|
|
8
|
+
}
|
|
9
|
+
function ptToAssetRateDecoder(result) {
|
|
10
|
+
return (0, decoders_1.generalDecoder)(result, ['uint256'], 0n, value => value[0].toBigInt());
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/aave-v3-pt-roll-over/utils.ts"],"names":[],"mappings":";;AAIA,gDASC;AAED,oDAIC;AAjBD,iDAAoD;AAEpD,SAAgB,kBAAkB,CAChC,MAA0C;IAE1C,OAAO,IAAA,yBAAc,EACnB,MAAM,EACN,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAC1B,KAAK,EACL,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACjD,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAClC,MAA0C;IAE1C,OAAO,IAAA,yBAAc,EAAC,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
4
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
+
import { Address, Log, Logger } from '../../types';
|
|
6
|
+
import { LogDescription } from 'ethers/lib/utils';
|
|
7
|
+
import { FactoryState, Pool } from './types';
|
|
8
|
+
export declare class AlgebraIntegralFactory extends StatefulEventSubscriber<FactoryState> {
|
|
9
|
+
readonly parentName: string;
|
|
10
|
+
protected network: number;
|
|
11
|
+
protected dexHelper: IDexHelper;
|
|
12
|
+
protected factoryAddress: Address;
|
|
13
|
+
protected subgraphURL: string;
|
|
14
|
+
protected factoryIface: Interface;
|
|
15
|
+
handlers: {
|
|
16
|
+
[event: string]: (event: any) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
logDecoder: (log: Log) => any;
|
|
19
|
+
private pools;
|
|
20
|
+
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, factoryAddress: Address, subgraphURL: string, factoryIface?: Interface);
|
|
21
|
+
initialize(blockNumber: number): Promise<void>;
|
|
22
|
+
generateState(): FactoryState;
|
|
23
|
+
protected processLog(_: DeepReadonly<FactoryState>, log: Readonly<Log>): Promise<FactoryState>;
|
|
24
|
+
getAvailablePoolsForPair(srcToken: Address, destToken: Address, blockNumber: number): Promise<Pool[]>;
|
|
25
|
+
queryAllAvailablePools(blockNumber: number): Promise<Pool[]>;
|
|
26
|
+
private queryOnePageForAllAvailablePoolsFromSubgraph;
|
|
27
|
+
handleNewPool(event: LogDescription): Promise<void>;
|
|
28
|
+
handleNewCustomPool(event: LogDescription): Promise<void>;
|
|
29
|
+
}
|