@galacticcouncil/sdk 0.2.2 → 0.4.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.
@@ -1,5 +1,4 @@
1
1
  import { ApiPromise } from '@polkadot/api';
2
- import '@polkadot/api-augment';
3
2
  import '@galacticcouncil/api-augment/hydradx';
4
3
  import '@galacticcouncil/api-augment/basilisk';
5
4
  export declare abstract class PolkadotApiClient {
@@ -3,4 +3,5 @@ export declare const SYSTEM_ASSET_ID = "0";
3
3
  export declare const SYSTEM_ASSET_DECIMALS = 12;
4
4
  export declare const HYDRADX_PARACHAIN_ID = 2034;
5
5
  export declare const HYDRADX_SS58_PREFIX = 63;
6
+ export declare const BASILISK_PARACHAIN_ID = 2090;
6
7
  export declare const DENOMINATOR = 1000;
@@ -8,37 +8,38 @@ export type WeightedPoolToken = PoolToken & {
8
8
  weight: BigNumber;
9
9
  };
10
10
  export type LbpPoolBase = PoolBase & {
11
+ fee: PoolFee;
11
12
  repayFee: PoolFee;
12
13
  repayFeeApply: boolean;
13
14
  };
14
15
  export declare class LbpPool implements Pool {
15
16
  type: PoolType;
16
17
  address: string;
17
- tradeFee: PoolFee;
18
18
  tokens: WeightedPoolToken[];
19
19
  maxInRatio: number;
20
20
  maxOutRatio: number;
21
21
  minTradingLimit: number;
22
+ fee: PoolFee;
22
23
  repayFee: PoolFee;
23
24
  repayFeeApply: boolean;
24
25
  static fromPool(pool: LbpPoolBase): LbpPool;
25
- constructor(address: string, swapFee: PoolFee, tokens: WeightedPoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number, repayFee: PoolFee, repayFeeApply: boolean);
26
- validPair(_tokenIn: string, _tokenOut: string): boolean;
27
- parsePoolPair(tokenIn: string, tokenOut: string): WeightedPoolPair;
26
+ constructor(address: string, tokens: WeightedPoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number, fee: PoolFee, repayFee: PoolFee, repayFeeApply: boolean);
27
+ validatePair(_tokenIn: string, _tokenOut: string): boolean;
28
+ parsePair(tokenIn: string, tokenOut: string): WeightedPoolPair;
28
29
  /**
29
30
  * Validate buy transfer
30
31
  *
31
32
  * a) Accumulated asset is bought (out) from the pool for distributed asset (in) - User(Buyer) bears the fee
32
33
  * b) Distributed asset is bought (out) from the pool for accumualted asset (in) - Pool bears the fee
33
34
  */
34
- validateBuy(poolPair: WeightedPoolPair, amountOut: BigNumber): BuyTransfer;
35
+ validateAndBuy(poolPair: WeightedPoolPair, amountOut: BigNumber): BuyTransfer;
35
36
  /**
36
37
  * Validate sell transfer
37
38
  *
38
39
  * a) Accumulated asset is sold (in) to the pool for distributed asset (out) - Pool bears the fee
39
40
  * b) Distributed asset is sold (in) to the pool for accumualted asset (out) - User(Seller) bears the fee
40
41
  */
41
- validateSell(poolPair: WeightedPoolPair, amountIn: BigNumber): SellTransfer;
42
+ validateAndSell(poolPair: WeightedPoolPair, amountIn: BigNumber): SellTransfer;
42
43
  calculateInGivenOut(poolPair: WeightedPoolPair, amountOut: BigNumber): BigNumber;
43
44
  calculateOutGivenIn(poolPair: WeightedPoolPair, amountIn: BigNumber): BigNumber;
44
45
  spotPriceInGivenOut(poolPair: WeightedPoolPair): BigNumber;
@@ -18,7 +18,6 @@ export type OmniPoolBase = PoolBase & {
18
18
  export declare class OmniPool implements Pool {
19
19
  type: PoolType;
20
20
  address: string;
21
- tradeFee: PoolFee;
22
21
  tokens: OmniPoolToken[];
23
22
  maxInRatio: number;
24
23
  maxOutRatio: number;
@@ -27,11 +26,11 @@ export declare class OmniPool implements Pool {
27
26
  protocolFee: PoolFee;
28
27
  hubAssetId: string;
29
28
  static fromPool(pool: OmniPoolBase): OmniPool;
30
- constructor(address: string, swapFee: PoolFee, tokens: OmniPoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number, assetFee: PoolFee, protocolFee: PoolFee, hubAssetId: string);
31
- validPair(_tokenIn: string, tokenOut: string): boolean;
32
- parsePoolPair(tokenIn: string, tokenOut: string): OmniPoolPair;
33
- validateBuy(poolPair: OmniPoolPair, amountOut: BigNumber): BuyTransfer;
34
- validateSell(poolPair: OmniPoolPair, amountIn: BigNumber): SellTransfer;
29
+ constructor(address: string, tokens: OmniPoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number, assetFee: PoolFee, protocolFee: PoolFee, hubAssetId: string);
30
+ validatePair(_tokenIn: string, tokenOut: string): boolean;
31
+ parsePair(tokenIn: string, tokenOut: string): OmniPoolPair;
32
+ validateAndBuy(poolPair: OmniPoolPair, amountOut: BigNumber): BuyTransfer;
33
+ validateAndSell(poolPair: OmniPoolPair, amountIn: BigNumber): SellTransfer;
35
34
  calculateInGivenOut(poolPair: OmniPoolPair, amountOut: BigNumber, applyFee: boolean): BigNumber;
36
35
  calculateLrnaInGivenOut(poolPair: OmniPoolPair, amountOut: BigNumber, applyFee: boolean): BigNumber;
37
36
  calculateOutGivenIn(poolPair: OmniPoolPair, amountIn: BigNumber, applyFee: boolean): BigNumber;
@@ -40,5 +39,4 @@ export declare class OmniPool implements Pool {
40
39
  spotPriceLrnaInGivenOut(poolPair: OmniPoolPair): BigNumber;
41
40
  spotPriceOutGivenIn(poolPair: OmniPoolPair): BigNumber;
42
41
  spotPriceOutGivenLrnaIn(poolPair: OmniPoolPair): BigNumber;
43
- calculateTradeFee(amount: BigNumber): BigNumber;
44
42
  }
@@ -7,7 +7,6 @@ export declare class OmniPoolClient extends PoolClient {
7
7
  private loadPool;
8
8
  private syncPool;
9
9
  private getPoolTokenState;
10
- getTradeFee(): PoolFee;
11
10
  getAssetFee(): PoolFee;
12
11
  getProtocolFee(): PoolFee;
13
12
  getPoolId(): string;
@@ -1,19 +1,22 @@
1
1
  import { BuyTransfer, Pool, PoolBase, PoolFee, PoolPair, PoolToken, PoolType, SellTransfer } from '../../types';
2
2
  import { BigNumber } from '../../utils/bignumber';
3
+ export type XykPoolBase = PoolBase & {
4
+ exchangeFee: PoolFee;
5
+ };
3
6
  export declare class XykPool implements Pool {
4
7
  type: PoolType;
5
8
  address: string;
6
- tradeFee: PoolFee;
7
9
  tokens: PoolToken[];
8
10
  maxInRatio: number;
9
11
  maxOutRatio: number;
10
12
  minTradingLimit: number;
11
- static fromPool(pool: PoolBase): XykPool;
12
- constructor(address: string, swapFee: PoolFee, tokens: PoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number);
13
- validPair(_tokenIn: string, _tokenOut: string): boolean;
14
- parsePoolPair(tokenIn: string, tokenOut: string): PoolPair;
15
- validateBuy(poolPair: PoolPair, amountOut: BigNumber): BuyTransfer;
16
- validateSell(poolPair: PoolPair, amountIn: BigNumber): SellTransfer;
13
+ exchangeFee: PoolFee;
14
+ static fromPool(pool: XykPoolBase): XykPool;
15
+ constructor(address: string, tokens: PoolToken[], maxInRation: number, maxOutRatio: number, minTradeLimit: number, exchangeFee: PoolFee);
16
+ validatePair(_tokenIn: string, _tokenOut: string): boolean;
17
+ parsePair(tokenIn: string, tokenOut: string): PoolPair;
18
+ validateAndBuy(poolPair: PoolPair, amountOut: BigNumber): BuyTransfer;
19
+ validateAndSell(poolPair: PoolPair, amountIn: BigNumber): SellTransfer;
17
20
  calculateInGivenOut(poolPair: PoolPair, amountOut: BigNumber): BigNumber;
18
21
  calculateOutGivenIn(poolPair: PoolPair, amountIn: BigNumber): BigNumber;
19
22
  spotPriceInGivenOut(poolPair: PoolPair): BigNumber;
@@ -6,6 +6,6 @@ export declare class XykPoolClient extends PoolClient {
6
6
  getPools(): Promise<PoolBase[]>;
7
7
  private loadPools;
8
8
  private syncPools;
9
- getTradeFee(): PoolFee;
9
+ getExchangeFee(): PoolFee;
10
10
  getPoolLimits(): PoolLimits;
11
11
  }
@@ -25,7 +25,6 @@ export interface PoolPair {
25
25
  export type PoolBase = {
26
26
  address: string;
27
27
  type: PoolType;
28
- tradeFee: PoolFee;
29
28
  tokens: PoolToken[];
30
29
  maxInRatio: number;
31
30
  maxOutRatio: number;
@@ -52,15 +51,14 @@ export type Transfer = {
52
51
  export type SellTransfer = Transfer & PoolSell;
53
52
  export type BuyTransfer = Transfer & PoolBuy;
54
53
  export interface Pool extends PoolBase {
55
- validPair(tokenIn: string, tokenOut: string): boolean;
56
- parsePoolPair(tokenIn: string, tokenOut: string): PoolPair;
57
- validateBuy(poolPair: PoolPair, amountOut: BigNumber): BuyTransfer;
58
- validateSell(poolPair: PoolPair, amountOut: BigNumber): SellTransfer;
54
+ validatePair(tokenIn: string, tokenOut: string): boolean;
55
+ parsePair(tokenIn: string, tokenOut: string): PoolPair;
56
+ validateAndBuy(poolPair: PoolPair, amountOut: BigNumber): BuyTransfer;
57
+ validateAndSell(poolPair: PoolPair, amountOut: BigNumber): SellTransfer;
59
58
  calculateInGivenOut(poolPair: PoolPair, amountOut: BigNumber, applyFee: boolean): BigNumber;
60
59
  calculateOutGivenIn(poolPair: PoolPair, amountIn: BigNumber, applyFee: boolean): BigNumber;
61
60
  spotPriceInGivenOut(poolPair: PoolPair): BigNumber;
62
61
  spotPriceOutGivenIn(poolPair: PoolPair): BigNumber;
63
- calculateTradeFee(amount: BigNumber): BigNumber;
64
62
  }
65
63
  export interface IPoolService {
66
64
  getPools(includeOnly?: PoolType[]): Promise<PoolBase[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacticcouncil/sdk",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "description": "Galactic SDK",
6
6
  "author": "Pavol Noha <palo@hydradx.io>",
@@ -23,7 +23,7 @@
23
23
  }
24
24
  },
25
25
  "devDependencies": {
26
- "@galacticcouncil/api-augment": "^0.0.2",
26
+ "@galacticcouncil/api-augment": "^0.0.4",
27
27
  "@types/jest": "^28.1.8",
28
28
  "es-jest": "^2.0.0",
29
29
  "esbuild": "^0.14.53",
@@ -45,8 +45,7 @@
45
45
  "lodash.clonedeep": "^4.5.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@polkadot/api": "^9.14.2",
49
- "capi": "^0.1.0-beta.12",
48
+ "@polkadot/api": "^10.9.1",
50
49
  "ethers": "^6.0.5"
51
50
  }
52
51
  }