@galacticcouncil/sdk-next 0.6.0-pr194-1c1c0d6 → 0.6.1-pr196-4dadb83

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.
@@ -0,0 +1,89 @@
1
+ import { BalanceClient } from '../client/BalanceClient';
2
+ import { LiquidityMiningClient } from './LiquidityMiningClient';
3
+ export declare class LiquidityMiningApi {
4
+ private readonly client;
5
+ private readonly balanceClient;
6
+ protected omnipoolAssetIds: string[];
7
+ constructor(client: LiquidityMiningClient, balanceClient: BalanceClient);
8
+ getOraclePrice(rewardCurrency: number, incentivizedAsset: number): Promise<bigint | undefined>;
9
+ private getFarmAddress;
10
+ private getGlobalRewardPerPeriod;
11
+ private getPoolYieldPerPeriod;
12
+ private farmData;
13
+ getAllOmnipoolFarms(): Promise<({
14
+ apr: string;
15
+ minApr: string | undefined;
16
+ isDistributed: boolean;
17
+ estimatedEndPeriod: string;
18
+ maxRewards: bigint;
19
+ incentivizedAsset: number;
20
+ rewardCurrency: number;
21
+ loyaltyCurve: {
22
+ initial_reward_percentage: bigint;
23
+ scale_coef: number;
24
+ } | undefined;
25
+ currentPeriod: string;
26
+ potMaxRewards: bigint;
27
+ fullness: string;
28
+ yieldFarmId: number;
29
+ globalFarmId: number;
30
+ poolId: string;
31
+ } | undefined)[][]>;
32
+ getOmnipoolFarms(id: string): Promise<({
33
+ apr: string;
34
+ minApr: string | undefined;
35
+ isDistributed: boolean;
36
+ estimatedEndPeriod: string;
37
+ maxRewards: bigint;
38
+ incentivizedAsset: number;
39
+ rewardCurrency: number;
40
+ loyaltyCurve: {
41
+ initial_reward_percentage: bigint;
42
+ scale_coef: number;
43
+ } | undefined;
44
+ currentPeriod: string;
45
+ potMaxRewards: bigint;
46
+ fullness: string;
47
+ yieldFarmId: number;
48
+ globalFarmId: number;
49
+ poolId: string;
50
+ } | undefined)[]>;
51
+ getAllIsolatedFarms(): Promise<({
52
+ apr: string;
53
+ minApr: string | undefined;
54
+ isDistributed: boolean;
55
+ estimatedEndPeriod: string;
56
+ maxRewards: bigint;
57
+ incentivizedAsset: number;
58
+ rewardCurrency: number;
59
+ loyaltyCurve: {
60
+ initial_reward_percentage: bigint;
61
+ scale_coef: number;
62
+ } | undefined;
63
+ currentPeriod: string;
64
+ potMaxRewards: bigint;
65
+ fullness: string;
66
+ yieldFarmId: number;
67
+ globalFarmId: number;
68
+ poolId: string;
69
+ } | undefined)[][]>;
70
+ getIsolatedFarms(id: string): Promise<({
71
+ apr: string;
72
+ minApr: string | undefined;
73
+ isDistributed: boolean;
74
+ estimatedEndPeriod: string;
75
+ maxRewards: bigint;
76
+ incentivizedAsset: number;
77
+ rewardCurrency: number;
78
+ loyaltyCurve: {
79
+ initial_reward_percentage: bigint;
80
+ scale_coef: number;
81
+ } | undefined;
82
+ currentPeriod: string;
83
+ potMaxRewards: bigint;
84
+ fullness: string;
85
+ yieldFarmId: number;
86
+ globalFarmId: number;
87
+ poolId: string;
88
+ } | undefined)[]>;
89
+ }
@@ -0,0 +1,130 @@
1
+ import { Papi } from '../api';
2
+ import { Enum } from 'polkadot-api';
3
+ export declare class LiquidityMiningClient extends Papi {
4
+ protected omnipoolAssetIds: string[];
5
+ getOraclePrice(orderedAssets: [number, number]): Promise<[{
6
+ price: {
7
+ n: bigint;
8
+ d: bigint;
9
+ };
10
+ volume: {
11
+ a_in: bigint;
12
+ b_out: bigint;
13
+ a_out: bigint;
14
+ b_in: bigint;
15
+ };
16
+ liquidity: {
17
+ a: bigint;
18
+ b: bigint;
19
+ };
20
+ shares_issuance: bigint | undefined;
21
+ updated_at: number;
22
+ }, number] | undefined>;
23
+ getRelayBlockNumber(): Promise<number | undefined>;
24
+ getAllOmnipooFarms(): Promise<{
25
+ keyArgs: [number, number];
26
+ value: number;
27
+ }[]>;
28
+ getOmnipooFarms(id: number): Promise<{
29
+ keyArgs: [number, number];
30
+ value: number;
31
+ }[]>;
32
+ getOmnipoolGlobalFarm(id: number): Promise<{
33
+ id: number;
34
+ owner: import("polkadot-api").SS58String;
35
+ updated_at: number;
36
+ total_shares_z: bigint;
37
+ accumulated_rpz: bigint;
38
+ reward_currency: number;
39
+ pending_rewards: bigint;
40
+ accumulated_paid_rewards: bigint;
41
+ yield_per_period: bigint;
42
+ planned_yielding_periods: number;
43
+ blocks_per_period: number;
44
+ incentivized_asset: number;
45
+ max_reward_per_period: bigint;
46
+ min_deposit: bigint;
47
+ live_yield_farms_count: number;
48
+ total_yield_farms_count: number;
49
+ price_adjustment: bigint;
50
+ state: Enum<{
51
+ Active: undefined;
52
+ Stopped: undefined;
53
+ Terminated: undefined;
54
+ }>;
55
+ } | undefined>;
56
+ getOmnipoolYieldFarm(id: number, globalFarmId: number, yieldFarmId: number): Promise<{
57
+ id: number;
58
+ updated_at: number;
59
+ accumulated_rpz: bigint;
60
+ state: Enum<{
61
+ Active: undefined;
62
+ Stopped: undefined;
63
+ Terminated: undefined;
64
+ }>;
65
+ total_shares: bigint;
66
+ total_valued_shares: bigint;
67
+ accumulated_rpvs: bigint;
68
+ loyalty_curve: {
69
+ initial_reward_percentage: bigint;
70
+ scale_coef: number;
71
+ } | undefined;
72
+ multiplier: bigint;
73
+ entries_count: bigint;
74
+ left_to_distribute: bigint;
75
+ total_stopped: number;
76
+ } | undefined>;
77
+ getAllIsolatedFarms(): Promise<{
78
+ keyArgs: [import("polkadot-api").SS58String, number];
79
+ value: number;
80
+ }[]>;
81
+ getIsolatedFarms(id: string): Promise<{
82
+ keyArgs: [import("polkadot-api").SS58String, number];
83
+ value: number;
84
+ }[]>;
85
+ getIsolatedGlobalFarm(id: number): Promise<{
86
+ id: number;
87
+ owner: import("polkadot-api").SS58String;
88
+ updated_at: number;
89
+ total_shares_z: bigint;
90
+ accumulated_rpz: bigint;
91
+ reward_currency: number;
92
+ pending_rewards: bigint;
93
+ accumulated_paid_rewards: bigint;
94
+ yield_per_period: bigint;
95
+ planned_yielding_periods: number;
96
+ blocks_per_period: number;
97
+ incentivized_asset: number;
98
+ max_reward_per_period: bigint;
99
+ min_deposit: bigint;
100
+ live_yield_farms_count: number;
101
+ total_yield_farms_count: number;
102
+ price_adjustment: bigint;
103
+ state: Enum<{
104
+ Active: undefined;
105
+ Stopped: undefined;
106
+ Terminated: undefined;
107
+ }>;
108
+ } | undefined>;
109
+ getIsolatedYieldFarm(id: string, globalFarmId: number, yieldFarmId: number): Promise<{
110
+ id: number;
111
+ updated_at: number;
112
+ accumulated_rpz: bigint;
113
+ state: Enum<{
114
+ Active: undefined;
115
+ Stopped: undefined;
116
+ Terminated: undefined;
117
+ }>;
118
+ total_shares: bigint;
119
+ total_valued_shares: bigint;
120
+ accumulated_rpvs: bigint;
121
+ loyalty_curve: {
122
+ initial_reward_percentage: bigint;
123
+ scale_coef: number;
124
+ } | undefined;
125
+ multiplier: bigint;
126
+ entries_count: bigint;
127
+ left_to_distribute: bigint;
128
+ total_stopped: number;
129
+ } | undefined>;
130
+ }
@@ -0,0 +1,2 @@
1
+ export * from './LiquidityMiningApi';
2
+ export * from './LiquidityMiningClient';
@@ -0,0 +1,7 @@
1
+ import { EvmClient } from '../evm';
2
+ import { MmOracleEntry } from './types';
3
+ export declare class MmOracleClient {
4
+ private client;
5
+ constructor(evm: EvmClient);
6
+ getData(address: string, blockTimeInSec?: number): Promise<MmOracleEntry>;
7
+ }
@@ -0,0 +1,87 @@
1
+ export declare const AGGREGATOR_V3_ABI: readonly [{
2
+ readonly inputs: readonly [];
3
+ readonly name: "decimals";
4
+ readonly outputs: readonly [{
5
+ readonly internalType: "uint8";
6
+ readonly name: "";
7
+ readonly type: "uint8";
8
+ }];
9
+ readonly stateMutability: "view";
10
+ readonly type: "function";
11
+ }, {
12
+ readonly inputs: readonly [];
13
+ readonly name: "description";
14
+ readonly outputs: readonly [{
15
+ readonly internalType: "string";
16
+ readonly name: "";
17
+ readonly type: "string";
18
+ }];
19
+ readonly stateMutability: "view";
20
+ readonly type: "function";
21
+ }, {
22
+ readonly inputs: readonly [];
23
+ readonly name: "version";
24
+ readonly outputs: readonly [{
25
+ readonly internalType: "uint256";
26
+ readonly name: "";
27
+ readonly type: "uint256";
28
+ }];
29
+ readonly stateMutability: "view";
30
+ readonly type: "function";
31
+ }, {
32
+ readonly inputs: readonly [{
33
+ readonly internalType: "uint80";
34
+ readonly name: "_roundId";
35
+ readonly type: "uint80";
36
+ }];
37
+ readonly name: "getRoundData";
38
+ readonly outputs: readonly [{
39
+ readonly internalType: "uint80";
40
+ readonly name: "roundId";
41
+ readonly type: "uint80";
42
+ }, {
43
+ readonly internalType: "int256";
44
+ readonly name: "answer";
45
+ readonly type: "int256";
46
+ }, {
47
+ readonly internalType: "uint256";
48
+ readonly name: "startedAt";
49
+ readonly type: "uint256";
50
+ }, {
51
+ readonly internalType: "uint256";
52
+ readonly name: "updatedAt";
53
+ readonly type: "uint256";
54
+ }, {
55
+ readonly internalType: "uint80";
56
+ readonly name: "answeredInRound";
57
+ readonly type: "uint80";
58
+ }];
59
+ readonly stateMutability: "view";
60
+ readonly type: "function";
61
+ }, {
62
+ readonly inputs: readonly [];
63
+ readonly name: "latestRoundData";
64
+ readonly outputs: readonly [{
65
+ readonly internalType: "uint80";
66
+ readonly name: "roundId";
67
+ readonly type: "uint80";
68
+ }, {
69
+ readonly internalType: "int256";
70
+ readonly name: "answer";
71
+ readonly type: "int256";
72
+ }, {
73
+ readonly internalType: "uint256";
74
+ readonly name: "startedAt";
75
+ readonly type: "uint256";
76
+ }, {
77
+ readonly internalType: "uint256";
78
+ readonly name: "updatedAt";
79
+ readonly type: "uint256";
80
+ }, {
81
+ readonly internalType: "uint80";
82
+ readonly name: "answeredInRound";
83
+ readonly type: "uint80";
84
+ }];
85
+ readonly stateMutability: "view";
86
+ readonly type: "function";
87
+ }];
@@ -0,0 +1,2 @@
1
+ export { MmOracleClient } from './MmOracleClient';
2
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ export type MmOracleEntry = {
2
+ price: bigint;
3
+ decimals: number;
4
+ updatedAt: number;
5
+ };
@@ -1,12 +1,16 @@
1
1
  import { PolkadotClient } from 'polkadot-api';
2
2
  import { type Observable } from 'rxjs';
3
3
  import { BalanceClient } from '../client';
4
+ import { EvmClient } from '../evm';
5
+ import { MmOracleClient } from '../oracle';
4
6
  import { PoolBase, PoolFees, PoolTokenOverride, PoolType } from './types';
5
7
  export declare abstract class PoolClient<T extends PoolBase> extends BalanceClient {
8
+ protected evm: EvmClient;
9
+ protected mmOracle: MmOracleClient;
6
10
  private override;
7
11
  private mem;
8
12
  private memPools;
9
- constructor(client: PolkadotClient);
13
+ constructor(client: PolkadotClient, evm: EvmClient);
10
14
  protected abstract loadPools(): Promise<T[]>;
11
15
  abstract getPoolFees(pool: T, feeAsset: number): Promise<PoolFees>;
12
16
  abstract getPoolType(): PoolType;
@@ -1,7 +1,9 @@
1
1
  import { PolkadotClient } from 'polkadot-api';
2
2
  import { Papi } from '../api';
3
+ import { EvmClient } from '../evm';
3
4
  import { IPoolCtxProvider, PoolBase, PoolFees, PoolFilter, PoolTokenOverride } from './types';
4
5
  export declare class PoolContextProvider extends Papi implements IPoolCtxProvider {
6
+ readonly evm: EvmClient;
5
7
  private readonly lbpClient;
6
8
  private readonly omniClient;
7
9
  private readonly stableClient;
@@ -17,7 +19,7 @@ export declare class PoolContextProvider extends Papi implements IPoolCtxProvide
17
19
  private aaveSub;
18
20
  private isReady;
19
21
  private isDestroyed;
20
- constructor(client: PolkadotClient);
22
+ constructor(client: PolkadotClient, evm: EvmClient);
21
23
  private subscribe;
22
24
  withOmnipool(): this;
23
25
  withStableswap(): this;
@@ -4,17 +4,17 @@ import { PoolClient } from '../PoolClient';
4
4
  import { StableSwapBase } from './StableSwap';
5
5
  export declare class StableSwapClient extends PoolClient<StableSwapBase> {
6
6
  private poolsData;
7
- protected loadPools(): Promise<StableSwapBase[]>;
7
+ getPoolType(): PoolType;
8
+ private getPoolAddress;
9
+ private getPoolLimits;
8
10
  private getPoolDelta;
9
11
  private getPoolTokens;
12
+ isSupported(): Promise<boolean>;
13
+ protected loadPools(): Promise<StableSwapBase[]>;
14
+ getPoolFees(pool: StableSwapBase): Promise<PoolFees>;
10
15
  private getPoolPegs;
11
16
  private getDefaultPegs;
12
17
  private getRecentPegs;
13
18
  private getLatestPegs;
14
- private getPoolAddress;
15
- private getPoolLimits;
16
- getPoolFees(pool: StableSwapBase): Promise<PoolFees>;
17
- getPoolType(): PoolType;
18
- isSupported(): Promise<boolean>;
19
19
  subscribePoolChange(pool: StableSwapBase): Observable<StableSwapBase>;
20
20
  }
@@ -7,7 +7,7 @@ export declare class StakingApi {
7
7
  private readonly client;
8
8
  private readonly balanceClient;
9
9
  constructor(client: StakingClient, balanceClient: BalanceClient);
10
- getTransferablePotBalance(): Promise<bigint>;
10
+ getFreePotBalance(): Promise<bigint>;
11
11
  getStakingPosition(id: bigint): Promise<{
12
12
  stake: bigint | undefined;
13
13
  rewardPerStake: bigint | undefined;
@@ -32,11 +32,6 @@ export declare class StakingClient extends Papi {
32
32
  "track": number;
33
33
  "origin": import("polkadot-api").Enum<{
34
34
  system: import("@galacticcouncil/descriptors").DispatchRawOrigin;
35
- Council: import("polkadot-api").Enum<{
36
- "Members": import("polkadot-api").FixedSizeArray<2, number>;
37
- "Member": import("polkadot-api").SS58String;
38
- "_Phantom": undefined;
39
- }>;
40
35
  TechnicalCommittee: import("polkadot-api").Enum<{
41
36
  "Members": import("polkadot-api").FixedSizeArray<2, number>;
42
37
  "Member": import("polkadot-api").SS58String;
@@ -1,4 +1,5 @@
1
1
  import { PolkadotClient } from 'polkadot-api';
2
+ import { PublicClient } from 'viem';
2
3
  import { AaveUtils } from '../aave';
3
4
  import { Papi } from '../api';
4
5
  import { BalanceClient } from '../client';
@@ -6,10 +7,11 @@ import { EvmClient } from '../evm';
6
7
  import { Swap } from '../sor';
7
8
  import { DryRunResult, Transaction, Tx } from './types';
8
9
  export declare abstract class TxBuilder extends Papi {
9
- protected readonly evmClient: EvmClient;
10
+ protected readonly evm: EvmClient;
11
+ protected readonly evmClient: PublicClient;
10
12
  protected readonly balanceClient: BalanceClient;
11
13
  protected readonly aaveUtils: AaveUtils;
12
- constructor(client: PolkadotClient, evmClient?: EvmClient);
14
+ constructor(client: PolkadotClient, evm: EvmClient);
13
15
  protected wrapTx(name: string, tx: Transaction): Tx;
14
16
  protected dispatchWithExtraGas(tx: Transaction): Promise<Transaction>;
15
17
  protected dryRun(account: string, tx: Transaction): Promise<DryRunResult>;
@@ -6,7 +6,7 @@ import { OrderTxBuilder } from './OrderTxBuilder';
6
6
  export declare class TxBuilderFactory {
7
7
  private client;
8
8
  private evmClient;
9
- constructor(client: PolkadotClient, evmClient?: EvmClient);
9
+ constructor(client: PolkadotClient, evmClient: EvmClient);
10
10
  trade(trade: Trade): TradeTxBuilder;
11
11
  order(order: TradeOrder): OrderTxBuilder;
12
12
  }
@@ -1,4 +1,11 @@
1
1
  import { PoolFee } from '../pool';
2
- export declare function toPct(fee: PoolFee): number;
3
- export declare function toDecimals(fee: PoolFee): number;
4
- export declare function fromPermill(permill: number): PoolFee;
2
+ export declare class FeeUtils {
3
+ static toPct(fee: PoolFee): number;
4
+ static toRaw(fee: PoolFee): number;
5
+ static fromPermill(permill: number): PoolFee;
6
+ static fromPerbill(perbill: number): PoolFee;
7
+ static fromRate(numerator: number, denominator: number): PoolFee;
8
+ static safeDivide(numerator: number, denominator: number, decimals?: number): number;
9
+ static safeRound(value: number): number;
10
+ }
11
+ export declare function shiftNeg(amount: string | number | bigint, decimals: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacticcouncil/sdk-next",
3
- "version": "0.6.0-pr194-1c1c0d6",
3
+ "version": "0.6.1-pr196-4dadb83",
4
4
  "description": "Galactic next gen sdk (papi)",
5
5
  "author": "GalacticCouncil",
6
6
  "repository": {
@@ -35,11 +35,11 @@
35
35
  "@types/big.js": "^6.2.2"
36
36
  },
37
37
  "dependencies": {
38
- "@galacticcouncil/descriptors": "^1.3.0",
38
+ "@galacticcouncil/descriptors": "^1.4.0",
39
39
  "@galacticcouncil/math-lbp": "^1.2.0",
40
40
  "@galacticcouncil/math-liquidity-mining": "^1.2.0",
41
41
  "@galacticcouncil/math-omnipool": "^1.3.0",
42
- "@galacticcouncil/math-stableswap": "^2.2.0",
42
+ "@galacticcouncil/math-stableswap": "^2.3.0",
43
43
  "@galacticcouncil/math-xyk": "^1.2.0",
44
44
  "@noble/hashes": "^1.6.1",
45
45
  "@thi.ng/cache": "^2.1.35",