@paraswap/dex-lib 3.8.34-inception.2 → 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/inception/inception.js +1 -9
- package/build/dex/inception/inception.js.map +1 -1
- package/build/dex/inception/utils.d.ts +1 -0
- package/build/dex/inception/utils.js +22 -1
- package/build/dex/inception/utils.js.map +1 -1
- 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 -80
- 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 -279
- package/src/dex/inception/tokens.ts +0 -37
- package/src/dex/inception/types.ts +0 -26
- package/src/dex/inception/utils.ts +0 -44
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Network } from '../../constants';
|
|
2
|
-
import { DexParams } from './types';
|
|
3
|
-
|
|
4
|
-
export const Tokens: { [network: number]: { [symbol: string]: DexParams } } =
|
|
5
|
-
{};
|
|
6
|
-
|
|
7
|
-
const TokensByAddress: {
|
|
8
|
-
[network: number]: { [address: string]: DexParams };
|
|
9
|
-
} = {};
|
|
10
|
-
|
|
11
|
-
export function setTokensOnNetwork(network: Network, tokens: DexParams[]) {
|
|
12
|
-
if (Tokens[network] === undefined) {
|
|
13
|
-
Tokens[network] = {};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (TokensByAddress[network] === undefined) {
|
|
17
|
-
TokensByAddress[network] = {};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for (let token of tokens) {
|
|
21
|
-
token.vault = token.vault.toLowerCase();
|
|
22
|
-
token.token = token.token.toLowerCase();
|
|
23
|
-
token.baseToken = token.baseToken.toLowerCase();
|
|
24
|
-
|
|
25
|
-
Tokens[network][token.symbol] = token;
|
|
26
|
-
TokensByAddress[network][token.vault] = token;
|
|
27
|
-
TokensByAddress[network][token.token] = token;
|
|
28
|
-
TokensByAddress[network][token.baseToken] = token;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getTokenFromAddress(
|
|
33
|
-
network: Network,
|
|
34
|
-
address: string,
|
|
35
|
-
): DexParams | undefined {
|
|
36
|
-
return TokensByAddress[network]?.[address.toLowerCase()];
|
|
37
|
-
}
|
|
@@ -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,44 +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 getOnChainState(
|
|
10
|
-
multiContract: Contract,
|
|
11
|
-
poolInterface: Interface,
|
|
12
|
-
network: Network,
|
|
13
|
-
blockNumber: number | 'latest',
|
|
14
|
-
): Promise<PoolState> {
|
|
15
|
-
let tokenList = await getTokenList(network);
|
|
16
|
-
const state: PoolState = {};
|
|
17
|
-
for (const p of tokenList) {
|
|
18
|
-
let addr;
|
|
19
|
-
if (p.baseTokenSlug === 'ETH') {
|
|
20
|
-
addr = p.token;
|
|
21
|
-
} else {
|
|
22
|
-
addr = p.vault;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const data = await multiContract.methods
|
|
26
|
-
.aggregate([
|
|
27
|
-
{
|
|
28
|
-
target: addr,
|
|
29
|
-
callData: poolInterface.encodeFunctionData('ratio', []),
|
|
30
|
-
},
|
|
31
|
-
])
|
|
32
|
-
.call({}, blockNumber);
|
|
33
|
-
|
|
34
|
-
const decodedData = coder.decode(['uint256'], data.returnData[0]);
|
|
35
|
-
const ratio = BigInt(decodedData[0].toString());
|
|
36
|
-
state[p.symbol.toLowerCase()] = { ratio };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return state;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const getTokenList = async (network: Network): Promise<DexParams[]> => {
|
|
43
|
-
return InceptionConfig['InceptionLRT'][network];
|
|
44
|
-
};
|