@galacticcouncil/sdk 9.10.0 → 9.12.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/index.cjs +2 -2
- package/build/index.mjs +2 -2
- package/build/types/client/BalanceClient.d.ts +0 -1
- package/build/types/client/ChainParams.d.ts +0 -1
- package/build/types/evm/index.d.ts +1 -0
- package/build/types/evm/types.d.ts +7 -0
- package/build/types/gho/GhoTokenClient.d.ts +6 -0
- package/build/types/gho/abi.d.ts +124 -0
- package/build/types/gho/index.d.ts +2 -0
- package/build/types/pool/PoolClient.d.ts +8 -2
- package/build/types/pool/PoolService.d.ts +6 -0
- package/build/types/pool/aave/AavePool.d.ts +0 -1
- package/build/types/pool/aave/AavePoolClient.d.ts +3 -0
- package/build/types/pool/aave/types.d.ts +0 -7
- package/build/types/pool/hsm/HsmPool.d.ts +14 -3
- package/build/types/pool/hsm/HsmPoolClient.d.ts +8 -2
- package/build/types/pool/lbp/LbpPool.d.ts +0 -1
- package/build/types/pool/omni/OmniPool.d.ts +0 -1
- package/build/types/pool/omni/OmniPoolClient.d.ts +7 -2
- package/build/types/pool/stable/StableSwap.d.ts +0 -1
- package/build/types/pool/types.d.ts +3 -1
- package/build/types/pool/xyk/XykPool.d.ts +0 -1
- package/build/types/sor/TradeRouter.d.ts +92 -61
- package/build/types/sor/TradeScheduler.d.ts +0 -1
- package/build/types/sor/const.d.ts +1 -1
- package/build/types/sor/types.d.ts +0 -1
- package/build/types/types.d.ts +0 -1
- package/build/types/utils/math.d.ts +0 -1
- package/package.json +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export declare const GHO_TOKEN_ABI: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly internalType: "address";
|
|
4
|
+
readonly name: "facilitator";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
}];
|
|
7
|
+
readonly name: "getFacilitator";
|
|
8
|
+
readonly outputs: readonly [{
|
|
9
|
+
readonly type: "tuple";
|
|
10
|
+
readonly components: readonly [{
|
|
11
|
+
readonly name: "addr";
|
|
12
|
+
readonly type: "address";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "label";
|
|
15
|
+
readonly type: "bytes32";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "bucketCapacity";
|
|
18
|
+
readonly type: "uint128";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "bucketLevel";
|
|
21
|
+
readonly type: "uint128";
|
|
22
|
+
}];
|
|
23
|
+
}];
|
|
24
|
+
readonly stateMutability: "view";
|
|
25
|
+
readonly type: "function";
|
|
26
|
+
}, {
|
|
27
|
+
readonly inputs: readonly [{
|
|
28
|
+
readonly internalType: "address";
|
|
29
|
+
readonly name: "facilitator";
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
}];
|
|
32
|
+
readonly name: "getFacilitatorBucket";
|
|
33
|
+
readonly outputs: readonly [{
|
|
34
|
+
readonly internalType: "uint256";
|
|
35
|
+
readonly name: "";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}, {
|
|
38
|
+
readonly internalType: "uint256";
|
|
39
|
+
readonly name: "";
|
|
40
|
+
readonly type: "uint256";
|
|
41
|
+
}];
|
|
42
|
+
readonly stateMutability: "view";
|
|
43
|
+
readonly type: "function";
|
|
44
|
+
}, {
|
|
45
|
+
readonly inputs: readonly [];
|
|
46
|
+
readonly name: "getFacilitatorsList";
|
|
47
|
+
readonly outputs: readonly [{
|
|
48
|
+
readonly internalType: "address[]";
|
|
49
|
+
readonly name: "";
|
|
50
|
+
readonly type: "address[]";
|
|
51
|
+
}];
|
|
52
|
+
readonly stateMutability: "view";
|
|
53
|
+
readonly type: "function";
|
|
54
|
+
}, {
|
|
55
|
+
readonly anonymous: false;
|
|
56
|
+
readonly inputs: readonly [{
|
|
57
|
+
readonly indexed: true;
|
|
58
|
+
readonly internalType: "address";
|
|
59
|
+
readonly name: "facilitatorAddress";
|
|
60
|
+
readonly type: "address";
|
|
61
|
+
}, {
|
|
62
|
+
readonly indexed: true;
|
|
63
|
+
readonly internalType: "bytes32";
|
|
64
|
+
readonly name: "label";
|
|
65
|
+
readonly type: "bytes32";
|
|
66
|
+
}, {
|
|
67
|
+
readonly indexed: false;
|
|
68
|
+
readonly internalType: "uint256";
|
|
69
|
+
readonly name: "bucketCapacity";
|
|
70
|
+
readonly type: "uint256";
|
|
71
|
+
}];
|
|
72
|
+
readonly name: "FacilitatorAdded";
|
|
73
|
+
readonly type: "event";
|
|
74
|
+
}, {
|
|
75
|
+
readonly anonymous: false;
|
|
76
|
+
readonly inputs: readonly [{
|
|
77
|
+
readonly indexed: true;
|
|
78
|
+
readonly internalType: "address";
|
|
79
|
+
readonly name: "facilitatorAddress";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
}, {
|
|
82
|
+
readonly indexed: false;
|
|
83
|
+
readonly internalType: "uint256";
|
|
84
|
+
readonly name: "oldCapacity";
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
}, {
|
|
87
|
+
readonly indexed: false;
|
|
88
|
+
readonly internalType: "uint256";
|
|
89
|
+
readonly name: "newCapacity";
|
|
90
|
+
readonly type: "uint256";
|
|
91
|
+
}];
|
|
92
|
+
readonly name: "FacilitatorBucketCapacityUpdated";
|
|
93
|
+
readonly type: "event";
|
|
94
|
+
}, {
|
|
95
|
+
readonly anonymous: false;
|
|
96
|
+
readonly inputs: readonly [{
|
|
97
|
+
readonly indexed: true;
|
|
98
|
+
readonly internalType: "address";
|
|
99
|
+
readonly name: "facilitatorAddress";
|
|
100
|
+
readonly type: "address";
|
|
101
|
+
}, {
|
|
102
|
+
readonly indexed: false;
|
|
103
|
+
readonly internalType: "uint256";
|
|
104
|
+
readonly name: "oldLevel";
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
}, {
|
|
107
|
+
readonly indexed: false;
|
|
108
|
+
readonly internalType: "uint256";
|
|
109
|
+
readonly name: "newLevel";
|
|
110
|
+
readonly type: "uint256";
|
|
111
|
+
}];
|
|
112
|
+
readonly name: "FacilitatorBucketLevelUpdated";
|
|
113
|
+
readonly type: "event";
|
|
114
|
+
}, {
|
|
115
|
+
readonly anonymous: false;
|
|
116
|
+
readonly inputs: readonly [{
|
|
117
|
+
readonly indexed: true;
|
|
118
|
+
readonly internalType: "address";
|
|
119
|
+
readonly name: "facilitatorAddress";
|
|
120
|
+
readonly type: "address";
|
|
121
|
+
}];
|
|
122
|
+
readonly name: "FacilitatorRemoved";
|
|
123
|
+
readonly type: "event";
|
|
124
|
+
}];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ApiPromise } from '@polkadot/api';
|
|
2
2
|
import { UnsubscribePromise } from '@polkadot/api-base/types';
|
|
3
|
+
import { Vec } from '@polkadot/types';
|
|
4
|
+
import { FrameSystemEventRecord } from '@polkadot/types/lookup';
|
|
3
5
|
import { BalanceClient } from '../client';
|
|
4
6
|
import { EvmClient } from '../evm';
|
|
5
7
|
import { MmOracleClient } from '../oracle';
|
|
@@ -10,11 +12,15 @@ export declare abstract class PoolClient extends BalanceClient {
|
|
|
10
12
|
protected mmOracle: MmOracleClient;
|
|
11
13
|
protected pools: PoolBase[];
|
|
12
14
|
protected subs: UnsubscribePromise[];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
protected assets: Map<string, Asset>;
|
|
16
|
+
protected mem: number;
|
|
17
|
+
readonly onNewBlockHandler: (block: number) => void;
|
|
18
|
+
readonly onEventsHandler: (events: Vec<FrameSystemEventRecord>) => void;
|
|
15
19
|
private memPoolsCache;
|
|
16
20
|
private memPools;
|
|
17
21
|
constructor(api: ApiPromise, evm: EvmClient);
|
|
22
|
+
protected onNewBlock(_block: number): void;
|
|
23
|
+
protected onEvents(_events: Vec<FrameSystemEventRecord>): void;
|
|
18
24
|
abstract isSupported(): boolean;
|
|
19
25
|
abstract getPoolType(): PoolType;
|
|
20
26
|
abstract getPoolFees(block: number, pair: PoolPair, address: string): Promise<PoolFees>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ApiPromise } from '@polkadot/api';
|
|
2
|
+
import { Vec } from '@polkadot/types';
|
|
3
|
+
import { FrameSystemEventRecord } from '@polkadot/types/lookup';
|
|
2
4
|
import { PolkadotApiClient } from '../api';
|
|
3
5
|
import { AssetClient } from '../client';
|
|
4
6
|
import { EvmClient } from '../evm';
|
|
@@ -24,10 +26,14 @@ export declare class PoolService extends PolkadotApiClient implements IPoolServi
|
|
|
24
26
|
protected readonly clients: PoolClient[];
|
|
25
27
|
protected onChainAssets: Asset[];
|
|
26
28
|
protected block: number;
|
|
29
|
+
private blockHandlers;
|
|
30
|
+
private eventHandlers;
|
|
27
31
|
private disconnectSubscribeNewHeads;
|
|
32
|
+
private disconnectSubscribeEvents;
|
|
28
33
|
private memRegistry;
|
|
29
34
|
constructor(api: ApiPromise, evm: EvmClient);
|
|
30
35
|
protected onNewBlock(block: number): void;
|
|
36
|
+
protected onEvents(events: Vec<FrameSystemEventRecord>): void;
|
|
31
37
|
get assets(): Asset[];
|
|
32
38
|
get isRegistrySynced(): boolean;
|
|
33
39
|
syncRegistry(external?: ExternalAsset[]): Promise<void>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Vec } from '@polkadot/types';
|
|
2
|
+
import type { FrameSystemEventRecord } from '@polkadot/types/lookup';
|
|
1
3
|
import { UnsubscribePromise } from '@polkadot/api-base/types';
|
|
2
4
|
import { PoolBase, PoolType, PoolFees, PoolPair } from '../types';
|
|
3
5
|
import { PoolClient } from '../PoolClient';
|
|
@@ -9,6 +11,7 @@ export declare class AavePoolClient extends PoolClient {
|
|
|
9
11
|
isSupported(): boolean;
|
|
10
12
|
loadPools(): Promise<PoolBase[]>;
|
|
11
13
|
getPoolFees(_block: number, _poolPair: PoolPair, _poolAddress: string): Promise<PoolFees>;
|
|
14
|
+
protected onEvents(events: Vec<FrameSystemEventRecord>): void;
|
|
12
15
|
protected subscribeBalances(): UnsubscribePromise;
|
|
13
16
|
protected subscribeUpdates(): UnsubscribePromise;
|
|
14
17
|
protected updatePoolState(pool: PoolBase): Promise<void>;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { BuyCtx, PoolError, PoolFee, PoolPair, SellCtx } from '../types';
|
|
2
2
|
import { StableSwap, StableSwapBase, StableSwapPair } from '../stable';
|
|
3
|
-
import { BigNumber } from '../../utils/bignumber';
|
|
4
3
|
export type HsmPoolBase = StableSwapBase & {
|
|
4
|
+
hsmAddress: string;
|
|
5
|
+
hsmMintCapacity: BigNumber;
|
|
5
6
|
hollarId: string;
|
|
7
|
+
hollarH160: string;
|
|
8
|
+
collateralId: string;
|
|
9
|
+
collateralBalance: BigNumber;
|
|
6
10
|
maxBuyPriceCoefficient: BigNumber;
|
|
7
11
|
maxInHolding: BigNumber;
|
|
8
12
|
purchaseFee: PoolFee;
|
|
@@ -10,9 +14,14 @@ export type HsmPoolBase = StableSwapBase & {
|
|
|
10
14
|
buyBackRate: PoolFee;
|
|
11
15
|
};
|
|
12
16
|
export declare class HsmPool extends StableSwap {
|
|
17
|
+
hsmAddress: string;
|
|
18
|
+
hsmMintCapacity: BigNumber;
|
|
19
|
+
hollarId: string;
|
|
20
|
+
hollarH160: string;
|
|
21
|
+
collateralId: string;
|
|
22
|
+
collateralBalance: BigNumber;
|
|
13
23
|
maxBuyPriceCoefficient: BigNumber;
|
|
14
24
|
maxInHolding: BigNumber;
|
|
15
|
-
hollarId: string;
|
|
16
25
|
purchaseFee: PoolFee;
|
|
17
26
|
buyBackFee: PoolFee;
|
|
18
27
|
buyBackRate: PoolFee;
|
|
@@ -20,7 +29,9 @@ export declare class HsmPool extends StableSwap {
|
|
|
20
29
|
constructor(pool: HsmPoolBase);
|
|
21
30
|
validatePair(_tokenIn: string, _tokenOut: string): boolean;
|
|
22
31
|
parsePair(tokenIn: string, tokenOut: string): StableSwapPair;
|
|
23
|
-
|
|
32
|
+
validateTradeHollarIn(poolPair: PoolPair, amountIn: BigNumber, amountOut: BigNumber, errors: PoolError[]): PoolError[];
|
|
33
|
+
validateTradeHollarOut(amountIn: BigNumber, amountOut: BigNumber, errors: PoolError[]): PoolError[];
|
|
34
|
+
validateTradeConstraints(poolPair: PoolPair, amountIn: BigNumber, amountOut: BigNumber): PoolError[];
|
|
24
35
|
validateAndBuy(poolPair: PoolPair, amountOut: BigNumber): BuyCtx;
|
|
25
36
|
validateAndSell(poolPair: PoolPair, amountIn: BigNumber): SellCtx;
|
|
26
37
|
private calculateHollarInGivenCollateralOut;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { ApiPromise } from '@polkadot/api';
|
|
1
|
+
import type { ApiPromise } from '@polkadot/api';
|
|
2
|
+
import type { Vec } from '@polkadot/types';
|
|
3
|
+
import type { FrameSystemEventRecord } from '@polkadot/types/lookup';
|
|
2
4
|
import { UnsubscribePromise } from '@polkadot/api-base/types';
|
|
3
5
|
import { EvmClient } from '../../evm';
|
|
4
|
-
import { PoolType, PoolPair, PoolFees, PoolBase } from '../types';
|
|
5
6
|
import { StableSwapClient } from '../stable';
|
|
7
|
+
import { PoolType, PoolPair, PoolFees, PoolBase } from '../types';
|
|
6
8
|
import { PoolClient } from '../PoolClient';
|
|
7
9
|
export declare class HsmClient extends PoolClient {
|
|
8
10
|
private stableClient;
|
|
11
|
+
private ghoTokenClient;
|
|
9
12
|
constructor(api: ApiPromise, evm: EvmClient, stableClient: StableSwapClient);
|
|
10
13
|
getPoolType(): PoolType;
|
|
11
14
|
private getPoolId;
|
|
15
|
+
private getFacilitatorAddress;
|
|
16
|
+
private getHollarAddress;
|
|
12
17
|
isSupported(): boolean;
|
|
13
18
|
loadPools(): Promise<PoolBase[]>;
|
|
14
19
|
getPoolFees(_block: number, _poolPair: PoolPair, _poolAddress: string): Promise<PoolFees>;
|
|
20
|
+
protected onEvents(events: Vec<FrameSystemEventRecord>): void;
|
|
15
21
|
protected subscribeBalances(): UnsubscribePromise;
|
|
16
22
|
protected subscribeUpdates(): UnsubscribePromise;
|
|
17
23
|
}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { UnsubscribePromise } from '@polkadot/api-base/types';
|
|
2
|
-
import { PoolBase, PoolType,
|
|
2
|
+
import { PoolBase, PoolType, PoolPair } from '../types';
|
|
3
3
|
import { PoolClient } from '../PoolClient';
|
|
4
|
+
import { OmniPoolFees } from './OmniPool';
|
|
4
5
|
export declare class OmniPoolClient extends PoolClient {
|
|
5
6
|
private dynamicFees;
|
|
7
|
+
private dynamicFeesConfiguration;
|
|
6
8
|
private oracles;
|
|
7
9
|
private memQueryCache;
|
|
8
10
|
private memOracleQuery;
|
|
9
11
|
private memFeesQuery;
|
|
12
|
+
private memFeesConfigurationQuery;
|
|
10
13
|
getPoolType(): PoolType;
|
|
11
14
|
private getPoolId;
|
|
12
15
|
private getOracleKey;
|
|
13
16
|
private getPoolLimits;
|
|
14
17
|
private getDynamicFees;
|
|
18
|
+
private getDynamicFeesConfiguration;
|
|
15
19
|
private getOraclePrice;
|
|
16
20
|
isSupported(): boolean;
|
|
21
|
+
isAssetConfigSupported(): boolean;
|
|
17
22
|
loadPools(): Promise<PoolBase[]>;
|
|
18
|
-
getPoolFees(block: number, poolPair: PoolPair, _poolAddress: string): Promise<
|
|
23
|
+
getPoolFees(block: number, poolPair: PoolPair, _poolAddress: string): Promise<OmniPoolFees>;
|
|
19
24
|
private getAssetFee;
|
|
20
25
|
private getProtocolFee;
|
|
21
26
|
protected subscribeUpdates(): UnsubscribePromise;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Asset } from '../types';
|
|
2
|
-
import type { BigNumber } from '../utils/bignumber';
|
|
3
2
|
export type PoolFilter = {
|
|
4
3
|
includeOnly?: PoolType[];
|
|
5
4
|
exclude?: PoolType[];
|
|
@@ -14,7 +13,10 @@ export declare enum PoolType {
|
|
|
14
13
|
}
|
|
15
14
|
export declare enum PoolError {
|
|
16
15
|
UnknownError = "UnknownError",
|
|
16
|
+
FacilitatorCapacityExceeded = "FacilitatorCapacityExceeded",
|
|
17
17
|
InsufficientTradingAmount = "InsufficientTradingAmount",
|
|
18
|
+
InsufficientCollateral = "InsufficientCollateral",
|
|
19
|
+
MaxHoldingExceeded = "MaxHoldingExceeded",
|
|
18
20
|
MaxInRatioExceeded = "MaxInRatioExceeded",
|
|
19
21
|
MaxOutRatioExceeded = "MaxOutRatioExceeded",
|
|
20
22
|
TradeNotAllowed = "TradeNotAllowed",
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { Router } from './Router';
|
|
2
2
|
import { Hop } from '../pool';
|
|
3
3
|
import { Amount } from '../types';
|
|
4
|
-
import { BigNumber } from '../utils/bignumber';
|
|
5
4
|
import { Trade } from './types';
|
|
6
5
|
export declare class TradeRouter extends Router {
|
|
7
6
|
private loadRouteContext;
|
|
8
7
|
/**
|
|
9
8
|
* Check whether trade is direct or not
|
|
10
9
|
*
|
|
11
|
-
* @param swaps -
|
|
10
|
+
* @param swaps - trade route
|
|
12
11
|
* @returns true if direct trade, otherwise false
|
|
13
12
|
*/
|
|
14
13
|
private isDirectTrade;
|
|
15
14
|
/**
|
|
16
15
|
* Find best sell swap without errors, if there is none return first one found
|
|
17
16
|
*
|
|
18
|
-
* @param swaps -
|
|
19
|
-
* @returns best sell
|
|
17
|
+
* @param swaps - sell routes
|
|
18
|
+
* @returns best sell route if exist, otherwise first one found
|
|
20
19
|
*/
|
|
21
20
|
private findBestSellRoute;
|
|
22
21
|
/**
|
|
23
22
|
* Return route fee range [min,max] in case pool is using dynamic fees
|
|
24
23
|
*
|
|
25
|
-
* @param swaps -
|
|
24
|
+
* @param swaps - trade route
|
|
26
25
|
* @returns min & max fee range if swap through the pool with dynamic fees support
|
|
27
26
|
*/
|
|
28
27
|
private getRouteFeeRange;
|
|
@@ -34,107 +33,139 @@ export declare class TradeRouter extends Router {
|
|
|
34
33
|
*/
|
|
35
34
|
private getPoolFeeRange;
|
|
36
35
|
/**
|
|
37
|
-
* Calculate and return best possible sell trade for assetIn>assetOut
|
|
36
|
+
* Calculate and return best possible sell trade for assetIn > assetOut pair
|
|
38
37
|
*
|
|
39
|
-
* @param {string} assetIn -
|
|
40
|
-
* @param {string} assetOut -
|
|
41
|
-
* @param {BigNumber} amountIn -
|
|
42
|
-
* @returns
|
|
38
|
+
* @param {string} assetIn - asset in
|
|
39
|
+
* @param {string} assetOut - asset out
|
|
40
|
+
* @param {BigNumber} amountIn - amount of assetIn to sell for assetOut
|
|
41
|
+
* @returns best possible sell trade of given asset pair
|
|
43
42
|
*/
|
|
44
43
|
getBestSell(assetIn: string, assetOut: string, amountIn: BigNumber | string | number): Promise<Trade>;
|
|
45
44
|
/**
|
|
46
|
-
* Calculate and return sell trade for assetIn>assetOut
|
|
45
|
+
* Calculate and return sell trade for assetIn > assetOut pair
|
|
47
46
|
*
|
|
48
|
-
* @param {string} assetIn -
|
|
49
|
-
* @param {string} assetOut -
|
|
50
|
-
* @param {BigNumber} amountIn -
|
|
51
|
-
* @param {Hop[]} route -
|
|
52
|
-
* @returns
|
|
47
|
+
* @param {string} assetIn - asset in
|
|
48
|
+
* @param {string} assetOut - asset out
|
|
49
|
+
* @param {BigNumber} amountIn - amount of assetIn to sell for assetOut
|
|
50
|
+
* @param {Hop[]} route - explicit route to use for trade
|
|
51
|
+
* @returns sell trade of given asset pair
|
|
53
52
|
*/
|
|
54
53
|
getSell(assetIn: string, assetOut: string, amountIn: BigNumber | string | number, route?: Hop[]): Promise<Trade>;
|
|
55
54
|
/**
|
|
56
|
-
* Calculate
|
|
55
|
+
* Calculate and return all possible sell trades for assetIn > assetOut
|
|
57
56
|
*
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
61
|
-
* @returns
|
|
57
|
+
* @param {string} assetIn - asset in
|
|
58
|
+
* @param {string} assetOut - asset out
|
|
59
|
+
* @param {BigNumber} amountIn - amount of assetIn to sell for assetOut
|
|
60
|
+
* @returns possible sell trades of given asset pair
|
|
61
|
+
*/
|
|
62
|
+
getSellTrades(assetIn: string, assetOut: string, amountIn: BigNumber | string | number): Promise<Trade[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Build sell trade
|
|
65
|
+
*
|
|
66
|
+
* @param poolsMap - pools map
|
|
67
|
+
* @param route - sell route
|
|
68
|
+
* @returns - sell trade
|
|
69
|
+
*/
|
|
70
|
+
private buildSell;
|
|
71
|
+
/**
|
|
72
|
+
* Calculates the output amount of a trade assuming fees are zero
|
|
73
|
+
*
|
|
74
|
+
* @param amountIn - amount of assetIn to sell for assetOut
|
|
75
|
+
* @param route - trade route
|
|
76
|
+
* @param poolsMap - pools map
|
|
77
|
+
* @returns the amount out if fees are zero
|
|
62
78
|
*/
|
|
63
79
|
private calculateDelta0Y;
|
|
64
80
|
/**
|
|
65
|
-
* Calculate and return sell
|
|
66
|
-
* - final amount of previous swap is entry to next one
|
|
81
|
+
* Calculate and return sell route for given path
|
|
67
82
|
*
|
|
68
|
-
* @param amountIn -
|
|
69
|
-
* @param path -
|
|
70
|
-
* @param poolsMap -
|
|
71
|
-
* @returns
|
|
83
|
+
* @param amountIn - amount of assetIn to sell for assetOut
|
|
84
|
+
* @param path - current path
|
|
85
|
+
* @param poolsMap - pools map
|
|
86
|
+
* @returns sell route for given path with corresponding pool pairs
|
|
72
87
|
*/
|
|
73
88
|
private toSellSwaps;
|
|
74
89
|
/**
|
|
75
|
-
* Calculate and return most liquid route
|
|
90
|
+
* Calculate and return the most liquid route
|
|
76
91
|
*
|
|
77
92
|
* To avoid routing through the pools with low liquidity, 0.1% from the
|
|
78
93
|
* most liquid pool asset is used as reference value to determine the
|
|
79
94
|
* sweet spot.
|
|
80
95
|
*
|
|
81
|
-
* @param {string} assetIn -
|
|
82
|
-
* @param {string} assetOut -
|
|
83
|
-
* @return
|
|
96
|
+
* @param {string} assetIn - asset in
|
|
97
|
+
* @param {string} assetOut - asset out
|
|
98
|
+
* @return most liquid route of given asset pair
|
|
84
99
|
*/
|
|
85
100
|
getMostLiquidRoute(assetIn: string, assetOut: string): Promise<Hop[]>;
|
|
86
101
|
/**
|
|
87
|
-
* Calculate and return best possible spot price for
|
|
102
|
+
* Calculate and return best possible spot price for assetIn > assetOut pair
|
|
88
103
|
*
|
|
89
|
-
* @param {string} assetIn -
|
|
90
|
-
* @param {string} assetOut -
|
|
91
|
-
* @return
|
|
104
|
+
* @param {string} assetIn - asset in
|
|
105
|
+
* @param {string} assetOut - asset out
|
|
106
|
+
* @return best possible spot price of given asset pair, or undefined if trade not supported
|
|
92
107
|
*/
|
|
93
108
|
getBestSpotPrice(assetIn: string, assetOut: string): Promise<Amount | undefined>;
|
|
94
109
|
/**
|
|
95
|
-
* Find best buy
|
|
110
|
+
* Find best buy route without errors, if there is none return first one found
|
|
96
111
|
*
|
|
97
|
-
* @param swaps -
|
|
98
|
-
* @returns best
|
|
112
|
+
* @param swaps - buy routes
|
|
113
|
+
* @returns best buy route if exist, otherwise first one found
|
|
99
114
|
*/
|
|
100
115
|
private findBestBuyRoute;
|
|
101
116
|
/**
|
|
102
|
-
* Calculate and return best possible buy trade for assetIn>assetOut
|
|
117
|
+
* Calculate and return best possible buy trade for assetIn > assetOut pair
|
|
103
118
|
*
|
|
104
|
-
* @param {string} assetIn -
|
|
105
|
-
* @param {string} assetOut -
|
|
106
|
-
* @param {BigNumber} amountOut -
|
|
107
|
-
* @returns
|
|
119
|
+
* @param {string} assetIn - asset in
|
|
120
|
+
* @param {string} assetOut - asset out
|
|
121
|
+
* @param {BigNumber} amountOut - amount of assetOut to buy for assetIn
|
|
122
|
+
* @returns best possible buy trade of given asset pair
|
|
108
123
|
*/
|
|
109
124
|
getBestBuy(assetIn: string, assetOut: string, amountOut: BigNumber | string | number): Promise<Trade>;
|
|
110
125
|
/**
|
|
111
|
-
* Calculate and return buy trade for assetIn>assetOut
|
|
126
|
+
* Calculate and return buy trade for assetIn > assetOut pair
|
|
112
127
|
*
|
|
113
|
-
* @param {string} assetIn -
|
|
114
|
-
* @param {string} assetOut -
|
|
115
|
-
* @param {BigNumber} amountOut -
|
|
116
|
-
* @param {Hop[]} route -
|
|
117
|
-
* @returns
|
|
128
|
+
* @param {string} assetIn - asset in
|
|
129
|
+
* @param {string} assetOut - asset out
|
|
130
|
+
* @param {BigNumber} amountOut - amount of assetOut to buy for assetIn
|
|
131
|
+
* @param {Hop[]} route - explicit route to use for trade
|
|
132
|
+
* @returns buy trade of given asset pair
|
|
118
133
|
*/
|
|
119
134
|
getBuy(assetIn: string, assetOut: string, amountOut: BigNumber | string | number, route?: Hop[]): Promise<Trade>;
|
|
120
135
|
/**
|
|
121
|
-
* Calculate
|
|
136
|
+
* Calculate and return all possible buy trades for assetIn > assetOut
|
|
137
|
+
*
|
|
138
|
+
* @param {string} assetIn - asset in
|
|
139
|
+
* @param {string} assetOut - asset out
|
|
140
|
+
* @param {BigNumber} amountOut - amount of assetOut to buy for assetIn
|
|
141
|
+
* @returns possible buy trades of given asset pair
|
|
142
|
+
*/
|
|
143
|
+
getBuyTrades(assetIn: string, assetOut: string, amountOut: BigNumber | string | number): Promise<Trade[]>;
|
|
144
|
+
/**
|
|
145
|
+
* Build buy trade
|
|
146
|
+
*
|
|
147
|
+
* @param poolsMap - pools map
|
|
148
|
+
* @param route - buy route
|
|
149
|
+
* @returns - buy trade
|
|
150
|
+
*/
|
|
151
|
+
private buildBuy;
|
|
152
|
+
/**
|
|
153
|
+
* Calculates the required input amount for a trade to receive a desired output amount,
|
|
154
|
+
* assuming fees are zero.
|
|
122
155
|
*
|
|
123
|
-
* @param amountOut -
|
|
124
|
-
* @param
|
|
125
|
-
* @param poolsMap -
|
|
126
|
-
* @returns the amount
|
|
156
|
+
* @param amountOut - amount of assetOut to buy for assetIn
|
|
157
|
+
* @param route - trade route
|
|
158
|
+
* @param poolsMap - pools map
|
|
159
|
+
* @returns the required input amount for a trade if fees are zero
|
|
127
160
|
*/
|
|
128
161
|
private calculateDelta0X;
|
|
129
162
|
/**
|
|
130
|
-
* Calculate and return buy
|
|
131
|
-
* - final amount of previous swap is entry to next one
|
|
132
|
-
* - calculation is done backwards (swaps in reversed order)
|
|
163
|
+
* Calculate and return buy route for given path
|
|
133
164
|
*
|
|
134
|
-
* @param amountOut -
|
|
135
|
-
* @param path -
|
|
136
|
-
* @param poolsMap -
|
|
137
|
-
* @returns
|
|
165
|
+
* @param amountOut - amount of assetOut to buy for assetIn
|
|
166
|
+
* @param path - current path
|
|
167
|
+
* @param poolsMap - pools map
|
|
168
|
+
* @returns buy route for given path
|
|
138
169
|
*/
|
|
139
170
|
private toBuySwaps;
|
|
140
171
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const DEFAULT_BLOCK_TIME = 6000;
|
|
2
|
-
export declare const DEFAULT_MIN_BUDGET:
|
|
2
|
+
export declare const DEFAULT_MIN_BUDGET: BigNumber;
|
|
3
3
|
export declare const TWAP_BLOCK_PERIOD = 6;
|
|
4
4
|
export declare const TWAP_MAX_PRICE_IMPACT = -5;
|
|
5
5
|
export declare const TWAP_MAX_DURATION: number;
|
package/build/types/types.d.ts
CHANGED
package/package.json
CHANGED