@rhea-finance/cross-chain-sdk 0.1.2 → 0.1.3

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/dist/index.d.cts CHANGED
@@ -19,6 +19,108 @@ declare function process_signature_solana(signature: Uint8Array<ArrayBufferLike>
19
19
  declare function prepare_sign_message_btc(message: string): string;
20
20
  declare function process_signature_btc(signature: string): string;
21
21
 
22
+ interface IFarmId {
23
+ Supplied?: string;
24
+ Borrowed?: string;
25
+ }
26
+ interface AccountFarmRewardView {
27
+ boosted_shares: string;
28
+ unclaimed_amount: string;
29
+ reward_token_id: string;
30
+ asset_farm_reward: {
31
+ reward_per_day: string;
32
+ remaining_rewards: string;
33
+ boosted_shares: string;
34
+ booster_log_bases: {
35
+ [tokenId: string]: string;
36
+ };
37
+ };
38
+ }
39
+ interface IFarm {
40
+ farm_id: IFarmId | "NetTvl";
41
+ rewards: AccountFarmRewardView[];
42
+ }
43
+ interface IPortfolioAssetOrigin {
44
+ token_id: string;
45
+ apr: string;
46
+ balance: string;
47
+ shares: string;
48
+ }
49
+ interface IPositionsOrigin {
50
+ [shadow_id: string]: {
51
+ collateral: IPortfolioAssetOrigin[];
52
+ borrowed: IPortfolioAssetOrigin[];
53
+ };
54
+ }
55
+ interface PortfolioAsset {
56
+ apr?: string;
57
+ balance: string;
58
+ shares: string;
59
+ }
60
+ interface IPositions {
61
+ [shadow_id: string]: {
62
+ collateral: {
63
+ [tokenId: string]: PortfolioAsset;
64
+ };
65
+ borrowed: {
66
+ [tokenId: string]: PortfolioAsset;
67
+ };
68
+ };
69
+ }
70
+ interface IBoosterStaking {
71
+ staked_booster_amount: string;
72
+ unlock_timestamp: string;
73
+ x_booster_amount: string;
74
+ }
75
+ interface Farm {
76
+ [reward_token_id: string]: AccountFarmRewardView;
77
+ }
78
+ interface Portfolio {
79
+ supplied: {
80
+ [tokenId: string]: PortfolioAsset;
81
+ };
82
+ collateral: {
83
+ [tokenId: string]: PortfolioAsset;
84
+ };
85
+ borrowed: {
86
+ [tokenId: string]: PortfolioAsset;
87
+ };
88
+ positions: IPositions;
89
+ farms: {
90
+ supplied: {
91
+ [tokenId: string]: Farm;
92
+ };
93
+ borrowed: {
94
+ [tokenId: string]: Farm;
95
+ };
96
+ tokennetbalance: {
97
+ [tokenId: string]: Farm;
98
+ };
99
+ netTvl: {
100
+ [tokenId: string]: AccountFarmRewardView;
101
+ };
102
+ };
103
+ staking: IBoosterStaking;
104
+ stakings?: Record<string, IBoosterStaking>;
105
+ hasNonFarmedAssets: boolean;
106
+ collateralAll: {
107
+ [tokenId: string]: PortfolioAsset;
108
+ };
109
+ supplies: any[];
110
+ collaterals: any[];
111
+ borrows: any[];
112
+ }
113
+ interface IAccountAllPositionsDetailed {
114
+ account_id: string;
115
+ supplied: IPortfolioAssetOrigin[];
116
+ farms: IFarm[];
117
+ booster_staking: IBoosterStaking;
118
+ booster_stakings: Record<string, IBoosterStaking>;
119
+ has_non_farmed_assets: boolean;
120
+ is_locked: boolean;
121
+ positions: IPositionsOrigin;
122
+ }
123
+
22
124
  interface ITransferAction {
23
125
  receiver_id: string;
24
126
  amount: string;
@@ -121,6 +223,20 @@ interface IIntentSwapDetails {
121
223
  hash: string;
122
224
  }[];
123
225
  }
226
+ interface IGasData {
227
+ portfolioMinusGas: Portfolio;
228
+ tokenId: string;
229
+ amount: string | number;
230
+ amountToken: string | number;
231
+ amountBurrow: string | number;
232
+ relayerFeeUsd: string | number;
233
+ simpleWithdrawData: {
234
+ tokenId: string;
235
+ amount: string;
236
+ amountToken: string;
237
+ amountBurrow: string;
238
+ };
239
+ }
124
240
 
125
241
  interface IConfig {
126
242
  booster_decimals: number;
@@ -143,108 +259,6 @@ interface IConfig {
143
259
  }
144
260
  type TokenAction = "Supply" | "Borrow" | "Repay" | "Adjust" | "Withdraw";
145
261
 
146
- interface IFarmId {
147
- Supplied?: string;
148
- Borrowed?: string;
149
- }
150
- interface AccountFarmRewardView {
151
- boosted_shares: string;
152
- unclaimed_amount: string;
153
- reward_token_id: string;
154
- asset_farm_reward: {
155
- reward_per_day: string;
156
- remaining_rewards: string;
157
- boosted_shares: string;
158
- booster_log_bases: {
159
- [tokenId: string]: string;
160
- };
161
- };
162
- }
163
- interface IFarm {
164
- farm_id: IFarmId | "NetTvl";
165
- rewards: AccountFarmRewardView[];
166
- }
167
- interface IPortfolioAssetOrigin {
168
- token_id: string;
169
- apr: string;
170
- balance: string;
171
- shares: string;
172
- }
173
- interface IPositionsOrigin {
174
- [shadow_id: string]: {
175
- collateral: IPortfolioAssetOrigin[];
176
- borrowed: IPortfolioAssetOrigin[];
177
- };
178
- }
179
- interface PortfolioAsset {
180
- apr?: string;
181
- balance: string;
182
- shares: string;
183
- }
184
- interface IPositions {
185
- [shadow_id: string]: {
186
- collateral: {
187
- [tokenId: string]: PortfolioAsset;
188
- };
189
- borrowed: {
190
- [tokenId: string]: PortfolioAsset;
191
- };
192
- };
193
- }
194
- interface IBoosterStaking {
195
- staked_booster_amount: string;
196
- unlock_timestamp: string;
197
- x_booster_amount: string;
198
- }
199
- interface Farm {
200
- [reward_token_id: string]: AccountFarmRewardView;
201
- }
202
- interface Portfolio {
203
- supplied: {
204
- [tokenId: string]: PortfolioAsset;
205
- };
206
- collateral: {
207
- [tokenId: string]: PortfolioAsset;
208
- };
209
- borrowed: {
210
- [tokenId: string]: PortfolioAsset;
211
- };
212
- positions: IPositions;
213
- farms: {
214
- supplied: {
215
- [tokenId: string]: Farm;
216
- };
217
- borrowed: {
218
- [tokenId: string]: Farm;
219
- };
220
- tokennetbalance: {
221
- [tokenId: string]: Farm;
222
- };
223
- netTvl: {
224
- [tokenId: string]: AccountFarmRewardView;
225
- };
226
- };
227
- staking: IBoosterStaking;
228
- stakings?: Record<string, IBoosterStaking>;
229
- hasNonFarmedAssets: boolean;
230
- collateralAll: {
231
- [tokenId: string]: PortfolioAsset;
232
- };
233
- supplies: any[];
234
- collaterals: any[];
235
- borrows: any[];
236
- }
237
- interface IAccountAllPositionsDetailed {
238
- account_id: string;
239
- supplied: IPortfolioAssetOrigin[];
240
- farms: IFarm[];
241
- booster_staking: IBoosterStaking;
242
- booster_stakings: Record<string, IBoosterStaking>;
243
- has_non_farmed_assets: boolean;
244
- is_locked: boolean;
245
- positions: IPositionsOrigin;
246
- }
247
-
248
262
  interface IPrice {
249
263
  decimals: number;
250
264
  multiplier: string;
@@ -741,27 +755,6 @@ declare const getAssets: ({ assets_paged_detailed, token_pyth_infos, config, }:
741
755
  }) => Promise<Assets>;
742
756
  declare const getAssetsDetail: () => Promise<IAssetDetailed[]>;
743
757
 
744
- /**
745
- * Convert IAccountAllPositionsDetailed to Portfolio
746
- * @param accountPositions - Account all positions detailed data
747
- * @returns Portfolio object with array converted to object structure
748
- */
749
- declare const getPortfolio: (accountPositions: IAccountAllPositionsDetailed) => {
750
- supplied: {
751
- [tokenId: string]: PortfolioAsset;
752
- };
753
- collateral: {
754
- [tokenId: string]: PortfolioAsset;
755
- };
756
- borrowed: {
757
- [tokenId: string]: PortfolioAsset;
758
- };
759
- positions: IPositions;
760
- farms: IFarm[];
761
- staking: IBoosterStaking;
762
- stakings: Record<string, IBoosterStaking>;
763
- hasNonFarmedAssets: boolean;
764
- };
765
758
  declare const getAccountAllPositions: (account_id: string) => Promise<IAccountAllPositionsDetailed>;
766
759
 
767
760
  declare const getBalance: (tokenId: string, accountId: string) => Promise<string>;
@@ -811,9 +804,7 @@ declare const initialStaking: {
811
804
  unlock_timestamp: string;
812
805
  x_booster_amount: string;
813
806
  };
814
- declare const transformPortfolio: (account: {
815
- portfolio: IAccountAllPositionsDetailed;
816
- }) => Portfolio | undefined;
807
+ declare const transformPortfolio: (portfolio: IAccountAllPositionsDetailed) => Portfolio | undefined;
817
808
 
818
809
  declare function transformAssets(assets: Assets): IAssetsView;
819
810
  declare function transformFarms(allFarms: [Record<string, string>, IAssetFarm][]): IFarms;
@@ -848,6 +839,7 @@ interface INEARConfig {
848
839
  hiddenAssets: string[];
849
840
  oneClickUrl: string;
850
841
  RELAYER_ID: string;
842
+ HHHH: string;
851
843
  }
852
844
  declare const setCustomNodeUrl: (nodeUrl: string) => void;
853
845
  declare const config_near: INEARConfig;
@@ -1027,28 +1019,102 @@ declare const computeRelayerGas: ({ nearStorageAmount, mca, relayerGasFees, asse
1027
1019
  nearStorageAmount: string | number;
1028
1020
  mca: string;
1029
1021
  relayerGasFees: Record<string, string>;
1030
- assets: Assets;
1022
+ assets: IAssetsView | Assets;
1031
1023
  portfolio: Portfolio;
1024
+ }) => IGasData | undefined;
1025
+
1026
+ declare const recomputeHealthFactorAdjust: ({ tokenId, amount, portfolio, assets, }: {
1027
+ tokenId: string;
1028
+ amount: number;
1029
+ portfolio: Portfolio;
1030
+ assets: IAssetsView | Assets;
1032
1031
  }) => {
1033
- portfolioMinusGas: Portfolio;
1032
+ healthFactor: number;
1033
+ maxBorrowValue: Decimal;
1034
+ };
1035
+
1036
+ declare const recomputeHealthFactorBorrow: ({ tokenId, amount, position, portfolio, assets, }: {
1034
1037
  tokenId: string;
1035
- amount: string;
1036
- relayerFeeUsd: string | undefined;
1037
- amountToken: string;
1038
- amountBurrow: string;
1039
- } | undefined;
1038
+ amount: number;
1039
+ position?: string;
1040
+ portfolio: Portfolio;
1041
+ assets: IAssetsView | Assets;
1042
+ }) => {
1043
+ healthFactor: number;
1044
+ maxBorrowValue: Decimal;
1045
+ };
1040
1046
 
1041
- declare const getSimpleWithdrawData: ({ nearStorageAmount, mca, relayerGasFees, assets, portfolio, }: {
1042
- nearStorageAmount: string | number;
1043
- mca: string;
1044
- relayerGasFees: Record<string, string>;
1045
- assets: Assets;
1047
+ declare const recomputeHealthFactorRepay: ({ tokenId, amount, position, portfolio, assets, }: {
1048
+ tokenId: string;
1049
+ amount: number;
1050
+ position?: string;
1046
1051
  portfolio: Portfolio;
1047
- }) => Promise<{
1052
+ assets: IAssetsView | Assets;
1053
+ }) => {
1054
+ healthFactor: number;
1055
+ maxBorrowValue: Decimal;
1056
+ };
1057
+
1058
+ declare const recomputeHealthFactorRepayFromDeposits: ({ tokenId, amount, portfolio, assets, }: {
1048
1059
  tokenId: string;
1049
- amount: string;
1050
- amountToken: string;
1051
- amountBurrow: string;
1052
- } | null>;
1060
+ amount: number;
1061
+ portfolio: Portfolio;
1062
+ assets: IAssetsView | Assets;
1063
+ }) => {
1064
+ healthFactor: number;
1065
+ maxBorrowValue: Decimal;
1066
+ };
1067
+
1068
+ declare const recomputeHealthFactorSupply: ({ tokenId, amount, portfolio, assets, useAsCollateral, }: {
1069
+ tokenId: string;
1070
+ amount: number;
1071
+ portfolio: Portfolio;
1072
+ assets: IAssetsView | Assets;
1073
+ useAsCollateral: boolean;
1074
+ }) => {
1075
+ healthFactor: number;
1076
+ maxBorrowValue: Decimal;
1077
+ };
1078
+
1079
+ declare const recomputeHealthFactorWithdraw: ({ tokenId, amount, portfolio, assets, }: {
1080
+ tokenId: string;
1081
+ amount: number;
1082
+ portfolio: Portfolio;
1083
+ assets: IAssetsView | Assets;
1084
+ }) => {
1085
+ healthFactor: number;
1086
+ maxBorrowValue: Decimal;
1087
+ };
1088
+
1089
+ declare const getAdjustedSum: ({ type, portfolio, assets, }: {
1090
+ type: "borrowed" | "collateral";
1091
+ portfolio: Portfolio;
1092
+ assets: IAssetsView | Assets;
1093
+ }) => Decimal;
1094
+
1095
+ declare const getBorrowMaxAmount: ({ tokenId, portfolio, assets, }: {
1096
+ tokenId: string;
1097
+ portfolio: Portfolio;
1098
+ assets: Assets | IAssetsView;
1099
+ }) => {
1100
+ [x: string]: {
1101
+ maxBorrowAmount: number;
1102
+ maxBorrowValue: number;
1103
+ };
1104
+ };
1105
+
1106
+ declare const computeWithdrawMaxAmount: ({ tokenId, assets, portfolio, }: {
1107
+ tokenId: string;
1108
+ assets: Assets | IAssetsView;
1109
+ portfolio: Portfolio;
1110
+ }) => {
1111
+ maxAmount: Decimal;
1112
+ canWithdrawAll: boolean;
1113
+ };
1114
+ declare const getWithdrawMaxAmount: ({ tokenId, assets, portfolio, }: {
1115
+ tokenId: string;
1116
+ assets: Assets | IAssetsView;
1117
+ portfolio: Portfolio;
1118
+ }) => number;
1053
1119
 
1054
- export { type AccountFarmRewardView, type Asset, type Assets, ChangeMethodsLogic, ChangeMethodsOracle, DEFAULT_POSITION, FRACTION_DIGITS, type Farm, type IAccountAllPositionsDetailed, type IAssetConfig, type IAssetDetailed, type IAssetFarm, type IAssetFarmReward, type IAssetFarmView, type IAssetPrice, type IAssetsView, type IBoosterStaking, type IBusiness, type IChain, type IConfig, type IExecutionResult, type IFarm, type IFarmId, type IFarms, type IIntentItem, type IIntentSwapDetails, type IIntentsQuote, type IIntentsQuoteResult, type ILendingData, type IMetadata, type IPool, type IPortfolioAssetOrigin, type IPositions, type IPositionsOrigin, type IPrice, type IPrices, type IPythInfo, type IPythPrice, type IRelayerResult, type ISimpleWithdraw, type IStatus, type IWallet, MAX_RATIO, NDeposit, NEAR_STORAGE_DEPOSIT, type Portfolio, type PortfolioAsset, type QuotationParams, TGas, TOKEN_STORAGE_DEPOSIT_READ, type TokenAction, ViewMethodsLogic, ViewMethodsOracle, ViewMethodsPyth, ViewMethodsToken, batchViews, computeRelayerGas, config_btc, config_evm, config_near, config_solana, decimalMax, decimalMin, expandToken, expandTokenDecimal, fetchIntentsQuotation, fetchIntentsTokens, fetchIntentsTransactionStatus, format_wallet, getAccountAllPositions, getAccountBalance, getAllFarms, getAssets, getAssetsDetail, getAuthenticationHeaders, getBalance, getBoosterTokens, getCeateMcaFee, getConfig, getCreateMcaCustomRecipientMsg, getCreateMcaFeePaged, getListWalletsByMca, getMcaByWallet, getMultichainLendingConfig, getMultichainLendingData, getMultichainLendingHistory, getMultichainTokensByChains, getNearValue, getNearValuesPaged, getPortfolio, getPrices, getRepayCustomRecipientMsg, getSignature, getSimpleWithdrawData, getSupplyCustomRecipientMsg, getTokenPythInfos, get_all_tokens_metadata, get_interest_rate, get_liquidations, get_nonce_deadline, get_records, get_simple_withdraw_tx, get_token_detail, get_tx_id, hasZeroSharesFarmRewards, initialStaking, intentsQuotation, listFarmToMap, lpTokenPrefix, pollingRelayerTransactionResult, pollingTransactionStatus, postMultichainLendingReport, postMultichainLendingRequests, prepareBusinessDataOnAddWallet, prepareBusinessDataOnAdjust, prepareBusinessDataOnBorrow, prepareBusinessDataOnClaim, prepareBusinessDataOnRemoveWallet, prepareBusinessDataOnRepayFromSupplied, prepareBusinessDataOnWithdraw, prepareBusinessDataOninnerWithdraw, prepare_sign_message_btc, prepare_sign_message_evm, prepare_sign_message_solana, process_signature_btc, process_signature_evm, process_signature_solana, query_account_register_token_tx, query_intents_tansfer_txs, serializationObj, setCustomNodeUrl, shrinkToken, shrinkTokenDecimal, submitSignedTransactionToRelayer, transformAccountFarms, transformAssetFarms, transformAssets, transformFarms, transformPortfolio, view_on_near };
1120
+ export { type AccountFarmRewardView, type Asset, type Assets, ChangeMethodsLogic, ChangeMethodsOracle, DEFAULT_POSITION, FRACTION_DIGITS, type Farm, type IAccountAllPositionsDetailed, type IAssetConfig, type IAssetDetailed, type IAssetFarm, type IAssetFarmReward, type IAssetFarmView, type IAssetPrice, type IAssetsView, type IBoosterStaking, type IBusiness, type IChain, type IConfig, type IExecutionResult, type IFarm, type IFarmId, type IFarms, type IGasData, type IIntentItem, type IIntentSwapDetails, type IIntentsQuote, type IIntentsQuoteResult, type ILendingData, type IMetadata, type IPool, type IPortfolioAssetOrigin, type IPositions, type IPositionsOrigin, type IPrice, type IPrices, type IPythInfo, type IPythPrice, type IRelayerResult, type ISimpleWithdraw, type IStatus, type IWallet, MAX_RATIO, NDeposit, NEAR_STORAGE_DEPOSIT, type Portfolio, type PortfolioAsset, type QuotationParams, TGas, TOKEN_STORAGE_DEPOSIT_READ, type TokenAction, ViewMethodsLogic, ViewMethodsOracle, ViewMethodsPyth, ViewMethodsToken, batchViews, computeRelayerGas, computeWithdrawMaxAmount, config_btc, config_evm, config_near, config_solana, decimalMax, decimalMin, expandToken, expandTokenDecimal, fetchIntentsQuotation, fetchIntentsTokens, fetchIntentsTransactionStatus, format_wallet, getAccountAllPositions, getAccountBalance, getAdjustedSum, getAllFarms, getAssets, getAssetsDetail, getAuthenticationHeaders, getBalance, getBoosterTokens, getBorrowMaxAmount, getCeateMcaFee, getConfig, getCreateMcaCustomRecipientMsg, getCreateMcaFeePaged, getListWalletsByMca, getMcaByWallet, getMultichainLendingConfig, getMultichainLendingData, getMultichainLendingHistory, getMultichainTokensByChains, getNearValue, getNearValuesPaged, getPrices, getRepayCustomRecipientMsg, getSignature, getSupplyCustomRecipientMsg, getTokenPythInfos, getWithdrawMaxAmount, get_all_tokens_metadata, get_interest_rate, get_liquidations, get_nonce_deadline, get_records, get_simple_withdraw_tx, get_token_detail, get_tx_id, hasZeroSharesFarmRewards, initialStaking, intentsQuotation, listFarmToMap, lpTokenPrefix, pollingRelayerTransactionResult, pollingTransactionStatus, postMultichainLendingReport, postMultichainLendingRequests, prepareBusinessDataOnAddWallet, prepareBusinessDataOnAdjust, prepareBusinessDataOnBorrow, prepareBusinessDataOnClaim, prepareBusinessDataOnRemoveWallet, prepareBusinessDataOnRepayFromSupplied, prepareBusinessDataOnWithdraw, prepareBusinessDataOninnerWithdraw, prepare_sign_message_btc, prepare_sign_message_evm, prepare_sign_message_solana, process_signature_btc, process_signature_evm, process_signature_solana, query_account_register_token_tx, query_intents_tansfer_txs, recomputeHealthFactorAdjust, recomputeHealthFactorBorrow, recomputeHealthFactorRepay, recomputeHealthFactorRepayFromDeposits, recomputeHealthFactorSupply, recomputeHealthFactorWithdraw, serializationObj, setCustomNodeUrl, shrinkToken, shrinkTokenDecimal, submitSignedTransactionToRelayer, transformAccountFarms, transformAssetFarms, transformAssets, transformFarms, transformPortfolio, view_on_near };