@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.
- package/README.md +1 -1
- package/dist/index.esm.js +3 -3
- package/dist/index.js +2 -2
- package/dist/types/client/PolkadotApi.d.ts +0 -1
- package/dist/types/consts.d.ts +1 -0
- package/dist/types/pool/lbp/LbpPool.d.ts +7 -6
- package/dist/types/pool/omni/OmniPool.d.ts +5 -7
- package/dist/types/pool/omni/OmniPoolClient.d.ts +0 -1
- package/dist/types/pool/xyk/XykPool.d.ts +10 -7
- package/dist/types/pool/xyk/XykPoolClient.d.ts +1 -1
- package/dist/types/types.d.ts +4 -6
- package/package.json +3 -4
package/dist/types/consts.d.ts
CHANGED
|
@@ -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,
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
}
|
|
@@ -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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
49
|
-
"capi": "^0.1.0-beta.12",
|
|
48
|
+
"@polkadot/api": "^10.9.1",
|
|
50
49
|
"ethers": "^6.0.5"
|
|
51
50
|
}
|
|
52
51
|
}
|