@galacticcouncil/sdk-next 0.8.0-pr203-9b6a8a3 → 0.8.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.
@@ -85,3 +85,112 @@ export declare const AGGREGATOR_V3_ABI: readonly [{
85
85
  readonly stateMutability: "view";
86
86
  readonly type: "function";
87
87
  }];
88
+ export declare const DIA_ORACLE_ABI: readonly [{
89
+ readonly inputs: readonly [];
90
+ readonly stateMutability: "nonpayable";
91
+ readonly type: "constructor";
92
+ }, {
93
+ readonly anonymous: false;
94
+ readonly inputs: readonly [{
95
+ readonly indexed: false;
96
+ readonly internalType: "string";
97
+ readonly name: "key";
98
+ readonly type: "string";
99
+ }, {
100
+ readonly indexed: false;
101
+ readonly internalType: "uint128";
102
+ readonly name: "value";
103
+ readonly type: "uint128";
104
+ }, {
105
+ readonly indexed: false;
106
+ readonly internalType: "uint128";
107
+ readonly name: "timestamp";
108
+ readonly type: "uint128";
109
+ }];
110
+ readonly name: "OracleUpdate";
111
+ readonly type: "event";
112
+ }, {
113
+ readonly anonymous: false;
114
+ readonly inputs: readonly [{
115
+ readonly indexed: false;
116
+ readonly internalType: "address";
117
+ readonly name: "newUpdater";
118
+ readonly type: "address";
119
+ }];
120
+ readonly name: "UpdaterAddressChange";
121
+ readonly type: "event";
122
+ }, {
123
+ readonly inputs: readonly [{
124
+ readonly internalType: "string";
125
+ readonly name: "key";
126
+ readonly type: "string";
127
+ }];
128
+ readonly name: "getValue";
129
+ readonly outputs: readonly [{
130
+ readonly internalType: "uint128";
131
+ readonly name: "";
132
+ readonly type: "uint128";
133
+ }, {
134
+ readonly internalType: "uint128";
135
+ readonly name: "";
136
+ readonly type: "uint128";
137
+ }];
138
+ readonly stateMutability: "view";
139
+ readonly type: "function";
140
+ }, {
141
+ readonly inputs: readonly [{
142
+ readonly internalType: "string[]";
143
+ readonly name: "keys";
144
+ readonly type: "string[]";
145
+ }, {
146
+ readonly internalType: "uint256[]";
147
+ readonly name: "compressedValues";
148
+ readonly type: "uint256[]";
149
+ }];
150
+ readonly name: "setMultipleValues";
151
+ readonly outputs: readonly [];
152
+ readonly stateMutability: "nonpayable";
153
+ readonly type: "function";
154
+ }, {
155
+ readonly inputs: readonly [{
156
+ readonly internalType: "string";
157
+ readonly name: "key";
158
+ readonly type: "string";
159
+ }, {
160
+ readonly internalType: "uint128";
161
+ readonly name: "value";
162
+ readonly type: "uint128";
163
+ }, {
164
+ readonly internalType: "uint128";
165
+ readonly name: "timestamp";
166
+ readonly type: "uint128";
167
+ }];
168
+ readonly name: "setValue";
169
+ readonly outputs: readonly [];
170
+ readonly stateMutability: "nonpayable";
171
+ readonly type: "function";
172
+ }, {
173
+ readonly inputs: readonly [{
174
+ readonly internalType: "address";
175
+ readonly name: "newOracleUpdaterAddress";
176
+ readonly type: "address";
177
+ }];
178
+ readonly name: "updateOracleUpdaterAddress";
179
+ readonly outputs: readonly [];
180
+ readonly stateMutability: "nonpayable";
181
+ readonly type: "function";
182
+ }, {
183
+ readonly inputs: readonly [{
184
+ readonly internalType: "string";
185
+ readonly name: "";
186
+ readonly type: "string";
187
+ }];
188
+ readonly name: "values";
189
+ readonly outputs: readonly [{
190
+ readonly internalType: "uint256";
191
+ readonly name: "";
192
+ readonly type: "uint256";
193
+ }];
194
+ readonly stateMutability: "view";
195
+ readonly type: "function";
196
+ }];
@@ -1,2 +1,3 @@
1
1
  export { MmOracleClient } from './MmOracleClient';
2
+ export * from './abi';
2
3
  export * from './types';
@@ -1,29 +1,29 @@
1
1
  import { PolkadotClient } from 'polkadot-api';
2
- import { type Observable } from 'rxjs';
2
+ import { Observable, Subscription } from 'rxjs';
3
3
  import { BalanceClient } from '../client';
4
4
  import { EvmClient } from '../evm';
5
- import { MmOracleClient } from '../oracle';
6
- import { PoolBase, PoolFees, PoolTokenOverride, PoolType } from './types';
5
+ import { PoolBase, PoolFees, PoolPair, PoolType } from './types';
6
+ import { PoolStore } from './PoolStore';
7
7
  export declare abstract class PoolClient<T extends PoolBase> extends BalanceClient {
8
8
  protected evm: EvmClient;
9
- protected mmOracle: MmOracleClient;
10
- private override;
9
+ protected store: PoolStore<T>;
10
+ private shared$?;
11
11
  private mem;
12
+ private memPoolsCache;
12
13
  private memPools;
13
14
  constructor(client: PolkadotClient, evm: EvmClient);
14
- protected abstract loadPools(): Promise<T[]>;
15
- abstract getPoolFees(pool: T, feeAsset: number): Promise<PoolFees>;
16
- abstract getPoolType(): PoolType;
17
15
  abstract isSupported(): Promise<boolean>;
18
- abstract subscribePoolChange(pool: T): Observable<T>;
19
- withOverride(override?: PoolTokenOverride[]): Promise<void>;
20
- getPoolsMem(): Promise<T[]>;
16
+ abstract getPoolFees(pair: PoolPair, address: string): Promise<PoolFees>;
17
+ abstract getPoolType(): PoolType;
18
+ protected abstract loadPools(): Promise<T[]>;
19
+ protected abstract subscribeUpdates(): Subscription;
20
+ private getMemPools;
21
21
  getPools(): Promise<T[]>;
22
- getSubscriber(): Observable<T>;
23
- private subscribe;
24
- private subscribePoolBalance;
22
+ getSubscriber(): Observable<T[]>;
23
+ private subscribeStore;
24
+ protected subscribeBalances(): Subscription;
25
25
  private hasSystemAsset;
26
26
  private hasErc20Asset;
27
27
  private hasValidAssets;
28
- private updatePool;
28
+ private updateBalances;
29
29
  }
@@ -1,22 +1,27 @@
1
1
  import { PolkadotClient } from 'polkadot-api';
2
2
  import { Papi } from '../api';
3
3
  import { EvmClient } from '../evm';
4
- import { IPoolCtxProvider, PoolBase, PoolFees, PoolFilter, PoolTokenOverride } from './types';
4
+ import { AavePoolClient } from './aave';
5
+ import { LbpPoolClient } from './lbp';
6
+ import { OmniPoolClient } from './omni';
7
+ import { XykPoolClient } from './xyk';
8
+ import { StableSwapClient } from './stable';
9
+ import { IPoolCtxProvider, Pool, PoolBase, PoolFees, PoolPair, PoolTokenOverride } from './types';
5
10
  export declare class PoolContextProvider extends Papi implements IPoolCtxProvider {
6
11
  readonly evm: EvmClient;
7
- private readonly lbpClient;
8
- private readonly omniClient;
9
- private readonly stableClient;
10
- private readonly xykClient;
11
- private readonly aaveClient;
12
+ readonly aave: AavePoolClient;
13
+ readonly omnipool: OmniPoolClient;
14
+ readonly stableswap: StableSwapClient;
15
+ readonly xyk: XykPoolClient;
16
+ readonly lbp: LbpPoolClient;
12
17
  private readonly active;
13
- private readonly clients;
14
18
  private readonly pools;
15
- private lbpSub;
19
+ private readonly clients;
20
+ private aaveSub;
16
21
  private omniSub;
17
22
  private stableSub;
18
23
  private xykSub;
19
- private aaveSub;
24
+ private lbpSub;
20
25
  private isReady;
21
26
  private isDestroyed;
22
27
  constructor(client: PolkadotClient, evm: EvmClient);
@@ -27,7 +32,6 @@ export declare class PoolContextProvider extends Papi implements IPoolCtxProvide
27
32
  withAave(): this;
28
33
  withXyk(override?: PoolTokenOverride[]): this;
29
34
  destroy(): void;
30
- getPools(filter?: PoolFilter): Promise<PoolBase[]>;
31
- private getFilteredPools;
32
- getPoolFees(pool: PoolBase, feeAsset: number): Promise<PoolFees>;
35
+ getPools(): Promise<PoolBase[]>;
36
+ getPoolFees(poolPair: PoolPair, pool: Pool): Promise<PoolFees>;
33
37
  }
@@ -0,0 +1,20 @@
1
+ import { Observable } from 'rxjs';
2
+ import { PoolBase } from './types';
3
+ export declare class PoolStore<T extends PoolBase> {
4
+ private store$;
5
+ private updateQueue;
6
+ private changeset;
7
+ get pools(): readonly T[];
8
+ asObservable(): Observable<T[]>;
9
+ applyChangeset(state: T[]): T[];
10
+ set(next: T[]): void;
11
+ /**
12
+ * Apply a batched mutation to the store.
13
+ *
14
+ * Updates are applied one at a time in call order (internally queued).
15
+ *
16
+ * @param patch - update callback
17
+ */
18
+ update(patch: (state: readonly T[]) => T[] | Promise<T[]>): void;
19
+ destroy(): void;
20
+ }
@@ -1,14 +1,19 @@
1
- import { Observable } from 'rxjs';
1
+ import { Subscription } from 'rxjs';
2
2
  import { PoolBase, PoolFees, PoolType } from '../types';
3
3
  import { PoolClient } from '../PoolClient';
4
4
  export declare class AavePoolClient extends PoolClient<PoolBase> {
5
- loadPools(): Promise<PoolBase[]>;
6
- private getPoolDelta;
7
- private getPoolId;
8
- private getPoolLimits;
9
- getPoolFees(_pool: PoolBase, _feeAsset: number): Promise<PoolFees>;
10
5
  getPoolType(): PoolType;
11
6
  isSupported(): Promise<boolean>;
12
- subscribePoolChange(pool: PoolBase): Observable<PoolBase>;
7
+ private getPoolId;
8
+ private getPoolLimits;
9
+ loadPools(): Promise<PoolBase[]>;
10
+ private getPoolDelta;
11
+ getPoolFees(): Promise<PoolFees>;
13
12
  private getReserveH160Id;
13
+ private parseRouterLog;
14
+ private parseEvmLog;
15
+ private subscribeRouterExecuted;
16
+ private subscribeEvmLog;
17
+ protected subscribeBalances(): Subscription;
18
+ protected subscribeUpdates(): Subscription;
14
19
  }
@@ -0,0 +1,13 @@
1
+ import { HydrationEvents } from '@galacticcouncil/descriptors';
2
+ export type TEvmPayload = HydrationEvents['EVM']['Log'];
3
+ export type TEvmEvent = {
4
+ eventName: string;
5
+ reserve: string;
6
+ key: string;
7
+ };
8
+ export type TRouterExecutedPayload = HydrationEvents['Router']['Executed'];
9
+ export type TRouterEvent = {
10
+ assetIn: number;
11
+ assetOut: number;
12
+ key: string;
13
+ };
@@ -1,18 +1,20 @@
1
- import { type Observable } from 'rxjs';
2
- import { PoolType, PoolFees } from '../types';
1
+ import { Subscription } from 'rxjs';
2
+ import { PoolType, PoolFees, PoolPair } from '../types';
3
3
  import { PoolClient } from '../PoolClient';
4
4
  import { LbpPoolBase } from './LbpPool';
5
5
  export declare class LbpPoolClient extends PoolClient<LbpPoolBase> {
6
6
  private readonly MAX_FINAL_WEIGHT;
7
7
  private poolsData;
8
+ getPoolType(): PoolType;
9
+ private getPoolLimits;
10
+ private getPoolWeights;
11
+ isSupported(): Promise<boolean>;
8
12
  protected loadPools(): Promise<LbpPoolBase[]>;
9
13
  private getPoolDelta;
10
14
  private isActivePool;
11
15
  private isRepayFeeApplied;
12
16
  private getRepayFee;
13
- private getPoolLimits;
14
- getPoolFees(pool: LbpPoolBase): Promise<PoolFees>;
15
- getPoolType(): PoolType;
16
- isSupported(): Promise<boolean>;
17
- subscribePoolChange(pool: LbpPoolBase): Observable<LbpPoolBase>;
17
+ getPoolFees(_pair: PoolPair, address: string): Promise<PoolFees>;
18
+ private subscribeValidationData;
19
+ protected subscribeUpdates(): Subscription;
18
20
  }
@@ -9,10 +9,12 @@ export declare class OmniMath {
9
9
  static calculateLiquidityOut(assetReserve: string, assetHubReserve: string, assetShares: string, positionAmount: string, positionShares: string, positionPrice: string, sharesToRemove: string, withdrawalFee: string): string;
10
10
  static calculateLiquidityLRNAOut(assetReserve: string, assetHubReserve: string, assetShares: string, positionAmount: string, positionShares: string, positionPrice: string, sharesToRemove: string, withdrawalFee: string): string;
11
11
  static calculateCapDifference(assetReserve: string, assetHubReserve: string, assetCap: string, totalHubReserve: string): string;
12
- static verifyAssetCap(assetReserve: string, assetCap: string, hubAdded: string, totalHubReserve: string): boolean;
13
12
  static calculateLimitHubIn(assetReserve: string, assetHubReserve: string, assetShares: string, amountIn: string): string;
14
13
  static isSellAllowed(bits: number): boolean;
15
14
  static isBuyAllowed(bits: number): boolean;
16
15
  static isAddLiquidityAllowed(bits: number): boolean;
17
16
  static isRemoveLiquidityAllowed(bits: number): boolean;
17
+ static recalculateAssetFee(oracleAmountIn: string, oracleAmountOut: string, oracleLiquidity: string, oraclePeriod: string, currentAssetLiquidity: string, previousFee: string, blocDifference: string, minFee: string, maxFee: string, decay: string, amplification: string): string;
18
+ static recalculateProtocolFee(oracleAmountIn: string, oracleAmountOut: string, oracleLiquidity: string, oraclePeriod: string, currentAssetLiquidity: string, previousFee: string, blocDifference: string, minFee: string, maxFee: string, decay: string, amplification: string): string;
19
+ static verifyAssetCap(assetReserve: string, assetCap: string, hubAdded: string, totalHubReserve: string): boolean;
18
20
  }
@@ -1,13 +1,27 @@
1
- import { type Observable } from 'rxjs';
2
- import { PoolType, PoolFees } from '../types';
1
+ import { Subscription } from 'rxjs';
3
2
  import { PoolClient } from '../PoolClient';
4
- import { OmniPoolBase } from './OmniPool';
3
+ import { PoolType, PoolPair } from '../types';
4
+ import { OmniPoolBase, OmniPoolFees } from './OmniPool';
5
5
  export declare class OmniPoolClient extends PoolClient<OmniPoolBase> {
6
- protected loadPools(): Promise<OmniPoolBase[]>;
6
+ private queryBus;
7
+ private block;
8
+ private dynamicFeesConfig;
9
+ private dynamicFees;
10
+ private emaOracles;
11
+ getPoolType(): PoolType;
7
12
  private getPoolAddress;
13
+ private getOraclePair;
8
14
  private getPoolLimits;
9
- getPoolFees(_pool: OmniPoolBase, feeAsset: number): Promise<PoolFees>;
10
- getPoolType(): PoolType;
11
15
  isSupported(): Promise<boolean>;
12
- subscribePoolChange(pool: OmniPoolBase): Observable<OmniPoolBase>;
16
+ protected loadPools(): Promise<OmniPoolBase[]>;
17
+ getPoolFees(pair: PoolPair): Promise<OmniPoolFees>;
18
+ private getAssetFee;
19
+ private getProtocolFee;
20
+ private subscribeEmaOracles;
21
+ private subscribeDynamicFees;
22
+ private subscribeDynamicFeesConfig;
23
+ private subscribeBlock;
24
+ private subscribeAssets;
25
+ protected subscribeUpdates(): Subscription;
26
+ private updateTokenState;
13
27
  }
@@ -0,0 +1,10 @@
1
+ import { FixedSizeArray } from 'polkadot-api';
2
+ import { HydrationConstants, HydrationQueries } from '@galacticcouncil/descriptors';
3
+ export type TDynamicFees = HydrationQueries['DynamicFees']['AssetFee']['Value'];
4
+ export type TDynamicFeesConfig = HydrationQueries['DynamicFees']['AssetFeeConfiguration']['Value'];
5
+ export type TDynamicFeeRange = [number, number, number];
6
+ export type TAssetFeeParams = HydrationConstants['DynamicFees']['AssetFeeParameters'];
7
+ export type TProtocolFeeParams = HydrationConstants['DynamicFees']['ProtocolFeeParameters'];
8
+ export type TEmaOracle = HydrationQueries['EmaOracle']['Oracles']['Value'];
9
+ export type TEmaPair = FixedSizeArray<2, number>;
10
+ export type TOmnipoolAsset = HydrationQueries['Omnipool']['Assets']['Value'];
@@ -1,4 +1,4 @@
1
- import { BuyCtx, Pool, PoolBase, PoolFee, PoolFees, PoolPair, PoolToken, PoolType, SellCtx } from '../types';
1
+ import { BuyCtx, Pool, PoolBase, PoolFee, PoolFees, PoolPair, PoolPegs, PoolToken, PoolType, SellCtx } from '../types';
2
2
  export type StableSwapPair = PoolPair & {
3
3
  tradeableIn: number;
4
4
  tradeableOut: number;
@@ -8,11 +8,11 @@ export type StableSwapFees = PoolFees & {
8
8
  };
9
9
  export type StableSwapBase = PoolBase & {
10
10
  amplification: bigint;
11
+ isRampPeriod: boolean;
11
12
  id: number;
12
13
  fee: PoolFee;
13
14
  totalIssuance: bigint;
14
- pegs: string[][];
15
- pegsFee: PoolFee;
15
+ pegs: PoolPegs;
16
16
  };
17
17
  export declare class StableSwap implements Pool {
18
18
  type: PoolType;
@@ -22,11 +22,13 @@ export declare class StableSwap implements Pool {
22
22
  maxOutRatio: bigint;
23
23
  minTradingLimit: bigint;
24
24
  amplification: bigint;
25
+ isRampPeriod: boolean;
25
26
  id: number;
26
27
  fee: PoolFee;
27
28
  totalIssuance: bigint;
29
+ pegs: string[][];
28
30
  static fromPool(pool: StableSwapBase): StableSwap;
29
- constructor(address: string, tokens: PoolToken[], maxInRation: bigint, maxOutRatio: bigint, minTradeLimit: bigint, amplification: bigint, id: number, fee: PoolFee, totalIssuance: bigint);
31
+ constructor(address: string, tokens: PoolToken[], maxInRation: bigint, maxOutRatio: bigint, minTradeLimit: bigint, amplification: bigint, isRampPeriod: boolean, id: number, fee: PoolFee, totalIssuance: bigint, pegs: PoolPegs);
30
32
  validatePair(_tokenIn: number, _tokenOut: number): boolean;
31
33
  parsePair(tokenIn: number, tokenOut: number): StableSwapPair;
32
34
  validateAndBuy(poolPair: StableSwapPair, amountOut: bigint, fees: StableSwapFees): BuyCtx;
@@ -1,20 +1,23 @@
1
- import { type Observable } from 'rxjs';
2
- import { PoolType, PoolFees } from '../types';
1
+ import { Subscription } from 'rxjs';
2
+ import { PoolType, PoolFees, PoolPair } from '../types';
3
3
  import { PoolClient } from '../PoolClient';
4
4
  import { StableSwapBase } from './StableSwap';
5
+ import { TStableswap } from './types';
5
6
  export declare class StableSwapClient extends PoolClient<StableSwapBase> {
6
- private poolsData;
7
+ protected poolsData: Map<number, TStableswap>;
7
8
  getPoolType(): PoolType;
8
9
  private getPoolAddress;
9
10
  private getPoolLimits;
10
- private getPoolDelta;
11
+ private getPoolAmplification;
11
12
  private getPoolTokens;
12
13
  isSupported(): Promise<boolean>;
13
14
  protected loadPools(): Promise<StableSwapBase[]>;
14
- getPoolFees(pool: StableSwapBase): Promise<PoolFees>;
15
- private getPoolPegs;
15
+ getPoolFees(_pair: PoolPair, address: string): Promise<PoolFees>;
16
16
  private getDefaultPegs;
17
17
  private getRecentPegs;
18
- private getLatestPegs;
19
- subscribePoolChange(pool: StableSwapBase): Observable<StableSwapBase>;
18
+ private subscribeIssuance;
19
+ private subscribePoolPegs;
20
+ private subscribeBlock;
21
+ protected subscribeUpdates(): Subscription;
22
+ private hasOnRamps;
20
23
  }
@@ -0,0 +1,15 @@
1
+ import { Enum, FixedSizeArray, FixedSizeBinary } from 'polkadot-api';
2
+ import { HydrationQueries } from '@galacticcouncil/descriptors';
3
+ export type TStableswap = HydrationQueries['Stableswap']['Pools']['Value'];
4
+ export type TStableswapPeg = HydrationQueries['Stableswap']['PoolPegs']['Value'];
5
+ export type TEmaOracle = HydrationQueries['EmaOracle']['Oracles']['Value'];
6
+ export type TEmaName = FixedSizeBinary<8>;
7
+ export type TEmaPair = FixedSizeArray<2, number>;
8
+ export type TEmaPeriod = Enum<{
9
+ LastBlock: undefined;
10
+ Short: undefined;
11
+ TenMinutes: undefined;
12
+ Hour: undefined;
13
+ Day: undefined;
14
+ Week: undefined;
15
+ }>;
@@ -36,6 +36,7 @@ export type PoolBase = {
36
36
  maxOutRatio: bigint;
37
37
  minTradingLimit: bigint;
38
38
  };
39
+ export type PoolPegs = string[][];
39
40
  export interface PoolToken {
40
41
  id: number;
41
42
  balance: bigint;
@@ -76,8 +77,8 @@ export interface Pool extends PoolBase {
76
77
  spotPriceOutGivenIn(poolPair: PoolPair): bigint;
77
78
  }
78
79
  export interface IPoolCtxProvider {
79
- getPools(filter?: PoolFilter): Promise<PoolBase[]>;
80
- getPoolFees(pool: PoolBase, feeAsset: number): Promise<PoolFees>;
80
+ getPools(): Promise<PoolBase[]>;
81
+ getPoolFees(poolPair: PoolPair, pool: Pool): Promise<PoolFees>;
81
82
  }
82
83
  export type Hop = {
83
84
  pool: PoolType;
@@ -1,12 +1,14 @@
1
- import { type Observable } from 'rxjs';
2
- import { PoolBase, PoolType, PoolFees } from '../types';
1
+ import { Subscription } from 'rxjs';
2
+ import { PoolBase, PoolType, PoolFees, PoolTokenOverride } from '../types';
3
3
  import { PoolClient } from '../PoolClient';
4
4
  export declare class XykPoolClient extends PoolClient<PoolBase> {
5
- protected loadPools(): Promise<PoolBase[]>;
6
- private getExchangeFee;
7
- private getPoolLimits;
8
- getPoolFees(): Promise<PoolFees>;
5
+ private decimals;
9
6
  getPoolType(): PoolType;
7
+ withOverride(override?: PoolTokenOverride[]): Promise<void>;
8
+ private getPoolLimits;
10
9
  isSupported(): Promise<boolean>;
11
- subscribePoolChange(pool: PoolBase): Observable<PoolBase>;
10
+ loadPools(): Promise<PoolBase[]>;
11
+ getPoolFees(): Promise<PoolFees>;
12
+ private getExchangeFee;
13
+ protected subscribeUpdates(): Subscription;
12
14
  }
@@ -1,12 +1,23 @@
1
1
  import { Hop, IPoolCtxProvider, Pool, PoolBase, PoolFilter } from '../pool';
2
- export type RouterOptions = PoolFilter;
3
2
  export declare class Router {
4
3
  private readonly routeSuggester;
5
4
  private readonly routeProposals;
6
- private readonly routerOptions;
7
5
  protected readonly ctx: IPoolCtxProvider;
8
- constructor(ctx: IPoolCtxProvider, routerOptions?: RouterOptions);
6
+ private filter;
7
+ constructor(ctx: IPoolCtxProvider);
8
+ withFilter(filter?: PoolFilter): Promise<void>;
9
9
  protected buildRouteKey(assetIn: number, assetOut: number, pools: PoolBase[]): string;
10
+ /**
11
+ * Filter pools given the following contraints:
12
+ *
13
+ * 1) Exclusions always win
14
+ * 2) If useOnly is specified, allow only those types
15
+ * 3) Otherwise everything not excluded passes
16
+ *
17
+ * @param pools - supported & active amms
18
+ * @returns filtered pools
19
+ */
20
+ protected applyPoolFilter(pools: PoolBase[]): PoolBase[];
10
21
  /**
11
22
  * List trading pools
12
23
  */
@@ -1,11 +1,11 @@
1
- import { Router, RouterOptions } from './Router';
1
+ import { Router } from './Router';
2
2
  import { Trade } from './types';
3
3
  import { Hop, IPoolCtxProvider } from '../pool';
4
4
  import { Amount } from '../types';
5
5
  export declare class TradeRouter extends Router {
6
6
  private readonly mlr;
7
7
  private poolsSnapshot?;
8
- constructor(ctx: IPoolCtxProvider, routerOptions?: RouterOptions);
8
+ constructor(ctx: IPoolCtxProvider);
9
9
  private buildCtxSync;
10
10
  private withCtx;
11
11
  /**
@@ -16,10 +16,10 @@ export declare class TradeRouter extends Router {
16
16
  */
17
17
  private isDirectTrade;
18
18
  /**
19
- * Find the best sell swap without errors
19
+ * Find the best sell route
20
20
  *
21
- * @param {SellSwap[]} swaps - all possible sell routes
22
- * @returns best sell swap if exist, otherwise first one found
21
+ * @param {SellSwap[]} swaps - sell routes
22
+ * @returns the most beneficial route without errors, if exist
23
23
  */
24
24
  private findBestSellRoute;
25
25
  /**
@@ -48,9 +48,9 @@ export declare class TradeRouter extends Router {
48
48
  */
49
49
  getBestSell(assetIn: number, assetOut: number, amountIn: bigint | string): Promise<Trade>;
50
50
  /**
51
- * Calculate and return sell spot price for assetIn>assetOut
51
+ * Calculate and return sell spot price for assetIn > assetOut
52
52
  *
53
- * @param route - best possible trade route (sell)
53
+ * @param route - sell route
54
54
  * @returns sell spot price
55
55
  */
56
56
  private getSellSpot;
@@ -61,9 +61,18 @@ export declare class TradeRouter extends Router {
61
61
  * @param {number} assetOut - asset out
62
62
  * @param {bigint | string} amountIn - amount of assetIn to sell for assetOut
63
63
  * @param {Hop[]} route - explicit route to use for trade
64
- * @returns sell trade of given asset pair
64
+ * @returns sell trade breakdown of given asset pair
65
65
  */
66
66
  getSell(assetIn: number, assetOut: number, amountIn: bigint | string, route?: Hop[]): Promise<Trade>;
67
+ /**
68
+ * Calculate and return all possible sells for assetIn > assetOut
69
+ *
70
+ * @param {number} assetIn - asset in
71
+ * @param {number} assetOut - asset out
72
+ * @param {bigint | string} amountIn - amount of assetIn to sell for assetOut
73
+ * @returns possible sell trades of given asset pair
74
+ */
75
+ getSells(assetIn: number, assetOut: number, amountIn: bigint | string): Promise<Trade[]>;
67
76
  /**
68
77
  * Build sell trade
69
78
  *
@@ -117,14 +126,14 @@ export declare class TradeRouter extends Router {
117
126
  *
118
127
  * @param {number} assetIn - asset in
119
128
  * @param {number} assetOut - asset out
120
- * @return best possible spot price of given asset pair, or undefined if trade not supported
129
+ * @return spot price of given asset pair, or undefined if trade not supported
121
130
  */
122
- getSpotPrice(assetIn: number, assetOut: number): Promise<Amount>;
131
+ getSpotPrice(assetIn: number, assetOut: number): Promise<Amount | undefined>;
123
132
  /**
124
- * Find best buy route without errors, if there is none return first one found
133
+ * Find best buy route
125
134
  *
126
135
  * @param swaps - buy routes
127
- * @returns best buy route if exist, otherwise first one found
136
+ * @returns the most beneficial route without errors, if exist
128
137
  */
129
138
  private findBestBuyRoute;
130
139
  /**
@@ -137,9 +146,9 @@ export declare class TradeRouter extends Router {
137
146
  */
138
147
  getBestBuy(assetIn: number, assetOut: number, amountOut: bigint | string): Promise<Trade>;
139
148
  /**
140
- * Calculate and return buy spot price for assetIn>assetOut
149
+ * Calculate and return buy spot price for assetIn > assetOut
141
150
  *
142
- * @param route - best possible trade route (buy)
151
+ * @param route - buy route
143
152
  * @returns buy spot price
144
153
  */
145
154
  private getBuySpot;
@@ -150,9 +159,18 @@ export declare class TradeRouter extends Router {
150
159
  * @param {number} assetOut - asset out
151
160
  * @param {bigint | string} amountOut - amount of assetOut to buy for assetIn
152
161
  * @param {Hop[]} route - explicit route to use for trade
153
- * @returns buy trade of given asset pair
162
+ * @returns buy trade breakdown of given asset pair
154
163
  */
155
164
  getBuy(assetIn: number, assetOut: number, amountOut: bigint | string, route?: Hop[]): Promise<Trade>;
165
+ /**
166
+ * Calculate and return all possible buy trades for assetIn > assetOut
167
+ *
168
+ * @param {number} assetIn - asset in
169
+ * @param {number} assetOut - asset out
170
+ * @param {bigint | string} amountOut - amount of assetOut to buy for assetIn
171
+ * @returns possible buy trades of given asset pair
172
+ */
173
+ getBuys(assetIn: number, assetOut: number, amountOut: bigint | string): Promise<Trade[]>;
156
174
  /**
157
175
  * Build buy trade
158
176
  *