@paraswap/dex-lib 2.47.5 → 2.47.7
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/balancer-v2/gyro-e.abi.json +1595 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +6 -3
- package/build/dex/balancer-v2/balancer-v2.js +56 -35
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.d.ts +32 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js +149 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.d.ts +37 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js +222 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.d.ts +2 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js +19 -0
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js.map +1 -0
- package/build/dex/balancer-v2/queryOnChain.d.ts +1 -0
- package/build/dex/balancer-v2/queryOnChain.js +40 -0
- package/build/dex/balancer-v2/queryOnChain.js.map +1 -0
- package/build/dex/balancer-v2/types.d.ts +24 -1
- package/build/dex/balancer-v2/types.js +2 -0
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/balancer-v2/utils.d.ts +8 -0
- package/build/dex/balancer-v2/utils.js +17 -1
- package/build/dex/balancer-v2/utils.js.map +1 -1
- package/package.json +2 -1
- package/src/abi/balancer-v2/gyro-e.abi.json +1595 -0
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +94 -0
- package/src/dex/balancer-v2/balancer-v2-gyro3.test.ts +268 -0
- package/src/dex/balancer-v2/balancer-v2-gyroE.test.ts +401 -0
- package/src/dex/balancer-v2/balancer-v2-integration.test.ts +253 -112
- package/src/dex/balancer-v2/balancer-v2.ts +107 -67
- package/src/dex/balancer-v2/pools/gyro/Gyro3Pool.ts +255 -0
- package/src/dex/balancer-v2/pools/gyro/GyroEPool.ts +403 -0
- package/src/dex/balancer-v2/pools/gyro/gyro-helpers.ts +15 -0
- package/src/dex/balancer-v2/queryOnChain.ts +48 -0
- package/src/dex/balancer-v2/types.ts +26 -0
- package/src/dex/balancer-v2/utils.ts +16 -0
- package/src/dex/synthetix/synthetix-state.ts +2 -2
- package/tests/constants-e2e.ts +26 -0
- package/build/abi/Redstone.json +0 -739
- package/build/abi/angle/stagToken.json +0 -963
- package/build/abi/angle-transmuter/Pyth.json +0 -1534
- package/build/abi/angle-transmuter/Transmuter.json +0 -1719
- package/build/abi/smardex/smardex-factory.json +0 -185
- package/build/abi/smardex/smardex-pool.json +0 -578
- package/build/abi/smardex/smardex-router.json +0 -648
- package/build/abi/trader-joe-v2_1/FactoryABI.json +0 -1208
- package/build/abi/trader-joe-v2_1/PairABI.json +0 -1493
- package/build/abi/trader-joe-v2_1/RouterABI.json +0 -1489
- package/build/abi/trader-joe-v2_1/StateMulticall.json +0 -193
- package/build/abi/wombat/pool.json +0 -1289
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +0 -53
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +0 -175
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +0 -1
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +0 -42
- package/build/dex/angle-staked-stable/angle-staked-stable.js +0 -232
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +0 -1
- package/build/dex/angle-staked-stable/config.d.ts +0 -4
- package/build/dex/angle-staked-stable/config.js +0 -26
- package/build/dex/angle-staked-stable/config.js.map +0 -1
- package/build/dex/angle-staked-stable/types.d.ts +0 -15
- package/build/dex/angle-staked-stable/types.js +0 -3
- package/build/dex/angle-staked-stable/types.js.map +0 -1
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +0 -43
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +0 -309
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +0 -1
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +0 -46
- package/build/dex/angle-transmuter/angle-transmuter.js +0 -233
- package/build/dex/angle-transmuter/angle-transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/backedOracle.d.ts +0 -19
- package/build/dex/angle-transmuter/backedOracle.js +0 -56
- package/build/dex/angle-transmuter/backedOracle.js.map +0 -1
- package/build/dex/angle-transmuter/config.d.ts +0 -4
- package/build/dex/angle-transmuter/config.js +0 -20
- package/build/dex/angle-transmuter/config.js.map +0 -1
- package/build/dex/angle-transmuter/constants.d.ts +0 -4
- package/build/dex/angle-transmuter/constants.js +0 -8
- package/build/dex/angle-transmuter/constants.js.map +0 -1
- package/build/dex/angle-transmuter/pyth.d.ts +0 -19
- package/build/dex/angle-transmuter/pyth.js +0 -71
- package/build/dex/angle-transmuter/pyth.js.map +0 -1
- package/build/dex/angle-transmuter/redstone.d.ts +0 -20
- package/build/dex/angle-transmuter/redstone.js +0 -73
- package/build/dex/angle-transmuter/redstone.js.map +0 -1
- package/build/dex/angle-transmuter/transmuter.d.ts +0 -50
- package/build/dex/angle-transmuter/transmuter.js +0 -314
- package/build/dex/angle-transmuter/transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/types.d.ts +0 -144
- package/build/dex/angle-transmuter/types.js +0 -31
- package/build/dex/angle-transmuter/types.js.map +0 -1
- package/build/dex/angle-transmuter/utils.d.ts +0 -9
- package/build/dex/angle-transmuter/utils.js +0 -264
- package/build/dex/angle-transmuter/utils.js.map +0 -1
- package/build/dex/smardex/subgraph-queries.d.ts +0 -1
- package/build/dex/smardex/subgraph-queries.js +0 -17
- package/build/dex/smardex/subgraph-queries.js.map +0 -1
- package/build/dex/smardex/usd-reserves.d.ts +0 -23
- package/build/dex/smardex/usd-reserves.js +0 -86
- package/build/dex/smardex/usd-reserves.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/config.d.ts +0 -4
- package/build/dex/trader-joe-v2-1-2/config.js +0 -47
- package/build/dex/trader-joe-v2-1-2/config.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2-1-2/constants.js +0 -22
- package/build/dex/trader-joe-v2-1-2/constants.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2-1-2/math/index.js +0 -291
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +0 -248
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +0 -53
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +0 -307
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/types.d.ts +0 -82
- package/build/dex/trader-joe-v2-1-2/types.js +0 -9
- package/build/dex/trader-joe-v2-1-2/types.js.map +0 -1
- package/build/dex/trader-joe-v2_1/config.d.ts +0 -4
- package/build/dex/trader-joe-v2_1/config.js +0 -47
- package/build/dex/trader-joe-v2_1/config.js.map +0 -1
- package/build/dex/trader-joe-v2_1/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2_1/constants.js +0 -22
- package/build/dex/trader-joe-v2_1/constants.js.map +0 -1
- package/build/dex/trader-joe-v2_1/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2_1/math/index.js +0 -291
- package/build/dex/trader-joe-v2_1/math/index.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +0 -384
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +0 -247
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +0 -53
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +0 -307
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/types.d.ts +0 -82
- package/build/dex/trader-joe-v2_1/types.js +0 -9
- package/build/dex/trader-joe-v2_1/types.js.map +0 -1
- package/build/dex/wombat/wombat-pool-poller.d.ts +0 -22
- package/build/dex/wombat/wombat-pool-poller.js +0 -164
- package/build/dex/wombat/wombat-pool-poller.js.map +0 -1
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Address } from '../../types';
|
|
2
|
-
import { BigNumber } from 'ethers';
|
|
3
|
-
import { NumberAsString } from '@paraswap/core';
|
|
4
|
-
export declare type Bin = {
|
|
5
|
-
id: bigint;
|
|
6
|
-
reserveX: bigint;
|
|
7
|
-
reserveY: bigint;
|
|
8
|
-
};
|
|
9
|
-
export declare type PoolState = {
|
|
10
|
-
tokenX: Address;
|
|
11
|
-
tokenY: Address;
|
|
12
|
-
binStep: bigint;
|
|
13
|
-
bins: Bin[];
|
|
14
|
-
pairAddress: string;
|
|
15
|
-
blockTimestamp: bigint;
|
|
16
|
-
reserves: {
|
|
17
|
-
reserveX: bigint;
|
|
18
|
-
reserveY: bigint;
|
|
19
|
-
};
|
|
20
|
-
activeId: bigint;
|
|
21
|
-
protocolFees: {
|
|
22
|
-
protocolFeeX: bigint;
|
|
23
|
-
protocolFeeY: bigint;
|
|
24
|
-
};
|
|
25
|
-
staticFeeParameters: {
|
|
26
|
-
baseFactor: bigint;
|
|
27
|
-
filterPeriod: bigint;
|
|
28
|
-
decayPeriod: bigint;
|
|
29
|
-
reductionFactor: bigint;
|
|
30
|
-
variableFeeControl: bigint;
|
|
31
|
-
protocolShare: bigint;
|
|
32
|
-
maxVolatilityAccumulator: bigint;
|
|
33
|
-
};
|
|
34
|
-
variableFeeParameters: {
|
|
35
|
-
volatilityAccumulator: bigint;
|
|
36
|
-
volatilityReference: bigint;
|
|
37
|
-
idReference: bigint;
|
|
38
|
-
timeOfLastUpdate: bigint;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export declare type DecodedStateMultiCallResult = {};
|
|
42
|
-
export declare type TraderJoeV2_1Data = {
|
|
43
|
-
tokenIn: string;
|
|
44
|
-
tokenOut: string;
|
|
45
|
-
binStep: string;
|
|
46
|
-
};
|
|
47
|
-
export declare type DexParams = {
|
|
48
|
-
factory: Address;
|
|
49
|
-
router: Address;
|
|
50
|
-
stateMulticall: Address;
|
|
51
|
-
};
|
|
52
|
-
export declare type LBPairsAvailable = {
|
|
53
|
-
binStep: BigNumber;
|
|
54
|
-
LBPair: string;
|
|
55
|
-
createdByOwner: boolean;
|
|
56
|
-
ignoredForRouting: boolean;
|
|
57
|
-
tokenX: string;
|
|
58
|
-
};
|
|
59
|
-
export declare type RouterPath = [
|
|
60
|
-
pairBinSteps: NumberAsString[],
|
|
61
|
-
versions: NumberAsString[],
|
|
62
|
-
tokenPath: Address[]
|
|
63
|
-
];
|
|
64
|
-
export declare type TraderJoeV2RouterSellParams = [
|
|
65
|
-
_amountIn: NumberAsString,
|
|
66
|
-
_amountOutMin: NumberAsString,
|
|
67
|
-
_routerPath: RouterPath,
|
|
68
|
-
to: Address,
|
|
69
|
-
_deadline: string
|
|
70
|
-
];
|
|
71
|
-
export declare type TraderJoeV2RouterBuyParams = [
|
|
72
|
-
_amountOut: NumberAsString,
|
|
73
|
-
_amountInMax: NumberAsString,
|
|
74
|
-
_routerPath: RouterPath,
|
|
75
|
-
to: Address,
|
|
76
|
-
_deadline: string
|
|
77
|
-
];
|
|
78
|
-
export declare type TraderJoeV2RouterParam = TraderJoeV2RouterSellParams | TraderJoeV2RouterBuyParams;
|
|
79
|
-
export declare enum TraderJoeV2RouterFunctions {
|
|
80
|
-
swapExactTokensForTokens = "swapExactTokensForTokens",
|
|
81
|
-
swapTokensForExactTokens = "swapTokensForExactTokens"
|
|
82
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TraderJoeV2RouterFunctions = void 0;
|
|
4
|
-
var TraderJoeV2RouterFunctions;
|
|
5
|
-
(function (TraderJoeV2RouterFunctions) {
|
|
6
|
-
TraderJoeV2RouterFunctions["swapExactTokensForTokens"] = "swapExactTokensForTokens";
|
|
7
|
-
TraderJoeV2RouterFunctions["swapTokensForExactTokens"] = "swapTokensForExactTokens";
|
|
8
|
-
})(TraderJoeV2RouterFunctions = exports.TraderJoeV2RouterFunctions || (exports.TraderJoeV2RouterFunctions = {}));
|
|
9
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/trader-joe-v2_1/types.ts"],"names":[],"mappings":";;;AAyGA,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,mFAAqD,CAAA;IACrD,mFAAqD,CAAA;AACvD,CAAC,EAHW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAGrC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { Address } from '@paraswap/core';
|
|
3
|
-
import { MultiCallParams, MultiResult } from '../../lib/multi-wrapper';
|
|
4
|
-
import { IDexHelper } from '../../dex-helper';
|
|
5
|
-
import { StatefulRpcPoller } from '../../lib/stateful-rpc-poller/stateful-rpc-poller';
|
|
6
|
-
import { ObjWithUpdateInfo } from '../../lib/stateful-rpc-poller/types';
|
|
7
|
-
import { MulticallResultOutputs, PoolState } from './types';
|
|
8
|
-
export declare class WombatPool extends StatefulRpcPoller<PoolState, MulticallResultOutputs> {
|
|
9
|
-
protected poolAddress: Address;
|
|
10
|
-
protected asset2TokenMap: Map<Address, Address>;
|
|
11
|
-
static readonly poolInterface: Interface;
|
|
12
|
-
static readonly assetInterface: Interface;
|
|
13
|
-
constructor(dexKey: string, poolIdentifier: string, dexHelper: IDexHelper, poolAddress: Address, asset2TokenMap: Map<Address, Address>);
|
|
14
|
-
protected _getFetchStateMultiCalls(): MultiCallParams<MulticallResultOutputs>[];
|
|
15
|
-
protected _parseStateFromMultiResults(multiOutputs: MulticallResultOutputs[]): PoolState;
|
|
16
|
-
fetchLatestStateFromRpc(): Promise<ObjWithUpdateInfo<PoolState> | null>;
|
|
17
|
-
parseStateFromMultiResultsWithBlockInfo(multiOutputs: [
|
|
18
|
-
MultiResult<number>,
|
|
19
|
-
...MultiResult<MulticallResultOutputs>[]
|
|
20
|
-
], lastUpdatedAtMs: number): ObjWithUpdateInfo<PoolState>;
|
|
21
|
-
addAssets(asset2TokenMap: Map<Address, Address>): void;
|
|
22
|
-
}
|
|
@@ -1,164 +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.WombatPool = void 0;
|
|
7
|
-
const abi_1 = require("@ethersproject/abi");
|
|
8
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
const stateful_rpc_poller_1 = require("../../lib/stateful-rpc-poller/stateful-rpc-poller");
|
|
10
|
-
const state_polling_manager_1 = require("../../lib/stateful-rpc-poller/state-polling-manager");
|
|
11
|
-
const utils_1 = require("../../lib/stateful-rpc-poller/utils");
|
|
12
|
-
const decoders_1 = require("../../lib/decoders");
|
|
13
|
-
const pool_json_1 = __importDefault(require("../../abi/wombat/pool.json"));
|
|
14
|
-
const asset_json_1 = __importDefault(require("../../abi/wombat/asset.json"));
|
|
15
|
-
const utils_2 = require("./utils");
|
|
16
|
-
class WombatPool extends stateful_rpc_poller_1.StatefulRpcPoller {
|
|
17
|
-
constructor(dexKey, poolIdentifier, dexHelper, poolAddress, asset2TokenMap) {
|
|
18
|
-
const callbacks = (0, utils_1.pollingManagerCbExtractor)(state_polling_manager_1.StatePollingManager.getInstance(dexHelper));
|
|
19
|
-
super(dexKey, poolIdentifier, dexHelper, 0, 0, false, callbacks);
|
|
20
|
-
this.poolAddress = poolAddress;
|
|
21
|
-
this.asset2TokenMap = asset2TokenMap;
|
|
22
|
-
}
|
|
23
|
-
_getFetchStateMultiCalls() {
|
|
24
|
-
const params = [];
|
|
25
|
-
params.push({
|
|
26
|
-
target: this.poolAddress,
|
|
27
|
-
callData: WombatPool.poolInterface.encodeFunctionData('paused'),
|
|
28
|
-
decodeFunction: decoders_1.booleanDecode,
|
|
29
|
-
});
|
|
30
|
-
params.push({
|
|
31
|
-
target: this.poolAddress,
|
|
32
|
-
callData: WombatPool.poolInterface.encodeFunctionData('ampFactor'),
|
|
33
|
-
decodeFunction: decoders_1.uint256ToBigInt,
|
|
34
|
-
});
|
|
35
|
-
params.push({
|
|
36
|
-
target: this.poolAddress,
|
|
37
|
-
callData: WombatPool.poolInterface.encodeFunctionData('haircutRate'),
|
|
38
|
-
decodeFunction: decoders_1.uint256ToBigInt,
|
|
39
|
-
});
|
|
40
|
-
params.push({
|
|
41
|
-
target: this.poolAddress,
|
|
42
|
-
callData: WombatPool.poolInterface.encodeFunctionData('startCovRatio'),
|
|
43
|
-
decodeFunction: decoders_1.uint256ToBigInt,
|
|
44
|
-
});
|
|
45
|
-
params.push({
|
|
46
|
-
target: this.poolAddress,
|
|
47
|
-
callData: WombatPool.poolInterface.encodeFunctionData('endCovRatio'),
|
|
48
|
-
decodeFunction: decoders_1.uint256ToBigInt,
|
|
49
|
-
});
|
|
50
|
-
params.push({
|
|
51
|
-
target: this.poolAddress,
|
|
52
|
-
callData: WombatPool.poolInterface.encodeFunctionData('getTokens'),
|
|
53
|
-
decodeFunction: decoders_1.addressArrayDecode,
|
|
54
|
-
});
|
|
55
|
-
this.asset2TokenMap.forEach((token, asset) => {
|
|
56
|
-
params.push({
|
|
57
|
-
target: this.poolAddress,
|
|
58
|
-
callData: WombatPool.poolInterface.encodeFunctionData('isPaused', [
|
|
59
|
-
token,
|
|
60
|
-
]),
|
|
61
|
-
decodeFunction: decoders_1.booleanDecode,
|
|
62
|
-
});
|
|
63
|
-
params.push({
|
|
64
|
-
target: asset,
|
|
65
|
-
callData: WombatPool.assetInterface.encodeFunctionData('cash'),
|
|
66
|
-
decodeFunction: utils_2.uint120ToBigInt,
|
|
67
|
-
});
|
|
68
|
-
params.push({
|
|
69
|
-
target: asset,
|
|
70
|
-
callData: WombatPool.assetInterface.encodeFunctionData('liability'),
|
|
71
|
-
decodeFunction: utils_2.uint120ToBigInt,
|
|
72
|
-
});
|
|
73
|
-
params.push({
|
|
74
|
-
target: asset,
|
|
75
|
-
callData: WombatPool.assetInterface.encodeFunctionData('underlyingTokenDecimals'),
|
|
76
|
-
decodeFunction: decoders_1.uint8ToNumber,
|
|
77
|
-
});
|
|
78
|
-
params.push({
|
|
79
|
-
target: asset,
|
|
80
|
-
callData: WombatPool.assetInterface.encodeFunctionData('getRelativePrice'),
|
|
81
|
-
decodeFunction: decoders_1.uint256ToBigInt,
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
return params;
|
|
85
|
-
}
|
|
86
|
-
_parseStateFromMultiResults(multiOutputs) {
|
|
87
|
-
const [paused, ampFactor, haircutRate, startCovRatio, endCovRatio, tokens, ...remained] = multiOutputs;
|
|
88
|
-
const assetTokenArray = Array.from(this.asset2TokenMap.entries());
|
|
89
|
-
const token2AssetStates = new Map();
|
|
90
|
-
lodash_1.default.chunk(remained, 5).forEach((chunk, i) => {
|
|
91
|
-
const [paused, cash, liability, underlyingTokenDecimals, relativePrice] = chunk;
|
|
92
|
-
const [asset, token] = assetTokenArray[i];
|
|
93
|
-
token2AssetStates.set(token, {
|
|
94
|
-
address: asset,
|
|
95
|
-
paused,
|
|
96
|
-
cash,
|
|
97
|
-
liability,
|
|
98
|
-
underlyingTokenDecimals,
|
|
99
|
-
relativePrice,
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
const poolState = {
|
|
103
|
-
params: {
|
|
104
|
-
paused,
|
|
105
|
-
ampFactor,
|
|
106
|
-
haircutRate,
|
|
107
|
-
startCovRatio,
|
|
108
|
-
endCovRatio,
|
|
109
|
-
},
|
|
110
|
-
underlyingAddresses: tokens,
|
|
111
|
-
asset: {},
|
|
112
|
-
};
|
|
113
|
-
const isMainPool = Array.from(token2AssetStates.values()).filter(assetState => assetState.relativePrice === undefined).length > 0;
|
|
114
|
-
for (const token of poolState.underlyingAddresses) {
|
|
115
|
-
if (!token2AssetStates.has(token)) {
|
|
116
|
-
// this happens when asset has been added to pool but is not added to BMW yet
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
poolState.asset[token] = token2AssetStates.get(token);
|
|
120
|
-
if (isMainPool) {
|
|
121
|
-
poolState.asset[token].relativePrice = undefined;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return poolState;
|
|
125
|
-
}
|
|
126
|
-
async fetchLatestStateFromRpc() {
|
|
127
|
-
const multiCalls = this.getFetchStateWithBlockInfoMultiCalls();
|
|
128
|
-
try {
|
|
129
|
-
const lastUpdatedAtMs = Date.now();
|
|
130
|
-
const aggregatedResults = (await this.dexHelper.multiWrapper.tryAggregate(false, multiCalls, undefined, undefined,
|
|
131
|
-
// multiCalls includes calls asset.isPaused, asset.getRelativePrice
|
|
132
|
-
// some of the contracts don't have these methods, so prevent logging errors
|
|
133
|
-
false));
|
|
134
|
-
return this.parseStateFromMultiResultsWithBlockInfo(aggregatedResults, lastUpdatedAtMs);
|
|
135
|
-
}
|
|
136
|
-
catch (e) {
|
|
137
|
-
this._logMessageWithSuppression('ERROR_FETCHING_STATE_FROM_RPC', e);
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
parseStateFromMultiResultsWithBlockInfo(multiOutputs, lastUpdatedAtMs) {
|
|
142
|
-
const [blockNumber, ...outputsForAbstract] = multiOutputs.map((m, i) => {
|
|
143
|
-
return m.returnData;
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
value: this._parseStateFromMultiResults(outputsForAbstract),
|
|
147
|
-
blockNumber,
|
|
148
|
-
lastUpdatedAtMs,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
addAssets(asset2TokenMap) {
|
|
152
|
-
for (const [asset, token] of asset2TokenMap) {
|
|
153
|
-
if (this.asset2TokenMap.has(asset)) {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
this.asset2TokenMap.set(asset, token);
|
|
157
|
-
this._cachedMultiCallData = undefined;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
exports.WombatPool = WombatPool;
|
|
162
|
-
WombatPool.poolInterface = new abi_1.Interface(pool_json_1.default);
|
|
163
|
-
WombatPool.assetInterface = new abi_1.Interface(asset_json_1.default);
|
|
164
|
-
//# sourceMappingURL=wombat-pool-poller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wombat-pool-poller.js","sourceRoot":"","sources":["../../../src/dex/wombat/wombat-pool-poller.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAE/C,oDAAuB;AAIvB,2FAAsF;AACtF,+FAA0F;AAE1F,+DAAgF;AAChF,iDAK4B;AAC5B,2EAAiD;AACjD,6EAAmD;AACnD,mCAA0C;AAG1C,MAAa,UAAW,SAAQ,uCAG/B;IAIC,YACE,MAAc,EACd,cAAsB,EACtB,SAAqB,EACX,WAAoB,EACpB,cAAqC;QAE/C,MAAM,SAAS,GAAG,IAAA,iCAAyB,EACzC,2CAAmB,CAAC,WAAW,CAAC,SAAS,CAAC,CAC3C,CAAC;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