@paraswap/dex-lib 3.7.8-oswap → 3.7.8-oswap.2
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/smardex/smardex-factory.json +185 -0
- package/build/abi/smardex/smardex-pool.json +578 -0
- package/build/abi/smardex/smardex-router.json +648 -0
- package/build/abi/trader-joe-v2_1/FactoryABI.json +1208 -0
- package/build/abi/trader-joe-v2_1/PairABI.json +1493 -0
- package/build/abi/trader-joe-v2_1/RouterABI.json +1489 -0
- package/build/abi/trader-joe-v2_1/StateMulticall.json +193 -0
- package/build/abi/wombat/pool.json +1289 -0
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -22
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v2/tokens-avalanche.json +44 -0
- package/build/dex/aave-v2/tokens-mainnet.json +188 -0
- package/build/dex/aave-v2/tokens-polygon.json +44 -0
- package/build/dex/bProtocol.d.ts +18 -0
- package/build/dex/bProtocol.js +39 -0
- package/build/dex/bProtocol.js.map +1 -0
- package/build/dex/bancor.d.ts +26 -0
- package/build/dex/bancor.js +58 -0
- package/build/dex/bancor.js.map +1 -0
- package/build/dex/compound.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- package/build/dex/curve-v2.d.ts +58 -0
- package/build/dex/curve-v2.js +180 -0
- package/build/dex/curve-v2.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +33 -0
- package/build/dex/dodo-v1.js +63 -0
- package/build/dex/dodo-v1.js.map +1 -0
- package/build/dex/lido.d.ts +19 -0
- package/build/dex/lido.js +42 -0
- package/build/dex/lido.js.map +1 -0
- package/build/dex/onebit.d.ts +25 -0
- package/build/dex/onebit.js +42 -0
- package/build/dex/onebit.js.map +1 -0
- package/build/dex/oswap/oswap.js +4 -1
- package/build/dex/oswap/oswap.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -31
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/smardex/subgraph-queries.d.ts +1 -0
- package/build/dex/smardex/subgraph-queries.js +17 -0
- package/build/dex/smardex/subgraph-queries.js.map +1 -0
- package/build/dex/smardex/usd-reserves.d.ts +23 -0
- package/build/dex/smardex/usd-reserves.js +86 -0
- package/build/dex/smardex/usd-reserves.js.map +1 -0
- package/build/dex/smoothy.d.ts +26 -0
- package/build/dex/smoothy.js +48 -0
- package/build/dex/smoothy.js.map +1 -0
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +62 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -10
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2-1-2/config.d.ts +4 -0
- package/build/dex/trader-joe-v2-1-2/config.js +47 -0
- package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2-1-2/constants.js +22 -0
- package/build/dex/trader-joe-v2-1-2/constants.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js +291 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +248 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +53 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +307 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/types.d.ts +82 -0
- package/build/dex/trader-joe-v2-1-2/types.js +9 -0
- package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +79 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/config.d.ts +4 -0
- package/build/dex/trader-joe-v2_1/config.js +47 -0
- package/build/dex/trader-joe-v2_1/config.js.map +1 -0
- package/build/dex/trader-joe-v2_1/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2_1/constants.js +22 -0
- package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
- package/build/dex/trader-joe-v2_1/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2_1/math/index.js +291 -0
- package/build/dex/trader-joe-v2_1/math/index.js.map +1 -0
- 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 +384 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +247 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +53 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +307 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/types.d.ts +82 -0
- package/build/dex/trader-joe-v2_1/types.js +9 -0
- package/build/dex/trader-joe-v2_1/types.js.map +1 -0
- package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
- package/build/dex/wombat/wombat-pool-poller.js +164 -0
- package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
- package/build/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/dex/oswap/oswap.ts +9 -1
- package/build/abi/inception/inception-ineth-pool.json +0 -1062
- package/build/abi/inception/inception-ineth.json +0 -609
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
- package/build/dex/idle-dao/idle-dao-pool.js +0 -176
- package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
- package/build/dex/idle-dao/scripts.d.ts +0 -9
- package/build/dex/idle-dao/scripts.js +0 -552
- package/build/dex/idle-dao/scripts.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -5
- package/build/dex/inception/config.js +0 -100
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-native.d.ts +0 -43
- package/build/dex/inception/inception-native.js +0 -131
- package/build/dex/inception/inception-native.js.map +0 -1
- package/build/dex/inception/inception-pool.d.ts +0 -18
- package/build/dex/inception/inception-pool.js +0 -32
- package/build/dex/inception/inception-pool.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -42
- package/build/dex/inception/inception.js +0 -128
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -11
- package/build/dex/inception/types.js +0 -3
- package/build/dex/inception/types.js.map +0 -1
- package/build/dex/inception/utils.d.ts +0 -4
- package/build/dex/inception/utils.js +0 -22
- package/build/dex/inception/utils.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
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G,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACrE,OAAO,CAAC,CAAC,UAAU,CAAC;QACtB,CAAC,CAA0C,CAAC;QAE5C,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,2BAA2B,CAAC,kBAAkB,CAAC;YAC3D,WAAW;YACX,eAAe;SAChB,CAAC;IACJ,CAAC;IAEM,SAAS,CAAC,cAAqC;QACpD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,cAAc,EAAE;YAC3C,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBAClC,SAAS;aACV;YAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACtC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;SACvC;IACH,CAAC;;AArNH,gCAsNC;AAlNiB,wBAAa,GAAG,IAAI,eAAS,CAAC,mBAAO,CAAC,CAAC;AACvC,yBAAc,GAAG,IAAI,eAAS,CAAC,oBAAQ,CAAC,CAAC"}
|
package/build/utils.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { MultiResult } from './lib/multi-wrapper';
|
|
|
6
6
|
import { Contract } from 'web3-eth-contract';
|
|
7
7
|
import Web3 from 'web3';
|
|
8
8
|
import { AxiosError } from 'axios';
|
|
9
|
-
export declare const isAxiosError: (e: any) => e is AxiosError<
|
|
9
|
+
export declare const isAxiosError: (e: any) => e is AxiosError<unknown, any>;
|
|
10
10
|
export declare const isETHAddress: (address: string) => boolean;
|
|
11
11
|
export declare const prependWithOx: (str: string) => string;
|
|
12
12
|
export declare const uuidToBytes16: (uuid: string) => string;
|
package/package.json
CHANGED
package/src/dex/oswap/oswap.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import { OSwapConfig, Adapters, OSWAP_GAS_COST } from './config';
|
|
26
26
|
import { OSwapEventPool } from './oswap-pool';
|
|
27
27
|
import OSwapABI from '../../abi/oswap/oswap.abi.json';
|
|
28
|
+
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
28
29
|
|
|
29
30
|
export class OSwap extends SimpleExchange implements IDex<OSwapData> {
|
|
30
31
|
readonly eventPools: { [id: string]: OSwapEventPool } = {};
|
|
@@ -276,10 +277,17 @@ export class OSwap extends SimpleExchange implements IDex<OSwapData> {
|
|
|
276
277
|
): DexExchangeParam {
|
|
277
278
|
let method: string;
|
|
278
279
|
let args: any;
|
|
280
|
+
let returnAmountPos: number | undefined = undefined;
|
|
279
281
|
|
|
280
282
|
const deadline = getLocalDeadlineAsFriendlyPlaceholder();
|
|
281
283
|
if (side === SwapSide.SELL) {
|
|
282
284
|
method = 'swapExactTokensForTokens';
|
|
285
|
+
returnAmountPos = extractReturnAmountPosition(
|
|
286
|
+
this.iOSwap,
|
|
287
|
+
method,
|
|
288
|
+
'amounts',
|
|
289
|
+
1,
|
|
290
|
+
);
|
|
283
291
|
args = [srcAmount, destAmount, data.path, recipient, deadline];
|
|
284
292
|
} else {
|
|
285
293
|
method = 'swapTokensForExactTokens';
|
|
@@ -293,7 +301,7 @@ export class OSwap extends SimpleExchange implements IDex<OSwapData> {
|
|
|
293
301
|
dexFuncHasRecipient: true,
|
|
294
302
|
exchangeData: swapData,
|
|
295
303
|
targetExchange: data.pool,
|
|
296
|
-
returnAmountPos
|
|
304
|
+
returnAmountPos,
|
|
297
305
|
};
|
|
298
306
|
}
|
|
299
307
|
|