@paraswap/dex-lib 3.8.34-inception → 3.8.34
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/dex/index.js +0 -2
- package/build/dex/index.js.map +1 -1
- package/package.json +1 -1
- package/src/dex/index.ts +0 -2
- package/tests/constants-e2e.ts +7 -106
- package/src/abi/inception/inception-ineth-pool.json +0 -1062
- package/src/abi/inception/inception-ratio-feed.json +0 -329
- package/src/abi/inception/inception-vault.json +0 -991
- package/src/dex/inception/config.ts +0 -109
- package/src/dex/inception/inception-e2e.test.ts +0 -67
- package/src/dex/inception/inception-event-pool.ts +0 -62
- package/src/dex/inception/inception-events.test.ts +0 -64
- package/src/dex/inception/inception-integration.test.ts +0 -76
- package/src/dex/inception/inception.ts +0 -271
- package/src/dex/inception/tokens.ts +0 -37
- package/src/dex/inception/types.ts +0 -26
- package/src/dex/inception/utils.ts +0 -71
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type PoolState = {
|
|
2
|
-
[symbol: string]: {
|
|
3
|
-
ratio: bigint;
|
|
4
|
-
};
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type PoolConfig = {
|
|
8
|
-
ratioFeedAddress: string;
|
|
9
|
-
initState: PoolState;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type InceptionDexData = {
|
|
13
|
-
exchange: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type DexParams = {
|
|
17
|
-
symbol: string;
|
|
18
|
-
vault: string;
|
|
19
|
-
token: string;
|
|
20
|
-
baseToken: string;
|
|
21
|
-
baseTokenSlug: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type PricePoolParams = {
|
|
25
|
-
ratioFeed: string;
|
|
26
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Contract } from 'web3-eth-contract';
|
|
2
|
-
import { DexParams, PoolState } from './types';
|
|
3
|
-
import { AbiCoder, Interface } from '@ethersproject/abi';
|
|
4
|
-
import { InceptionConfig } from './config';
|
|
5
|
-
import { Network } from '../../constants';
|
|
6
|
-
|
|
7
|
-
const coder = new AbiCoder();
|
|
8
|
-
|
|
9
|
-
export async function getOnChainRatio(
|
|
10
|
-
multiContract: Contract,
|
|
11
|
-
poolInterface: Interface,
|
|
12
|
-
network: Network,
|
|
13
|
-
p: DexParams,
|
|
14
|
-
blockNumber: number | 'latest',
|
|
15
|
-
): Promise<bigint> {
|
|
16
|
-
let addr;
|
|
17
|
-
if (p.baseTokenSlug === 'ETH') {
|
|
18
|
-
addr = p.token;
|
|
19
|
-
} else {
|
|
20
|
-
addr = p.vault;
|
|
21
|
-
}
|
|
22
|
-
const data: { returnData: any[] } = await multiContract.methods
|
|
23
|
-
.aggregate([
|
|
24
|
-
{
|
|
25
|
-
target: addr,
|
|
26
|
-
callData: poolInterface.encodeFunctionData('ratio', []),
|
|
27
|
-
},
|
|
28
|
-
])
|
|
29
|
-
.call({}, blockNumber);
|
|
30
|
-
|
|
31
|
-
const decodedData = coder.decode(['uint256'], data.returnData[0]);
|
|
32
|
-
const ratio = BigInt(decodedData[0].toString());
|
|
33
|
-
return ratio;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function getOnChainState(
|
|
37
|
-
multiContract: Contract,
|
|
38
|
-
poolInterface: Interface,
|
|
39
|
-
network: Network,
|
|
40
|
-
blockNumber: number | 'latest',
|
|
41
|
-
): Promise<PoolState> {
|
|
42
|
-
let tokenList = await getTokenList(network);
|
|
43
|
-
const state: PoolState = {};
|
|
44
|
-
for (const p of tokenList) {
|
|
45
|
-
let addr;
|
|
46
|
-
if (p.baseTokenSlug === 'ETH') {
|
|
47
|
-
addr = p.token;
|
|
48
|
-
} else {
|
|
49
|
-
addr = p.vault;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const data = await multiContract.methods
|
|
53
|
-
.aggregate([
|
|
54
|
-
{
|
|
55
|
-
target: addr,
|
|
56
|
-
callData: poolInterface.encodeFunctionData('ratio', []),
|
|
57
|
-
},
|
|
58
|
-
])
|
|
59
|
-
.call({}, blockNumber);
|
|
60
|
-
|
|
61
|
-
const decodedData = coder.decode(['uint256'], data.returnData[0]);
|
|
62
|
-
const ratio = BigInt(decodedData[0].toString());
|
|
63
|
-
state[p.symbol.toLowerCase()] = { ratio };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return state;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const getTokenList = async (network: Network): Promise<DexParams[]> => {
|
|
70
|
-
return InceptionConfig['InceptionLRT'][network];
|
|
71
|
-
};
|