@paraswap/dex-lib 2.33.4-balancer-v2-multihop.2 → 2.33.4-base-support.0
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/config.js +26 -0
- package/build/config.js.map +1 -1
- package/build/constants.d.ts +2 -1
- package/build/constants.js +2 -1
- package/build/constants.js.map +1 -1
- package/build/dex/balancer-v2/optimizer.d.ts +0 -1
- package/build/dex/balancer-v2/optimizer.js +21 -29
- package/build/dex/balancer-v2/optimizer.js.map +1 -1
- package/build/dex/pancakeswap-v3/types.d.ts +137 -0
- package/build/dex/pancakeswap-v3/types.js +9 -0
- package/build/dex/pancakeswap-v3/types.js.map +1 -0
- package/build/dex/uniswap-v3/config.js +12 -0
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/weth/config.js +3 -0
- package/build/dex/weth/config.js.map +1 -1
- package/build/web3-provider.d.ts +3 -0
- package/build/web3-provider.js +13 -0
- package/build/web3-provider.js.map +1 -0
- package/package.json +1 -1
- package/src/config.ts +29 -0
- package/src/constants.ts +2 -1
- package/src/dex/balancer-v2/optimizer.ts +23 -38
- package/src/dex/uniswap-v3/config.ts +13 -0
- package/src/dex/weth/config.ts +3 -0
- package/build/abi/algebra/AlgebraFactory-v1_1.abi.json +0 -250
- package/build/abi/api3-proxy.json +0 -46
- package/build/abi/api3-server-v1.json +0 -463
- package/build/abi/quick-perps/fast-price-events.json +0 -70
- package/build/abi/quick-perps/fast-price-feed.json +0 -741
- package/build/abi/quick-perps/reader.json +0 -313
- package/build/abi/quick-perps/vault-price-feed.json +0 -323
- package/build/abi/quick-perps/vault.json +0 -1953
- package/build/abi/quickPerps/fast-price-events.json +0 -70
- package/build/abi/quickPerps/fast-price-feed.json +0 -748
- package/build/abi/quickPerps/reader.json +0 -313
- package/build/abi/quickPerps/vault-price-feed.json +0 -477
- package/build/abi/quickPerps/vault.json +0 -1953
- package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
- package/build/abi/woo-fi/WooPP.abi.json +0 -548
- package/build/abi/woo-fi/Wooracle.abi.json +0 -260
- package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
- package/build/dex/aave-v3/tokens/avalanche.json +0 -74
- package/build/dex/aave-v3/tokens/fantom.json +0 -62
- package/build/dex/aave-v3/tokens/optimism.json +0 -50
- package/build/dex/aave-v3/tokens/polygon.json +0 -116
- package/build/dex/quick-perps/config.d.ts +0 -11
- package/build/dex/quick-perps/config.js +0 -27
- package/build/dex/quick-perps/config.js.map +0 -1
- package/build/dex/quick-perps/fast-price-feed.d.ts +0 -26
- package/build/dex/quick-perps/fast-price-feed.js +0 -176
- package/build/dex/quick-perps/fast-price-feed.js.map +0 -1
- package/build/dex/quick-perps/pool.d.ts +0 -21
- package/build/dex/quick-perps/pool.js +0 -210
- package/build/dex/quick-perps/pool.js.map +0 -1
- package/build/dex/quick-perps/quick-perps.d.ts +0 -52
- package/build/dex/quick-perps/quick-perps.js +0 -205
- package/build/dex/quick-perps/quick-perps.js.map +0 -1
- package/build/dex/quick-perps/types.d.ts +0 -98
- package/build/dex/quick-perps/types.js +0 -3
- package/build/dex/quick-perps/types.js.map +0 -1
- package/build/dex/quick-perps/usdq.d.ts +0 -15
- package/build/dex/quick-perps/usdq.js +0 -61
- package/build/dex/quick-perps/usdq.js.map +0 -1
- package/build/dex/quick-perps/vault-price-feed.d.ts +0 -43
- package/build/dex/quick-perps/vault-price-feed.js +0 -194
- package/build/dex/quick-perps/vault-price-feed.js.map +0 -1
- package/build/dex/quick-perps/vault-utils.d.ts +0 -8
- package/build/dex/quick-perps/vault-utils.js +0 -41
- package/build/dex/quick-perps/vault-utils.js.map +0 -1
- package/build/dex/quick-perps/vault.d.ts +0 -46
- package/build/dex/quick-perps/vault.js +0 -166
- package/build/dex/quick-perps/vault.js.map +0 -1
- package/build/dex/quickswap/camelot-v3.d.ts +0 -6
- package/build/dex/quickswap/camelot-v3.js +0 -19
- package/build/dex/quickswap/camelot-v3.js.map +0 -1
- package/build/dex/quickswap-v3.d.ts +0 -21
- package/build/dex/quickswap-v3.js +0 -40
- package/build/dex/quickswap-v3.js.map +0 -1
- package/build/dex/test-dex/config.d.ts +0 -4
- package/build/dex/test-dex/config.js +0 -15
- package/build/dex/test-dex/config.js.map +0 -1
- package/build/dex/test-dex/test-dex-pool.d.ts +0 -39
- package/build/dex/test-dex/test-dex-pool.js +0 -63
- package/build/dex/test-dex/test-dex-pool.js.map +0 -1
- package/build/dex/test-dex/test-dex.d.ts +0 -37
- package/build/dex/test-dex/test-dex.js +0 -126
- package/build/dex/test-dex/test-dex.js.map +0 -1
- package/build/dex/test-dex/types.d.ts +0 -6
- package/build/dex/test-dex/types.js +0 -3
- package/build/dex/test-dex/types.js.map +0 -1
- package/build/dex/woo-fi/config.d.ts +0 -4
- package/build/dex/woo-fi/config.js +0 -141
- package/build/dex/woo-fi/config.js.map +0 -1
- package/build/dex/woo-fi/constants.d.ts +0 -5
- package/build/dex/woo-fi/constants.js +0 -20
- package/build/dex/woo-fi/constants.js.map +0 -1
- package/build/dex/woo-fi/types.d.ts +0 -48
- package/build/dex/woo-fi/types.js +0 -3
- package/build/dex/woo-fi/types.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
- package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
- package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
- package/build/dex/woo-fi/woo-fi-math.js +0 -300
- package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi.d.ts +0 -65
- package/build/dex/woo-fi/woo-fi.js +0 -480
- package/build/dex/woo-fi/woo-fi.js.map +0 -1
- package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
- package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
- package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
- package/build/lib/api3-feed.d.ts +0 -26
- package/build/lib/api3-feed.js +0 -82
- package/build/lib/api3-feed.js.map +0 -1
- package/src/dex/balancer-v2/balancer-v2-optimizer.test.ts +0 -226
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Vault } from './vault';
|
|
2
|
-
import { Address } from '../../types';
|
|
3
|
-
import { DeepReadonly } from 'ts-essentials';
|
|
4
|
-
export declare class VaultUtils<State> {
|
|
5
|
-
protected vault: Vault<State>;
|
|
6
|
-
constructor(vault: Vault<State>);
|
|
7
|
-
getFeeBasisPoints(state: DeepReadonly<State>, _token: Address, _usdqDelta: bigint, _feeBasisPoints: bigint, _taxBasisPoints: bigint, _increment: boolean): bigint;
|
|
8
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VaultUtils = void 0;
|
|
4
|
-
class VaultUtils {
|
|
5
|
-
constructor(vault) {
|
|
6
|
-
this.vault = vault;
|
|
7
|
-
}
|
|
8
|
-
getFeeBasisPoints(state, _token, _usdqDelta, _feeBasisPoints, _taxBasisPoints, _increment) {
|
|
9
|
-
if (!this.vault.hasDynamicFees) {
|
|
10
|
-
return _feeBasisPoints;
|
|
11
|
-
}
|
|
12
|
-
const initialAmount = this.vault.getUSDQAmount(state, _token);
|
|
13
|
-
let nextAmount = initialAmount + _usdqDelta;
|
|
14
|
-
if (!_increment) {
|
|
15
|
-
nextAmount = _usdqDelta > initialAmount ? 0n : initialAmount - _usdqDelta;
|
|
16
|
-
}
|
|
17
|
-
const targetAmount = this.vault.getTargetUsdqAmount(state, _token);
|
|
18
|
-
if (targetAmount == 0n) {
|
|
19
|
-
return _feeBasisPoints;
|
|
20
|
-
}
|
|
21
|
-
const initialDiff = initialAmount > targetAmount
|
|
22
|
-
? initialAmount - targetAmount
|
|
23
|
-
: targetAmount - initialAmount;
|
|
24
|
-
const nextDiff = nextAmount > targetAmount
|
|
25
|
-
? nextAmount - targetAmount
|
|
26
|
-
: targetAmount - nextAmount;
|
|
27
|
-
// action improves relative asset balance
|
|
28
|
-
if (nextDiff < initialDiff) {
|
|
29
|
-
const rebateBps = (_taxBasisPoints * initialDiff) / targetAmount;
|
|
30
|
-
return rebateBps > _feeBasisPoints ? 0n : _feeBasisPoints - rebateBps;
|
|
31
|
-
}
|
|
32
|
-
let averageDiff = (initialDiff + nextDiff) / 2n;
|
|
33
|
-
if (averageDiff > targetAmount) {
|
|
34
|
-
averageDiff = targetAmount;
|
|
35
|
-
}
|
|
36
|
-
const taxBps = (_taxBasisPoints * averageDiff) / targetAmount;
|
|
37
|
-
return _feeBasisPoints + taxBps;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.VaultUtils = VaultUtils;
|
|
41
|
-
//# sourceMappingURL=vault-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vault-utils.js","sourceRoot":"","sources":["../../../src/dex/quick-perps/vault-utils.ts"],"names":[],"mappings":";;;AAIA,MAAa,UAAU;IACrB,YAAsB,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAE7C,iBAAiB,CACf,KAA0B,EAC1B,MAAe,EACf,UAAkB,EAClB,eAAuB,EACvB,eAAuB,EACvB,UAAmB;QAEnB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YAC9B,OAAO,eAAe,CAAC;SACxB;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC9D,IAAI,UAAU,GAAG,aAAa,GAAG,UAAU,CAAC;QAC5C,IAAI,CAAC,UAAU,EAAE;YACf,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,GAAG,UAAU,CAAC;SAC3E;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACnE,IAAI,YAAY,IAAI,EAAE,EAAE;YACtB,OAAO,eAAe,CAAC;SACxB;QAED,MAAM,WAAW,GACf,aAAa,GAAG,YAAY;YAC1B,CAAC,CAAC,aAAa,GAAG,YAAY;YAC9B,CAAC,CAAC,YAAY,GAAG,aAAa,CAAC;QACnC,MAAM,QAAQ,GACZ,UAAU,GAAG,YAAY;YACvB,CAAC,CAAC,UAAU,GAAG,YAAY;YAC3B,CAAC,CAAC,YAAY,GAAG,UAAU,CAAC;QAEhC,yCAAyC;QACzC,IAAI,QAAQ,GAAG,WAAW,EAAE;YAC1B,MAAM,SAAS,GAAG,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,YAAY,CAAC;YACjE,OAAO,SAAS,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,GAAG,SAAS,CAAC;SACvE;QAED,IAAI,WAAW,GAAG,CAAC,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;QAChD,IAAI,WAAW,GAAG,YAAY,EAAE;YAC9B,WAAW,GAAG,YAAY,CAAC;SAC5B;QACD,MAAM,MAAM,GAAG,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,YAAY,CAAC;QAC9D,OAAO,eAAe,GAAG,MAAM,CAAC;IAClC,CAAC;CACF;AAhDD,gCAgDC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
3
|
-
import { PartialEventSubscriber } from '../../composed-event-subscriber';
|
|
4
|
-
import { Lens } from '../../lens';
|
|
5
|
-
import { VaultUtils } from './vault-utils';
|
|
6
|
-
import { VaultConfig, VaultState } from './types';
|
|
7
|
-
import { VaultPriceFeed } from './vault-price-feed';
|
|
8
|
-
import { USDQ } from './usdq';
|
|
9
|
-
import { MultiCallInput, MultiCallOutput, Address, Logger, Log } from '../../types';
|
|
10
|
-
import { BlockHeader } from 'web3-eth';
|
|
11
|
-
export declare class Vault<State> extends PartialEventSubscriber<State, VaultState> {
|
|
12
|
-
readonly vaultAddress: Address;
|
|
13
|
-
protected tokenAddresses: Address[];
|
|
14
|
-
protected vaultPriceFeed: VaultPriceFeed<State>;
|
|
15
|
-
protected usdq: USDQ<State>;
|
|
16
|
-
static readonly interface: Interface;
|
|
17
|
-
protected vaultUtils: VaultUtils<State>;
|
|
18
|
-
tokenDecimals: {
|
|
19
|
-
[address: string]: number;
|
|
20
|
-
};
|
|
21
|
-
stableTokens: {
|
|
22
|
-
[address: string]: boolean;
|
|
23
|
-
};
|
|
24
|
-
protected tokenWeights: {
|
|
25
|
-
[address: string]: bigint;
|
|
26
|
-
};
|
|
27
|
-
stableSwapFeeBasisPoints: bigint;
|
|
28
|
-
swapFeeBasisPoints: bigint;
|
|
29
|
-
stableTaxBasisPoints: bigint;
|
|
30
|
-
taxBasisPoints: bigint;
|
|
31
|
-
hasDynamicFees: bigint;
|
|
32
|
-
protected includeAmmPrice: boolean;
|
|
33
|
-
protected useSwapPricing: boolean;
|
|
34
|
-
protected totalTokenWeights: bigint;
|
|
35
|
-
constructor(vaultAddress: Address, tokenAddresses: Address[], config: VaultConfig, vaultPriceFeed: VaultPriceFeed<State>, usdq: USDQ<State>, lens: Lens<DeepReadonly<State>, DeepReadonly<VaultState>>, logger: Logger);
|
|
36
|
-
getMinPrice(state: DeepReadonly<State>, _token: Address): bigint;
|
|
37
|
-
getMaxPrice(state: DeepReadonly<State>, _token: Address): bigint;
|
|
38
|
-
getFeeBasisPoints(state: DeepReadonly<State>, _token: Address, _usdqDelta: bigint, _feeBasisPoints: bigint, _taxBasisPoints: bigint, _increment: boolean): bigint;
|
|
39
|
-
getTargetUsdqAmount(state: DeepReadonly<State>, _token: Address): bigint;
|
|
40
|
-
static getConfigMulticallInputs(vaultAddress: Address, tokenAddresses: Address[]): MultiCallInput[];
|
|
41
|
-
static getConfig(multicallOutputs: MultiCallOutput[], tokenAddresses: Address[]): VaultConfig;
|
|
42
|
-
getGenerateStateMultiCallInputs(): MultiCallInput[];
|
|
43
|
-
generateState(multicallOutputs: MultiCallOutput[], blockNumber?: number | 'latest'): DeepReadonly<VaultState>;
|
|
44
|
-
getUSDQAmount(state: DeepReadonly<State>, token: Address): bigint;
|
|
45
|
-
processLog(state: DeepReadonly<VaultState>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): AsyncOrSync<VaultState | null>;
|
|
46
|
-
}
|
|
@@ -1,166 +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.Vault = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const abi_1 = require("@ethersproject/abi");
|
|
9
|
-
const composed_event_subscriber_1 = require("../../composed-event-subscriber");
|
|
10
|
-
const vault_json_1 = __importDefault(require("../../abi/quick-perps/vault.json"));
|
|
11
|
-
const vault_utils_1 = require("./vault-utils");
|
|
12
|
-
class Vault extends composed_event_subscriber_1.PartialEventSubscriber {
|
|
13
|
-
constructor(vaultAddress, tokenAddresses, config, vaultPriceFeed, usdq, lens, logger) {
|
|
14
|
-
super([vaultAddress], lens, logger);
|
|
15
|
-
this.vaultAddress = vaultAddress;
|
|
16
|
-
this.tokenAddresses = tokenAddresses;
|
|
17
|
-
this.vaultPriceFeed = vaultPriceFeed;
|
|
18
|
-
this.usdq = usdq;
|
|
19
|
-
this.vaultUtils = new vault_utils_1.VaultUtils(this);
|
|
20
|
-
this.tokenDecimals = config.tokenDecimals;
|
|
21
|
-
this.stableTokens = config.stableTokens;
|
|
22
|
-
this.tokenWeights = config.tokenWeights;
|
|
23
|
-
this.stableSwapFeeBasisPoints = config.stableSwapFeeBasisPoints;
|
|
24
|
-
this.swapFeeBasisPoints = config.swapFeeBasisPoints;
|
|
25
|
-
this.stableTaxBasisPoints = config.stableTaxBasisPoints;
|
|
26
|
-
this.taxBasisPoints = config.taxBasisPoints;
|
|
27
|
-
this.hasDynamicFees = config.hasDynamicFees;
|
|
28
|
-
this.includeAmmPrice = config.includeAmmPrice;
|
|
29
|
-
this.useSwapPricing = config.useSwapPricing;
|
|
30
|
-
this.totalTokenWeights = config.totalTokenWeights;
|
|
31
|
-
}
|
|
32
|
-
getMinPrice(state, _token) {
|
|
33
|
-
return this.vaultPriceFeed.getPrice(state, _token, false, this.includeAmmPrice, this.useSwapPricing);
|
|
34
|
-
}
|
|
35
|
-
getMaxPrice(state, _token) {
|
|
36
|
-
return this.vaultPriceFeed.getPrice(state, _token, true, this.includeAmmPrice, this.useSwapPricing);
|
|
37
|
-
}
|
|
38
|
-
getFeeBasisPoints(state, _token, _usdqDelta, _feeBasisPoints, _taxBasisPoints, _increment) {
|
|
39
|
-
return this.vaultUtils.getFeeBasisPoints(state, _token, _usdqDelta, _feeBasisPoints, _taxBasisPoints, _increment);
|
|
40
|
-
}
|
|
41
|
-
getTargetUsdqAmount(state, _token) {
|
|
42
|
-
const supply = this.usdq.getTotalSupply(state);
|
|
43
|
-
if (supply == 0n) {
|
|
44
|
-
return 0n;
|
|
45
|
-
}
|
|
46
|
-
const weight = this.tokenWeights[_token];
|
|
47
|
-
return (weight * supply) / this.totalTokenWeights;
|
|
48
|
-
}
|
|
49
|
-
static getConfigMulticallInputs(vaultAddress, tokenAddresses) {
|
|
50
|
-
return [
|
|
51
|
-
...tokenAddresses.map(t => ({
|
|
52
|
-
target: vaultAddress,
|
|
53
|
-
callData: Vault.interface.encodeFunctionData('tokenDecimals', [t]),
|
|
54
|
-
})),
|
|
55
|
-
...tokenAddresses.map(t => ({
|
|
56
|
-
target: vaultAddress,
|
|
57
|
-
callData: Vault.interface.encodeFunctionData('stableTokens', [t]),
|
|
58
|
-
})),
|
|
59
|
-
...tokenAddresses.map(t => ({
|
|
60
|
-
target: vaultAddress,
|
|
61
|
-
callData: Vault.interface.encodeFunctionData('tokenWeights', [t]),
|
|
62
|
-
})),
|
|
63
|
-
...[
|
|
64
|
-
'stableSwapFeeBasisPoints',
|
|
65
|
-
'swapFeeBasisPoints',
|
|
66
|
-
'stableTaxBasisPoints',
|
|
67
|
-
'taxBasisPoints',
|
|
68
|
-
'hasDynamicFees',
|
|
69
|
-
'includeAmmPrice',
|
|
70
|
-
'useSwapPricing',
|
|
71
|
-
'totalTokenWeights',
|
|
72
|
-
].map(fn => ({
|
|
73
|
-
target: vaultAddress,
|
|
74
|
-
callData: Vault.interface.encodeFunctionData(fn),
|
|
75
|
-
})),
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
static getConfig(multicallOutputs, tokenAddresses) {
|
|
79
|
-
let i = 0;
|
|
80
|
-
return {
|
|
81
|
-
tokenDecimals: tokenAddresses.reduce((acc, t) => {
|
|
82
|
-
acc[t] = parseInt(Vault.interface
|
|
83
|
-
.decodeFunctionResult('tokenDecimals', multicallOutputs[i++])[0]
|
|
84
|
-
.toString());
|
|
85
|
-
return acc;
|
|
86
|
-
}, {}),
|
|
87
|
-
stableTokens: tokenAddresses.reduce((acc, t) => {
|
|
88
|
-
acc[t] = Vault.interface.decodeFunctionResult('stableTokens', multicallOutputs[i++])[0];
|
|
89
|
-
return acc;
|
|
90
|
-
}, {}),
|
|
91
|
-
tokenWeights: tokenAddresses.reduce((acc, t) => {
|
|
92
|
-
acc[t] = BigInt(Vault.interface
|
|
93
|
-
.decodeFunctionResult('tokenWeights', multicallOutputs[i++])[0]
|
|
94
|
-
.toString());
|
|
95
|
-
return acc;
|
|
96
|
-
}, {}),
|
|
97
|
-
stableSwapFeeBasisPoints: BigInt(Vault.interface
|
|
98
|
-
.decodeFunctionResult('stableSwapFeeBasisPoints', multicallOutputs[i++])[0]
|
|
99
|
-
.toString()),
|
|
100
|
-
swapFeeBasisPoints: BigInt(Vault.interface
|
|
101
|
-
.decodeFunctionResult('swapFeeBasisPoints', multicallOutputs[i++])[0]
|
|
102
|
-
.toString()),
|
|
103
|
-
stableTaxBasisPoints: BigInt(Vault.interface
|
|
104
|
-
.decodeFunctionResult('stableTaxBasisPoints', multicallOutputs[i++])[0]
|
|
105
|
-
.toString()),
|
|
106
|
-
taxBasisPoints: BigInt(Vault.interface
|
|
107
|
-
.decodeFunctionResult('taxBasisPoints', multicallOutputs[i++])[0]
|
|
108
|
-
.toString()),
|
|
109
|
-
hasDynamicFees: Vault.interface.decodeFunctionResult('hasDynamicFees', multicallOutputs[i++])[0],
|
|
110
|
-
includeAmmPrice: Vault.interface.decodeFunctionResult('includeAmmPrice', multicallOutputs[i++])[0],
|
|
111
|
-
useSwapPricing: Vault.interface.decodeFunctionResult('useSwapPricing', multicallOutputs[i++])[0],
|
|
112
|
-
totalTokenWeights: BigInt(Vault.interface
|
|
113
|
-
.decodeFunctionResult('totalTokenWeights', multicallOutputs[i++])[0]
|
|
114
|
-
.toString()),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
getGenerateStateMultiCallInputs() {
|
|
118
|
-
return this.tokenAddresses.map((t) => ({
|
|
119
|
-
target: this.vaultAddress,
|
|
120
|
-
callData: Vault.interface.encodeFunctionData('usdqAmounts', [t]),
|
|
121
|
-
}));
|
|
122
|
-
}
|
|
123
|
-
generateState(multicallOutputs, blockNumber) {
|
|
124
|
-
let vaultState = {
|
|
125
|
-
usdqAmounts: {},
|
|
126
|
-
};
|
|
127
|
-
this.tokenAddresses.forEach((t, i) => (vaultState.usdqAmounts[t] = BigInt(Vault.interface
|
|
128
|
-
.decodeFunctionResult('usdqAmounts', multicallOutputs[i])[0]
|
|
129
|
-
.toString())));
|
|
130
|
-
return vaultState;
|
|
131
|
-
}
|
|
132
|
-
getUSDQAmount(state, token) {
|
|
133
|
-
return this.lens.get()(state).usdqAmounts[token];
|
|
134
|
-
}
|
|
135
|
-
processLog(state, log, blockHeader) {
|
|
136
|
-
try {
|
|
137
|
-
const parsed = Vault.interface.parseLog(log);
|
|
138
|
-
const _state = lodash_1.default.cloneDeep(state);
|
|
139
|
-
switch (parsed.name) {
|
|
140
|
-
case 'IncreaseUsdqAmount': {
|
|
141
|
-
const tokenAddress = parsed.args.token.toLowerCase();
|
|
142
|
-
const amount = BigInt(parsed.args.amount.toString());
|
|
143
|
-
if (tokenAddress in state.usdqAmounts)
|
|
144
|
-
_state.usdqAmounts[tokenAddress] += amount;
|
|
145
|
-
return _state;
|
|
146
|
-
}
|
|
147
|
-
case 'DecreaseUsdqAmount': {
|
|
148
|
-
const tokenAddress = parsed.args.token.toLowerCase();
|
|
149
|
-
const amount = BigInt(parsed.args.amount.toString());
|
|
150
|
-
if (tokenAddress in state.usdqAmounts)
|
|
151
|
-
_state.usdqAmounts[tokenAddress] -= amount;
|
|
152
|
-
return _state;
|
|
153
|
-
}
|
|
154
|
-
default:
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
catch (e) {
|
|
159
|
-
this.logger.error('Failed to parse log', e);
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
exports.Vault = Vault;
|
|
165
|
-
Vault.interface = new abi_1.Interface(vault_json_1.default);
|
|
166
|
-
//# sourceMappingURL=vault.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../../../src/dex/quick-perps/vault.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,4CAA+C;AAE/C,+EAAyE;AAEzE,kFAAwD;AACxD,+CAA2C;AAkB3C,MAAa,KAAa,SAAQ,kDAAyC;IAiBzE,YACkB,YAAqB,EAC3B,cAAyB,EACnC,MAAmB,EACT,cAAqC,EACrC,IAAiB,EAC3B,IAAyD,EACzD,MAAc;QAEd,KAAK,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QARpB,iBAAY,GAAZ,YAAY,CAAS;Q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,KAAK,CAAC,WAAW,EAAE,CAAC;oBACrD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;oBACrD,IAAI,YAAY,IAAI,KAAK,CAAC,WAAW;wBACnC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC;oBAC7C,OAAO,MAAM,CAAC;iBACf;gBACD,KAAK,oBAAoB,CAAC,CAAC;oBACzB,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;oBACrD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;oBACrD,IAAI,YAAY,IAAI,KAAK,CAAC,WAAW;wBACnC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC;oBAC7C,OAAO,MAAM,CAAC;iBACf;gBACD;oBACE,OAAO,IAAI,CAAC;aACf;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;SACb;IACH,CAAC;;AAxQH,sBAyQC;AAxQiB,eAAS,GAAc,IAAI,eAAS,CAAC,oBAAQ,CAAC,CAAC"}
|
|
@@ -1,19 +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.CamelotV3 = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const config_1 = require("./config");
|
|
9
|
-
const quickswap_v3_1 = require("./quickswap-v3");
|
|
10
|
-
const config = lodash_1.default.pick(config_1.QuickSwapConfig, ['CamelotV3']).CamelotV3;
|
|
11
|
-
class CamelotV3 extends quickswap_v3_1.QuickSwapV3 {
|
|
12
|
-
// public static dexKeysWithNetwork
|
|
13
|
-
constructor(dexHelper) {
|
|
14
|
-
super(dexHelper, 'camelotv3', config[dexHelper.config.data.network].router);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.CamelotV3 = CamelotV3;
|
|
18
|
-
CamelotV3.dexKeys = ['camelotv3'];
|
|
19
|
-
//# sourceMappingURL=camelot-v3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"camelot-v3.js","sourceRoot":"","sources":["../../../src/dex/quickswap/camelot-v3.ts"],"names":[],"mappings":";;;;;;AACA,oDAAuB;AACvB,qCAA2C;AAC3C,iDAA6C;AAE7C,MAAM,MAAM,GAAG,gBAAC,CAAC,IAAI,CAAC,wBAAe,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAEhE,MAAa,SAAU,SAAQ,0BAAW;IAGxC,mCAAmC;IACnC,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC;;AANH,8BAOC;AANQ,iBAAO,GAAG,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SwapSide } from '../constants';
|
|
2
|
-
import { Address } from '../types';
|
|
3
|
-
import { IDexTxBuilder } from './idex';
|
|
4
|
-
import { UniswapV3, UniswapV3Param } from './uniswap-v3';
|
|
5
|
-
import { IDexHelper } from '../dex-helper';
|
|
6
|
-
export declare type QuickSwapV3Data = {
|
|
7
|
-
deadline?: number;
|
|
8
|
-
path: {
|
|
9
|
-
tokenIn: Address;
|
|
10
|
-
tokenOut: Address;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
13
|
-
export declare class QuickSwapV3 extends UniswapV3 implements IDexTxBuilder<QuickSwapV3Data, UniswapV3Param> {
|
|
14
|
-
static dexKeys: string[];
|
|
15
|
-
constructor(dexHelper: IDexHelper);
|
|
16
|
-
protected encodePath(path: {
|
|
17
|
-
tokenIn: Address;
|
|
18
|
-
tokenOut: Address;
|
|
19
|
-
fee: number;
|
|
20
|
-
}[], side: SwapSide): string;
|
|
21
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QuickSwapV3 = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const uniswap_v3_1 = require("./uniswap-v3");
|
|
6
|
-
const solidity_1 = require("@ethersproject/solidity");
|
|
7
|
-
const QUICKSWAP_V3_ROUTER_ADDRESSES = {
|
|
8
|
-
[constants_1.Network.POLYGON]: '0xf5b509bb0909a69b1c207e495f687a596c168e12',
|
|
9
|
-
};
|
|
10
|
-
class QuickSwapV3 extends uniswap_v3_1.UniswapV3 {
|
|
11
|
-
constructor(dexHelper) {
|
|
12
|
-
super(dexHelper, 'quickswapv3', QUICKSWAP_V3_ROUTER_ADDRESSES[dexHelper.config.data.network]);
|
|
13
|
-
}
|
|
14
|
-
// override parent as QuickSwapV3 handles fees dynamically.
|
|
15
|
-
encodePath(path, side) {
|
|
16
|
-
if (path.length === 0) {
|
|
17
|
-
return '0x';
|
|
18
|
-
}
|
|
19
|
-
const { _path, types } = path.reduce(({ _path, types }, curr, index) => {
|
|
20
|
-
if (index === 0) {
|
|
21
|
-
return {
|
|
22
|
-
types: ['address', 'address'],
|
|
23
|
-
_path: [curr.tokenIn, curr.tokenOut],
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return {
|
|
28
|
-
types: [...types, 'address'],
|
|
29
|
-
_path: [..._path, curr.tokenOut],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}, { _path: [], types: [] });
|
|
33
|
-
return side === constants_1.SwapSide.BUY
|
|
34
|
-
? (0, solidity_1.pack)(types.reverse(), _path.reverse())
|
|
35
|
-
: (0, solidity_1.pack)(types, _path);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.QuickSwapV3 = QuickSwapV3;
|
|
39
|
-
QuickSwapV3.dexKeys = ['quickswapv3'];
|
|
40
|
-
//# sourceMappingURL=quickswap-v3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quickswap-v3.js","sourceRoot":"","sources":["../../src/dex/quickswap-v3.ts"],"names":[],"mappings":";;;AAAA,4CAAiD;AAIjD,6CAAyD;AACzD,sDAA+C;AAG/C,MAAM,6BAA6B,GAAmC;IACpE,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,4CAA4C;CAChE,CAAC;AAWF,MAAa,WACX,SAAQ,sBAAS;IAKjB,YAAY,SAAqB;QAC/B,KAAK,CACH,SAAS,EACT,aAAa,EACb,6BAA6B,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAC7D,CAAC;IACJ,CAAC;IAED,2DAA2D;IACjD,UAAU,CAClB,IAIG,EACH,IAAc;QAEd,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC;SACb;QAED,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,CAClC,CACE,EAAE,KAAK,EAAE,KAAK,EAAwC,EACtD,IAAI,EACJ,KAAK,EACiC,EAAE;YACxC,IAAI,KAAK,KAAK,CAAC,EAAE;gBACf,OAAO;oBACL,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;oBAC7B,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC;iBACrC,CAAC;aACH;iBAAM;gBACL,OAAO;oBACL,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC;oBAC5B,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;iBACjC,CAAC;aACH;QACH,CAAC,EACD,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CACzB,CAAC;QAEF,OAAO,IAAI,KAAK,oBAAQ,CAAC,GAAG;YAC1B,CAAC,CAAC,IAAA,eAAI,EAAC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YACxC,CAAC,CAAC,IAAA,eAAI,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;;AAnDH,kCAoDC;AAhDQ,mBAAO,GAAG,CAAC,aAAa,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Adapters = exports.TestDexConfig = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
exports.TestDexConfig = {
|
|
6
|
-
TestDex: {
|
|
7
|
-
// TODO: complete me!
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
exports.Adapters = {
|
|
11
|
-
// TODO: add adapters for each chain
|
|
12
|
-
// This is an example to copy
|
|
13
|
-
[constants_1.Network.MAINNET]: { [constants_1.SwapSide.SELL]: [{ name: '', index: 0 }] },
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/test-dex/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;IACP,qBAAqB;KACtB;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,oCAAoC;IACpC,6BAA6B;IAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;CACjE,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
-
import { Log, Logger } from '../../types';
|
|
4
|
-
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
-
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
-
import { PoolState } from './types';
|
|
7
|
-
export declare class TestDexEventPool extends StatefulEventSubscriber<PoolState> {
|
|
8
|
-
protected parentName: string;
|
|
9
|
-
protected network: number;
|
|
10
|
-
protected dexHelper: IDexHelper;
|
|
11
|
-
protected testDexIface: Interface;
|
|
12
|
-
handlers: {
|
|
13
|
-
[event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
|
|
14
|
-
};
|
|
15
|
-
logDecoder: (log: Log) => any;
|
|
16
|
-
addressesSubscribed: string[];
|
|
17
|
-
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, testDexIface?: Interface);
|
|
18
|
-
/**
|
|
19
|
-
* The function is called every time any of the subscribed
|
|
20
|
-
* addresses release log. The function accepts the current
|
|
21
|
-
* state, updates the state according to the log, and returns
|
|
22
|
-
* the updated state.
|
|
23
|
-
* @param state - Current state of event subscriber
|
|
24
|
-
* @param log - Log released by one of the subscribed addresses
|
|
25
|
-
* @returns Updates state of the event subscriber after the log
|
|
26
|
-
*/
|
|
27
|
-
protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
28
|
-
/**
|
|
29
|
-
* The function generates state using on-chain calls. This
|
|
30
|
-
* function is called to regenerate state if the event based
|
|
31
|
-
* system fails to fetch events and the local state is no
|
|
32
|
-
* more correct.
|
|
33
|
-
* @param blockNumber - Blocknumber for which the state should
|
|
34
|
-
* should be generated
|
|
35
|
-
* @returns state of the event subscriber at blocknumber
|
|
36
|
-
*/
|
|
37
|
-
generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
|
|
38
|
-
handleMyEvent(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
39
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestDexEventPool = void 0;
|
|
4
|
-
const abi_1 = require("@ethersproject/abi");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
7
|
-
class TestDexEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
8
|
-
constructor(parentName, network, dexHelper, logger, testDexIface = new abi_1.Interface('' /* TODO: Import and put here TestDex ABI */)) {
|
|
9
|
-
super(parentName, logger);
|
|
10
|
-
this.parentName = parentName;
|
|
11
|
-
this.network = network;
|
|
12
|
-
this.dexHelper = dexHelper;
|
|
13
|
-
this.testDexIface = testDexIface;
|
|
14
|
-
this.handlers = {};
|
|
15
|
-
// TODO: make logDecoder decode logs that
|
|
16
|
-
this.logDecoder = (log) => this.testDexIface.parseLog(log);
|
|
17
|
-
this.addressesSubscribed = [
|
|
18
|
-
/* subscribed addresses */
|
|
19
|
-
];
|
|
20
|
-
// Add handlers
|
|
21
|
-
this.handlers['myEvent'] = this.handleMyEvent.bind(this);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The function is called every time any of the subscribed
|
|
25
|
-
* addresses release log. The function accepts the current
|
|
26
|
-
* state, updates the state according to the log, and returns
|
|
27
|
-
* the updated state.
|
|
28
|
-
* @param state - Current state of event subscriber
|
|
29
|
-
* @param log - Log released by one of the subscribed addresses
|
|
30
|
-
* @returns Updates state of the event subscriber after the log
|
|
31
|
-
*/
|
|
32
|
-
processLog(state, log) {
|
|
33
|
-
try {
|
|
34
|
-
const event = this.logDecoder(log);
|
|
35
|
-
if (event.name in this.handlers) {
|
|
36
|
-
return this.handlers[event.name](event, state, log);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* The function generates state using on-chain calls. This
|
|
46
|
-
* function is called to regenerate state if the event based
|
|
47
|
-
* system fails to fetch events and the local state is no
|
|
48
|
-
* more correct.
|
|
49
|
-
* @param blockNumber - Blocknumber for which the state should
|
|
50
|
-
* should be generated
|
|
51
|
-
* @returns state of the event subscriber at blocknumber
|
|
52
|
-
*/
|
|
53
|
-
async generateState(blockNumber) {
|
|
54
|
-
// TODO: complete me!
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
// Its just a dummy example
|
|
58
|
-
handleMyEvent(event, state, log) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.TestDexEventPool = TestDexEventPool;
|
|
63
|
-
//# sourceMappingURL=test-dex-pool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-dex-pool.js","sourceRoot":"","sources":["../../../src/dex/test-dex/test-dex-pool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAI1E,MAAa,gBAAiB,SAAQ,mDAAkC;IAWtE,YACY,UAAkB,EAClB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,eAAe,IAAI,eAAS,CACpC,EAAE,CAAC,2CAA2C,CAC/C;QAED,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QARhB,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAErB,iBAAY,GAAZ,YAAY,CAErB;QAjBH,aAAQ,GAIJ,EAAE,CAAC;QAiBL,yCAAyC;QACzC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,mBAAmB,GAAG;QACzB,0BAA0B;SAC3B,CAAC;QAEF,eAAe;QACf,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;OAQG;IACO,UAAU,CAClB,KAA8B,EAC9B,GAAkB;QAElB,IAAI;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;aACrD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,0BAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,qBAAqB;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,2BAA2B;IAC3B,aAAa,CACX,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/ED,4CA+EC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
-
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
|
|
3
|
-
import { SwapSide, Network } from '../../constants';
|
|
4
|
-
import { IDex } from '../../dex/idex';
|
|
5
|
-
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
-
import { TestDexData } from './types';
|
|
7
|
-
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
-
import { TestDexEventPool } from './test-dex-pool';
|
|
9
|
-
export declare class TestDex extends SimpleExchange implements IDex<TestDexData> {
|
|
10
|
-
readonly network: Network;
|
|
11
|
-
readonly dexKey: string;
|
|
12
|
-
readonly dexHelper: IDexHelper;
|
|
13
|
-
protected adapters: import("../../types").AdapterMappings;
|
|
14
|
-
protected eventPools: TestDexEventPool;
|
|
15
|
-
readonly hasConstantPriceLargeAmounts = false;
|
|
16
|
-
readonly needWrapNative = true;
|
|
17
|
-
readonly isFeeOnTransferSupported = false;
|
|
18
|
-
static dexKeysWithNetwork: {
|
|
19
|
-
key: string;
|
|
20
|
-
networks: Network[];
|
|
21
|
-
}[];
|
|
22
|
-
logger: Logger;
|
|
23
|
-
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
|
|
24
|
-
initializePricing(blockNumber: number): Promise<void>;
|
|
25
|
-
getAdapters(side: SwapSide): {
|
|
26
|
-
name: string;
|
|
27
|
-
index: number;
|
|
28
|
-
}[] | null;
|
|
29
|
-
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
30
|
-
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<TestDexData>>;
|
|
31
|
-
getCalldataGasCost(poolPrices: PoolPrices<TestDexData>): number | number[];
|
|
32
|
-
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestDexData, side: SwapSide): AdapterExchangeParam;
|
|
33
|
-
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestDexData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
34
|
-
updatePoolState(): Promise<void>;
|
|
35
|
-
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
36
|
-
releaseResources(): AsyncOrSync<void>;
|
|
37
|
-
}
|