@paraswap/dex-lib 3.7.2 → 3.7.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.
- package/build/abi/Redstone.json +739 -0
- package/build/abi/aavev3stata/Factory.json +128 -0
- package/build/abi/aavev3stata/Token.json +735 -0
- package/build/abi/angle-transmuter/MorphoOracle.json +193 -0
- package/build/abi/angle-transmuter/MorphoVault.json +2506 -0
- package/build/abi/angle-transmuter/Pyth.json +1534 -0
- package/build/abi/angle-transmuter/Transmuter.json +1711 -0
- package/build/abi/angle-transmuter/TransmuterSidechain.json +1798 -0
- package/build/abi/idle-dao/idle-cdo-factory.json +38 -0
- package/build/abi/idle-dao/idle-cdo.json +1245 -0
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +22 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v3-stata/aave-v3-stata.d.ts +50 -0
- package/build/dex/aave-v3-stata/aave-v3-stata.js +365 -0
- package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -0
- package/build/dex/aave-v3-stata/config.d.ts +4 -0
- package/build/dex/aave-v3-stata/config.js +50 -0
- package/build/dex/aave-v3-stata/config.js.map +1 -0
- package/build/dex/aave-v3-stata/tokens.d.ts +9 -0
- package/build/dex/aave-v3-stata/tokens.js +37 -0
- package/build/dex/aave-v3-stata/tokens.js.map +1 -0
- package/build/dex/aave-v3-stata/types.d.ts +46 -0
- package/build/dex/aave-v3-stata/types.js +23 -0
- package/build/dex/aave-v3-stata/types.js.map +1 -0
- package/build/dex/aave-v3-stata/utils.d.ts +4 -0
- package/build/dex/aave-v3-stata/utils.js +67 -0
- package/build/dex/aave-v3-stata/utils.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +67 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +448 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +59 -0
- package/build/dex/angle-transmuter/angle-transmuter.js +264 -0
- package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
- package/build/dex/angle-transmuter/backedOracle.js +56 -0
- package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
- package/build/dex/angle-transmuter/config.d.ts +4 -0
- package/build/dex/angle-transmuter/config.js +50 -0
- package/build/dex/angle-transmuter/config.js.map +1 -0
- package/build/dex/angle-transmuter/constants.d.ts +9 -0
- package/build/dex/angle-transmuter/constants.js +136 -0
- package/build/dex/angle-transmuter/constants.js.map +1 -0
- package/build/dex/angle-transmuter/morphoOracle.d.ts +42 -0
- package/build/dex/angle-transmuter/morphoOracle.js +179 -0
- package/build/dex/angle-transmuter/morphoOracle.js.map +1 -0
- package/build/dex/angle-transmuter/morphoVault.d.ts +20 -0
- package/build/dex/angle-transmuter/morphoVault.js +84 -0
- package/build/dex/angle-transmuter/morphoVault.js.map +1 -0
- package/build/dex/angle-transmuter/pyth.d.ts +19 -0
- package/build/dex/angle-transmuter/pyth.js +70 -0
- package/build/dex/angle-transmuter/pyth.js.map +1 -0
- package/build/dex/angle-transmuter/redstone.d.ts +20 -0
- package/build/dex/angle-transmuter/redstone.js +64 -0
- package/build/dex/angle-transmuter/redstone.js.map +1 -0
- package/build/dex/angle-transmuter/transmuter.d.ts +55 -0
- package/build/dex/angle-transmuter/transmuter.js +398 -0
- package/build/dex/angle-transmuter/transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/types.d.ts +189 -0
- package/build/dex/angle-transmuter/types.js +33 -0
- package/build/dex/angle-transmuter/types.js.map +1 -0
- package/build/dex/angle-transmuter/utils.d.ts +9 -0
- package/build/dex/angle-transmuter/utils.js +257 -0
- package/build/dex/angle-transmuter/utils.js.map +1 -0
- package/build/dex/idle-dao/config.d.ts +6 -0
- package/build/dex/idle-dao/config.js +307 -0
- package/build/dex/idle-dao/config.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao.d.ts +41 -0
- package/build/dex/idle-dao/idle-dao.js +238 -0
- package/build/dex/idle-dao/idle-dao.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/idle-dao/tokens.d.ts +9 -0
- package/build/dex/idle-dao/tokens.js +65 -0
- package/build/dex/idle-dao/tokens.js.map +1 -0
- package/build/dex/idle-dao/types.d.ts +35 -0
- package/build/dex/idle-dao/types.js +11 -0
- package/build/dex/idle-dao/types.js.map +1 -0
- package/build/dex/idle-dao/utils.d.ts +8 -0
- package/build/dex/idle-dao/utils.js +148 -0
- package/build/dex/idle-dao/utils.js.map +1 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +31 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +10 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/lib/chainlink.d.ts +2 -0
- package/build/lib/chainlink.js +9 -0
- package/build/lib/chainlink.js.map +1 -1
- package/build/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/abi/Redstone.json +739 -0
- package/src/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
- package/src/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -0
- package/src/abi/angle-transmuter/MorphoOracle.json +193 -0
- package/src/abi/angle-transmuter/MorphoVault.json +2506 -0
- package/src/abi/angle-transmuter/Pyth.json +1534 -0
- package/src/abi/angle-transmuter/Transmuter.json +1711 -0
- package/src/abi/angle-transmuter/TransmuterSidechain.json +1798 -0
- package/src/dex/angle-transmuter/angle-transmuter-e2e.test.ts +156 -0
- package/src/dex/angle-transmuter/angle-transmuter-events.test.ts +365 -0
- package/src/dex/angle-transmuter/angle-transmuter-integration.test.ts +390 -0
- package/src/dex/angle-transmuter/angle-transmuter-pool.ts +895 -0
- package/src/dex/angle-transmuter/angle-transmuter.ts +408 -0
- package/src/dex/angle-transmuter/backedOracle.ts +91 -0
- package/src/dex/angle-transmuter/config.ts +50 -0
- package/src/dex/angle-transmuter/constants.ts +138 -0
- package/src/dex/angle-transmuter/morphoOracle.ts +335 -0
- package/src/dex/angle-transmuter/morphoVault.ts +134 -0
- package/src/dex/angle-transmuter/pyth.ts +105 -0
- package/src/dex/angle-transmuter/redstone.ts +105 -0
- package/src/dex/angle-transmuter/transmuter.ts +619 -0
- package/src/dex/angle-transmuter/types.ts +203 -0
- package/src/dex/angle-transmuter/utils.ts +358 -0
- package/src/dex/index.ts +2 -0
- package/src/lib/chainlink.ts +15 -0
- package/tests/constants-e2e.ts +48 -3
- package/build/abi/Uncompressor.json +0 -250
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/etherfi/etherfi.d.ts +0 -26
- package/build/dex/etherfi/etherfi.js +0 -96
- package/build/dex/etherfi/etherfi.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/sdai/config.d.ts +0 -11
- package/build/dex/sdai/config.js +0 -21
- package/build/dex/sdai/config.js.map +0 -1
- package/build/dex/sdai/constants.d.ts +0 -2
- package/build/dex/sdai/constants.js +0 -6
- package/build/dex/sdai/constants.js.map +0 -1
- package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
- package/build/dex/sdai/scripts/validate-state.js +0 -102
- package/build/dex/sdai/scripts/validate-state.js.map +0 -1
- package/build/dex/sdai/sdai-pool.d.ts +0 -16
- package/build/dex/sdai/sdai-pool.js +0 -85
- package/build/dex/sdai/sdai-pool.js.map +0 -1
- package/build/dex/sdai/sdai.d.ts +0 -51
- package/build/dex/sdai/sdai.js +0 -172
- package/build/dex/sdai/sdai.js.map +0 -1
- package/build/dex/sdai/types.d.ts +0 -21
- package/build/dex/sdai/types.js +0 -11
- package/build/dex/sdai/types.js.map +0 -1
- package/build/dex/sdai/utils.d.ts +0 -4
- package/build/dex/sdai/utils.js +0 -39
- package/build/dex/sdai/utils.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- package/build/executor/compressor/Compressor.d.ts +0 -23
- package/build/executor/compressor/Compressor.js +0 -144
- package/build/executor/compressor/Compressor.js.map +0 -1
- package/build/executor/compressor/compress.d.ts +0 -17
- package/build/executor/compressor/compress.js +0 -187
- package/build/executor/compressor/compress.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
- package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
- package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +0 -17
- package/build/executor/compressor/fetchSaved.js.map +0 -1
- package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
- package/build/executor/compressor/utils/computeCostL2.js +0 -14
- package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
- package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
- package/build/executor/compressor/utils/getAllIndexes.js +0 -12
- package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
- package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
- package/build/executor/compressor/utils/getByteForAddress.js +0 -14
- package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
- package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
- package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intToByte.d.ts +0 -2
- package/build/executor/compressor/utils/intToByte.js +0 -10
- package/build/executor/compressor/utils/intToByte.js.map +0 -1
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { Interface, Result } from '@ethersproject/abi';
|
|
6
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
7
|
+
import { Network, SwapSide } from '../../constants';
|
|
8
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
+
import { AngleTransmuter } from './angle-transmuter';
|
|
10
|
+
import {
|
|
11
|
+
checkPoolPrices,
|
|
12
|
+
checkPoolsLiquidity,
|
|
13
|
+
checkConstantPoolPrices,
|
|
14
|
+
} from '../../../tests/utils';
|
|
15
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
16
|
+
import { Address } from '../../types';
|
|
17
|
+
import { SmartTokenParams } from '../../../tests/smart-tokens';
|
|
18
|
+
import { TransmuterSubscriber } from './transmuter';
|
|
19
|
+
import { AngleTransmuterConfig } from './config';
|
|
20
|
+
|
|
21
|
+
export type Collateral = { [stablecoin: string]: SmartTokenParams[] };
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
README
|
|
25
|
+
======
|
|
26
|
+
|
|
27
|
+
This test script adds tests for AngleTransmuter general integration
|
|
28
|
+
with the DEX interface. The test cases below are example tests.
|
|
29
|
+
It is recommended to add tests which cover AngleTransmuter specific
|
|
30
|
+
logic.
|
|
31
|
+
|
|
32
|
+
You can run this individual test script by running:
|
|
33
|
+
`npx jest src/dex/angle-transmuter/angle-transmuter-integration.test.ts`
|
|
34
|
+
|
|
35
|
+
(This comment should be removed from the final implementation)
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function getReaderCalldata(
|
|
39
|
+
exchangeAddress: string,
|
|
40
|
+
readerIface: Interface,
|
|
41
|
+
amounts: bigint[],
|
|
42
|
+
funcName: string,
|
|
43
|
+
tokenIn: Address,
|
|
44
|
+
tokenOut: Address,
|
|
45
|
+
) {
|
|
46
|
+
return amounts.map(amount => ({
|
|
47
|
+
target: exchangeAddress,
|
|
48
|
+
callData: readerIface.encodeFunctionData(funcName, [
|
|
49
|
+
amount,
|
|
50
|
+
tokenIn,
|
|
51
|
+
tokenOut,
|
|
52
|
+
]),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function decodeReaderResult(
|
|
57
|
+
results: Result,
|
|
58
|
+
readerIface: Interface,
|
|
59
|
+
funcName: string,
|
|
60
|
+
) {
|
|
61
|
+
return results.map(result => {
|
|
62
|
+
const parsed = readerIface.decodeFunctionResult(funcName, result);
|
|
63
|
+
return BigInt(parsed[0]._hex);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getExchangeAddress(
|
|
68
|
+
network: Network,
|
|
69
|
+
srcAddress: Address,
|
|
70
|
+
dstAddress: Address,
|
|
71
|
+
): Address {
|
|
72
|
+
const config = AngleTransmuterConfig.AngleTransmuter[network];
|
|
73
|
+
const transmuter =
|
|
74
|
+
srcAddress.toLowerCase() === config.EUR?.stablecoin.address.toLowerCase() ||
|
|
75
|
+
dstAddress.toLowerCase() === config.EUR?.stablecoin.address.toLowerCase()
|
|
76
|
+
? config.EUR?.transmuter
|
|
77
|
+
: config.USD?.transmuter;
|
|
78
|
+
return transmuter!;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function checkOnChainPricing(
|
|
82
|
+
network: Network,
|
|
83
|
+
angleTransmuter: AngleTransmuter,
|
|
84
|
+
funcName: string,
|
|
85
|
+
blockNumber: number,
|
|
86
|
+
prices: bigint[],
|
|
87
|
+
amounts: bigint[],
|
|
88
|
+
tokenIn: Address,
|
|
89
|
+
tokenOut: Address,
|
|
90
|
+
) {
|
|
91
|
+
const exchangeAddress = getExchangeAddress(network, tokenIn, tokenOut);
|
|
92
|
+
const readerIface = TransmuterSubscriber.transmuterCrosschainInterface;
|
|
93
|
+
|
|
94
|
+
const readerCallData = getReaderCalldata(
|
|
95
|
+
exchangeAddress,
|
|
96
|
+
readerIface,
|
|
97
|
+
amounts.slice(1),
|
|
98
|
+
funcName,
|
|
99
|
+
tokenIn,
|
|
100
|
+
tokenOut,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const readerResult = (
|
|
104
|
+
await angleTransmuter.dexHelper.multiContract.methods
|
|
105
|
+
.aggregate(readerCallData)
|
|
106
|
+
.call({}, blockNumber)
|
|
107
|
+
).returnData;
|
|
108
|
+
|
|
109
|
+
const expectedPrices = [0n].concat(
|
|
110
|
+
decodeReaderResult(readerResult, readerIface, funcName),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// No exact computation because of the bigInt approx
|
|
114
|
+
for (let i = 0; i < expectedPrices.length; ++i) {
|
|
115
|
+
expect(prices[i]).toBeGreaterThanOrEqual(
|
|
116
|
+
(expectedPrices[i] * 99999n) / 100000n,
|
|
117
|
+
);
|
|
118
|
+
expect(prices[i]).toBeLessThanOrEqual(
|
|
119
|
+
(expectedPrices[i] * 100001n) / 100000n,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function testPricingOnNetwork(
|
|
125
|
+
angleTransmuter: AngleTransmuter,
|
|
126
|
+
network: Network,
|
|
127
|
+
dexKey: string,
|
|
128
|
+
blockNumber: number,
|
|
129
|
+
srcTokenSymbol: string,
|
|
130
|
+
destTokenSymbol: string,
|
|
131
|
+
side: SwapSide,
|
|
132
|
+
amounts: bigint[],
|
|
133
|
+
funcNameToCheck: string,
|
|
134
|
+
) {
|
|
135
|
+
const networkTokens = Tokens[network];
|
|
136
|
+
|
|
137
|
+
const pools = await angleTransmuter.getPoolIdentifiers(
|
|
138
|
+
networkTokens[srcTokenSymbol],
|
|
139
|
+
networkTokens[destTokenSymbol],
|
|
140
|
+
side,
|
|
141
|
+
blockNumber,
|
|
142
|
+
);
|
|
143
|
+
console.log(
|
|
144
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
|
|
145
|
+
pools,
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
149
|
+
|
|
150
|
+
const poolPrices = await angleTransmuter.getPricesVolume(
|
|
151
|
+
networkTokens[srcTokenSymbol],
|
|
152
|
+
networkTokens[destTokenSymbol],
|
|
153
|
+
amounts,
|
|
154
|
+
side,
|
|
155
|
+
blockNumber,
|
|
156
|
+
pools,
|
|
157
|
+
);
|
|
158
|
+
console.log(
|
|
159
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
|
|
160
|
+
poolPrices,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
expect(poolPrices).not.toBeNull();
|
|
164
|
+
if (angleTransmuter.hasConstantPriceLargeAmounts) {
|
|
165
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
166
|
+
} else {
|
|
167
|
+
checkPoolPrices(poolPrices!, amounts, side, dexKey);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Check if onchain pricing equals to calculated ones
|
|
171
|
+
await checkOnChainPricing(
|
|
172
|
+
network,
|
|
173
|
+
angleTransmuter,
|
|
174
|
+
funcNameToCheck,
|
|
175
|
+
blockNumber,
|
|
176
|
+
poolPrices![0].prices,
|
|
177
|
+
amounts,
|
|
178
|
+
networkTokens[srcTokenSymbol].address,
|
|
179
|
+
networkTokens[destTokenSymbol].address,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
describe('AngleTransmuter', () => {
|
|
184
|
+
const dexKey = 'AngleTransmuter';
|
|
185
|
+
let blockNumber: number;
|
|
186
|
+
let angleTransmuter: AngleTransmuter;
|
|
187
|
+
|
|
188
|
+
const networks = [Network.MAINNET, Network.ARBITRUM, Network.BASE];
|
|
189
|
+
// const networks = [Network.MAINNET];
|
|
190
|
+
const stablesPerNetwork: { [network: number]: SmartTokenParams[] } = {
|
|
191
|
+
[Network.MAINNET]: [
|
|
192
|
+
Tokens[Network.MAINNET].EURA,
|
|
193
|
+
Tokens[Network.MAINNET].USDA,
|
|
194
|
+
],
|
|
195
|
+
[Network.ARBITRUM]: [Tokens[Network.ARBITRUM].USDA],
|
|
196
|
+
[Network.BASE]: [Tokens[Network.BASE].USDA],
|
|
197
|
+
};
|
|
198
|
+
const collateralsPerNetwork: {
|
|
199
|
+
[network: number]: { [stable: string]: SmartTokenParams[] };
|
|
200
|
+
} = {
|
|
201
|
+
[Network.MAINNET]: {
|
|
202
|
+
USDA: [
|
|
203
|
+
Tokens[Network.MAINNET].bIB01,
|
|
204
|
+
Tokens[Network.MAINNET].USDC,
|
|
205
|
+
Tokens[Network.MAINNET].steakUSDC,
|
|
206
|
+
],
|
|
207
|
+
EURA: [
|
|
208
|
+
Tokens[Network.MAINNET].EUROC,
|
|
209
|
+
Tokens[Network.MAINNET].bC3M,
|
|
210
|
+
Tokens[Network.MAINNET].bERNX,
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
[Network.ARBITRUM]: {
|
|
214
|
+
USDA: [Tokens[Network.ARBITRUM].USDC],
|
|
215
|
+
},
|
|
216
|
+
[Network.BASE]: {
|
|
217
|
+
USDA: [Tokens[Network.BASE].USDC],
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
networks.forEach(network =>
|
|
222
|
+
describe(`${Network[network]}`, () => {
|
|
223
|
+
const dexHelper = new DummyDexHelper(network);
|
|
224
|
+
|
|
225
|
+
const tokens = Tokens[network];
|
|
226
|
+
|
|
227
|
+
const stables = stablesPerNetwork[network];
|
|
228
|
+
const collaterals = collateralsPerNetwork[network];
|
|
229
|
+
|
|
230
|
+
const isKYC: { [token: string]: boolean } = {};
|
|
231
|
+
if (network === Network.MAINNET) {
|
|
232
|
+
isKYC[tokens.bIB01.symbol!] = true;
|
|
233
|
+
isKYC[tokens.bC3M.symbol!] = true;
|
|
234
|
+
isKYC[tokens.bERNX.symbol!] = true;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const amounts = [
|
|
238
|
+
0n,
|
|
239
|
+
1n * BI_POWS[tokens.USDA.decimals],
|
|
240
|
+
2n * BI_POWS[tokens.USDA.decimals],
|
|
241
|
+
3n * BI_POWS[tokens.USDA.decimals],
|
|
242
|
+
4n * BI_POWS[tokens.USDA.decimals],
|
|
243
|
+
5n * BI_POWS[tokens.USDA.decimals],
|
|
244
|
+
6n * BI_POWS[tokens.USDA.decimals],
|
|
245
|
+
7n * BI_POWS[tokens.USDA.decimals],
|
|
246
|
+
8n * BI_POWS[tokens.USDA.decimals],
|
|
247
|
+
9n * BI_POWS[tokens.USDA.decimals],
|
|
248
|
+
10n * BI_POWS[tokens.USDA.decimals],
|
|
249
|
+
];
|
|
250
|
+
|
|
251
|
+
beforeAll(async () => {
|
|
252
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
253
|
+
angleTransmuter = new AngleTransmuter(network, dexKey, dexHelper);
|
|
254
|
+
if (angleTransmuter.initializePricing) {
|
|
255
|
+
await angleTransmuter.initializePricing(blockNumber);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
stables.forEach(stable =>
|
|
260
|
+
collaterals[stable.symbol! as keyof Collateral].forEach(collateral =>
|
|
261
|
+
describe(`${stable.symbol}/${collateral.symbol}`, () => {
|
|
262
|
+
const amountsCollateral = [
|
|
263
|
+
0n,
|
|
264
|
+
1n * BI_POWS[collateral.decimals],
|
|
265
|
+
2n * BI_POWS[collateral.decimals],
|
|
266
|
+
3n * BI_POWS[collateral.decimals],
|
|
267
|
+
4n * BI_POWS[collateral.decimals],
|
|
268
|
+
5n * BI_POWS[collateral.decimals],
|
|
269
|
+
6n * BI_POWS[collateral.decimals],
|
|
270
|
+
7n * BI_POWS[collateral.decimals],
|
|
271
|
+
8n * BI_POWS[collateral.decimals],
|
|
272
|
+
9n * BI_POWS[collateral.decimals],
|
|
273
|
+
10n * BI_POWS[collateral.decimals],
|
|
274
|
+
];
|
|
275
|
+
|
|
276
|
+
it('getTopPoolsForToken - collateral', async () => {
|
|
277
|
+
// We have to check without calling initializePricing, because
|
|
278
|
+
// pool-tracker is not calling that function
|
|
279
|
+
const newAngleTransmuter = new AngleTransmuter(
|
|
280
|
+
network,
|
|
281
|
+
dexKey,
|
|
282
|
+
dexHelper,
|
|
283
|
+
);
|
|
284
|
+
if (newAngleTransmuter.updatePoolState) {
|
|
285
|
+
await newAngleTransmuter.updatePoolState();
|
|
286
|
+
}
|
|
287
|
+
const poolLiquidity =
|
|
288
|
+
await newAngleTransmuter.getTopPoolsForToken(
|
|
289
|
+
collateral.address,
|
|
290
|
+
10,
|
|
291
|
+
);
|
|
292
|
+
console.log(
|
|
293
|
+
`${collateral.symbol}: ${collateral.address} Top Pools:`,
|
|
294
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
if (!newAngleTransmuter.hasConstantPriceLargeAmounts) {
|
|
298
|
+
checkPoolsLiquidity(poolLiquidity, collateral.address, dexKey);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('getTopPoolsForToken - stablecoin', async () => {
|
|
303
|
+
// We have to check without calling initializePricing, because
|
|
304
|
+
// pool-tracker is not calling that function
|
|
305
|
+
const newAngleTransmuter = new AngleTransmuter(
|
|
306
|
+
network,
|
|
307
|
+
dexKey,
|
|
308
|
+
dexHelper,
|
|
309
|
+
);
|
|
310
|
+
if (newAngleTransmuter.updatePoolState) {
|
|
311
|
+
await newAngleTransmuter.updatePoolState();
|
|
312
|
+
}
|
|
313
|
+
const poolLiquidity =
|
|
314
|
+
await newAngleTransmuter.getTopPoolsForToken(
|
|
315
|
+
stable.address,
|
|
316
|
+
10,
|
|
317
|
+
);
|
|
318
|
+
console.log(
|
|
319
|
+
`${stable.symbol}: ${stable.address} Top Pools:`,
|
|
320
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
if (!newAngleTransmuter.hasConstantPriceLargeAmounts) {
|
|
324
|
+
checkPoolsLiquidity(poolLiquidity, stable.address, dexKey);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('getPoolIdentifiers and getPricesVolume SELL - collateral', async () => {
|
|
329
|
+
await testPricingOnNetwork(
|
|
330
|
+
angleTransmuter,
|
|
331
|
+
network,
|
|
332
|
+
dexKey,
|
|
333
|
+
blockNumber,
|
|
334
|
+
collateral.symbol!,
|
|
335
|
+
stable.symbol!,
|
|
336
|
+
SwapSide.SELL,
|
|
337
|
+
amountsCollateral,
|
|
338
|
+
'quoteIn',
|
|
339
|
+
);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('getPoolIdentifiers and getPricesVolume BUY - collateral', async () => {
|
|
343
|
+
await testPricingOnNetwork(
|
|
344
|
+
angleTransmuter,
|
|
345
|
+
network,
|
|
346
|
+
dexKey,
|
|
347
|
+
blockNumber,
|
|
348
|
+
collateral.symbol!,
|
|
349
|
+
stable.symbol!,
|
|
350
|
+
SwapSide.BUY,
|
|
351
|
+
amounts,
|
|
352
|
+
'quoteOut',
|
|
353
|
+
);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
if (!isKYC[collateral.symbol!]) {
|
|
357
|
+
it('getPoolIdentifiers and getPricesVolume SELL - stablecoin', async () => {
|
|
358
|
+
await testPricingOnNetwork(
|
|
359
|
+
angleTransmuter,
|
|
360
|
+
network,
|
|
361
|
+
dexKey,
|
|
362
|
+
blockNumber,
|
|
363
|
+
stable.symbol!,
|
|
364
|
+
collateral.symbol!,
|
|
365
|
+
SwapSide.SELL,
|
|
366
|
+
amounts,
|
|
367
|
+
'quoteIn',
|
|
368
|
+
);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('getPoolIdentifiers and getPricesVolume BUY - stablecoin', async () => {
|
|
372
|
+
await testPricingOnNetwork(
|
|
373
|
+
angleTransmuter,
|
|
374
|
+
network,
|
|
375
|
+
dexKey,
|
|
376
|
+
blockNumber,
|
|
377
|
+
stable.symbol!,
|
|
378
|
+
collateral.symbol!,
|
|
379
|
+
SwapSide.BUY,
|
|
380
|
+
amountsCollateral,
|
|
381
|
+
'quoteOut',
|
|
382
|
+
);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}),
|
|
386
|
+
),
|
|
387
|
+
);
|
|
388
|
+
}),
|
|
389
|
+
);
|
|
390
|
+
});
|