@galacticcouncil/sdk-next 1.0.0-beta.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.
Files changed (54) hide show
  1. package/README.md +141 -0
  2. package/build/index.cjs +1 -0
  3. package/build/index.mjs +1 -0
  4. package/build/types/api/Papi.d.ts +375 -0
  5. package/build/types/api/client.d.ts +2 -0
  6. package/build/types/api/index.d.ts +2 -0
  7. package/build/types/client/AssetClient.d.ts +24 -0
  8. package/build/types/client/BalanceClient.d.ts +17 -0
  9. package/build/types/client/index.d.ts +2 -0
  10. package/build/types/consts.d.ts +8 -0
  11. package/build/types/errors.d.ts +10 -0
  12. package/build/types/index.d.ts +8 -0
  13. package/build/types/pool/PoolClient.d.ts +25 -0
  14. package/build/types/pool/PoolContextProvider.d.ts +26 -0
  15. package/build/types/pool/PoolFactory.d.ts +4 -0
  16. package/build/types/pool/index.d.ts +7 -0
  17. package/build/types/pool/lbp/LbpMath.d.ts +7 -0
  18. package/build/types/pool/lbp/LbpPool.d.ts +49 -0
  19. package/build/types/pool/lbp/LbpPoolClient.d.ts +18 -0
  20. package/build/types/pool/lbp/index.d.ts +3 -0
  21. package/build/types/pool/omni/OmniMath.d.ts +19 -0
  22. package/build/types/pool/omni/OmniPool.d.ts +45 -0
  23. package/build/types/pool/omni/OmniPoolClient.d.ts +13 -0
  24. package/build/types/pool/omni/index.d.ts +3 -0
  25. package/build/types/pool/stable/StableMath.d.ts +14 -0
  26. package/build/types/pool/stable/StableSwap.d.ts +46 -0
  27. package/build/types/pool/stable/StableSwapClient.d.ts +16 -0
  28. package/build/types/pool/stable/index.d.ts +3 -0
  29. package/build/types/pool/types.d.ts +84 -0
  30. package/build/types/pool/xyk/XykMath.d.ts +12 -0
  31. package/build/types/pool/xyk/XykPool.d.ts +23 -0
  32. package/build/types/pool/xyk/XykPoolClient.d.ts +12 -0
  33. package/build/types/pool/xyk/index.d.ts +3 -0
  34. package/build/types/sor/Router.d.ts +66 -0
  35. package/build/types/sor/TradeRouter.d.ts +155 -0
  36. package/build/types/sor/TradeUtils.d.ts +12 -0
  37. package/build/types/sor/index.d.ts +4 -0
  38. package/build/types/sor/route/bfs.d.ts +37 -0
  39. package/build/types/sor/route/graph.d.ts +12 -0
  40. package/build/types/sor/route/index.d.ts +3 -0
  41. package/build/types/sor/route/suggester.d.ts +24 -0
  42. package/build/types/sor/types.d.ts +31 -0
  43. package/build/types/types.d.ts +40 -0
  44. package/build/types/utils/Queue.d.ts +13 -0
  45. package/build/types/utils/Stack.d.ts +15 -0
  46. package/build/types/utils/big.d.ts +3 -0
  47. package/build/types/utils/evm.d.ts +3 -0
  48. package/build/types/utils/format.d.ts +4 -0
  49. package/build/types/utils/index.d.ts +6 -0
  50. package/build/types/utils/json.d.ts +3 -0
  51. package/build/types/utils/math.d.ts +62 -0
  52. package/build/types/utils/traversal/bfs.d.ts +27 -0
  53. package/build/types/utils/xc.d.ts +1 -0
  54. package/package.json +53 -0
@@ -0,0 +1,375 @@
1
+ import { PolkadotClient } from 'polkadot-api';
2
+ export declare abstract class Papi {
3
+ readonly client: PolkadotClient;
4
+ constructor(client: PolkadotClient);
5
+ get api(): import("polkadot-api").TypedApi<{
6
+ descriptors: {
7
+ pallets: {
8
+ __storage: {
9
+ System: {
10
+ Account: import("polkadot-api").StorageDescriptor<[Key: import("polkadot-api").SS58String], {
11
+ nonce: number;
12
+ consumers: number;
13
+ providers: number;
14
+ sufficients: number;
15
+ data: {
16
+ free: bigint;
17
+ reserved: bigint;
18
+ frozen: bigint;
19
+ flags: bigint;
20
+ };
21
+ }, false, never>;
22
+ Number: import("polkadot-api").StorageDescriptor<[], number, false, never>;
23
+ };
24
+ AssetRegistry: {
25
+ Assets: import("polkadot-api").StorageDescriptor<[Key: number], {
26
+ symbol: import("polkadot-api").Binary | undefined;
27
+ decimals: number | undefined;
28
+ name: import("polkadot-api").Binary | undefined;
29
+ asset_type: import("polkadot-api").Enum<{
30
+ Token: undefined;
31
+ XYK: undefined;
32
+ StableSwap: undefined;
33
+ Bond: undefined;
34
+ External: undefined;
35
+ Erc20: undefined;
36
+ }>;
37
+ existential_deposit: bigint;
38
+ xcm_rate_limit: bigint | undefined;
39
+ is_sufficient: boolean;
40
+ }, true, never>;
41
+ AssetLocations: import("polkadot-api").StorageDescriptor<[Key: number], {
42
+ parents: number;
43
+ interior: import("@galacticcouncil/descriptors").XcmV3Junctions;
44
+ }, true, never>;
45
+ };
46
+ Omnipool: {
47
+ Assets: import("polkadot-api").StorageDescriptor<[Key: number], {
48
+ shares: bigint;
49
+ hub_reserve: bigint;
50
+ protocol_shares: bigint;
51
+ cap: bigint;
52
+ tradable: number;
53
+ }, true, never>;
54
+ HubAssetTradability: import("polkadot-api").StorageDescriptor<[], number, false, never>;
55
+ };
56
+ DynamicFees: {
57
+ AssetFee: import("polkadot-api").StorageDescriptor<[Key: number], {
58
+ asset_fee: number;
59
+ protocol_fee: number;
60
+ timestamp: number;
61
+ }, true, never>;
62
+ };
63
+ Stableswap: {
64
+ Pools: import("polkadot-api").StorageDescriptor<[Key: number], {
65
+ assets: number[];
66
+ initial_amplification: number;
67
+ final_amplification: number;
68
+ initial_block: number;
69
+ final_block: number;
70
+ fee: number;
71
+ }, true, never>;
72
+ AssetTradability: import("polkadot-api").StorageDescriptor<import("polkadot-api").FixedSizeArray<2, number>, number, false, never>;
73
+ };
74
+ Bonds: {
75
+ Bonds: import("polkadot-api").StorageDescriptor<[Key: number], [number, bigint], true, never>;
76
+ };
77
+ LBP: {
78
+ PoolData: import("polkadot-api").StorageDescriptor<[Key: import("polkadot-api").SS58String], {
79
+ assets: import("polkadot-api").FixedSizeArray<2, number>;
80
+ fee: import("polkadot-api").FixedSizeArray<2, number>;
81
+ owner: import("polkadot-api").SS58String;
82
+ start: number | undefined;
83
+ end: number | undefined;
84
+ initial_weight: number;
85
+ final_weight: number;
86
+ weight_curve: {
87
+ type: "Linear";
88
+ value: undefined;
89
+ };
90
+ fee_collector: import("polkadot-api").SS58String;
91
+ repay_target: bigint;
92
+ }, true, never>;
93
+ };
94
+ XYK: {
95
+ PoolAssets: import("polkadot-api").StorageDescriptor<[Key: import("polkadot-api").SS58String], import("polkadot-api").FixedSizeArray<2, number>, true, never>;
96
+ };
97
+ Tokens: {
98
+ TotalIssuance: import("polkadot-api").StorageDescriptor<[Key: number], bigint, false, never>;
99
+ Accounts: import("polkadot-api").StorageDescriptor<[import("polkadot-api").SS58String, number], {
100
+ free: bigint;
101
+ frozen: bigint;
102
+ reserved: bigint;
103
+ }, false, never>;
104
+ };
105
+ ParachainSystem: {
106
+ ValidationData: import("polkadot-api").StorageDescriptor<[], {
107
+ parent_head: import("polkadot-api").Binary;
108
+ relay_parent_number: number;
109
+ relay_parent_storage_root: import("polkadot-api").FixedSizeBinary<32>;
110
+ max_pov_size: number;
111
+ }, true, never>;
112
+ };
113
+ };
114
+ __tx: {
115
+ Omnipool: {
116
+ sell: import("polkadot-api").TxDescriptor<{
117
+ amount: bigint;
118
+ asset_out: number;
119
+ asset_in: number;
120
+ min_buy_amount: bigint;
121
+ }>;
122
+ buy: import("polkadot-api").TxDescriptor<{
123
+ amount: bigint;
124
+ asset_out: number;
125
+ asset_in: number;
126
+ max_sell_amount: bigint;
127
+ }>;
128
+ };
129
+ Router: {
130
+ sell: import("polkadot-api").TxDescriptor<{
131
+ asset_out: number;
132
+ asset_in: number;
133
+ route: {
134
+ pool: import("polkadot-api").Enum<{
135
+ "XYK": undefined;
136
+ "LBP": undefined;
137
+ "Stableswap": number;
138
+ "Omnipool": undefined;
139
+ "Aave": undefined;
140
+ }>;
141
+ asset_in: number;
142
+ asset_out: number;
143
+ }[];
144
+ amount_in: bigint;
145
+ min_amount_out: bigint;
146
+ }>;
147
+ buy: import("polkadot-api").TxDescriptor<{
148
+ asset_out: number;
149
+ asset_in: number;
150
+ amount_out: bigint;
151
+ max_amount_in: bigint;
152
+ route: {
153
+ pool: import("polkadot-api").Enum<{
154
+ "XYK": undefined;
155
+ "LBP": undefined;
156
+ "Stableswap": number;
157
+ "Omnipool": undefined;
158
+ "Aave": undefined;
159
+ }>;
160
+ asset_in: number;
161
+ asset_out: number;
162
+ }[];
163
+ }>;
164
+ sell_all: import("polkadot-api").TxDescriptor<{
165
+ asset_out: number;
166
+ asset_in: number;
167
+ route: {
168
+ pool: import("polkadot-api").Enum<{
169
+ "XYK": undefined;
170
+ "LBP": undefined;
171
+ "Stableswap": number;
172
+ "Omnipool": undefined;
173
+ "Aave": undefined;
174
+ }>;
175
+ asset_in: number;
176
+ asset_out: number;
177
+ }[];
178
+ min_amount_out: bigint;
179
+ }>;
180
+ };
181
+ };
182
+ __event: {
183
+ EVM: {
184
+ Log: import("polkadot-api").PlainDescriptor<{
185
+ log: {
186
+ address: import("polkadot-api").FixedSizeBinary<20>;
187
+ topics: import("polkadot-api").FixedSizeBinary<32>[];
188
+ data: import("polkadot-api").Binary;
189
+ };
190
+ }>;
191
+ };
192
+ };
193
+ __error: {};
194
+ __const: {
195
+ System: {
196
+ BlockWeights: import("polkadot-api").PlainDescriptor<{
197
+ base_block: {
198
+ ref_time: bigint;
199
+ proof_size: bigint;
200
+ };
201
+ max_block: {
202
+ ref_time: bigint;
203
+ proof_size: bigint;
204
+ };
205
+ per_class: {
206
+ normal: {
207
+ "base_extrinsic": {
208
+ ref_time: bigint;
209
+ proof_size: bigint;
210
+ };
211
+ "max_extrinsic"?: ({
212
+ ref_time: bigint;
213
+ proof_size: bigint;
214
+ }) | undefined;
215
+ "max_total"?: ({
216
+ ref_time: bigint;
217
+ proof_size: bigint;
218
+ }) | undefined;
219
+ "reserved"?: ({
220
+ ref_time: bigint;
221
+ proof_size: bigint;
222
+ }) | undefined;
223
+ };
224
+ operational: {
225
+ "base_extrinsic": {
226
+ ref_time: bigint;
227
+ proof_size: bigint;
228
+ };
229
+ "max_extrinsic"?: ({
230
+ ref_time: bigint;
231
+ proof_size: bigint;
232
+ }) | undefined;
233
+ "max_total"?: ({
234
+ ref_time: bigint;
235
+ proof_size: bigint;
236
+ }) | undefined;
237
+ "reserved"?: ({
238
+ ref_time: bigint;
239
+ proof_size: bigint;
240
+ }) | undefined;
241
+ };
242
+ mandatory: {
243
+ "base_extrinsic": {
244
+ ref_time: bigint;
245
+ proof_size: bigint;
246
+ };
247
+ "max_extrinsic"?: ({
248
+ ref_time: bigint;
249
+ proof_size: bigint;
250
+ }) | undefined;
251
+ "max_total"?: ({
252
+ ref_time: bigint;
253
+ proof_size: bigint;
254
+ }) | undefined;
255
+ "reserved"?: ({
256
+ ref_time: bigint;
257
+ proof_size: bigint;
258
+ }) | undefined;
259
+ };
260
+ };
261
+ }>;
262
+ BlockLength: import("polkadot-api").PlainDescriptor<{
263
+ normal: number;
264
+ operational: number;
265
+ mandatory: number;
266
+ }>;
267
+ BlockHashCount: import("polkadot-api").PlainDescriptor<number>;
268
+ DbWeight: import("polkadot-api").PlainDescriptor<{
269
+ read: bigint;
270
+ write: bigint;
271
+ }>;
272
+ Version: import("polkadot-api").PlainDescriptor<{
273
+ apis: [import("polkadot-api").FixedSizeBinary<8>, number][];
274
+ spec_name: string;
275
+ impl_name: string;
276
+ authoring_version: number;
277
+ spec_version: number;
278
+ impl_version: number;
279
+ transaction_version: number;
280
+ state_version: number;
281
+ }>;
282
+ SS58Prefix: import("polkadot-api").PlainDescriptor<number>;
283
+ };
284
+ Omnipool: {
285
+ HdxAssetId: import("polkadot-api").PlainDescriptor<number>;
286
+ HubAssetId: import("polkadot-api").PlainDescriptor<number>;
287
+ MinWithdrawalFee: import("polkadot-api").PlainDescriptor<number>;
288
+ MinimumTradingLimit: import("polkadot-api").PlainDescriptor<bigint>;
289
+ MinimumPoolLiquidity: import("polkadot-api").PlainDescriptor<bigint>;
290
+ MaxInRatio: import("polkadot-api").PlainDescriptor<bigint>;
291
+ MaxOutRatio: import("polkadot-api").PlainDescriptor<bigint>;
292
+ NFTCollectionId: import("polkadot-api").PlainDescriptor<bigint>;
293
+ BurnProtocolFee: import("polkadot-api").PlainDescriptor<number>;
294
+ };
295
+ DynamicFees: {
296
+ AssetFeeParameters: import("polkadot-api").PlainDescriptor<{
297
+ min_fee: number;
298
+ max_fee: number;
299
+ decay: bigint;
300
+ amplification: bigint;
301
+ }>;
302
+ ProtocolFeeParameters: import("polkadot-api").PlainDescriptor<{
303
+ min_fee: number;
304
+ max_fee: number;
305
+ decay: bigint;
306
+ amplification: bigint;
307
+ }>;
308
+ };
309
+ Stableswap: {
310
+ MinPoolLiquidity: import("polkadot-api").PlainDescriptor<bigint>;
311
+ MinTradingLimit: import("polkadot-api").PlainDescriptor<bigint>;
312
+ AmplificationRange: import("polkadot-api").PlainDescriptor<{
313
+ start: number;
314
+ end: number;
315
+ }>;
316
+ };
317
+ LBP: {
318
+ MinTradingLimit: import("polkadot-api").PlainDescriptor<bigint>;
319
+ MinPoolLiquidity: import("polkadot-api").PlainDescriptor<bigint>;
320
+ MaxInRatio: import("polkadot-api").PlainDescriptor<bigint>;
321
+ MaxOutRatio: import("polkadot-api").PlainDescriptor<bigint>;
322
+ repay_fee: import("polkadot-api").PlainDescriptor<import("polkadot-api").FixedSizeArray<2, number>>;
323
+ };
324
+ XYK: {
325
+ NativeAssetId: import("polkadot-api").PlainDescriptor<number>;
326
+ GetExchangeFee: import("polkadot-api").PlainDescriptor<import("polkadot-api").FixedSizeArray<2, number>>;
327
+ MinTradingLimit: import("polkadot-api").PlainDescriptor<bigint>;
328
+ MinPoolLiquidity: import("polkadot-api").PlainDescriptor<bigint>;
329
+ MaxInRatio: import("polkadot-api").PlainDescriptor<bigint>;
330
+ MaxOutRatio: import("polkadot-api").PlainDescriptor<bigint>;
331
+ OracleSource: import("polkadot-api").PlainDescriptor<import("polkadot-api").FixedSizeBinary<8>>;
332
+ };
333
+ };
334
+ };
335
+ apis: {
336
+ CurrenciesApi: {
337
+ account: import("polkadot-api").RuntimeDescriptor<[asset_id: number, who: import("polkadot-api").SS58String], {
338
+ free: bigint;
339
+ frozen: bigint;
340
+ reserved: bigint;
341
+ }>;
342
+ accounts: import("polkadot-api").RuntimeDescriptor<[who: import("polkadot-api").SS58String], [number, {
343
+ free: bigint;
344
+ frozen: bigint;
345
+ reserved: bigint;
346
+ }][]>;
347
+ free_balance: import("polkadot-api").RuntimeDescriptor<[asset_id: number, who: import("polkadot-api").SS58String], bigint>;
348
+ };
349
+ AaveTradeExecutor: {
350
+ pairs: import("polkadot-api").RuntimeDescriptor<[], import("polkadot-api").FixedSizeArray<2, number>[]>;
351
+ liquidity_depth: import("polkadot-api").RuntimeDescriptor<[asset_in: number, asset_out: number], bigint | undefined>;
352
+ pool: import("polkadot-api").RuntimeDescriptor<[reserve: number, atoken: number], {
353
+ reserve: number;
354
+ atoken: number;
355
+ liqudity_in: bigint;
356
+ liqudity_out: bigint;
357
+ }>;
358
+ pools: import("polkadot-api").RuntimeDescriptor<[], {
359
+ reserve: number;
360
+ atoken: number;
361
+ liqudity_in: bigint;
362
+ liqudity_out: bigint;
363
+ }[]>;
364
+ };
365
+ };
366
+ } & Promise<any>;
367
+ metadataTypes: Promise<Uint8Array>;
368
+ asset: {
369
+ _type?: void | undefined;
370
+ };
371
+ getMetadata: () => Promise<Uint8Array>;
372
+ genesis: string | undefined;
373
+ }>;
374
+ logSync(who: string, action: string, payload: any): void;
375
+ }
@@ -0,0 +1,2 @@
1
+ import { PolkadotClient } from 'polkadot-api';
2
+ export declare const getWs: (wsUrl: string | string[]) => Promise<PolkadotClient>;
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ export * from './Papi';
@@ -0,0 +1,24 @@
1
+ import { PolkadotClient } from 'polkadot-api';
2
+ import { HydrationQueries } from '@galacticcouncil/descriptors';
3
+ import { Papi } from '../api';
4
+ import { Asset, ExternalAsset } from '../types';
5
+ type TStableswapPool = HydrationQueries['Stableswap']['Pools']['Value'];
6
+ type TBond = HydrationQueries['Bonds']['Bonds']['Value'];
7
+ type TAssetDetails = HydrationQueries['AssetRegistry']['Assets']['Value'];
8
+ type TAssetLocation = HydrationQueries['AssetRegistry']['AssetLocations']['Value'];
9
+ export declare class AssetClient extends Papi {
10
+ private SUPPORTED_TYPES;
11
+ constructor(client: PolkadotClient);
12
+ queryShares(): Promise<Map<number, TStableswapPool>>;
13
+ queryBonds(): Promise<Map<number, TBond>>;
14
+ queryAssets(): Promise<Map<number, TAssetDetails>>;
15
+ queryAssetLocations(): Promise<Map<number, TAssetLocation>>;
16
+ private mapToken;
17
+ private mapBond;
18
+ private mapShares;
19
+ private mapExternal;
20
+ private parseMetadata;
21
+ getOnChainAssets(includeInvalid?: boolean, external?: ExternalAsset[]): Promise<Asset[]>;
22
+ private isValidAsset;
23
+ }
24
+ export {};
@@ -0,0 +1,17 @@
1
+ import { PolkadotClient } from 'polkadot-api';
2
+ import { type Observable } from 'rxjs';
3
+ import { Papi } from '../api';
4
+ import { AssetAmount } from '../types';
5
+ export declare class BalanceClient extends Papi {
6
+ constructor(client: PolkadotClient);
7
+ getBalance(account: string, assetId: number): Promise<bigint>;
8
+ getSystemBalance(account: string): Promise<bigint>;
9
+ getTokenBalance(account: string, assetId: number): Promise<bigint>;
10
+ getErc20Balance(account: string, assetId: number): Promise<bigint>;
11
+ subscribeBalance(address: string): Observable<AssetAmount[]>;
12
+ subscribeSystemBalance(address: string): Observable<AssetAmount>;
13
+ subscribeTokenBalance(address: string, assetId: number): Observable<AssetAmount>;
14
+ subscribeTokensBalance(address: string): Observable<AssetAmount[]>;
15
+ subscribeErc20Balance(address: string, includeOnly?: number[]): Observable<AssetAmount[]>;
16
+ private getTokenBalanceData;
17
+ }
@@ -0,0 +1,2 @@
1
+ export { AssetClient } from './AssetClient';
2
+ export { BalanceClient } from './BalanceClient';
@@ -0,0 +1,8 @@
1
+ export declare const RUNTIME_DECIMALS = 18;
2
+ export declare const SYSTEM_ASSET_ID = 0;
3
+ export declare const SYSTEM_ASSET_DECIMALS = 12;
4
+ export declare const HYDRATION_PARACHAIN_ID = 2034;
5
+ export declare const HYDRATION_SS58_PREFIX = 63;
6
+ export declare const HYDRATION_OMNIPOOL_ADDRESS = "7L53bUTBbfuj14UpdCNPwmgzzHSsrsTWBHX5pys32mVWM3C1";
7
+ export declare const HUB_ASSET_ID = 1;
8
+ export declare const TRADEABLE_DEFAULT = 15;
@@ -0,0 +1,10 @@
1
+ import { PoolType } from './pool';
2
+ export declare class AssetNotFound extends Error {
3
+ constructor(asset: number);
4
+ }
5
+ export declare class PoolNotFound extends Error {
6
+ constructor(poolType: PoolType);
7
+ }
8
+ export declare class RouteNotFound extends Error {
9
+ constructor(assetIn: number, assetOut: number);
10
+ }
@@ -0,0 +1,8 @@
1
+ export * as api from './api';
2
+ export * as client from './client';
3
+ export * as const from './consts';
4
+ export * as error from './errors';
5
+ export * as pool from './pool';
6
+ export * as sor from './sor';
7
+ export * from './types';
8
+ export * from './utils';
@@ -0,0 +1,25 @@
1
+ import { PolkadotClient } from 'polkadot-api';
2
+ import { type Observable } from 'rxjs';
3
+ import { BalanceClient } from '../client';
4
+ import { PoolBase, PoolFees, PoolTokenOverride, PoolType } from './types';
5
+ export declare abstract class PoolClient<T extends PoolBase> extends BalanceClient {
6
+ private override;
7
+ private mem;
8
+ private memPools;
9
+ constructor(client: PolkadotClient);
10
+ protected abstract loadPools(): Promise<T[]>;
11
+ abstract getPoolFees(pool: T, feeAsset: number): Promise<PoolFees>;
12
+ abstract getPoolType(): PoolType;
13
+ abstract isSupported(): Promise<boolean>;
14
+ abstract subscribePoolChange(pool: T): Observable<T>;
15
+ withOverride(override?: PoolTokenOverride[]): Promise<void>;
16
+ getPoolsMem(): Promise<T[]>;
17
+ getPools(): Promise<T[]>;
18
+ getSubscriber(): Observable<T>;
19
+ private subscribe;
20
+ private subscribePoolBalance;
21
+ private hasSystemAsset;
22
+ private hasErc20Asset;
23
+ private hasValidAssets;
24
+ private updatePool;
25
+ }
@@ -0,0 +1,26 @@
1
+ import { PolkadotClient } from 'polkadot-api';
2
+ import { Papi } from '../api';
3
+ import { IPoolCtxProvider, PoolBase, PoolFees, PoolTokenOverride } from './types';
4
+ export declare class PoolContextProvider extends Papi implements IPoolCtxProvider {
5
+ private readonly lbpClient;
6
+ private readonly omniClient;
7
+ private readonly stableClient;
8
+ private readonly xykClient;
9
+ private readonly active;
10
+ private readonly clients;
11
+ private readonly pools;
12
+ private lbpSub;
13
+ private omniSub;
14
+ private stableSub;
15
+ private xykSub;
16
+ private isReady;
17
+ private isDestroyed;
18
+ constructor(client: PolkadotClient);
19
+ withOmnipool(): this;
20
+ withStableswap(): this;
21
+ withLbp(): this;
22
+ withXyk(override?: PoolTokenOverride[]): this;
23
+ destroy(): void;
24
+ getPools(): Promise<PoolBase[]>;
25
+ getPoolFees(pool: PoolBase, feeAsset: number): Promise<PoolFees>;
26
+ }
@@ -0,0 +1,4 @@
1
+ import { Pool, PoolBase } from './types';
2
+ export declare class PoolFactory {
3
+ static get(pool: PoolBase): Pool;
4
+ }
@@ -0,0 +1,7 @@
1
+ export { PoolFactory } from './PoolFactory';
2
+ export { PoolContextProvider } from './PoolContextProvider';
3
+ export * as xyk from './xyk';
4
+ export * as omni from './omni';
5
+ export * as lbp from './lbp';
6
+ export * as stable from './stable';
7
+ export * from './types';
@@ -0,0 +1,7 @@
1
+ export declare class LbpMath {
2
+ static getSpotPrice(balanceA: string, balanceB: string, weightA: string, weightB: string, amount: string): string;
3
+ static calculateInGivenOut(balanceIn: string, balanceOut: string, weightIn: string, weightOut: string, amountOut: string): string;
4
+ static calculateOutGivenIn(balanceIn: string, balanceOut: string, weightIn: string, weightOut: string, amountIn: string): string;
5
+ static calculateLinearWeights(start: string, end: string, initialWeight: string, finalWeight: string, at: string): string;
6
+ static calculatePoolTradeFee(amount: string, feeNumerator: number, feeDenominator: number): string;
7
+ }
@@ -0,0 +1,49 @@
1
+ import { BuyCtx, Pool, PoolBase, PoolFee, PoolFees, PoolPair, PoolToken, PoolType, SellCtx } from '../types';
2
+ export type WeightedPoolPair = PoolPair & {
3
+ weightIn: bigint;
4
+ weightOut: bigint;
5
+ };
6
+ export type WeightedPoolToken = PoolToken & {
7
+ weight: bigint;
8
+ };
9
+ export type LbpPoolFees = PoolFees & {
10
+ exchangeFee: PoolFee;
11
+ repayFee: PoolFee;
12
+ };
13
+ export type LbpPoolBase = PoolBase & {
14
+ fee: PoolFee;
15
+ repayFeeApply: boolean;
16
+ };
17
+ export declare class LbpPool implements Pool {
18
+ type: PoolType;
19
+ address: string;
20
+ tokens: WeightedPoolToken[];
21
+ maxInRatio: bigint;
22
+ maxOutRatio: bigint;
23
+ minTradingLimit: bigint;
24
+ fee: PoolFee;
25
+ repayFeeApply: boolean;
26
+ static fromPool(pool: LbpPoolBase): LbpPool;
27
+ constructor(address: string, tokens: WeightedPoolToken[], maxInRatio: bigint, maxOutRatio: bigint, minTradingLimit: bigint, fee: PoolFee, repayFeeApply: boolean);
28
+ validatePair(_tokenIn: number, _tokenOut: number): boolean;
29
+ parsePair(tokenIn: number, tokenOut: number): WeightedPoolPair;
30
+ /**
31
+ * Validate buy transfer
32
+ *
33
+ * a) Accumulated asset is bought (out) from the pool for distributed asset (in) - User(Buyer) bears the fee
34
+ * b) Distributed asset is bought (out) from the pool for accumualted asset (in) - Pool bears the fee
35
+ */
36
+ validateAndBuy(poolPair: WeightedPoolPair, amountOut: bigint, fees: LbpPoolFees): BuyCtx;
37
+ /**
38
+ * Validate sell transfer
39
+ *
40
+ * a) Accumulated asset is sold (in) to the pool for distributed asset (out) - Pool bears the fee
41
+ * b) Distributed asset is sold (in) to the pool for accumualted asset (out) - User(Seller) bears the fee
42
+ */
43
+ validateAndSell(poolPair: WeightedPoolPair, amountIn: bigint, fees: LbpPoolFees): SellCtx;
44
+ calculateInGivenOut(poolPair: WeightedPoolPair, amountOut: bigint): bigint;
45
+ calculateOutGivenIn(poolPair: WeightedPoolPair, amountIn: bigint): bigint;
46
+ spotPriceInGivenOut(poolPair: WeightedPoolPair): bigint;
47
+ spotPriceOutGivenIn(poolPair: WeightedPoolPair): bigint;
48
+ calculateTradeFee(amount: bigint, fees: LbpPoolFees): bigint;
49
+ }
@@ -0,0 +1,18 @@
1
+ import { type Observable } from 'rxjs';
2
+ import { PoolType, PoolFees } from '../types';
3
+ import { PoolClient } from '../PoolClient';
4
+ import { LbpPoolBase } from './LbpPool';
5
+ export declare class LbpPoolClient extends PoolClient<LbpPoolBase> {
6
+ private readonly MAX_FINAL_WEIGHT;
7
+ private poolsData;
8
+ protected loadPools(): Promise<LbpPoolBase[]>;
9
+ private getPoolDelta;
10
+ private isActivePool;
11
+ private isRepayFeeApplied;
12
+ private getRepayFee;
13
+ private getPoolLimits;
14
+ getPoolFees(pool: LbpPoolBase): Promise<PoolFees>;
15
+ getPoolType(): PoolType;
16
+ isSupported(): Promise<boolean>;
17
+ subscribePoolChange(pool: LbpPoolBase): Observable<LbpPoolBase>;
18
+ }
@@ -0,0 +1,3 @@
1
+ export * from './LbpMath';
2
+ export * from './LbpPool';
3
+ export * from './LbpPoolClient';
@@ -0,0 +1,19 @@
1
+ export declare class OmniMath {
2
+ static calculateSpotPrice(assetInBalance: string, assetInHubReserve: string, assetOutBalance: string, assetOutHubReserve: string): string;
3
+ static calculateLrnaSpotPrice(assetBalance: string, assetHubReserve: string): string;
4
+ static calculateInGivenOut(assetInBalance: string, assetInHubReserve: string, assetInShares: string, assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountOut: string, assetFee: string, protocolFee: string): string;
5
+ static calculateLrnaInGivenOut(assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountOut: string, assetFee: string): string;
6
+ static calculateOutGivenIn(assetInBalance: string, assetInHubReserve: string, assetInShares: string, assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountIn: string, assetFee: string, protocolFee: string): string;
7
+ static calculateOutGivenLrnaIn(assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountOut: string, assetFee: string): string;
8
+ static calculatePoolTradeFee(amount: string, feeNumerator: number, feeDenominator: number): string;
9
+ static calculateShares(assetReserve: string, assetHubReserve: string, assetShares: string, amountIn: string): string;
10
+ static calculateLiquidityOut(assetReserve: string, assetHubReserve: string, assetShares: string, positionAmount: string, positionShares: string, positionPrice: string, sharesToRemove: string, withdrawalFee: string): string;
11
+ static calculateLiquidityLRNAOut(assetReserve: string, assetHubReserve: string, assetShares: string, positionAmount: string, positionShares: string, positionPrice: string, sharesToRemove: string, withdrawalFee: string): string;
12
+ static calculateCapDifference(assetReserve: string, assetHubReserve: string, assetCap: string, totalHubReserve: string): string;
13
+ static verifyAssetCap(assetReserve: string, assetCap: string, hubAdded: string, totalHubReserve: string): boolean;
14
+ static calculateLimitHubIn(assetReserve: string, assetHubReserve: string, assetShares: string, amountIn: string): string;
15
+ static isSellAllowed(bits: number): boolean;
16
+ static isBuyAllowed(bits: number): boolean;
17
+ static isAddLiquidityAllowed(bits: number): boolean;
18
+ static isRemoveLiquidityAllowed(bits: number): boolean;
19
+ }