@paraswap/dex-lib 4.6.11 → 4.6.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.
Files changed (104) hide show
  1. package/build/abi/miro-migrator/MiroMigrator.abi.json +36 -19
  2. package/build/dex/algebra/lib/AlgebraMath.js +13 -3
  3. package/build/dex/algebra/lib/AlgebraMath.js.map +1 -1
  4. package/build/dex/algebra/lib/TickManager.js +5 -0
  5. package/build/dex/algebra/lib/TickManager.js.map +1 -1
  6. package/build/dex/idle-dao/idle-dao.d.ts +1 -0
  7. package/build/dex/idle-dao/idle-dao.js +23 -11
  8. package/build/dex/idle-dao/idle-dao.js.map +1 -1
  9. package/build/dex/maker-psm/maker-psm.d.ts +4 -41
  10. package/build/dex/maker-psm/maker-psm.js +41 -144
  11. package/build/dex/maker-psm/maker-psm.js.map +1 -1
  12. package/build/dex/miro-migrator/config.js +3 -10
  13. package/build/dex/miro-migrator/config.js.map +1 -1
  14. package/build/dex/miro-migrator/constants.d.ts +2 -1
  15. package/build/dex/miro-migrator/constants.js +3 -2
  16. package/build/dex/miro-migrator/constants.js.map +1 -1
  17. package/build/dex/miro-migrator/miro-migrator-pool.d.ts +9 -5
  18. package/build/dex/miro-migrator/miro-migrator-pool.js +49 -28
  19. package/build/dex/miro-migrator/miro-migrator-pool.js.map +1 -1
  20. package/build/dex/miro-migrator/miro-migrator.d.ts +5 -4
  21. package/build/dex/miro-migrator/miro-migrator.js +41 -83
  22. package/build/dex/miro-migrator/miro-migrator.js.map +1 -1
  23. package/build/dex/miro-migrator/types.d.ts +2 -4
  24. package/build/dex/miro-migrator/types.js +1 -2
  25. package/build/dex/miro-migrator/types.js.map +1 -1
  26. package/build/dex/pancakeswap-v3/contract-math/Tick.d.ts +1 -1
  27. package/build/dex/pancakeswap-v3/contract-math/Tick.js +10 -1
  28. package/build/dex/pancakeswap-v3/contract-math/Tick.js.map +1 -1
  29. package/build/dex/pancakeswap-v3/contract-math/pancakeswap-v3-math.js +11 -3
  30. package/build/dex/pancakeswap-v3/contract-math/pancakeswap-v3-math.js.map +1 -1
  31. package/build/dex/uniswap-v3/contract-math/Tick.d.ts +1 -1
  32. package/build/dex/uniswap-v3/contract-math/Tick.js +10 -1
  33. package/build/dex/uniswap-v3/contract-math/Tick.js.map +1 -1
  34. package/build/dex/uniswap-v3/contract-math/uniswap-v3-math.js +11 -3
  35. package/build/dex/uniswap-v3/contract-math/uniswap-v3-math.js.map +1 -1
  36. package/build/dex/uniswap-v3/contract-math/utils.js +3 -0
  37. package/build/dex/uniswap-v3/contract-math/utils.js.map +1 -1
  38. package/build/dex/uniswap-v3/types.d.ts +3 -0
  39. package/build/dex/uniswap-v3/types.js.map +1 -1
  40. package/package.json +1 -1
  41. package/build/abi/pangolin-v3/PangolinV3StateMulticall.abi.json +0 -796
  42. package/build/abi/ring-v2/few-wrapped-token.json +0 -587
  43. package/build/abi/ring-v2/ring-v2-factory.json +0 -125
  44. package/build/abi/ring-v2/ring-v2-pool.json +0 -461
  45. package/build/abi/ring-v2/ring-v2-router.json +0 -332
  46. package/build/abi/uniswap-v4/hooks/cabalcoin-hook.abi.json +0 -682
  47. package/build/abi/uniswap-v4/hooks/fee-hook.abi.json +0 -1335
  48. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.d.ts +0 -39
  49. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js +0 -244
  50. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js.map +0 -1
  51. package/build/dex/aave-pt-to-underlying/config.d.ts +0 -3
  52. package/build/dex/aave-pt-to-underlying/config.js +0 -47
  53. package/build/dex/aave-pt-to-underlying/config.js.map +0 -1
  54. package/build/dex/aave-pt-to-underlying/constants.d.ts +0 -2
  55. package/build/dex/aave-pt-to-underlying/constants.js +0 -6
  56. package/build/dex/aave-pt-to-underlying/constants.js.map +0 -1
  57. package/build/dex/aave-pt-to-underlying/types.d.ts +0 -22
  58. package/build/dex/aave-pt-to-underlying/types.js +0 -3
  59. package/build/dex/aave-pt-to-underlying/types.js.map +0 -1
  60. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.d.ts +0 -39
  61. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js +0 -244
  62. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js.map +0 -1
  63. package/build/dex/aave-pt-to-usdc/config.d.ts +0 -3
  64. package/build/dex/aave-pt-to-usdc/config.js +0 -47
  65. package/build/dex/aave-pt-to-usdc/config.js.map +0 -1
  66. package/build/dex/aave-pt-to-usdc/constants.d.ts +0 -2
  67. package/build/dex/aave-pt-to-usdc/constants.js +0 -6
  68. package/build/dex/aave-pt-to-usdc/constants.js.map +0 -1
  69. package/build/dex/aave-pt-to-usdc/types.d.ts +0 -22
  70. package/build/dex/aave-pt-to-usdc/types.js +0 -3
  71. package/build/dex/aave-pt-to-usdc/types.js.map +0 -1
  72. package/build/dex/ekubo/pools/math/sqrt-ratio.d.ts +0 -8
  73. package/build/dex/ekubo/pools/math/sqrt-ratio.js +0 -113
  74. package/build/dex/ekubo/pools/math/sqrt-ratio.js.map +0 -1
  75. package/build/dex/ekubo/pools/mev-resist.d.ts +0 -7
  76. package/build/dex/ekubo/pools/mev-resist.js +0 -40
  77. package/build/dex/ekubo/pools/mev-resist.js.map +0 -1
  78. package/build/dex/ekubo/pools/pool.d.ts +0 -52
  79. package/build/dex/ekubo/pools/pool.js +0 -86
  80. package/build/dex/ekubo/pools/pool.js.map +0 -1
  81. package/build/dex/miro-migrator/miro-migrator-state.d.ts +0 -27
  82. package/build/dex/miro-migrator/miro-migrator-state.js +0 -89
  83. package/build/dex/miro-migrator/miro-migrator-state.js.map +0 -1
  84. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.d.ts +0 -4
  85. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js +0 -56
  86. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js.map +0 -1
  87. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.d.ts +0 -7
  88. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js +0 -28
  89. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js.map +0 -1
  90. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.d.ts +0 -0
  91. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js +0 -2
  92. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js.map +0 -1
  93. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.d.ts +0 -7
  94. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js +0 -28
  95. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js.map +0 -1
  96. package/build/dex/uniswap-v4/hooks/fee-hook/types.d.ts +0 -0
  97. package/build/dex/uniswap-v4/hooks/fee-hook/types.js +0 -2
  98. package/build/dex/uniswap-v4/hooks/fee-hook/types.js.map +0 -1
  99. package/build/dex/uniswap-v4/hooks/index.d.ts +0 -2
  100. package/build/dex/uniswap-v4/hooks/index.js +0 -8
  101. package/build/dex/uniswap-v4/hooks/index.js.map +0 -1
  102. package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +0 -26
  103. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +0 -75
  104. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +0 -1
@@ -1,244 +0,0 @@
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.AavePtToUsdc = 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
- class AavePtToUsdc extends simple_exchange_1.SimpleExchange {
49
- network;
50
- dexKey;
51
- dexHelper;
52
- hasConstantPriceLargeAmounts = false;
53
- needWrapNative = false;
54
- isFeeOnTransferSupported = false;
55
- config;
56
- oracleInterface;
57
- supportedMarkets;
58
- logger;
59
- static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.AavePtToUsdcConfig);
60
- constructor(network, dexKey, dexHelper) {
61
- super(dexHelper, dexKey);
62
- this.network = network;
63
- this.dexKey = dexKey;
64
- this.dexHelper = dexHelper;
65
- this.config = config_1.AavePtToUsdcConfig[dexKey][network];
66
- this.logger = dexHelper.getLogger(dexKey);
67
- this.oracleInterface = new abi_1.Interface(PendleOracle_json_1.default);
68
- this.supportedMarkets = this.config.supportedPts;
69
- }
70
- getAdapters() {
71
- return null;
72
- }
73
- getPoolIdentifier(marketAddress) {
74
- return `${this.dexKey}_${marketAddress.toLowerCase()}`;
75
- }
76
- async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
77
- const market = this.getMarketByPtToken(srcToken.address);
78
- if (!market) {
79
- return [];
80
- }
81
- // Only support PT -> underlying swaps
82
- if (destToken.address.toLowerCase() !==
83
- market.underlyingRawAddress.toLowerCase()) {
84
- return [];
85
- }
86
- return [this.getPoolIdentifier(market.marketAddress)];
87
- }
88
- getMarketByPtToken(ptToken) {
89
- return this.supportedMarkets.find(m => m.pt.address.toLowerCase() === ptToken.toLowerCase());
90
- }
91
- async getOracleRate(market) {
92
- try {
93
- const callData = this.oracleInterface.encodeFunctionData('getPtToAssetRate', [market.marketAddress, 0]);
94
- const rate = await this.dexHelper.provider.call({
95
- to: this.config.oracleAddress,
96
- data: callData,
97
- });
98
- return BigInt(rate);
99
- }
100
- catch (error) {
101
- this.logger.error(`Failed to fetch oracle rate: ${error}`);
102
- return 0n;
103
- }
104
- }
105
- async calculatePriceFromOracle(market, amounts, side) {
106
- const rate = await this.getOracleRate(market);
107
- if (rate === 0n)
108
- return [];
109
- if (side === constants_1.SwapSide.SELL) {
110
- return amounts.map(amount => (amount * rate) / 10n ** 18n);
111
- }
112
- else {
113
- return amounts.map(amount => (amount * 10n ** 18n + (rate - 1n)) / rate);
114
- }
115
- }
116
- async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
117
- const market = this.getMarketByPtToken(srcToken.address);
118
- if (!market) {
119
- return null;
120
- }
121
- const { underlyingRawAddress, marketAddress } = market;
122
- const isUnderlying = destToken.address.toLowerCase() === underlyingRawAddress.toLowerCase();
123
- if (!isUnderlying) {
124
- return null;
125
- }
126
- if (limitPools && limitPools.length > 0) {
127
- const poolId = this.getPoolIdentifier(marketAddress);
128
- if (!limitPools.includes(poolId)) {
129
- return null;
130
- }
131
- }
132
- const unit = (0, utils_1.getBigIntPow)(side === constants_1.SwapSide.SELL ? srcToken.decimals : destToken.decimals);
133
- const _amounts = [unit, ...amounts.slice(1)];
134
- const prices = await this.calculatePriceFromOracle(market, _amounts, side);
135
- if (prices.length === 0)
136
- return null;
137
- return [
138
- {
139
- exchange: this.dexKey,
140
- prices: [0n, ...prices.slice(1)],
141
- unit: prices[0],
142
- gasCost: constants_2.AAVE_PT_TO_UNDERLYING_GAS_COST,
143
- data: {
144
- marketAddress,
145
- },
146
- poolIdentifiers: [this.getPoolIdentifier(marketAddress)],
147
- poolAddresses: [marketAddress],
148
- },
149
- ];
150
- }
151
- getCalldataGasCost() {
152
- return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
153
- }
154
- getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
155
- const payload = '0x';
156
- return {
157
- targetExchange: this.config.pendleRouterAddress,
158
- payload,
159
- networkFee: '0',
160
- };
161
- }
162
- async getTopPoolsForToken(tokenAddress, limit) {
163
- const market = this.getMarketByPtToken(tokenAddress);
164
- if (market) {
165
- return [
166
- {
167
- exchange: this.dexKey,
168
- address: market.marketAddress,
169
- connectorTokens: [
170
- {
171
- address: market.underlyingAssetAddress,
172
- decimals: 18,
173
- liquidityUSD: constants_1.NO_USD_LIQUIDITY,
174
- },
175
- ],
176
- liquidityUSD: constants_1.UNLIMITED_USD_LIQUIDITY,
177
- },
178
- ];
179
- }
180
- return [];
181
- }
182
- async getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side, context, executorAddress) {
183
- const apiParams = {
184
- receiver: recipient,
185
- slippage: 0,
186
- ptAmount: srcAmount,
187
- ytAmount: '0',
188
- lpAmount: '0',
189
- tokenOut: destToken,
190
- enableAggregator: false,
191
- };
192
- const swapResp = await this.callPendleSdkApi(data.marketAddress, apiParams);
193
- if (!swapResp.success || !swapResp.tx) {
194
- const errorMsg = `Pendle SDK exit-positions endpoint failed: ${swapResp.error || 'No transaction data returned'}`;
195
- this.logger.error(errorMsg);
196
- throw new Error(errorMsg);
197
- }
198
- const tx = swapResp.tx;
199
- // Validate transaction data
200
- if (!tx.to || !tx.data) {
201
- const errorMsg = 'Invalid transaction data returned from Pendle SDK API';
202
- this.logger.error(`${errorMsg}: to=${tx.to}, hasData=${!!tx.data}`);
203
- throw new Error(errorMsg);
204
- }
205
- const result = {
206
- targetExchange: tx.to,
207
- exchangeData: tx.data,
208
- needWrapNative: false,
209
- dexFuncHasRecipient: true,
210
- returnAmountPos: 0,
211
- };
212
- return result;
213
- }
214
- async callPendleSdkApi(marketAddress, params) {
215
- const url = new URL(`${constants_2.PENDLE_API_URL}/v2/sdk/${this.network}/markets/${marketAddress}/exit-positions`);
216
- Object.keys(params).forEach(key => {
217
- if (params[key] !== undefined && params[key] !== null) {
218
- url.searchParams.append(key, params[key].toString());
219
- }
220
- });
221
- try {
222
- const response = await this.dexHelper.httpRequest.get(url.toString(), 30000, {
223
- Accept: 'application/json',
224
- });
225
- const responseData = response;
226
- const result = {
227
- success: true,
228
- data: responseData.data || responseData,
229
- tx: responseData.tx || responseData.data?.tx,
230
- };
231
- return result;
232
- }
233
- catch (error) {
234
- this.logger.error(`Pendle SDK API call failed: ${error}`);
235
- return {
236
- success: false,
237
- error: error instanceof Error ? error.message : String(error),
238
- tx: null,
239
- };
240
- }
241
- }
242
- }
243
- exports.AavePtToUsdc = AavePtToUsdc;
244
- //# sourceMappingURL=aave-pt-to-usdc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aave-pt-to-usdc.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-usdc/aave-pt-to-usdc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,+CAKyB;AACzB,2EAA6D;AAC7D,uCAAkE;AAIlE,wDAAoD;AACpD,qCAA8C;AAC9C,4CAA+C;AAC/C,oFAA4D;AAC5D,2CAA6E;A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C;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;YAC1D,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC7D,EAAE,EAAE,IAAI;aACT,CAAC;QACJ,CAAC;IACH,CAAC;;AApSH,oCAqSC"}
@@ -1,3 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap } from '../../types';
3
- export declare const AavePtToUsdcConfig: DexConfigMap<DexParams>;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AavePtToUsdcConfig = 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
- // Pendle Oracle https://etherscan.io/address/0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2
8
- const ORACLE_ADDRESS = '0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2';
9
- // PT sUSDe 25 Sep 2025: https://etherscan.io/address/0x9f56094c450763769ba0ea9fe2876070c0fd5f77
10
- // PT USDe 25 Sep 2025: https://etherscan.io/address/0xbc6736d346a5ebc0debc997397912cd9b8fae10a
11
- // sUSDe: https://etherscan.io/address/0x9d39a5de30e57443bff2a8307a4256c8797a3497
12
- // USDe: https://etherscan.io/address/0x4c9edd5852cd905f086c759e8383e09bff1e68b3
13
- exports.AavePtToUsdcConfig = {
14
- AavePtToUsdc: {
15
- [constants_1.Network.MAINNET]: {
16
- pendleRouterAddress: PENDLE_ROUTER_ADDRESS,
17
- oracleAddress: ORACLE_ADDRESS,
18
- supportedPts: [
19
- {
20
- pt: {
21
- address: '0x9f56094c450763769ba0ea9fe2876070c0fd5f77',
22
- decimals: 18,
23
- name: 'PT-sUSDe-25SEP2025',
24
- expiry: 1764201600,
25
- },
26
- marketAddress: '0xa36b60a14a1a5247912584768c6e53e1a269a9f7', // PT sUSDe 25 Sep 2025 market
27
- exitMarketAddress: '0xa36b60a14a1a5247912584768c6e53e1a269a9f7', // Same as market for now
28
- underlyingAssetAddress: '0x9D39A5DE30e57443BfF2A8307A4256c8797A3497', // sUSDe
29
- underlyingRawAddress: '0x9D39A5DE30e57443BfF2A8307A4256c8797A3497', // raw sUSDe
30
- },
31
- {
32
- pt: {
33
- address: '0xbc6736d346a5ebc0debc997397912cd9b8fae10a',
34
- decimals: 18,
35
- name: 'PT-USDe-25SEP2025',
36
- expiry: 1764201600,
37
- },
38
- marketAddress: '0x6d98a2b6cdbf44939362a3e99793339ba2016af4', // PT USDe market
39
- exitMarketAddress: '0x6d98a2b6cdbf44939362a3e99793339ba2016af4', // Same as market for now
40
- underlyingAssetAddress: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3', // USDe
41
- underlyingRawAddress: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3', // raw USDe
42
- },
43
- ],
44
- },
45
- },
46
- };
47
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-usdc/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE1C,gGAAgG;AAChG,MAAM,qBAAqB,GAAG,4CAA4C,CAAC;AAC3E,wFAAwF;AACxF,MAAM,cAAc,GAAG,4CAA4C,CAAC;AAEpE,gGAAgG;AAChG,+FAA+F;AAC/F,iFAAiF;AACjF,gFAAgF;AAEnE,QAAA,kBAAkB,GAA4B;IACzD,YAAY,EAAE;QACZ,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,mBAAmB,EAAE,qBAAqB;YAC1C,aAAa,EAAE,cAAc;YAC7B,YAAY,EAAE;gBACZ;oBACE,EAAE,EAAE;wBACF,OAAO,EAAE,4CAA4C;wBACrD,QAAQ,EAAE,EAAE;wBACZ,IAAI,EAAE,oBAAoB;wBAC1B,MAAM,EAAE,UAAU;qBACnB;oBACD,aAAa,EAAE,4CAA4C,EAAE,8BAA8B;oBAC3F,iBAAiB,EAAE,4CAA4C,EAAE,yBAAyB;oBAC1F,sBAAsB,EAAE,4CAA4C,EAAE,QAAQ;oBAC9E,oBAAoB,EAAE,4CAA4C,EAAE,YAAY;iBACjF;gBACD;oBACE,EAAE,EAAE;wBACF,OAAO,EAAE,4CAA4C;wBACrD,QAAQ,EAAE,EAAE;wBACZ,IAAI,EAAE,mBAAmB;wBACzB,MAAM,EAAE,UAAU;qBACnB;oBACD,aAAa,EAAE,4CAA4C,EAAE,iBAAiB;oBAC9E,iBAAiB,EAAE,4CAA4C,EAAE,yBAAyB;oBAC1F,sBAAsB,EAAE,4CAA4C,EAAE,OAAO;oBAC7E,oBAAoB,EAAE,4CAA4C,EAAE,WAAW;iBAChF;aACF;SACF;KACF;CACF,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const PENDLE_API_URL = "https://api-v2.pendle.finance/core";
2
- export declare const AAVE_PT_TO_UNDERLYING_GAS_COST = 200000;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AAVE_PT_TO_UNDERLYING_GAS_COST = exports.PENDLE_API_URL = void 0;
4
- exports.PENDLE_API_URL = 'https://api-v2.pendle.finance/core';
5
- exports.AAVE_PT_TO_UNDERLYING_GAS_COST = 200_000;
6
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-usdc/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,oCAAoC,CAAC;AACtD,QAAA,8BAA8B,GAAG,OAAO,CAAC"}
@@ -1,22 +0,0 @@
1
- import { Address } from '../../types';
2
- export type AavePtToUsdcData = {
3
- marketAddress: Address;
4
- };
5
- export interface PendleToken {
6
- address: string;
7
- decimals: number;
8
- name: string;
9
- expiry: number;
10
- }
11
- export interface SupportedPt {
12
- pt: PendleToken;
13
- marketAddress: string;
14
- exitMarketAddress: string;
15
- underlyingAssetAddress: string;
16
- underlyingRawAddress: string;
17
- }
18
- export interface DexParams {
19
- pendleRouterAddress: string;
20
- oracleAddress: string;
21
- supportedPts: SupportedPt[];
22
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-usdc/types.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- import { BigNumber } from 'ethers';
2
- export declare const ONE_FLOAT_SQRT_RATIO: bigint;
3
- export declare function floatSqrtRatioToFixed(sqrtRatioFloat: bigint): bigint;
4
- export declare function fixedSqrtRatioToFloat(sqrtRatioFixed: bigint): bigint;
5
- export declare const MAX_SQRT_RATIO_FLOAT: BigNumber;
6
- export declare const MIN_SQRT_RATIO_FLOAT: BigNumber;
7
- export declare function nextSqrtRatioFromAmount0(sqrtRatio: bigint, liquidity: bigint, amount0: bigint): bigint | null;
8
- export declare function nextSqrtRatioFromAmount1(sqrtRatio: bigint, liquidity: bigint, amount1: bigint): bigint | null;
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MIN_SQRT_RATIO_FLOAT = exports.MAX_SQRT_RATIO_FLOAT = exports.ONE_FLOAT_SQRT_RATIO = void 0;
4
- exports.floatSqrtRatioToFixed = floatSqrtRatioToFixed;
5
- exports.fixedSqrtRatioToFloat = fixedSqrtRatioToFloat;
6
- exports.nextSqrtRatioFromAmount0 = nextSqrtRatioFromAmount0;
7
- exports.nextSqrtRatioFromAmount1 = nextSqrtRatioFromAmount1;
8
- const ethers_1 = require("ethers");
9
- const constants_1 = require("./constants");
10
- const tick_1 = require("./tick");
11
- const BIT_MASK = 0xc00000000000000000000000n;
12
- const NOT_BIT_MASK = 0x3fffffffffffffffffffffffn;
13
- exports.ONE_FLOAT_SQRT_RATIO = (2n << 94n) | (1n << 62n);
14
- function floatSqrtRatioToFixed(sqrtRatioFloat) {
15
- return sqrtRatioFloat === 0n
16
- ? constants_1.TWO_POW_128 // Default value for the case that the passed value comes from an uninitialized pool
17
- : (sqrtRatioFloat & NOT_BIT_MASK) <<
18
- (2n + ((sqrtRatioFloat & BIT_MASK) >> 89n));
19
- }
20
- function fixedSqrtRatioToFloat(sqrtRatioFixed) {
21
- if (sqrtRatioFixed >= constants_1.TWO_POW_192) {
22
- throw new Error('Out of bounds');
23
- }
24
- else if (sqrtRatioFixed >= constants_1.TWO_POW_160) {
25
- return (sqrtRatioFixed >> 98n) + BIT_MASK;
26
- }
27
- else if (sqrtRatioFixed >= constants_1.TWO_POW_128) {
28
- return (sqrtRatioFixed >> 66n) + constants_1.TWO_POW_95;
29
- }
30
- else if (sqrtRatioFixed >= constants_1.TWO_POW_96) {
31
- return (sqrtRatioFixed >> 34n) + constants_1.TWO_POW_94;
32
- }
33
- else {
34
- return sqrtRatioFixed >> 2n;
35
- }
36
- }
37
- exports.MAX_SQRT_RATIO_FLOAT = ethers_1.BigNumber.from(fixedSqrtRatioToFloat(tick_1.MAX_SQRT_RATIO));
38
- exports.MIN_SQRT_RATIO_FLOAT = ethers_1.BigNumber.from(fixedSqrtRatioToFloat(tick_1.MIN_SQRT_RATIO));
39
- function nextSqrtRatioFromAmount0(sqrtRatio, liquidity, amount0) {
40
- if (amount0 === 0n)
41
- return sqrtRatio;
42
- if (liquidity === 0n)
43
- throw new Error('NO_LIQUIDITY');
44
- const numerator1 = liquidity << 128n;
45
- // because quotient is rounded down, this price movement is also rounded towards sqrt_ratio
46
- if (amount0 < 0n) {
47
- const product = amount0 * -1n * sqrtRatio;
48
- if (product >= constants_1.MAX_U256) {
49
- return null;
50
- }
51
- const denominator = numerator1 - product;
52
- if (denominator < 0n) {
53
- return null;
54
- }
55
- const num = numerator1 * sqrtRatio;
56
- const result = num / denominator + (num % denominator === 0n ? 0n : 1n);
57
- if (result > constants_1.MAX_U256) {
58
- return null;
59
- }
60
- return result;
61
- }
62
- else {
63
- const denomP1 = numerator1 / sqrtRatio;
64
- const denom = denomP1 + amount0;
65
- const quotient = numerator1 / denom;
66
- const remainder = numerator1 % denom;
67
- if (remainder === 0n)
68
- return quotient;
69
- const sum = quotient + 1n;
70
- if (sum > constants_1.MAX_U256)
71
- return null;
72
- return sum;
73
- }
74
- }
75
- function nextSqrtRatioFromAmount1(sqrtRatio, liquidity, amount1) {
76
- if (amount1 === 0n)
77
- return sqrtRatio;
78
- if (liquidity === 0n)
79
- throw new Error('NO_LIQUIDITY');
80
- const amountShifted = amount1 << 128n;
81
- const quotient = amountShifted / liquidity;
82
- const remainder = amountShifted % liquidity;
83
- // because quotient is rounded down, this price movement is also rounded towards sqrt_ratio
84
- if (amount1 < 0n) {
85
- // adding amount1, taking out amount0
86
- const res = sqrtRatio + quotient;
87
- if (res < 0n) {
88
- return null;
89
- }
90
- if (remainder === 0n) {
91
- return res;
92
- }
93
- else {
94
- if (res != 0n) {
95
- return res - 1n;
96
- }
97
- else {
98
- return null;
99
- }
100
- }
101
- }
102
- else {
103
- // adding amount1, taking out amount0, price goes up
104
- const res = sqrtRatio + quotient;
105
- if (res > constants_1.MAX_U256) {
106
- return null;
107
- }
108
- else {
109
- return res;
110
- }
111
- }
112
- }
113
- //# sourceMappingURL=sqrt-ratio.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqrt-ratio.js","sourceRoot":"","sources":["../../../../../src/dex/ekubo/pools/math/sqrt-ratio.ts"],"names":[],"mappings":";;;AAiBA,sDAKC;AAED,sDAYC;AASD,4DA8CC;AAED,4DAsCC;AAnID,mCAAmC;AACnC,2CAQqB;AACrB,iCAAwD;AAExD,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AA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AiB,EACjB,SAAiB,EACjB,OAAe;IAEf,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAErC,IAAI,SAAS,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IAEtD,MAAM,aAAa,GAAG,OAAO,IAAI,IAAI,CAAC;IACtC,MAAM,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;IAC3C,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC;IAE5C,2FAA2F;IAC3F,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;QACjB,qCAAqC;QACrC,MAAM,GAAG,GAAG,SAAS,GAAG,QAAQ,CAAC;QACjC,IAAI,GAAG,GAAG,EAAE,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC;gBACd,OAAO,GAAG,GAAG,EAAE,CAAC;YAClB,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,oDAAoD;QACpD,MAAM,GAAG,GAAG,SAAS,GAAG,QAAQ,CAAC;QACjC,IAAI,GAAG,GAAG,oBAAQ,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,7 +0,0 @@
1
- import { DeepReadonly } from 'ts-essentials';
2
- import { PoolKeyed, Quote } from './pool';
3
- import { BasePool, BasePoolState } from './base';
4
- export declare class MevResistPool extends BasePool {
5
- protected _quote(amount: bigint, isToken1: boolean, state: DeepReadonly<BasePoolState.Object>, sqrtRatioLimit?: bigint): Quote;
6
- quoteMevResist(this: PoolKeyed, amount: bigint, isToken1: boolean, state: DeepReadonly<BasePoolState.Object>, sqrtRatioLimit?: bigint): Quote<Pick<BasePoolState.Object, 'activeTickIndex' | 'sqrtRatio' | 'liquidity'>>;
7
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MevResistPool = void 0;
4
- const base_1 = require("./base");
5
- const tick_1 = require("./math/tick");
6
- const bigint_constants_1 = require("../../../bigint-constants");
7
- const swap_1 = require("./math/swap");
8
- const EXTRA_BASE_GAS_COST_OF_ONE_MEV_RESIST_SWAP = 33_500;
9
- class MevResistPool extends base_1.BasePool {
10
- _quote(amount, isToken1, state, sqrtRatioLimit) {
11
- return this.quoteMevResist(amount, isToken1, state, sqrtRatioLimit);
12
- }
13
- quoteMevResist(amount, isToken1, state, sqrtRatioLimit) {
14
- const quote = base_1.BasePool.prototype.quoteBase.call(this, amount, isToken1, state, sqrtRatioLimit);
15
- const tickAfterSwap = (0, tick_1.approximateSqrtRatioToTick)(quote.stateAfter.sqrtRatio);
16
- const poolConfig = this.key.config;
17
- const approximateFeeMultiplier = (Math.abs(tickAfterSwap - state.activeTick) + 1) / poolConfig.tickSpacing;
18
- let fixedPointAdditionalFee = BigInt(Math.round(approximateFeeMultiplier * Number(poolConfig.fee)));
19
- if (fixedPointAdditionalFee > bigint_constants_1.BI_MAX_UINT64) {
20
- fixedPointAdditionalFee = bigint_constants_1.BI_MAX_UINT64;
21
- }
22
- let calculatedAmount = quote.calculatedAmount;
23
- if (amount >= 0n) {
24
- // Exact input, remove the additional fee from the output
25
- calculatedAmount -= (0, swap_1.computeFee)(calculatedAmount, fixedPointAdditionalFee);
26
- }
27
- else {
28
- const inputAmountFee = (0, swap_1.computeFee)(calculatedAmount, poolConfig.fee);
29
- const inputAmount = calculatedAmount - inputAmountFee;
30
- const bf = (0, swap_1.amountBeforeFee)(inputAmount, fixedPointAdditionalFee);
31
- const fee = bf - inputAmount;
32
- calculatedAmount += fee;
33
- }
34
- quote.gasConsumed += EXTRA_BASE_GAS_COST_OF_ONE_MEV_RESIST_SWAP;
35
- quote.calculatedAmount = calculatedAmount;
36
- return quote;
37
- }
38
- }
39
- exports.MevResistPool = MevResistPool;
40
- //# sourceMappingURL=mev-resist.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mev-resist.js","sourceRoot":"","sources":["../../../../src/dex/ekubo/pools/mev-resist.ts"],"names":[],"mappings":";;;AAGA,iCAAiD;AACjD,sCAAyD;AACzD,gEAA0D;AAC1D,sCAA0D;AAE1D,MAAM,0CAA0C,GAAG,MAAM,CAAC;AAE1D,MAAa,aAAc,SAAQ,eAAQ;IACtB,MAAM,CACvB,MAAc,EACd,QAAiB,EACjB,KAAyC,EACzC,cAAuB;QAEvB,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IACtE,CAAC;IAEM,cAAc,CAEnB,MAAc,EACd,QAAiB,EACjB,KAAyC,EACzC,cAAuB;QAIvB,MAAM,KAAK,GAAG,eAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAC7C,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,cAAc,CACf,CAAC;QAEF,MAAM,aAAa,GAAG,IAAA,iCAA0B,EAC9C,KAAK,CAAC,UAAU,CAAC,SAAS,CAC3B,CAAC;QACF,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QACnC,MAAM,wBAAwB,GAC5B,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;QAE5E,IAAI,uBAAuB,GAAG,MAAM,CAClC,IAAI,CAAC,KAAK,CAAC,wBAAwB,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAC9D,CAAC;QAEF,IAAI,uBAAuB,GAAG,gCAAa,EAAE,CAAC;YAC5C,uBAAuB,GAAG,gCAAa,CAAC;QAC1C,CAAC;QAED,IAAI,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;QAE9C,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;YACjB,yDAAyD;YACzD,gBAAgB,IAAI,IAAA,iBAAU,EAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;QAC5E,CAAC;aAAM,CAAC;YACN,MAAM,cAAc,GAAG,IAAA,iBAAU,EAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACpE,MAAM,WAAW,GAAG,gBAAgB,GAAG,cAAc,CAAC;YAEtD,MAAM,EAAE,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,EAAE,GAAG,WAAW,CAAC;YAC7B,gBAAgB,IAAI,GAAG,CAAC;QAC1B,CAAC;QAED,KAAK,CAAC,WAAW,IAAI,0CAA0C,CAAC;QAChE,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAE1C,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA7DD,sCA6DC"}
@@ -1,52 +0,0 @@
1
- import { Interface, Result } from '@ethersproject/abi';
2
- import { Logger } from 'log4js';
3
- import { DeepReadonly } from 'ts-essentials';
4
- import { IDexHelper } from '../../../dex-helper/idex-helper';
5
- import { StatefulEventSubscriber } from '../../../stateful-event-subscriber';
6
- import { BlockHeader, Log } from '../../../types';
7
- import { PoolKey } from './utils';
8
- export type Quote<StateAfter = undefined> = {
9
- consumedAmount: bigint;
10
- calculatedAmount: bigint;
11
- gasConsumed: number;
12
- skipAhead: number;
13
- } & (StateAfter extends undefined ? {} : {
14
- stateAfter: StateAfter;
15
- });
16
- export interface PoolKeyed {
17
- key: PoolKey;
18
- }
19
- export interface IEkuboPool extends PoolKeyed {
20
- quote(amount: bigint, token: bigint, blockNumber: number): Quote;
21
- updateState(blockNumber: number): Promise<void>;
22
- computeTvl(): [bigint, bigint];
23
- }
24
- export type NamedEventHandler<State> = (args: Result, oldState: DeepReadonly<State>, blockHeader: Readonly<BlockHeader>) => DeepReadonly<State> | null;
25
- export type AnonymousEventHandler<State> = (data: string, oldState: DeepReadonly<State>, blockHeader: Readonly<BlockHeader>) => DeepReadonly<State> | null;
26
- export declare class NamedEventHandlers<State> {
27
- private readonly iface;
28
- private readonly handlers;
29
- constructor(iface: Interface, handlers: Record<string, NamedEventHandler<State>>);
30
- parseLog(log: Readonly<Log>, oldState: DeepReadonly<State>, blockHeader: Readonly<BlockHeader>): DeepReadonly<State> | null;
31
- }
32
- export declare abstract class EkuboPool<State> extends StatefulEventSubscriber<State> implements IEkuboPool {
33
- readonly key: PoolKey;
34
- private readonly namedEventHandlers;
35
- private readonly anonymousEventHandlers;
36
- protected constructor(parentName: string, dexHelper: IDexHelper, logger: Logger, key: PoolKey, namedEventHandlers: Record<string, NamedEventHandlers<State>>, anonymousEventHandlers: Record<string, AnonymousEventHandler<State>>);
37
- updateState(blockNumber: number): Promise<void>;
38
- /**
39
- * The function is called every time any of the subscribed
40
- * addresses release log. The function accepts the current
41
- * state, updates the state according to the log, and returns
42
- * the updated state.
43
- * @param state - Current state of event subscriber
44
- * @param log - Log released by one of the subscribed addresses
45
- * @returns Updates state of the event subscriber after the log
46
- */
47
- protected processLog(state: DeepReadonly<State>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): DeepReadonly<State> | null;
48
- quote(amount: bigint, token: bigint, blockNumber: number): Quote;
49
- protected abstract _quote(amount: bigint, isToken1: boolean, state: DeepReadonly<State>, sqrtRatioLimit?: bigint): Quote;
50
- computeTvl(): [bigint, bigint];
51
- protected abstract _computeTvl(state: DeepReadonly<State>): [bigint, bigint];
52
- }