@paraswap/dex-lib 4.3.9 → 4.3.10

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 (111) hide show
  1. package/build/dex/miro-migrator/constants.d.ts +1 -1
  2. package/build/dex/miro-migrator/constants.js +1 -1
  3. package/build/dex/miro-migrator/miro-migrator-pool.d.ts +1 -0
  4. package/build/dex/miro-migrator/miro-migrator-pool.js +1 -0
  5. package/build/dex/miro-migrator/miro-migrator-pool.js.map +1 -1
  6. package/build/dex/miro-migrator/miro-migrator.js +1 -0
  7. package/build/dex/miro-migrator/miro-migrator.js.map +1 -1
  8. package/build/dex/uniswap-v4/encoder.d.ts +5 -5
  9. package/build/dex/uniswap-v4/encoder.js +142 -31
  10. package/build/dex/uniswap-v4/encoder.js.map +1 -1
  11. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +1 -0
  12. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +33 -9
  13. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -1
  14. package/build/dex/uniswap-v4/uniswap-v4.d.ts +1 -0
  15. package/build/dex/uniswap-v4/uniswap-v4.js +37 -23
  16. package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -1
  17. package/build/executor/Executor01BytecodeBuilder.js +7 -3
  18. package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
  19. package/build/executor/Executor02BytecodeBuilder.js +7 -3
  20. package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
  21. package/build/executor/Executor03BytecodeBuilder.js +14 -3
  22. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  23. package/package.json +1 -1
  24. package/build/abi/BProtocol.json +0 -1155
  25. package/build/abi/Jarvis.json +0 -1172
  26. package/build/abi/MStableAsset.json +0 -1545
  27. package/build/abi/OneInchLp.json +0 -1304
  28. package/build/abi/Onebit.json +0 -736
  29. package/build/abi/Shell.json +0 -1294
  30. package/build/abi/TraderJoeV2Router.json +0 -50
  31. package/build/abi/algebra-integral/Quoter.abi.json +0 -231
  32. package/build/abi/algebra-integral/SwapRouter.abi.json +0 -810
  33. package/build/abi/wUSDM.json +0 -757
  34. package/build/abi/zrx.v2.json +0 -1967
  35. package/build/abi/zrx.v3.json +0 -3454
  36. package/build/abi/zrx.v4.json +0 -2193
  37. package/build/dex/OneInchLp.d.ts +0 -24
  38. package/build/dex/OneInchLp.js +0 -43
  39. package/build/dex/OneInchLp.js.map +0 -1
  40. package/build/dex/algebra-integral/algebra-integral.d.ts +0 -43
  41. package/build/dex/algebra-integral/algebra-integral.js +0 -446
  42. package/build/dex/algebra-integral/algebra-integral.js.map +0 -1
  43. package/build/dex/algebra-integral/config.d.ts +0 -3
  44. package/build/dex/algebra-integral/config.js +0 -17
  45. package/build/dex/algebra-integral/config.js.map +0 -1
  46. package/build/dex/algebra-integral/types.d.ts +0 -33
  47. package/build/dex/algebra-integral/types.js +0 -10
  48. package/build/dex/algebra-integral/types.js.map +0 -1
  49. package/build/dex/bProtocol/bProtocol.d.ts +0 -15
  50. package/build/dex/bProtocol/bProtocol.js +0 -56
  51. package/build/dex/bProtocol/bProtocol.js.map +0 -1
  52. package/build/dex/bProtocol/types.d.ts +0 -11
  53. package/build/dex/bProtocol/types.js +0 -8
  54. package/build/dex/bProtocol/types.js.map +0 -1
  55. package/build/dex/jarvis.d.ts +0 -56
  56. package/build/dex/jarvis.js +0 -163
  57. package/build/dex/jarvis.js.map +0 -1
  58. package/build/dex/mStable.d.ts +0 -44
  59. package/build/dex/mStable.js +0 -75
  60. package/build/dex/mStable.js.map +0 -1
  61. package/build/dex/onebit/onebit.d.ts +0 -16
  62. package/build/dex/onebit/onebit.js +0 -61
  63. package/build/dex/onebit/onebit.js.map +0 -1
  64. package/build/dex/onebit/types.d.ts +0 -14
  65. package/build/dex/onebit/types.js +0 -8
  66. package/build/dex/onebit/types.js.map +0 -1
  67. package/build/dex/shell.d.ts +0 -25
  68. package/build/dex/shell.js +0 -41
  69. package/build/dex/shell.js.map +0 -1
  70. package/build/dex/trader-joe-v2.d.ts +0 -40
  71. package/build/dex/trader-joe-v2.js +0 -74
  72. package/build/dex/trader-joe-v2.js.map +0 -1
  73. package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +0 -94
  74. package/build/dex/uniswap-v3/uniswap-v3-new.js +0 -923
  75. package/build/dex/uniswap-v3/uniswap-v3-new.js.map +0 -1
  76. package/build/dex/usual-bond/config.d.ts +0 -3
  77. package/build/dex/usual-bond/config.js +0 -13
  78. package/build/dex/usual-bond/config.js.map +0 -1
  79. package/build/dex/usual-bond/types.d.ts +0 -7
  80. package/build/dex/usual-bond/types.js +0 -3
  81. package/build/dex/usual-bond/types.js.map +0 -1
  82. package/build/dex/usual-bond/usual-bond.d.ts +0 -35
  83. package/build/dex/usual-bond/usual-bond.js +0 -176
  84. package/build/dex/usual-bond/usual-bond.js.map +0 -1
  85. package/build/dex/wusdm/config.d.ts +0 -3
  86. package/build/dex/wusdm/config.js +0 -43
  87. package/build/dex/wusdm/config.js.map +0 -1
  88. package/build/dex/wusdm/constants.d.ts +0 -2
  89. package/build/dex/wusdm/constants.js +0 -6
  90. package/build/dex/wusdm/constants.js.map +0 -1
  91. package/build/dex/wusdm/types.d.ts +0 -18
  92. package/build/dex/wusdm/types.js +0 -11
  93. package/build/dex/wusdm/types.js.map +0 -1
  94. package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
  95. package/build/dex/wusdm/wusdm-pool.js +0 -74
  96. package/build/dex/wusdm/wusdm-pool.js.map +0 -1
  97. package/build/dex/wusdm/wusdm.d.ts +0 -46
  98. package/build/dex/wusdm/wusdm.js +0 -243
  99. package/build/dex/wusdm/wusdm.js.map +0 -1
  100. package/build/dex/zerox/config.d.ts +0 -2
  101. package/build/dex/zerox/config.js +0 -33
  102. package/build/dex/zerox/config.js.map +0 -1
  103. package/build/dex/zerox/index.d.ts +0 -22
  104. package/build/dex/zerox/index.js +0 -225
  105. package/build/dex/zerox/index.js.map +0 -1
  106. package/build/dex/zerox/order.d.ts +0 -88
  107. package/build/dex/zerox/order.js +0 -53
  108. package/build/dex/zerox/order.js.map +0 -1
  109. package/build/dex/zerox/types.d.ts +0 -73
  110. package/build/dex/zerox/types.js +0 -21
  111. package/build/dex/zerox/types.js.map +0 -1
@@ -1,24 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { SwapSide } from '../constants';
3
- import { AdapterExchangeParam, SimpleExchangeParam } from '../types';
4
- import { IDexTxBuilder } from './idex';
5
- import { SimpleExchange } from './simple-exchange';
6
- import { IDexHelper } from '../dex-helper';
7
- export declare type OneInchLpData = {
8
- exchange: string;
9
- };
10
- declare type OneInchLpParam = [
11
- src: string,
12
- dst: string,
13
- amount: string,
14
- minReturn: string,
15
- referral: string
16
- ];
17
- export declare class OneInchLp extends SimpleExchange implements IDexTxBuilder<OneInchLpData, OneInchLpParam> {
18
- static dexKeys: string[];
19
- exchangeRouterInterface: Interface;
20
- constructor(dexHelper: IDexHelper);
21
- getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OneInchLpData, side: SwapSide): AdapterExchangeParam;
22
- getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OneInchLpData, side: SwapSide): Promise<SimpleExchangeParam>;
23
- }
24
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.OneInchLp = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const constants_1 = require("../constants");
9
- const simple_exchange_1 = require("./simple-exchange");
10
- const OneInchLp_json_1 = __importDefault(require("../abi/OneInchLp.json"));
11
- const utils_1 = require("../utils");
12
- var OneInchLpFunctions;
13
- (function (OneInchLpFunctions) {
14
- OneInchLpFunctions["swap"] = "swap";
15
- })(OneInchLpFunctions || (OneInchLpFunctions = {}));
16
- class OneInchLp extends simple_exchange_1.SimpleExchange {
17
- constructor(dexHelper) {
18
- super(dexHelper, 'oneinchlp');
19
- this.exchangeRouterInterface = new abi_1.Interface(OneInchLp_json_1.default);
20
- }
21
- getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
22
- return {
23
- targetExchange: data.exchange,
24
- payload: '0x',
25
- networkFee: '0',
26
- };
27
- }
28
- async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
29
- const swapFunction = OneInchLpFunctions.swap;
30
- const swapFunctionParams = [
31
- (0, utils_1.isETHAddress)(srcToken) ? constants_1.NULL_ADDRESS : srcToken,
32
- (0, utils_1.isETHAddress)(destToken) ? constants_1.NULL_ADDRESS : destToken,
33
- srcAmount,
34
- destAmount,
35
- constants_1.NULL_ADDRESS,
36
- ];
37
- const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
38
- return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.exchange);
39
- }
40
- }
41
- exports.OneInchLp = OneInchLp;
42
- OneInchLp.dexKeys = ['oneinchlp'];
43
- //# sourceMappingURL=OneInchLp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OneInchLp.js","sourceRoot":"","sources":["../../src/dex/OneInchLp.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAGtD,uDAAmD;AACnD,2EAAiD;AACjD,oCAAwC;AAcxC,IAAK,kBAEJ;AAFD,WAAK,kBAAkB;IACrB,mCAAa,CAAA;AACf,CAAC,EAFI,kBAAkB,KAAlB,kBAAkB,QAEtB;AAED,MAAa,SACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC9B,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAC1C,wBAA8B,CAC/B,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAmB,EACnB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,QAAQ;YAC7B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAmB,EACnB,IAAc;QAEd,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAAC;QAC7C,MAAM,kBAAkB,GAAmB;YACzC,IAAA,oBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,wBAAY,CAAC,CAAC,CAAC,QAAQ;YAChD,IAAA,oBAAY,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,wBAAY,CAAC,CAAC,CAAC,SAAS;YAClD,SAAS;YACT,UAAU;YACV,wBAAY;SACb,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;;AA1DH,8BA2DC;AAvDQ,iBAAO,GAAG,CAAC,WAAW,CAAC,CAAC"}
@@ -1,43 +0,0 @@
1
- import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, TransferFeeParams, Logger, DexExchangeParam, NumberAsString } from '../../types';
2
- import { SwapSide, Network } from '../../constants';
3
- import { Interface } from 'ethers/lib/utils';
4
- import { IDex } from '../../dex/idex';
5
- import { IDexHelper } from '../../dex-helper/idex-helper';
6
- import { AlgebraIntegralData, Pool } from './types';
7
- import { SimpleExchange } from '../simple-exchange';
8
- export declare class AlgebraIntegral extends SimpleExchange implements IDex<AlgebraIntegralData> {
9
- readonly network: Network;
10
- readonly dexKey: string;
11
- readonly dexHelper: IDexHelper;
12
- readonly routerIface: Interface;
13
- readonly quoterIface: Interface;
14
- readonly config: import("./types").DexParams;
15
- readonly hasConstantPriceLargeAmounts = false;
16
- readonly needWrapNative = true;
17
- readonly isFeeOnTransferSupported = true;
18
- static dexKeysWithNetwork: {
19
- key: string;
20
- networks: Network[];
21
- }[];
22
- logger: Logger;
23
- private uniswapMulti;
24
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, routerIface?: Interface, quoterIface?: Interface, config?: import("./types").DexParams);
25
- getAdapters(side: SwapSide): {
26
- name: string;
27
- index: number;
28
- }[] | null;
29
- getPoolIdentifier(srcAddress: Address, destAddress: Address, deployerAddress: Address): string;
30
- initializePricing(blockNumber: number): Promise<void>;
31
- getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
32
- getPricingFromRpc(from: Token, to: Token, amounts: bigint[], side: SwapSide, pools: Pool[], transferFees?: TransferFeeParams): Promise<ExchangePrices<AlgebraIntegralData> | null>;
33
- getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[], transferFees?: TransferFeeParams): Promise<null | ExchangePrices<AlgebraIntegralData>>;
34
- getCalldataGasCost(poolPrices: PoolPrices<AlgebraIntegralData>): number | number[];
35
- getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: AlgebraIntegralData, side: SwapSide): DexExchangeParam;
36
- getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: AlgebraIntegralData, side: SwapSide): AdapterExchangeParam;
37
- getAvailablePools(srcToken: Address, destToken: Address): Promise<Pool[]>;
38
- getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
39
- private _querySubgraph;
40
- private _encodePath;
41
- private _sortTokens;
42
- private _getLoweredAddresses;
43
- }
@@ -1,446 +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.AlgebraIntegral = void 0;
40
- const abi_1 = require("@ethersproject/abi");
41
- const solidity_1 = require("@ethersproject/solidity");
42
- const lodash_1 = __importDefault(require("lodash"));
43
- const constants_1 = require("../../constants");
44
- const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
45
- const utils_1 = require("ethers/lib/utils");
46
- const balancer_fetcher_1 = require("../../lib/tokens/balancer-fetcher");
47
- const SwapRouter_abi_json_1 = __importDefault(require("../../abi/algebra-integral/SwapRouter.abi.json"));
48
- const Quoter_abi_json_1 = __importDefault(require("../../abi/algebra-integral/Quoter.abi.json"));
49
- const UniswapMulti_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapMulti.abi.json"));
50
- const utils_2 = require("../../utils");
51
- const types_1 = require("./types");
52
- const simple_exchange_1 = require("../simple-exchange");
53
- const token_transfer_fee_1 = require("../../lib/token-transfer-fee");
54
- const config_1 = require("./config");
55
- const types_2 = require("../../lib/tokens/types");
56
- const utils_3 = require("../../executor/utils");
57
- const ALGEBRA_QUOTE_GASLIMIT = 2_000_000;
58
- const ALGEBRA_EFFICIENCY_FACTOR = 3;
59
- class AlgebraIntegral extends simple_exchange_1.SimpleExchange {
60
- network;
61
- dexKey;
62
- dexHelper;
63
- routerIface;
64
- quoterIface;
65
- config;
66
- hasConstantPriceLargeAmounts = false;
67
- needWrapNative = true;
68
- isFeeOnTransferSupported = true;
69
- static dexKeysWithNetwork = (0, utils_2.getDexKeysWithNetwork)(config_1.AlgebraIntegralConfig);
70
- logger;
71
- uniswapMulti;
72
- constructor(network, dexKey, dexHelper, routerIface = new utils_1.Interface(SwapRouter_abi_json_1.default), quoterIface = new utils_1.Interface(Quoter_abi_json_1.default), config = config_1.AlgebraIntegralConfig[dexKey][network]) {
73
- super(dexHelper, dexKey);
74
- this.network = network;
75
- this.dexKey = dexKey;
76
- this.dexHelper = dexHelper;
77
- this.routerIface = routerIface;
78
- this.quoterIface = quoterIface;
79
- this.config = config;
80
- this.logger = dexHelper.getLogger(dexKey);
81
- this.uniswapMulti = new this.dexHelper.web3Provider.eth.Contract(UniswapMulti_abi_json_1.default, this.config.uniswapMulticall);
82
- }
83
- getAdapters(side) {
84
- return null;
85
- }
86
- getPoolIdentifier(srcAddress, destAddress, deployerAddress) {
87
- const tokenAddresses = this._sortTokens(srcAddress, destAddress).join('_');
88
- return `${this.dexKey}_${tokenAddresses}_${deployerAddress}`;
89
- }
90
- async initializePricing(blockNumber) { }
91
- // Returns list of pool identifiers that can be used
92
- // for a given swap. poolIdentifiers must be unique
93
- // across DEXes. It is recommended to use
94
- // ${dexKey}_${poolAddress} as a poolIdentifier
95
- async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
96
- const _srcToken = this.dexHelper.config.wrapETH(srcToken);
97
- const _destToken = this.dexHelper.config.wrapETH(destToken);
98
- const [_srcAddress, _destAddress] = this._getLoweredAddresses(_srcToken, _destToken);
99
- if (_srcAddress === _destAddress)
100
- return [];
101
- const pools = await this.getAvailablePools(_srcAddress, _destAddress);
102
- if (pools.length === 0)
103
- return [];
104
- return pools.map(pool => this.getPoolIdentifier(_srcAddress, _destAddress, pool.deployer));
105
- }
106
- async getPricingFromRpc(from, to, amounts, side, pools, transferFees = {
107
- srcFee: 0,
108
- destFee: 0,
109
- srcDexFee: 0,
110
- destDexFee: 0,
111
- }) {
112
- if (pools.length === 0) {
113
- return null;
114
- }
115
- this.logger.warn(`fallback to rpc for ${pools.length} pool(s)`);
116
- const requests = pools.map(pool => ({
117
- owner: pool.poolAddress,
118
- asset: side == constants_1.SwapSide.SELL ? from.address : to.address,
119
- assetType: types_2.AssetType.ERC20,
120
- ids: [
121
- {
122
- id: types_2.DEFAULT_ID_ERC20,
123
- spenders: [],
124
- },
125
- ],
126
- }), []);
127
- const balances = await (0, balancer_fetcher_1.getBalances)(this.dexHelper.multiWrapper, requests);
128
- pools = pools.filter((pool, index) => {
129
- const balance = balances[index].amounts[types_2.DEFAULT_ID_ERC20_AS_STRING];
130
- if (balance >= amounts[amounts.length - 1]) {
131
- return true;
132
- }
133
- this.logger.warn(`[${this.network}] have no balance ${pool.poolAddress} ${from.address} ${to.address}. (Balance: ${balance})`);
134
- return false;
135
- });
136
- pools.forEach(pool => {
137
- this.logger.warn(`[${this.network}] fallback to rpc for ${pool.poolAddress} ${from.address} ${to.address}`);
138
- });
139
- const _isSrcTokenTransferFeeToBeExchanged = (0, utils_2.isSrcTokenTransferFeeToBeExchanged)(transferFees);
140
- const _isDestTokenTransferFeeToBeExchanged = (0, utils_2.isDestTokenTransferFeeToBeExchanged)(transferFees);
141
- if (_isSrcTokenTransferFeeToBeExchanged && side == constants_1.SwapSide.BUY) {
142
- this.logger.error(`DEX doesn't support buy for tax srcToken ${from.address}`);
143
- return null;
144
- }
145
- const unitVolume = (0, utils_2.getBigIntPow)((side === constants_1.SwapSide.SELL ? from : to).decimals);
146
- const chunks = amounts.length - 1;
147
- const _width = Math.floor(chunks / this.config.chunksCount);
148
- const _amounts = [unitVolume].concat(Array.from(Array(this.config.chunksCount).keys()).map(i => amounts[(i + 1) * _width]));
149
- const _amountsWithFee = _isSrcTokenTransferFeeToBeExchanged
150
- ? (0, token_transfer_fee_1.applyTransferFee)(_amounts, side, transferFees.srcDexFee, constants_1.SRC_TOKEN_DEX_TRANSFERS)
151
- : _amounts;
152
- const calldata = pools.map(pool => _amountsWithFee.map(_amount => ({
153
- target: this.config.quoter,
154
- gasLimit: ALGEBRA_QUOTE_GASLIMIT,
155
- callData: side === constants_1.SwapSide.SELL
156
- ? this.quoterIface.encodeFunctionData('quoteExactInputSingle', [
157
- from.address,
158
- to.address,
159
- pool.deployer,
160
- _amount.toString(),
161
- 0, //sqrtPriceLimitX96
162
- ])
163
- : this.quoterIface.encodeFunctionData('quoteExactOutputSingle', [
164
- from.address,
165
- to.address,
166
- pool.deployer,
167
- _amount.toString(),
168
- 0, //sqrtPriceLimitX96
169
- ]),
170
- })));
171
- const data = await this.uniswapMulti.methods
172
- .multicall(calldata.flat())
173
- .call();
174
- let totalGasCost = 0;
175
- let totalSuccessFullSwaps = 0;
176
- const decode = (j) => {
177
- const { success, gasUsed, returnData } = data.returnData[j];
178
- if (!success) {
179
- return 0n;
180
- }
181
- const decoded = abi_1.defaultAbiCoder.decode(['uint256'], returnData);
182
- totalGasCost += +gasUsed;
183
- totalSuccessFullSwaps++;
184
- return BigInt(decoded[0].toString());
185
- };
186
- const averageGasCost = !totalSuccessFullSwaps
187
- ? ALGEBRA_QUOTE_GASLIMIT
188
- : Math.round(totalGasCost / totalSuccessFullSwaps);
189
- let i = 0;
190
- const result = pools.map(pool => {
191
- const _rates = _amountsWithFee.map(() => decode(i++));
192
- const _ratesWithFee = _isDestTokenTransferFeeToBeExchanged
193
- ? (0, token_transfer_fee_1.applyTransferFee)(_rates, side, transferFees.destDexFee, constants_1.DEST_TOKEN_DEX_TRANSFERS)
194
- : _rates;
195
- const unit = _ratesWithFee[0];
196
- const prices = (0, utils_2.interpolate)(_amountsWithFee.slice(1), _ratesWithFee.slice(1), amounts, side);
197
- return {
198
- prices,
199
- unit,
200
- data: {
201
- feeOnTransfer: _isSrcTokenTransferFeeToBeExchanged,
202
- path: [
203
- {
204
- tokenIn: from.address,
205
- tokenOut: to.address,
206
- deployer: pool.deployer,
207
- },
208
- ],
209
- },
210
- poolIdentifier: this.getPoolIdentifier(pool.token0, pool.token1, pool.deployer),
211
- exchange: this.dexKey,
212
- gasCost: prices.map(p => (p === 0n ? 0 : averageGasCost)),
213
- poolAddresses: [pool.poolAddress],
214
- };
215
- });
216
- return result;
217
- }
218
- // Returns pool prices for amounts.
219
- // If limitPools is defined only pools in limitPools
220
- // should be used. If limitPools is undefined then
221
- // any pools can be used.
222
- async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools, transferFees = {
223
- srcFee: 0,
224
- destFee: 0,
225
- srcDexFee: 0,
226
- destDexFee: 0,
227
- }) {
228
- try {
229
- const _srcToken = this.dexHelper.config.wrapETH(srcToken);
230
- const _destToken = this.dexHelper.config.wrapETH(destToken);
231
- const [_srcAddress, _destAddress] = this._getLoweredAddresses(_srcToken, _destToken);
232
- if (_srcAddress === _destAddress)
233
- return null;
234
- const pools = await this.getAvailablePools(_srcAddress, _destAddress);
235
- const rpcPrice = await this.getPricingFromRpc(_srcToken, _destToken, amounts, side, pools, transferFees);
236
- return rpcPrice;
237
- }
238
- catch (e) {
239
- this.logger.error(`Error_getPricesVolume ${srcToken.symbol || srcToken.address}, ${destToken.symbol || destToken.address}, ${side}:`, e);
240
- return null;
241
- }
242
- }
243
- // Returns estimated gas cost of calldata for this DEX in multiSwap
244
- getCalldataGasCost(poolPrices) {
245
- // TODO: update if there is any payload in getAdapterParam
246
- return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
247
- }
248
- getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
249
- let swapFunction;
250
- let swapFunctionParams;
251
- if (data.feeOnTransfer) {
252
- (0, utils_2._require)(data.path.length === 1, `LOGIC ERROR: multihop is not supported for feeOnTransfer token, passed: ${data.path
253
- .map(p => `${p?.tokenIn}->${p?.tokenOut}`)
254
- .join(' ')}`);
255
- swapFunction = types_1.AlgebraIntegralFunctions.exactInputWithFeeToken;
256
- swapFunctionParams = {
257
- limitSqrtPrice: '0',
258
- recipient: recipient,
259
- deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
260
- amountIn: srcAmount,
261
- amountOutMinimum: destAmount,
262
- tokenIn: data.path[0].tokenIn,
263
- tokenOut: data.path[0].tokenOut,
264
- deployer: data.path[0].deployer,
265
- };
266
- }
267
- else {
268
- swapFunction =
269
- side === constants_1.SwapSide.SELL
270
- ? types_1.AlgebraIntegralFunctions.exactInput
271
- : types_1.AlgebraIntegralFunctions.exactOutput;
272
- const path = this._encodePath(data.path, side);
273
- swapFunctionParams =
274
- side === constants_1.SwapSide.SELL
275
- ? {
276
- recipient: recipient,
277
- deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
278
- amountIn: srcAmount,
279
- amountOutMinimum: destAmount,
280
- path,
281
- }
282
- : {
283
- recipient: recipient,
284
- deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
285
- amountOut: destAmount,
286
- amountInMaximum: srcAmount,
287
- path,
288
- };
289
- }
290
- const exchangeData = this.routerIface.encodeFunctionData(swapFunction, [
291
- swapFunctionParams,
292
- ]);
293
- return {
294
- needWrapNative: this.needWrapNative,
295
- dexFuncHasRecipient: true,
296
- exchangeData,
297
- targetExchange: this.config.router,
298
- returnAmountPos: side === constants_1.SwapSide.SELL
299
- ? (0, utils_3.extractReturnAmountPosition)(this.routerIface, swapFunction, 'amountOut')
300
- : undefined,
301
- };
302
- }
303
- getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
304
- // Encode here the payload for adapter
305
- const payload = '';
306
- return {
307
- targetExchange: this.config.router,
308
- payload,
309
- networkFee: '0',
310
- };
311
- }
312
- async getAvailablePools(srcToken, destToken) {
313
- // fetch only pools with positive totalValueLockedUSD
314
- const availablePoolsQuery = `query ($token0: Bytes!, $token1: Bytes!) {
315
- pools (where :{token0: $token0, token1: $token1, totalValueLockedUSD_gt: 0}, orderBy: totalValueLockedUSD, orderDirection: desc) {
316
- id
317
- deployer
318
- token0{
319
- id
320
- decimals
321
- }
322
- token1{
323
- id
324
- decimals
325
- }
326
- }
327
- }`;
328
- const [token0, token1] = parseInt(srcToken, 16) < parseInt(destToken, 16)
329
- ? [srcToken, destToken]
330
- : [destToken, srcToken];
331
- const { data } = await this.dexHelper.httpRequest.querySubgraph(this.config.subgraphURL, {
332
- query: availablePoolsQuery,
333
- variables: { token0, token1 },
334
- }, { timeout: constants_1.SUBGRAPH_TIMEOUT });
335
- return data.pools.map(pool => ({
336
- poolAddress: pool.id,
337
- token0: token0,
338
- token1: token1,
339
- deployer: pool.deployer,
340
- }));
341
- }
342
- // Returns list of top pools based on liquidity. Max
343
- // limit number pools should be returned.
344
- async getTopPoolsForToken(tokenAddress, limit) {
345
- const _tokenAddress = tokenAddress.toLowerCase();
346
- const res = await this._querySubgraph(`query ($token: Bytes!, $count: Int) {
347
- pools0: pools(first: $count, orderBy: totalValueLockedUSD, orderDirection: desc, where: {token0: $token}) {
348
- id
349
- deployer
350
- token0 {
351
- id
352
- decimals
353
- }
354
- token1 {
355
- id
356
- decimals
357
- }
358
- totalValueLockedUSD
359
- }
360
- pools1: pools(first: $count, orderBy: totalValueLockedUSD, orderDirection: desc, where: {token1: $token}) {
361
- id
362
- deployer
363
- token0 {
364
- id
365
- decimals
366
- }
367
- token1 {
368
- id
369
- decimals
370
- }
371
- totalValueLockedUSD
372
- }
373
- }`, {
374
- token: _tokenAddress,
375
- count: limit,
376
- });
377
- if (!(res && res.pools0 && res.pools1)) {
378
- this.logger.error(`Error_${this.dexKey}_Subgraph: couldn't fetch the pools from the subgraph`);
379
- return [];
380
- }
381
- const pools0 = lodash_1.default.map(res.pools0, pool => ({
382
- exchange: this.dexKey,
383
- address: pool.id.toLowerCase(),
384
- connectorTokens: [
385
- {
386
- address: pool.token1.id.toLowerCase(),
387
- decimals: parseInt(pool.token1.decimals),
388
- },
389
- ],
390
- liquidityUSD: parseFloat(pool.totalValueLockedUSD) * ALGEBRA_EFFICIENCY_FACTOR,
391
- }));
392
- const pools1 = lodash_1.default.map(res.pools1, pool => ({
393
- exchange: this.dexKey,
394
- address: pool.id.toLowerCase(),
395
- connectorTokens: [
396
- {
397
- address: pool.token0.id.toLowerCase(),
398
- decimals: parseInt(pool.token0.decimals),
399
- },
400
- ],
401
- liquidityUSD: parseFloat(pool.totalValueLockedUSD) * ALGEBRA_EFFICIENCY_FACTOR,
402
- }));
403
- const pools = lodash_1.default.slice(lodash_1.default.sortBy(lodash_1.default.concat(pools0, pools1), [pool => -1 * pool.liquidityUSD]), 0, limit);
404
- return pools;
405
- }
406
- async _querySubgraph(query, variables, timeout = 30000) {
407
- try {
408
- const res = await this.dexHelper.httpRequest.querySubgraph(this.config.subgraphURL, { query, variables }, { timeout });
409
- return res.data;
410
- }
411
- catch (e) {
412
- this.logger.error(`${this.dexKey}: can not query subgraph: `, e);
413
- return {};
414
- }
415
- }
416
- _encodePath(path, side) {
417
- if (path.length === 0) {
418
- return '0x';
419
- }
420
- const { _path, types } = path.reduce(({ _path, types }, curr, index) => {
421
- if (index === 0) {
422
- return {
423
- types: ['address', 'address', 'address'],
424
- _path: [curr.tokenIn, curr.deployer, curr.tokenOut],
425
- };
426
- }
427
- else {
428
- return {
429
- types: [...types, 'address', 'address'],
430
- _path: [..._path, curr.deployer, curr.tokenOut],
431
- };
432
- }
433
- }, { _path: [], types: [] });
434
- return side === constants_1.SwapSide.BUY
435
- ? (0, solidity_1.pack)(types.reverse(), _path.reverse())
436
- : (0, solidity_1.pack)(types, _path);
437
- }
438
- _sortTokens(srcAddress, destAddress) {
439
- return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
440
- }
441
- _getLoweredAddresses(srcToken, destToken) {
442
- return [srcToken.address.toLowerCase(), destToken.address.toLowerCase()];
443
- }
444
- }
445
- exports.AlgebraIntegral = AlgebraIntegral;
446
- //# sourceMappingURL=algebra-integral.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"algebra-integral.js","sourceRoot":"","sources":["../../../src/dex/algebra-integral/algebra-integral.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAqD;AAGrD,sDAA+C;AAC/C,oDAAuB;AAcvB,+CAMyB;AACzB,2EAA6D;AAC7D,4CAA6C;AAE7C,wEAAgF;AAChF,yGAAwE;AACxE,iGAA0E;AAC1E,uGAA2E;AAC3E,uCAOqB;AAGrB,mCAA8E;AAC9E,wDAG4B;AAC5B,qEAAgE;AAChE,qCAAiD;AACjD,kDAIgC;AAChC,gDAAmE;AAEnE,MAAM,sBAAsB,GAAG,SAAS,CAAC;AACzC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAa,eACX,SAAQ,gCAAc;IAgBX;IACA;IACA;IACA;IACA;IACA;IAlBF,4BAA4B,GAAG,KAAK,CAAC;IACrC,cAAc,GAAG,IAAI,CAAC;IAEtB,wBAAwB,GAAG,IAAI,CAAC;IAElC,MAAM,CAAC,kBAAkB,GAC9B,IAAA,6BAAqB,EAAC,8BAAqB,CAAC,CAAC;IAE/C,MAAM,CAAS;IAEP,YAAY,CAAW;IAE/B,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACrB,cAAc,IAAI,iBAAS,CAAC,6BAAU,CAAC,EACvC,cAAc,IAAI,iBAAS,CAAC,yBAAgB,CAAC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AAE,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IAEO,oBAAoB,CAAC,QAAe,EAAE,SAAgB;QAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3E,CAAC;;AA3lBH,0CA4lBC"}
@@ -1,3 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap } from '../../types';
3
- export declare const AlgebraIntegralConfig: DexConfigMap<DexParams>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AlgebraIntegralConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.AlgebraIntegralConfig = {
6
- QuickSwap: {
7
- [constants_1.Network.POLYGON]: {
8
- factory: '0x96117a894c2c99aafeeacb972c3310e6ac83e810',
9
- subgraphURL: 'B8VaWM5T8miDW4TKdGRAkZXvLekpptQykxNV8vVP8fhg',
10
- quoter: '0xae65e71bcd7c84c8bc53532f6f784ed15a68f8b7',
11
- router: '0xee2a7a531bcf524392dc3db67bb400bae3833991',
12
- uniswapMulticall: '0x536310b521120dd3c195e78e5c26d61b938a4594',
13
- chunksCount: 10,
14
- },
15
- },
16
- };
17
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/algebra-integral/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,qBAAqB,GAA4B;IAC5D,SAAS,EAAE;QACT,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,OAAO,EAAE,4CAA4C;YACrD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,gBAAgB,EAAE,4CAA4C;YAC9D,WAAW,EAAE,EAAE;SAChB;KACF;CACF,CAAC"}
@@ -1,33 +0,0 @@
1
- import { Address } from '../../types';
2
- export type AlgebraIntegralData = {
3
- path: {
4
- tokenIn: Address;
5
- tokenOut: Address;
6
- deployer: Address;
7
- }[];
8
- feeOnTransfer: boolean;
9
- isApproved?: boolean;
10
- };
11
- export type AlgebraDataWithFee = {
12
- tokenIn: Address;
13
- tokenOut: Address;
14
- };
15
- export type DexParams = {
16
- factory: Address;
17
- quoter: Address;
18
- router: Address;
19
- subgraphURL: string;
20
- uniswapMulticall: Address;
21
- chunksCount: number;
22
- };
23
- export type Pool = {
24
- poolAddress: Address;
25
- token0: Address;
26
- token1: Address;
27
- deployer: string;
28
- };
29
- export declare enum AlgebraIntegralFunctions {
30
- exactInput = "exactInput",
31
- exactOutput = "exactOutput",
32
- exactInputWithFeeToken = "exactInputSingleSupportingFeeOnTransferTokens"
33
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AlgebraIntegralFunctions = void 0;
4
- var AlgebraIntegralFunctions;
5
- (function (AlgebraIntegralFunctions) {
6
- AlgebraIntegralFunctions["exactInput"] = "exactInput";
7
- AlgebraIntegralFunctions["exactOutput"] = "exactOutput";
8
- AlgebraIntegralFunctions["exactInputWithFeeToken"] = "exactInputSingleSupportingFeeOnTransferTokens";
9
- })(AlgebraIntegralFunctions || (exports.AlgebraIntegralFunctions = AlgebraIntegralFunctions = {}));
10
- //# sourceMappingURL=types.js.map