@paraswap/dex-lib 3.6.2 → 3.6.3

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 (109) hide show
  1. package/build/dex/aave-v1/aave-v1.d.ts +1 -2
  2. package/build/dex/aave-v1/aave-v1.js +0 -23
  3. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  4. package/build/dex/compound.js +1 -1
  5. package/build/dex/compound.js.map +1 -1
  6. package/build/dex/etherfi/etherfi.d.ts +26 -0
  7. package/build/dex/etherfi/etherfi.js +96 -0
  8. package/build/dex/etherfi/etherfi.js.map +1 -0
  9. package/build/dex/index.js +2 -0
  10. package/build/dex/index.js.map +1 -1
  11. package/build/dex/maverick-v2/config.d.ts +2 -2
  12. package/build/dex/maverick-v2/config.js +16 -9
  13. package/build/dex/maverick-v2/config.js.map +1 -1
  14. package/build/dex/maverick-v2/maverick-math/maverick-basic-math.js +3 -3
  15. package/build/dex/maverick-v2/maverick-math/maverick-basic-math.js.map +1 -1
  16. package/build/dex/maverick-v2/maverick-math/maverick-bin-math.js +4 -4
  17. package/build/dex/maverick-v2/maverick-math/maverick-bin-math.js.map +1 -1
  18. package/build/dex/maverick-v2/maverick-math/maverick-math.js +3 -3
  19. package/build/dex/maverick-v2/maverick-math/maverick-math.js.map +1 -1
  20. package/build/dex/maverick-v2/maverick-math/maverick-pool-math.js +13 -13
  21. package/build/dex/maverick-v2/maverick-math/maverick-pool-math.js.map +1 -1
  22. package/build/dex/maverick-v2/maverick-math/maverick-swap-math.js +1 -1
  23. package/build/dex/maverick-v2/maverick-math/maverick-swap-math.js.map +1 -1
  24. package/build/dex/maverick-v2/maverick-math/maverick-tick-math.js +4 -4
  25. package/build/dex/maverick-v2/maverick-math/maverick-tick-math.js.map +1 -1
  26. package/build/dex/maverick-v2/maverick-math/maverick-twa-math.js +3 -3
  27. package/build/dex/maverick-v2/maverick-math/maverick-twa-math.js.map +1 -1
  28. package/build/dex/maverick-v2/maverick-v2-pool.d.ts +12 -9
  29. package/build/dex/maverick-v2/maverick-v2-pool.js +71 -16
  30. package/build/dex/maverick-v2/maverick-v2-pool.js.map +1 -1
  31. package/build/dex/maverick-v2/maverick-v2.d.ts +4 -8
  32. package/build/dex/maverick-v2/maverick-v2.js +62 -90
  33. package/build/dex/maverick-v2/maverick-v2.js.map +1 -1
  34. package/build/dex/maverick-v2/types.d.ts +1 -2
  35. package/build/dex/platypus/platypus.d.ts +1 -2
  36. package/build/dex/platypus/platypus.js +0 -45
  37. package/build/dex/platypus/platypus.js.map +1 -1
  38. package/build/dex/sdai/config.d.ts +11 -0
  39. package/build/dex/sdai/config.js +21 -0
  40. package/build/dex/sdai/config.js.map +1 -0
  41. package/build/dex/sdai/constants.d.ts +2 -0
  42. package/build/dex/sdai/constants.js +6 -0
  43. package/build/dex/sdai/constants.js.map +1 -0
  44. package/build/dex/sdai/scripts/validate-state.js +102 -0
  45. package/build/dex/sdai/scripts/validate-state.js.map +1 -0
  46. package/build/dex/sdai/sdai-pool.d.ts +16 -0
  47. package/build/dex/sdai/sdai-pool.js +85 -0
  48. package/build/dex/sdai/sdai-pool.js.map +1 -0
  49. package/build/dex/sdai/sdai.d.ts +51 -0
  50. package/build/dex/sdai/sdai.js +172 -0
  51. package/build/dex/sdai/sdai.js.map +1 -0
  52. package/build/dex/sdai/types.d.ts +21 -0
  53. package/build/dex/sdai/types.js +11 -0
  54. package/build/dex/sdai/types.js.map +1 -0
  55. package/build/dex/sdai/utils.d.ts +4 -0
  56. package/build/dex/sdai/utils.js +39 -0
  57. package/build/dex/sdai/utils.js.map +1 -0
  58. package/build/dex/stable-pool.js +8 -1
  59. package/build/dex/stable-pool.js.map +1 -1
  60. package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
  61. package/build/dex/swaap-v1/swaap-v1.js +0 -14
  62. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/abi/maverick-v2/MaverickV2Pool.json +1234 -0
  65. package/src/abi/maverick-v2/MaverickV2PoolLens.json +1232 -0
  66. package/src/abi/maverick-v2/MaverickV2Quoter.json +278 -0
  67. package/src/dex/index.ts +2 -0
  68. package/src/dex/maverick-v2/config.ts +28 -0
  69. package/src/dex/maverick-v2/maverick-math/maverick-basic-math.ts +152 -0
  70. package/src/dex/maverick-v2/maverick-math/maverick-bin-math.ts +288 -0
  71. package/src/dex/maverick-v2/maverick-math/maverick-delta-math.ts +32 -0
  72. package/src/dex/maverick-v2/maverick-math/maverick-math.ts +30 -0
  73. package/src/dex/maverick-v2/maverick-math/maverick-pool-lib.ts +42 -0
  74. package/src/dex/maverick-v2/maverick-math/maverick-pool-math.ts +709 -0
  75. package/src/dex/maverick-v2/maverick-math/maverick-swap-math.ts +199 -0
  76. package/src/dex/maverick-v2/maverick-math/maverick-tick-math.ts +171 -0
  77. package/src/dex/maverick-v2/maverick-math/maverick-twa-math.ts +54 -0
  78. package/src/dex/maverick-v2/maverick-v2-e2e.test.ts +193 -0
  79. package/src/dex/maverick-v2/maverick-v2-events.test.ts +112 -0
  80. package/src/dex/maverick-v2/maverick-v2-integration.test.ts +283 -0
  81. package/src/dex/maverick-v2/maverick-v2-pool.ts +346 -0
  82. package/src/dex/maverick-v2/maverick-v2.ts +380 -0
  83. package/src/dex/maverick-v2/types.ts +151 -0
  84. package/tests/constants-e2e.ts +2 -2
  85. package/.vscode/launch.json +0 -53
  86. package/.vscode/settings.json +0 -2
  87. package/.vscode/tasks.json +0 -15
  88. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
  89. package/build/abi/wombat/pool.json +0 -1289
  90. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  91. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  92. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  93. package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
  94. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  95. package/build/dex/maker-psm/scripts/validate-state.js +0 -185
  96. package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
  97. package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
  98. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
  99. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
  100. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
  101. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
  102. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
  103. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
  104. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
  105. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
  106. package/src/dex/maker-psm/scripts/gem.abi.json +0 -136
  107. package/src/dex/maker-psm/scripts/validate-state.ts +0 -221
  108. package/src/dex/maker-psm/scripts/vat.abi.json +0 -243
  109. /package/build/dex/{solidly-v3/scripts/check-event-pool-event.d.ts → sdai/scripts/validate-state.d.ts} +0 -0
@@ -1,221 +0,0 @@
1
- // /* eslint-disable no-console */
2
- // import dotenv from 'dotenv';
3
- // dotenv.config();
4
-
5
- // import { Network } from '../../../constants';
6
- // import { DummyDexHelper } from '../../../dex-helper';
7
- // import { BlockHeader } from 'web3-eth';
8
- // import { MakerPsmConfig } from '../config';
9
- // import { BigNumber, ethers } from 'ethers';
10
- // import { Interface } from '@ethersproject/abi';
11
- // import _ from 'lodash';
12
- // import vatABI from './vat.abi.json';
13
- // import gemABI from './gem.abi.json';
14
- // // @ts-ignore
15
- // import { Tokens } from '../../../../tests/constants-e2e';
16
-
17
- // const tokens = Tokens[Network.MAINNET];
18
-
19
- // const vatInterface = new Interface(vatABI);
20
- // const gemInterface = new Interface(gemABI);
21
- // const erc20Interface = new Interface([
22
- // {
23
- // constant: true,
24
- // inputs: [{ internalType: 'address', name: '', type: 'address' }],
25
- // name: 'balanceOf',
26
- // outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
27
- // payable: false,
28
- // stateMutability: 'view',
29
- // type: 'function',
30
- // },
31
- // ]);
32
-
33
- // const network = Network.MAINNET;
34
- // const vat = MakerPsmConfig.MakerPsm[Network.MAINNET].vatAddress;
35
- // const MOVE_TOPIC =
36
- // '0xbb35783b00000000000000000000000000000000000000000000000000000000';
37
-
38
- // const dexHelper = new DummyDexHelper(network);
39
-
40
- // async function findNewGems(): Promise<boolean> {
41
- // const network = Network.MAINNET;
42
- // const dexHelper = new DummyDexHelper(network);
43
-
44
- // const lastBlockNumber = await dexHelper.provider.getBlockNumber();
45
-
46
- // const startBlockNumber = lastBlockNumber - 1_000_000;
47
- // const endBlockNumber = lastBlockNumber;
48
- // // const startBlockNumber = endBlockNumber - 700_000;
49
-
50
- // const totalRange = endBlockNumber - startBlockNumber;
51
-
52
- // const smallChunkSize = 10_000;
53
- // const bigChunkSize = 100_000;
54
-
55
- // const bigChunks = Math.ceil(totalRange / bigChunkSize);
56
-
57
- // const smallChunks = Math.ceil(bigChunkSize / smallChunkSize);
58
-
59
- // const uniquePotentialGemJoinsSet = new Set();
60
-
61
- // for (let i = 0; i < bigChunks; i++) {
62
- // console.log('Processing chunk', i + 1, 'of', bigChunks);
63
- // const from = startBlockNumber + i * bigChunkSize;
64
- // console.log(
65
- // new Array(smallChunks).fill(0).map((_, smallChunkNumber) => ({
66
- // fromBlock: from + smallChunkNumber * smallChunkSize,
67
- // toBlock: from + smallChunkNumber * smallChunkSize + smallChunkSize,
68
- // })),
69
- // );
70
-
71
- // const logsToDispatch = (
72
- // await Promise.all(
73
- // new Array(smallChunks).fill(0).map((_, smallChunkNumber) =>
74
- // dexHelper.provider.getLogs({
75
- // fromBlock: from + smallChunkNumber * smallChunkSize,
76
- // toBlock: from + smallChunkNumber * smallChunkSize + smallChunkSize,
77
- // address: vat,
78
- // }),
79
- // ),
80
- // )
81
- // ).flat();
82
-
83
- // const moveLogs = logsToDispatch.filter(l => l.topics[0] === MOVE_TOPIC);
84
-
85
- // const potentialGemJoins = moveLogs.map(
86
- // l => ethers.utils.defaultAbiCoder.decode(['address'], l.topics[1])[0],
87
- // );
88
-
89
- // potentialGemJoins.forEach(gemJoin =>
90
- // uniquePotentialGemJoinsSet.add(gemJoin),
91
- // );
92
- // }
93
-
94
- // const uniquePotentialGemJoins = Array.from(uniquePotentialGemJoinsSet);
95
- // console.log('unique potential gem joins', uniquePotentialGemJoins.length);
96
-
97
- // const gemJoinCalldata = uniquePotentialGemJoins
98
- // .map(gemJoin => {
99
- // return [
100
- // {
101
- // target: gemJoin,
102
- // callData: vatInterface.encodeFunctionData('gemJoin'),
103
- // },
104
- // ];
105
- // })
106
- // .flat();
107
-
108
- // const slicedGemJoinCallData = _.chunk(gemJoinCalldata, 500);
109
-
110
- // const gemJoinData = (
111
- // await Promise.all(
112
- // slicedGemJoinCallData.map(async _multiCallData =>
113
- // dexHelper.multiContract.methods
114
- // .tryAggregate(false, _multiCallData)
115
- // .call({}),
116
- // ),
117
- // )
118
- // ).flat();
119
-
120
- // // console.log(
121
- // // gemJoinData
122
- // // .map((data, i) => ({ ...data, index: i }))
123
- // // .filter(d => d.returnData !== '0x' && d.returnData.length === 66)
124
- // // .map(d => [d.returnData, gemJoinCalldata[d.index]]),
125
- // // );
126
-
127
- // const gemJoins = gemJoinData
128
- // .filter(d => d.returnData !== '0x' && d.returnData.length === 66)
129
- // .map(
130
- // d => ethers.utils.defaultAbiCoder.decode(['address'], d.returnData)[0],
131
- // );
132
-
133
- // const uniqueGemJoins = [...new Set(gemJoins)];
134
- // console.log('unique gem joins', uniqueGemJoins.length);
135
-
136
- // const gemCalldata = uniqueGemJoins
137
- // .map(gemJoin => {
138
- // return [
139
- // {
140
- // target: gemJoin,
141
- // callData: gemInterface.encodeFunctionData('gem'),
142
- // },
143
- // ];
144
- // })
145
- // .flat();
146
-
147
- // const returnGemData = await dexHelper.multiContract.methods
148
- // .tryAggregate(false, gemCalldata)
149
- // .call({});
150
-
151
- // const gems = returnGemData
152
- // .filter((d: any) => d.returnData !== '0x')
153
- // .map(
154
- // (d: any) =>
155
- // ethers.utils.defaultAbiCoder.decode(['address'], d.returnData)[0],
156
- // );
157
-
158
- // const balanceCalldata = gems
159
- // .map((gem: any, i: number) => {
160
- // return [
161
- // {
162
- // target: gem,
163
- // callData: erc20Interface.encodeFunctionData('balanceOf', [
164
- // uniqueGemJoins[i],
165
- // ]),
166
- // },
167
- // ];
168
- // })
169
- // .flat();
170
-
171
- // const returnBalanceData = await dexHelper.multiContract.methods
172
- // .tryAggregate(false, balanceCalldata)
173
- // .call({});
174
-
175
- // console.log(returnBalanceData);
176
-
177
- // const balances: BigNumber[] = returnBalanceData
178
- // .filter((d: any) => d.returnData !== '0x')
179
- // .map(
180
- // (d: any) =>
181
- // ethers.utils.defaultAbiCoder.decode(['uint256'], d.returnData)[0],
182
- // );
183
-
184
- // console.log(balances.map(b => b.toString()));
185
-
186
- // const data = uniqueGemJoins.map((gemJoin, i) => {
187
- // const token = Object.values(tokens).find(
188
- // t => t.address.toLowerCase() === gems[i].toLowerCase(),
189
- // );
190
- // const symbol = token
191
- // ? Object.entries(tokens).find(
192
- // ([symbol, t]) => t.address.toLowerCase() === gems[i].toLowerCase(),
193
- // )?.[0]
194
- // : 'Not found';
195
- // const balance = token
196
- // ? Number(ethers.utils.formatUnits(balances[i], token.decimals))
197
- // : balances[i].toString();
198
-
199
- // return {
200
- // gemJoin,
201
- // gem: gems[i],
202
- // balance,
203
- // ...(token
204
- // ? {
205
- // address: gems[i],
206
- // decimals: token.decimals,
207
- // symbol,
208
- // }
209
- // : { address: gems[i] }),
210
- // };
211
- // });
212
-
213
- // console.log(data);
214
-
215
- // // const address = logsToDispatch[0].address;
216
- // return true;
217
- // }
218
-
219
- // findNewGems()
220
- // .then(() => console.log('Done'))
221
- // .catch(e => console.error(e));
@@ -1,243 +0,0 @@
1
- [
2
- {
3
- "inputs": [
4
- { "internalType": "address", "name": "gemJoin_", "type": "address" },
5
- { "internalType": "address", "name": "daiJoin_", "type": "address" },
6
- { "internalType": "address", "name": "vow_", "type": "address" }
7
- ],
8
- "stateMutability": "nonpayable",
9
- "type": "constructor"
10
- },
11
- {
12
- "anonymous": false,
13
- "inputs": [
14
- {
15
- "indexed": true,
16
- "internalType": "address",
17
- "name": "owner",
18
- "type": "address"
19
- },
20
- {
21
- "indexed": false,
22
- "internalType": "uint256",
23
- "name": "value",
24
- "type": "uint256"
25
- },
26
- {
27
- "indexed": false,
28
- "internalType": "uint256",
29
- "name": "fee",
30
- "type": "uint256"
31
- }
32
- ],
33
- "name": "BuyGem",
34
- "type": "event"
35
- },
36
- {
37
- "anonymous": false,
38
- "inputs": [
39
- {
40
- "indexed": false,
41
- "internalType": "address",
42
- "name": "user",
43
- "type": "address"
44
- }
45
- ],
46
- "name": "Deny",
47
- "type": "event"
48
- },
49
- {
50
- "anonymous": false,
51
- "inputs": [
52
- {
53
- "indexed": true,
54
- "internalType": "bytes32",
55
- "name": "what",
56
- "type": "bytes32"
57
- },
58
- {
59
- "indexed": false,
60
- "internalType": "uint256",
61
- "name": "data",
62
- "type": "uint256"
63
- }
64
- ],
65
- "name": "File",
66
- "type": "event"
67
- },
68
- {
69
- "anonymous": false,
70
- "inputs": [
71
- {
72
- "indexed": false,
73
- "internalType": "address",
74
- "name": "user",
75
- "type": "address"
76
- }
77
- ],
78
- "name": "Rely",
79
- "type": "event"
80
- },
81
- {
82
- "anonymous": false,
83
- "inputs": [
84
- {
85
- "indexed": true,
86
- "internalType": "address",
87
- "name": "owner",
88
- "type": "address"
89
- },
90
- {
91
- "indexed": false,
92
- "internalType": "uint256",
93
- "name": "value",
94
- "type": "uint256"
95
- },
96
- {
97
- "indexed": false,
98
- "internalType": "uint256",
99
- "name": "fee",
100
- "type": "uint256"
101
- }
102
- ],
103
- "name": "SellGem",
104
- "type": "event"
105
- },
106
- {
107
- "inputs": [
108
- { "internalType": "address", "name": "usr", "type": "address" },
109
- { "internalType": "uint256", "name": "gemAmt", "type": "uint256" }
110
- ],
111
- "name": "buyGem",
112
- "outputs": [],
113
- "stateMutability": "nonpayable",
114
- "type": "function"
115
- },
116
- {
117
- "inputs": [],
118
- "name": "dai",
119
- "outputs": [
120
- { "internalType": "contract DaiAbstract", "name": "", "type": "address" }
121
- ],
122
- "stateMutability": "view",
123
- "type": "function"
124
- },
125
- {
126
- "inputs": [],
127
- "name": "daiJoin",
128
- "outputs": [
129
- {
130
- "internalType": "contract DaiJoinAbstract",
131
- "name": "",
132
- "type": "address"
133
- }
134
- ],
135
- "stateMutability": "view",
136
- "type": "function"
137
- },
138
- {
139
- "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }],
140
- "name": "deny",
141
- "outputs": [],
142
- "stateMutability": "nonpayable",
143
- "type": "function"
144
- },
145
- {
146
- "inputs": [
147
- { "internalType": "bytes32", "name": "what", "type": "bytes32" },
148
- { "internalType": "uint256", "name": "data", "type": "uint256" }
149
- ],
150
- "name": "file",
151
- "outputs": [],
152
- "stateMutability": "nonpayable",
153
- "type": "function"
154
- },
155
- {
156
- "inputs": [],
157
- "name": "gemJoin",
158
- "outputs": [
159
- {
160
- "internalType": "contract AuthGemJoinAbstract",
161
- "name": "",
162
- "type": "address"
163
- }
164
- ],
165
- "stateMutability": "view",
166
- "type": "function"
167
- },
168
- {
169
- "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }],
170
- "name": "hope",
171
- "outputs": [],
172
- "stateMutability": "nonpayable",
173
- "type": "function"
174
- },
175
- {
176
- "inputs": [],
177
- "name": "ilk",
178
- "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
179
- "stateMutability": "view",
180
- "type": "function"
181
- },
182
- {
183
- "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }],
184
- "name": "nope",
185
- "outputs": [],
186
- "stateMutability": "nonpayable",
187
- "type": "function"
188
- },
189
- {
190
- "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }],
191
- "name": "rely",
192
- "outputs": [],
193
- "stateMutability": "nonpayable",
194
- "type": "function"
195
- },
196
- {
197
- "inputs": [
198
- { "internalType": "address", "name": "usr", "type": "address" },
199
- { "internalType": "uint256", "name": "gemAmt", "type": "uint256" }
200
- ],
201
- "name": "sellGem",
202
- "outputs": [],
203
- "stateMutability": "nonpayable",
204
- "type": "function"
205
- },
206
- {
207
- "inputs": [],
208
- "name": "tin",
209
- "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
210
- "stateMutability": "view",
211
- "type": "function"
212
- },
213
- {
214
- "inputs": [],
215
- "name": "tout",
216
- "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
217
- "stateMutability": "view",
218
- "type": "function"
219
- },
220
- {
221
- "inputs": [],
222
- "name": "vat",
223
- "outputs": [
224
- { "internalType": "contract VatAbstract", "name": "", "type": "address" }
225
- ],
226
- "stateMutability": "view",
227
- "type": "function"
228
- },
229
- {
230
- "inputs": [],
231
- "name": "vow",
232
- "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
233
- "stateMutability": "view",
234
- "type": "function"
235
- },
236
- {
237
- "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
238
- "name": "wards",
239
- "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
240
- "stateMutability": "view",
241
- "type": "function"
242
- }
243
- ]