@galacticcouncil/sdk 0.0.2 → 0.0.4
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 +3 -4
- package/dist/index.esm.js +1 -3
- package/dist/index.js +1 -3
- package/dist/types/client/polkadotApi.d.ts +0 -10
- package/dist/types/consts.d.ts +6 -0
- package/dist/types/errors.d.ts +4 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/pool/index.d.ts +3 -0
- package/dist/types/pool/lbp/lbpMath.d.ts +7 -13
- package/dist/types/pool/lbp/lbpPolkadotApiClient.d.ts +3 -2
- package/dist/types/pool/omni/omniMath.d.ts +16 -11
- package/dist/types/pool/omni/omniPolkadotApiClient.d.ts +2 -1
- package/dist/types/pool/xyk/xykMath.d.ts +10 -11
- package/dist/types/pool/xyk/xykPolkadotApiClient.d.ts +2 -1
- package/dist/types/types.d.ts +1 -0
- package/package.json +5 -3
|
@@ -2,16 +2,8 @@ import { ApiPromise } from '@polkadot/api';
|
|
|
2
2
|
import type { StorageKey } from '@polkadot/types';
|
|
3
3
|
import type { AnyTuple, Codec } from '@polkadot/types/types';
|
|
4
4
|
import type { AssetMetadata } from '@polkadot/types/interfaces';
|
|
5
|
-
import type { Balance } from '@polkadot/types/interfaces/runtime';
|
|
6
|
-
import type { Struct } from '@polkadot/types-codec';
|
|
7
5
|
import type { PoolToken } from '../types';
|
|
8
6
|
import '@polkadot/api-augment';
|
|
9
|
-
interface AssetDetail extends Struct {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly assetType: string;
|
|
12
|
-
readonly existentialDeposit: Balance;
|
|
13
|
-
readonly locked: boolean;
|
|
14
|
-
}
|
|
15
7
|
export declare class PolkadotApiClient {
|
|
16
8
|
protected readonly api: ApiPromise;
|
|
17
9
|
constructor(api: ApiPromise);
|
|
@@ -20,9 +12,7 @@ export declare class PolkadotApiClient {
|
|
|
20
12
|
getPoolTokens(poolAddress: string, assetKeys: string[]): Promise<PoolToken[]>;
|
|
21
13
|
syncPoolTokens(poolAddress: string, poolTokens: PoolToken[]): Promise<PoolToken[]>;
|
|
22
14
|
getAssetMetadata(tokenKey: string): Promise<AssetMetadata>;
|
|
23
|
-
getAssetDetail(tokenKey: string): Promise<AssetDetail>;
|
|
24
15
|
getAccountBalance(accountId: string, tokenKey: string): Promise<string>;
|
|
25
16
|
getSystemAccountBalance(accountId: string): Promise<string>;
|
|
26
17
|
getTokenAccountBalance(accountId: string, tokenKey: string): Promise<string>;
|
|
27
18
|
}
|
|
28
|
-
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
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 HYDRADX_PARACHAIN_ID = 2034;
|
|
5
|
+
export declare const HYDRADX_SS58_PREFIX = 63;
|
|
6
|
+
export declare const DENOMINATOR = 1000;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { PolkadotApiPoolService } from './polkadotApiPoolService';
|
|
2
2
|
export { PoolFactory } from './poolFactory';
|
|
3
3
|
export { XykPool } from './xyk/xykPool';
|
|
4
|
+
export { XykMath } from './xyk/xykMath';
|
|
4
5
|
export { OmniPool } from './omni/omniPool';
|
|
6
|
+
export { OmniMath } from './omni/omniMath';
|
|
5
7
|
export { LbpPool } from './lbp/lbpPool';
|
|
8
|
+
export { LbpMath } from './lbp/lbpMath';
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
calculateInGivenOut: typeof calculateInGivenOut;
|
|
9
|
-
calculateOutGivenIn: typeof calculateOutGivenIn;
|
|
10
|
-
calculateLinearWeights: typeof calculateLinearWeights;
|
|
11
|
-
calculatePoolTradeFee: typeof calculatePoolTradeFee;
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PolkadotApiClient } from '../../client';
|
|
2
|
-
import { PoolBase, PoolFee } from '../../types';
|
|
2
|
+
import { PoolBase, PoolFee, PoolLimits } from '../../types';
|
|
3
3
|
interface LbpPoolData {
|
|
4
4
|
readonly assets: string[];
|
|
5
5
|
readonly feeCollector: string;
|
|
@@ -19,7 +19,8 @@ export declare class LbpPolkadotApiClient extends PolkadotApiClient {
|
|
|
19
19
|
loadPools(): Promise<PoolBase[]>;
|
|
20
20
|
syncPools(): Promise<PoolBase[]>;
|
|
21
21
|
getLinearWeight(poolEntry: LbpPoolData): Promise<string>;
|
|
22
|
-
getRepayFee(): PoolFee;
|
|
23
22
|
isRepayFeeApplied(assetKey: string, poolEntry: LbpPoolData): Promise<boolean>;
|
|
23
|
+
getRepayFee(): PoolFee;
|
|
24
|
+
getPoolLimits(): PoolLimits;
|
|
24
25
|
}
|
|
25
26
|
export {};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export declare class OmniMath {
|
|
2
|
+
static calculateSpotPrice(assetInBalance: string, assetInHubReserve: string, assetOutBalance: string, assetOutHubReserve: string): string;
|
|
3
|
+
static calculateInGivenOut(assetInBalance: string, assetInHubReserve: string, assetInShares: string, assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountOut: string, assetFee: string, protocolFee: string): string;
|
|
4
|
+
static calculateOutGivenIn(assetInBalance: string, assetInHubReserve: string, assetInShares: string, assetOutBalance: string, assetOutHubReserve: string, assetOutShares: string, amountIn: string, assetFee: string, protocolFee: string): string;
|
|
5
|
+
static calculatePoolTradeFee(amount: string, feeNumerator: number, feeDenominator: number): string;
|
|
6
|
+
static calculateShares(assetReserve: string, assetHubReserve: string, assetShares: string, amountIn: string): string;
|
|
7
|
+
static calculateLiquidityOut(assetReserve: string, assetHubReserve: string, assetShares: string, positionAmount: string, positionShares: string, positionPrice: string, sharesToRemove: string): string;
|
|
8
|
+
static calculateLiquidityLRNAOut(assetReserve: string, assetHubReserve: string, assetShares: string, positionAmount: string, positionShares: string, positionPrice: string, sharesToRemove: string): string;
|
|
9
|
+
static calculateCapDifference(assetReserve: string, assetHubReserve: string, assetCap: string, totalHubReserve: string): string;
|
|
10
|
+
static verifyAssetCap(assetReserve: string, assetCap: string, hubAdded: string, totalHubReserve: string): boolean;
|
|
11
|
+
static calculateLimitHubIn(assetReserve: string, assetHubReserve: string, assetShares: string, amountIn: string): string;
|
|
12
|
+
static isSellAllowed(bits: number): boolean;
|
|
13
|
+
static isBuyAllowed(bits: number): boolean;
|
|
14
|
+
static isAddLiquidityAllowed(bits: number): boolean;
|
|
15
|
+
static isRemoveLiquidityAllowed(bits: number): boolean;
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PolkadotApiClient } from '../../client';
|
|
2
|
-
import { PoolBase, PoolFee } from '../../types';
|
|
2
|
+
import { PoolBase, PoolFee, PoolLimits } from '../../types';
|
|
3
3
|
export declare class OmniPolkadotApiClient extends PolkadotApiClient {
|
|
4
4
|
private pools;
|
|
5
5
|
private _poolLoaded;
|
|
@@ -10,4 +10,5 @@ export declare class OmniPolkadotApiClient extends PolkadotApiClient {
|
|
|
10
10
|
getAssetFee(): PoolFee;
|
|
11
11
|
getProtocolFee(): PoolFee;
|
|
12
12
|
getPoolId(): string;
|
|
13
|
+
getPoolLimits(): PoolLimits;
|
|
13
14
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export default _default;
|
|
1
|
+
export declare class XykMath {
|
|
2
|
+
static getSpotPrice(balanceA: string, balanceB: string, amount: string): string;
|
|
3
|
+
static calculateInGivenOut(balanceIn: string, balanceOut: string, amountOut: string): string;
|
|
4
|
+
static calculateOutGivenIn(balanceIn: string, balanceOut: string, amountIn: string): string;
|
|
5
|
+
static calculatePoolTradeFee(amount: string, feeNumerator: number, feeDenominator: number): string;
|
|
6
|
+
static calculateLiquidityIn(reserveA: string, reserveB: string, amountA: string): string;
|
|
7
|
+
static calculateShares(reserveA: string, amountA: string, totalShares: string): string;
|
|
8
|
+
static calculateLiquidityOutAssetA(reserveA: string, reserveB: string, shares: string, totalShares: string): string;
|
|
9
|
+
static calculateLiquidityOutAssetB(reserveA: string, reserveB: string, shares: string, totalShares: string): string;
|
|
10
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PolkadotApiClient } from '../../client';
|
|
2
|
-
import { PoolBase, PoolFee } from '../../types';
|
|
2
|
+
import { PoolBase, PoolFee, PoolLimits } from '../../types';
|
|
3
3
|
export declare class XykPolkadotApiClient extends PolkadotApiClient {
|
|
4
4
|
private pools;
|
|
5
5
|
private _poolsLoaded;
|
|
@@ -7,4 +7,5 @@ export declare class XykPolkadotApiClient extends PolkadotApiClient {
|
|
|
7
7
|
loadPools(): Promise<PoolBase[]>;
|
|
8
8
|
syncPools(): Promise<PoolBase[]>;
|
|
9
9
|
getTradeFee(): PoolFee;
|
|
10
|
+
getPoolLimits(): PoolLimits;
|
|
10
11
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare type PoolBase = {
|
|
|
35
35
|
assetFee?: PoolFee;
|
|
36
36
|
protocolFee?: PoolFee;
|
|
37
37
|
};
|
|
38
|
+
export declare type PoolLimits = Pick<PoolBase, 'maxInRatio' | 'maxOutRatio' | 'minTradingLimit'>;
|
|
38
39
|
export declare type PoolFee = [numerator: number, denominator: number];
|
|
39
40
|
export declare type PoolToken = PoolAsset & {
|
|
40
41
|
balance: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacticcouncil/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Galactic SDK",
|
|
6
6
|
"author": "Pavol Noha <palo@hydradx.io>",
|
|
@@ -29,9 +29,11 @@
|
|
|
29
29
|
"@galacticcouncil/math-lbp": "^0.0.4",
|
|
30
30
|
"@galacticcouncil/math-omnipool": "^0.0.4",
|
|
31
31
|
"@galacticcouncil/math-xyk": "^0.0.4",
|
|
32
|
-
"@polkadot/api": "^9.9.1",
|
|
33
32
|
"bignumber.js": "^9.1.0",
|
|
34
|
-
"capi": "^0.1.0-beta.12",
|
|
35
33
|
"lodash.clonedeep": "^4.5.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@polkadot/api": "^9.9.1",
|
|
37
|
+
"capi": "^0.1.0-beta.12"
|
|
36
38
|
}
|
|
37
39
|
}
|