@sonarwatch/portfolio-plugins 0.14.11 → 0.14.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/CHANGELOG.md +1636 -1632
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/src/plugins/balancer/helpers/pools.js +21 -21
  5. package/src/plugins/cetus/types.d.ts +109 -0
  6. package/src/plugins/jupiter/exchange/constants.js +1 -1
  7. package/src/plugins/kriya/clmmsFetcher.d.ts +3 -0
  8. package/src/plugins/kriya/clmmsFetcher.js +81 -0
  9. package/src/plugins/kriya/clmmsFetcher.js.map +1 -0
  10. package/src/plugins/kriya/constants.d.ts +9 -4
  11. package/src/plugins/kriya/constants.js +48 -5
  12. package/src/plugins/kriya/constants.js.map +1 -1
  13. package/src/plugins/kriya/farmsFetcher.js.map +1 -1
  14. package/src/plugins/kriya/index.js +4 -0
  15. package/src/plugins/kriya/index.js.map +1 -1
  16. package/src/plugins/kriya/lpFetcher.d.ts +3 -0
  17. package/src/plugins/kriya/lpFetcher.js +80 -0
  18. package/src/plugins/kriya/lpFetcher.js.map +1 -0
  19. package/src/plugins/kriya/types/common.d.ts +46 -0
  20. package/src/plugins/kriya/types/common.js +9 -0
  21. package/src/plugins/kriya/types/common.js.map +1 -0
  22. package/src/plugins/kriya/types/farms.d.ts +55 -0
  23. package/src/plugins/kriya/{types.js → types/farms.js} +2 -1
  24. package/src/plugins/kriya/types/farms.js.map +1 -0
  25. package/src/plugins/kriya/types/pools.d.ts +131 -0
  26. package/src/plugins/kriya/types/pools.js +3 -0
  27. package/src/plugins/kriya/types/pools.js.map +1 -0
  28. package/src/plugins/kriya/{types.d.ts → types/vaults.d.ts} +104 -86
  29. package/src/plugins/kriya/types/vaults.js +3 -0
  30. package/src/plugins/kriya/types/vaults.js.map +1 -0
  31. package/src/plugins/kriya/vaultsFetcher.js +67 -59
  32. package/src/plugins/kriya/vaultsFetcher.js.map +1 -1
  33. package/src/plugins/kriya/vaultsJob.js +52 -16
  34. package/src/plugins/kriya/vaultsJob.js.map +1 -1
  35. package/src/plugins/native-stake/solana/solanaValidatorsJob.js +4 -0
  36. package/src/plugins/native-stake/solana/solanaValidatorsJob.js.map +1 -1
  37. package/src/plugins/native-stake/solana/types.d.ts +8 -0
  38. package/src/plugins/parcl/stakingFetcher.js +10 -24
  39. package/src/plugins/parcl/stakingFetcher.js.map +1 -1
  40. package/src/plugins/sushiswap/helpers.js +24 -24
  41. package/src/plugins/uniswap-v2/helpers.js +22 -22
  42. package/src/plugins/zeta/airdropFetcher.js +14 -14
  43. package/src/utils/elementbuilder/LiquidityBuilder.js +1 -1
  44. package/src/utils/elementbuilder/LiquidityBuilder.js.map +1 -1
  45. package/src/utils/sei/constants.js +8 -8
  46. package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
  47. package/src/plugins/kriya/types.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // Farm
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.PoolSource = exports.FarmSource = void 0;
4
5
  var FarmSource;
@@ -13,4 +14,4 @@ var PoolSource;
13
14
  PoolSource["DeepbookV2"] = "deepbook_v2";
14
15
  PoolSource["Kriya"] = "kriya";
15
16
  })(PoolSource || (exports.PoolSource = PoolSource = {}));
16
- //# sourceMappingURL=types.js.map
17
+ //# sourceMappingURL=farms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"farms.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/kriya/types/farms.ts"],"names":[],"mappings":";AAAA,OAAO;;;AA8BP,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,wBAAU,CAAA;IACV,6BAAe,CAAA;AACjB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,wCAA0B,CAAA;IAC1B,6BAAe,CAAA;AACjB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB"}
@@ -0,0 +1,131 @@
1
+ import { ID } from '../../../utils/sui/structs/id';
2
+ import { TickIndex, Type } from './common';
3
+ export type Pool = {
4
+ id: ID;
5
+ is_deposit_enabled: boolean;
6
+ is_stable: boolean;
7
+ is_swap_enabled: boolean;
8
+ is_withdraw_enabled: boolean;
9
+ lp_fee_percent: string;
10
+ lsp_locked: string;
11
+ lsp_supply: LspSupply;
12
+ protocol_fee_percent: string;
13
+ protocol_fee_x: string;
14
+ protocol_fee_y: string;
15
+ scaleX: string;
16
+ scaleY: string;
17
+ token_x: string;
18
+ token_y: string;
19
+ };
20
+ export type ExtendedPool = Pool & {
21
+ token_x_mint: string;
22
+ token_y_mint: string;
23
+ };
24
+ export type LspSupply = {
25
+ fields: Fields;
26
+ type: string;
27
+ };
28
+ export type Fields = {
29
+ value: string;
30
+ };
31
+ export type LpTokenV2 = {
32
+ id: ID;
33
+ lsp: Lsp;
34
+ pool_id: string;
35
+ };
36
+ export type Lsp = {
37
+ fields: BalanceFields;
38
+ type: string;
39
+ };
40
+ export type BalanceFields = {
41
+ balance: string;
42
+ id: ID;
43
+ };
44
+ export type ClmmPosition = {
45
+ fee_growth_inside_x_last: string;
46
+ fee_growth_inside_y_last: string;
47
+ fee_rate: string;
48
+ id: ID;
49
+ liquidity: string;
50
+ owed_coin_x: string;
51
+ owed_coin_y: string;
52
+ pool_id: string;
53
+ reward_infos: PositionRewardInfo[];
54
+ tick_lower_index: TickIndex;
55
+ tick_upper_index: TickIndex;
56
+ type_x: Type;
57
+ type_y: Type;
58
+ };
59
+ export type PositionRewardInfo = {
60
+ fields: PositionRewardInfoFields;
61
+ type: string;
62
+ };
63
+ export type PositionRewardInfoFields = {
64
+ coins_owed_reward: string;
65
+ reward_growth_inside_last: string;
66
+ };
67
+ export type ClmmPool = {
68
+ fee_growth_global_x: string;
69
+ fee_growth_global_y: string;
70
+ flash_loan_fee_rate: string;
71
+ id: ID;
72
+ liquidity: string;
73
+ max_liquidity_per_tick: string;
74
+ observation_cardinality: string;
75
+ observation_cardinality_next: string;
76
+ observation_index: string;
77
+ observations: Observation[];
78
+ protocol_fee_share: string;
79
+ protocol_fee_x: string;
80
+ protocol_fee_y: string;
81
+ protocol_flash_loan_fee_share: string;
82
+ reserve_x: string;
83
+ reserve_y: string;
84
+ reward_infos: RewardInfo[];
85
+ sqrt_price: string;
86
+ swap_fee_rate: string;
87
+ tick_bitmap: Tick;
88
+ tick_index: TickIndex;
89
+ tick_spacing: number;
90
+ ticks: Tick;
91
+ type_x: Type;
92
+ type_y: Type;
93
+ };
94
+ export type RewardInfo = {
95
+ fields: RewardInfoFields;
96
+ type: string;
97
+ };
98
+ export type RewardInfoFields = {
99
+ ended_at_seconds: string;
100
+ last_update_time: string;
101
+ reward_coin_type: Type;
102
+ reward_growth_global: string;
103
+ reward_per_seconds: string;
104
+ total_reward: string;
105
+ total_reward_allocated: string;
106
+ };
107
+ export type Observation = {
108
+ fields: ObservationFields;
109
+ type: string;
110
+ };
111
+ export type ObservationFields = {
112
+ initialized: boolean;
113
+ seconds_per_liquidity_cumulative: string;
114
+ tick_cumulative: TickCumulative;
115
+ timestamp_s: string;
116
+ };
117
+ export type TickCumulative = {
118
+ fields: TickCumulativeFields;
119
+ type: string;
120
+ };
121
+ export type TickCumulativeFields = {
122
+ bits: string;
123
+ };
124
+ export type Tick = {
125
+ fields: TickBitmapFields;
126
+ type: string;
127
+ };
128
+ export type TickBitmapFields = {
129
+ id: ID;
130
+ size: string;
131
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=pools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pools.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/kriya/types/pools.ts"],"names":[],"mappings":""}
@@ -1,9 +1,5 @@
1
- import { ID } from '../../utils/sui/structs/id';
2
- export type VaultInfo = {
3
- id: string;
4
- underlyingPool: string;
5
- tokenType: string;
6
- };
1
+ import { ID } from '../../../utils/sui/structs/id';
2
+ import { RewardInfo, TickIndex, Type } from './common';
7
3
  export type Vault = {
8
4
  clmm_pool_id: string;
9
5
  fee_a: string;
@@ -54,23 +50,16 @@ export type TotalSupply = {
54
50
  export type TotalSupplyFields = {
55
51
  value: string;
56
52
  };
57
- export type VaultPositionInfo = {
58
- id: string;
59
- lowerTick: number;
60
- upperTick: number;
61
- liquidity: string;
62
- totalSupply: string;
63
- };
64
- export type VaultPosition = {
53
+ export type VaultPositionCetus = {
65
54
  id: ID;
66
55
  name: number[];
67
- value: Value;
56
+ value: ValueCetus;
68
57
  };
69
- export type Value = {
70
- fields: ValueFields;
58
+ export type ValueCetus = {
59
+ fields: PositionFieldsCetus;
71
60
  type: string;
72
61
  };
73
- export type ValueFields = {
62
+ export type PositionFieldsCetus = {
74
63
  coin_type_a: CoinType;
75
64
  coin_type_b: CoinType;
76
65
  description: string;
@@ -79,8 +68,8 @@ export type ValueFields = {
79
68
  liquidity: string;
80
69
  name: string;
81
70
  pool: string;
82
- tick_lower_index: TickErIndex;
83
- tick_upper_index: TickErIndex;
71
+ tick_lower_index: TickIndex;
72
+ tick_upper_index: TickIndex;
84
73
  url: string;
85
74
  };
86
75
  export type CoinType = {
@@ -90,66 +79,65 @@ export type CoinType = {
90
79
  export type CoinTypeAFields = {
91
80
  name: string;
92
81
  };
93
- export type TickErIndex = {
94
- fields: TickLowerIndexFields;
82
+ export type VaultPositionKriya = {
83
+ id: ID;
84
+ name: number[];
85
+ value: ValueKriya;
86
+ };
87
+ export type ValueKriya = {
88
+ fields: PositionFieldsKriya;
95
89
  type: string;
96
90
  };
97
- export type TickLowerIndexFields = {
98
- bits: number;
91
+ export type PositionFieldsKriya = {
92
+ fee_growth_inside_x_last: string;
93
+ fee_growth_inside_y_last: string;
94
+ fee_rate: string;
95
+ id: ID;
96
+ liquidity: string;
97
+ owed_coin_x: string;
98
+ owed_coin_y: string;
99
+ pool_id: string;
100
+ reward_infos: RewardInfo[];
101
+ tick_lower_index: TickIndex;
102
+ tick_upper_index: TickIndex;
103
+ type_x: Type;
104
+ type_y: Type;
99
105
  };
100
- export type FarmInfo = {
101
- tokenXReserve: string;
102
- lspSupply: string;
103
- protocolFeesPercent: string;
104
- createdAt: Date;
105
- farmSource: FarmSource;
106
- volume: number;
107
- packageId: string;
106
+ export type LeverageVaultInfo = {
107
+ depositedA: string;
108
+ apr: string;
109
+ borrowedBUsd: string;
110
+ farmStakeReceiptType: string;
111
+ decimalA: string;
112
+ createdAt: string;
113
+ farmSource: string;
114
+ coinB: string;
115
+ decimalB: string;
116
+ tvl: string;
117
+ borrowedB: string;
118
+ targetLeverage: string;
119
+ vaultName: string;
120
+ depositedAUsd: string;
121
+ lpSupply: string;
122
+ vaultSource: string;
108
123
  farmId: string;
124
+ fees: string;
125
+ coinA: string;
126
+ updatedAt: string;
127
+ id: string;
128
+ };
129
+ export type DynFieldPositionVault = {
130
+ name: Name;
131
+ bcsName: string;
132
+ type: string;
133
+ objectType: string;
109
134
  objectId: string;
110
- poolSource: PoolSource;
111
- lspType: string;
112
- lpFeesPercent: string;
113
- tokenYType: string;
114
- data: string;
115
- updatedAt: Date;
116
- isStable: boolean;
117
- tokenXType: string;
118
- tokenYReserve: string;
119
- tokenX: Token;
120
- tokenY: Token;
121
- tvl: number;
122
- apy: number;
123
- feeApy: number;
124
- };
125
- export declare enum FarmSource {
126
- Buck = "buck",
127
- Empty = "",
128
- Kriya = "kriya"
129
- }
130
- export declare enum PoolSource {
131
- Deepbook = "deepbook",
132
- DeepbookV2 = "deepbook_v2",
133
- Kriya = "kriya"
134
- }
135
- export type Token = {
136
- coinType: string;
137
- ticker: string;
138
- tokenName: string;
139
- updatedAt: Date;
140
- createdAt: Date;
141
- decimals: number;
142
- iconUrl: string;
143
- description: string;
144
- price: string;
135
+ version: number;
136
+ digest: string;
145
137
  };
146
- export type LiquidityPosition = {
147
- farm_id: string;
148
- id: ID;
149
- lock_until: string;
150
- stake_amount: string;
151
- stake_weight: string;
152
- start_unit: string;
138
+ export type Name = {
139
+ type: string;
140
+ value: number[];
153
141
  };
154
142
  export type StakeReceiptWithPoints = {
155
143
  farm_id: string;
@@ -178,26 +166,56 @@ export type StakeReceiptWithPoints = {
178
166
  type: string;
179
167
  };
180
168
  };
181
- export type LeverageVaultInfo = {
182
- depositedA: string;
169
+ export type VaultReceipt = {
170
+ farm_id: string;
171
+ id: ID;
172
+ reward_infos: RewardInfos;
173
+ shares: string;
174
+ user_points_info: UserPointsInfo;
175
+ };
176
+ export type RewardInfos = {
177
+ fields: RewardInfosFields;
178
+ type: string;
179
+ };
180
+ export type RewardInfosFields = {
181
+ id: ID;
182
+ size: string;
183
+ };
184
+ export type UserPointsInfo = {
185
+ fields: UserPointsInfoFields;
186
+ type: string;
187
+ };
188
+ export type UserPointsInfoFields = {
189
+ claimed_points: string;
190
+ index: string;
191
+ updated_at: string;
192
+ };
193
+ export type VaultData = {
194
+ lpPriceHigh: string;
183
195
  apr: string;
184
- borrowedBUsd: string;
185
- farmStakeReceiptType: string;
186
- decimalA: string;
187
- createdAt: string;
188
- farmSource: string;
196
+ createdAt: Date;
189
197
  coinB: string;
190
- decimalB: string;
191
198
  tvl: string;
192
- borrowedB: string;
193
- targetLeverage: string;
194
199
  vaultName: string;
195
- depositedAUsd: string;
200
+ lastRebalance: string;
196
201
  lpSupply: string;
197
202
  vaultSource: string;
198
203
  farmId: string;
199
204
  fees: string;
200
205
  coinA: string;
201
- updatedAt: string;
206
+ lpPriceLow: string;
207
+ updatedAt: Date;
208
+ currentLpPrice: string;
202
209
  id: string;
210
+ rebalanceCap: string;
211
+ pool: Pool;
212
+ };
213
+ export type Pool = {
214
+ tokenYDecimals: number;
215
+ vaultCoinType: string;
216
+ vaultType: string;
217
+ tokenXType: string;
218
+ tokenYType: string;
219
+ poolId: string;
220
+ tokenXDecimals: number;
203
221
  };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=vaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vaults.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/kriya/types/vaults.ts"],"names":[],"mappings":""}
@@ -17,77 +17,85 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
17
  const constants_1 = require("./constants");
18
18
  const clients_1 = require("../../utils/clients");
19
19
  const mulitpleGetBalances_1 = require("../../utils/sui/mulitpleGetBalances");
20
- const constants_2 = require("../cetus/constants");
21
20
  const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
22
- const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
21
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
22
+ const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
23
+ const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
24
+ const vaultsPositionInfoMemo = new MemoizedCache_1.MemoizedCache(constants_1.vaultsInfoKey, {
25
+ prefix: constants_1.platformId,
26
+ networkId: portfolio_core_1.NetworkId.sui,
27
+ });
23
28
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
29
+ var _a, _b;
24
30
  const client = (0, clients_1.getClientSui)();
25
- const vaultsBalances = yield (0, mulitpleGetBalances_1.getMultipleBalances)(client, owner, constants_1.vaultsInfo.map((vault) => vault.tokenType));
26
- if (!vaultsBalances.some((balance) => balance.totalBalance !== '0'))
27
- return [];
28
- const poolInfos = yield cache.getItems(constants_1.vaultsInfo.map((vault) => vault.underlyingPool), { prefix: constants_2.clmmPoolsPrefix, networkId: portfolio_core_1.NetworkId.sui });
29
- const vaultsPositionInfo = yield cache.getItem(constants_1.vaultsInfoKey, {
30
- prefix: constants_1.platformId,
31
- networkId: portfolio_core_1.NetworkId.sui,
32
- });
31
+ const [vaultsOldBalances, vaultBalances, vaultsPositionInfo] = yield Promise.all([
32
+ (0, mulitpleGetBalances_1.getMultipleBalances)(client, owner, constants_1.vaultsInfo.map((vault) => vault.tokenType)),
33
+ (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
34
+ filter: { StructType: constants_1.vaultStakeReceipt },
35
+ }),
36
+ vaultsPositionInfoMemo.getItem(cache),
37
+ ]);
33
38
  if (!vaultsPositionInfo)
34
39
  return [];
35
- const tokenPriceById = yield cache.getTokenPricesAsMap(poolInfos
36
- .map((pool) => (pool ? [pool.coinTypeA, pool.coinTypeB] : []))
37
- .flat(), portfolio_core_1.NetworkId.sui);
38
- let totalValue = 0;
39
- const liquidities = [];
40
- for (let i = 0; i < vaultsBalances.length; i++) {
41
- const balance = vaultsBalances[i];
42
- const pool = poolInfos[i];
43
- const vault = vaultsPositionInfo[i];
44
- if (!pool || !vault)
40
+ const vaultsByCoinType = new Map();
41
+ vaultsPositionInfo.forEach((vault) => vaultsByCoinType.set(vault.coinType, vault));
42
+ const vaultsByFarmId = new Map();
43
+ vaultsPositionInfo.forEach((vault) => vaultsByFarmId.set(vault.farmId, vault));
44
+ const registry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
45
+ const liquidities = registry.addElementLiquidity({
46
+ name: 'Vaults',
47
+ label: 'LiquidityPool',
48
+ });
49
+ for (let i = 0; i < vaultsOldBalances.length; i++) {
50
+ const liquidity = liquidities.addLiquidity();
51
+ const balance = vaultsOldBalances[i];
52
+ if (balance.totalBalance === '0')
53
+ continue;
54
+ const vault = vaultsByCoinType.get(balance.coinType);
55
+ if (!vault)
45
56
  continue;
46
57
  const totalSupply = new bignumber_js_1.default(vault.totalSupply);
47
- const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(vault.liquidity), pool.current_tick_index, vault.lowerTick, vault.upperTick, false);
58
+ const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(vault.liquidity), vault.currentTickIndex, vault.lowerTick, vault.upperTick, false);
48
59
  const shares = new bignumber_js_1.default(balance.totalBalance).dividedBy(totalSupply);
49
- const [tokenPriceA, tokenPriceB] = [
50
- tokenPriceById.get((0, portfolio_core_1.formatMoveTokenAddress)(pool.coinTypeA)),
51
- tokenPriceById.get((0, portfolio_core_1.formatMoveTokenAddress)(pool.coinTypeB)),
52
- ];
53
- if (!tokenPriceA || !tokenPriceB)
60
+ const amountA = tokenAmountA.times(shares);
61
+ const amountB = tokenAmountB.times(shares);
62
+ liquidity.addAsset({
63
+ address: vault.mintA,
64
+ amount: amountA,
65
+ });
66
+ liquidity.addAsset({
67
+ address: vault.mintB,
68
+ amount: amountB,
69
+ });
70
+ }
71
+ for (let i = 0; i < vaultBalances.length; i++) {
72
+ const liquidity = liquidities.addLiquidity();
73
+ const stakeReceipt = (_b = (_a = vaultBalances[i].data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields;
74
+ if (!stakeReceipt || stakeReceipt.shares === '0')
54
75
  continue;
55
- const amountA = tokenAmountA
56
- .times(shares)
57
- .dividedBy(Math.pow(10, tokenPriceA.decimals));
58
- const amountB = tokenAmountB
59
- .times(shares)
60
- .dividedBy(Math.pow(10, tokenPriceB.decimals));
61
- if (amountA.isZero() && amountB.isZero())
76
+ const vault = vaultsByFarmId.get(stakeReceipt.farm_id);
77
+ if (!vault)
62
78
  continue;
63
- const assetA = (0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, amountA.toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceA);
64
- const assetB = (0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, amountB.toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceB);
65
- const value = (0, portfolio_core_1.getUsdValueSum)([assetA.value, assetB.value]);
66
- totalValue = (0, portfolio_core_1.getUsdValueSum)([totalValue, value]);
67
- liquidities.push({
68
- assets: [assetA, assetB],
69
- assetsValue: value,
70
- rewardAssets: [],
71
- rewardAssetsValue: null,
72
- value,
73
- yields: [],
79
+ const totalSupply = new bignumber_js_1.default(vault.totalSupply);
80
+ const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(vault.liquidity), 600, vault.lowerTick, vault.upperTick, false);
81
+ const useApiData = tokenAmountA.isLessThan(0) || tokenAmountB.isLessThan(0);
82
+ const shares = new bignumber_js_1.default(stakeReceipt.shares).dividedBy(totalSupply);
83
+ const amountA = useApiData
84
+ ? new bignumber_js_1.default(vault.amountA).times(shares)
85
+ : tokenAmountA.times(shares);
86
+ const amountB = useApiData
87
+ ? new bignumber_js_1.default(vault.amountB).times(shares)
88
+ : tokenAmountB.times(shares);
89
+ liquidity.addAsset({
90
+ address: vault.mintA,
91
+ amount: amountA,
92
+ });
93
+ liquidity.addAsset({
94
+ address: vault.mintB,
95
+ amount: amountB,
74
96
  });
75
97
  }
76
- if (liquidities.length === 0)
77
- return [];
78
- return [
79
- {
80
- type: 'liquidity',
81
- data: {
82
- liquidities,
83
- },
84
- label: 'LiquidityPool',
85
- networkId: portfolio_core_1.NetworkId.sui,
86
- platformId: constants_1.platformId,
87
- value: totalValue,
88
- name: 'Vaults',
89
- },
90
- ];
98
+ return registry.getElements(cache);
91
99
  });
92
100
  const fetcher = {
93
101
  id: `${constants_1.platformId}-vaults`,
@@ -1 +1 @@
1
- {"version":3,"file":"vaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/vaultsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAGrC,2CAAoE;AACpE,iDAAmD;AACnD,6EAA0E;AAE1E,kDAAqD;AAErD,wFAAyF;AACzF,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,cAAc,GAAG,MAAM,IAAA,yCAAmB,EAC9C,MAAM,EACN,KAAK,E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EACb,WAAW,CACZ,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,gCAAsB,EACnC,WAAW,CAAC,OAAO,EACnB,OAAO,CAAC,QAAQ,EAAE,EAClB,0BAAS,CAAC,GAAG,EACb,WAAW,CACZ,CAAC;QACF,MAAM,KAAK,GAAG,IAAA,+BAAc,EAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAE3D,UAAU,GAAG,IAAA,+BAAc,EAAC,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;QACjD,WAAW,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;YACxB,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,EAAE;YAChB,iBAAiB,EAAE,IAAI;YACvB,KAAK;YACL,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAExC,OAAO;QACL;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE;gBACJ,WAAW;aACZ;YACD,KAAK,EAAE,eAAe;YACtB,SAAS,EAAE,0BAAS,CAAC,GAAG;YACxB,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,QAAQ;SACf;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"vaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/vaultsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,6EAA0E;AAE1E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