@strkfarm/sdk 1.0.55 → 1.0.56

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.ts CHANGED
@@ -1,8 +1,13 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import * as starknet from 'starknet';
3
- import { RpcProvider, BlockIdentifier, Contract, Uint256, Call, Account } from 'starknet';
3
+ import { RpcProvider, BlockIdentifier, Contract, Uint256, Call, Account, CairoCustomEnum, RawArgs } from 'starknet';
4
4
  import React, { ReactNode } from 'react';
5
5
  import { Quote } from '@avnu/avnu-sdk';
6
+ import { HexString, BytesLike } from '@ericnordelo/strk-merkle-tree/dist/bytes';
7
+ import { MultiProof } from '@ericnordelo/strk-merkle-tree/dist/core';
8
+ import { MerkleTreeImpl, MerkleTreeData } from '@ericnordelo/strk-merkle-tree/dist/merkletree';
9
+ import { MerkleTreeOptions } from '@ericnordelo/strk-merkle-tree/dist/options';
10
+ import { ValueType } from '@ericnordelo/strk-merkle-tree/dist/serde';
6
11
  import TelegramBot from 'node-telegram-bot-api';
7
12
 
8
13
  declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
@@ -40,6 +45,7 @@ declare class ContractAddr {
40
45
  static standardise(address: string | bigint): string;
41
46
  static eqString(a: string, b: string): boolean;
42
47
  toString(): string;
48
+ toBigInt(): bigint;
43
49
  }
44
50
 
45
51
  declare enum RiskType {
@@ -67,6 +73,7 @@ interface TokenInfo {
67
73
  logo: string;
68
74
  coingeckId?: string;
69
75
  displayDecimals: number;
76
+ priceCheckAmount?: number;
70
77
  }
71
78
  declare enum Network {
72
79
  mainnet = "mainnet",
@@ -137,7 +144,7 @@ interface IInvestmentFlow {
137
144
  linkedFlows: IInvestmentFlow[];
138
145
  style?: any;
139
146
  }
140
- declare function getMainnetConfig(rpcUrl: string, blockIdentifier?: BlockIdentifier): IConfig;
147
+ declare function getMainnetConfig(rpcUrl?: string, blockIdentifier?: BlockIdentifier): IConfig;
141
148
  declare const getRiskExplaination: (riskType: RiskType) => "The risk of the market moving against the position." | "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them." | "The risk of losing funds due to the position being liquidated." | "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position." | "The risk of the oracle being manipulated or incorrect." | "The risk of the smart contract being vulnerable to attacks." | "The risk of technical issues e.g. backend failure." | "The risk of the counterparty defaulting e.g. bad debt on lending platforms." | "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
142
149
  declare const getRiskColor: (risk: RiskFactor) => "light_green_2" | "yellow" | "red";
143
150
  declare const getNoRiskTags: (risks: RiskFactor[]) => RiskType[];
@@ -146,6 +153,15 @@ interface HighlightLink {
146
153
  link: string;
147
154
  }
148
155
  declare function highlightTextWithLinks(put: string, highlights: HighlightLink[]): ReactNode;
156
+ interface VaultPosition {
157
+ amount: Web3Number;
158
+ usdValue: number;
159
+ token: TokenInfo;
160
+ remarks: string;
161
+ }
162
+ declare const Protocols: {
163
+ VESU: IProtocol;
164
+ };
149
165
 
150
166
  interface ILendingMetadata {
151
167
  name: string;
@@ -320,12 +336,19 @@ declare class FatalError extends Error {
320
336
  * - fatalError: Things to do when a fatal error occurs
321
337
  */
322
338
  declare class Global {
339
+ static cache: Record<string, {
340
+ value: any;
341
+ ttl: number;
342
+ timestamp: number;
343
+ }>;
323
344
  static fatalError(message: string, err?: Error): void;
324
345
  static httpError(url: string, err: Error, message?: string): void;
325
346
  static getDefaultTokens(): TokenInfo[];
326
347
  static getTokens(): Promise<TokenInfo[]>;
327
348
  static assert(condition: any, message: string): void;
328
349
  static getTokenInfoFromAddr(addr: ContractAddr): Promise<TokenInfo>;
350
+ static setGlobalCache(key: string, data: any, ttl?: number): void;
351
+ static getGlobalCache<T>(key: string): T | null;
329
352
  }
330
353
 
331
354
  declare class AutoCompounderSTRK {
@@ -815,14 +838,6 @@ declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmou
815
838
  }
816
839
  declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
817
840
 
818
- declare class TelegramNotif {
819
- private subscribers;
820
- readonly bot: TelegramBot;
821
- constructor(token: string, shouldPoll: boolean);
822
- activateChatBot(): void;
823
- sendMessage(msg: string): void;
824
- }
825
-
826
841
  interface LeveledLogMethod {
827
842
  (message: string, ...meta: any[]): void;
828
843
  (message: any): void;
@@ -836,6 +851,27 @@ interface MyLogger {
836
851
  }
837
852
  declare const logger: MyLogger;
838
853
 
854
+ interface LeafData {
855
+ id: bigint;
856
+ readableId: string;
857
+ data: bigint[];
858
+ }
859
+ interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
860
+ format: 'standard-v1';
861
+ leafEncoding: ValueType[];
862
+ }
863
+ declare class StandardMerkleTree extends MerkleTreeImpl<LeafData> {
864
+ protected readonly tree: HexString[];
865
+ protected readonly values: StandardMerkleTreeData<LeafData>['values'];
866
+ protected readonly leafEncoding: ValueType[];
867
+ protected constructor(tree: HexString[], values: StandardMerkleTreeData<LeafData>['values'], leafEncoding: ValueType[]);
868
+ static of(values: LeafData[], leafEncoding?: ValueType[], options?: MerkleTreeOptions): StandardMerkleTree;
869
+ static load(data: StandardMerkleTreeData<LeafData>): StandardMerkleTree;
870
+ static verify<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], leaf: T, proof: BytesLike[]): boolean;
871
+ static verifyMultiProof<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], multiproof: MultiProof<BytesLike, T>): boolean;
872
+ dump(): StandardMerkleTreeData<LeafData>;
873
+ }
874
+
839
875
  type RequiredFields<T> = {
840
876
  [K in keyof T]-?: T[K];
841
877
  };
@@ -845,6 +881,233 @@ type RequiredKeys<T> = {
845
881
  declare function assert(condition: boolean, message: string): void;
846
882
  declare function getTrovesEndpoint(): string;
847
883
 
884
+ interface ManageCall {
885
+ sanitizer: ContractAddr;
886
+ call: {
887
+ contractAddress: ContractAddr;
888
+ selector: string;
889
+ calldata: bigint[];
890
+ };
891
+ }
892
+ type GenerateCallFn<T> = (params: T) => ManageCall;
893
+ type AdapterLeafType<T> = {
894
+ leaf: LeafData;
895
+ callConstructor: GenerateCallFn<T>;
896
+ };
897
+ type LeafAdapterFn<T> = () => AdapterLeafType<T>;
898
+ declare class BaseAdapter {
899
+ protected constructSimpleLeafData(params: {
900
+ id: string;
901
+ target: ContractAddr;
902
+ method: string;
903
+ packedArguments: bigint[];
904
+ }): LeafData;
905
+ }
906
+
907
+ interface FlashloanCallParams {
908
+ amount: Web3Number;
909
+ data: bigint[];
910
+ }
911
+ interface ApproveCallParams {
912
+ amount: Web3Number;
913
+ }
914
+ interface CommonAdapterConfig {
915
+ id: string;
916
+ manager: ContractAddr;
917
+ asset: ContractAddr;
918
+ }
919
+ declare class CommonAdapter extends BaseAdapter {
920
+ config: CommonAdapterConfig;
921
+ constructor(config: CommonAdapterConfig);
922
+ getFlashloanAdapter(): AdapterLeafType<FlashloanCallParams>;
923
+ getFlashloanCall(params: FlashloanCallParams): ManageCall;
924
+ getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams>;
925
+ getApproveCall(token: ContractAddr, spender: ContractAddr): (params: ApproveCallParams) => {
926
+ sanitizer: ContractAddr;
927
+ call: {
928
+ contractAddress: ContractAddr;
929
+ selector: string;
930
+ calldata: bigint[];
931
+ };
932
+ };
933
+ }
934
+
935
+ interface VesuPoolsInfo {
936
+ pools: any[];
937
+ isErrorPoolsAPI: boolean;
938
+ }
939
+ declare enum VesuAmountType {
940
+ Delta = 0,
941
+ Target = 1
942
+ }
943
+ declare enum VesuAmountDenomination {
944
+ Native = 0,
945
+ Assets = 1
946
+ }
947
+ interface i257 {
948
+ abs: Web3Number;
949
+ is_negative: boolean;
950
+ }
951
+ interface VesuAmount {
952
+ amount_type: VesuAmountType;
953
+ denomination: VesuAmountDenomination;
954
+ value: i257;
955
+ }
956
+ interface VesuModifyPositionCallParams {
957
+ collateralAmount: VesuAmount;
958
+ debtAmount: VesuAmount;
959
+ }
960
+ interface VesuAdapterConfig {
961
+ poolId: ContractAddr;
962
+ collateral: TokenInfo;
963
+ debt: TokenInfo;
964
+ vaultAllocator: ContractAddr;
965
+ id: string;
966
+ }
967
+ declare const VesuPools: {
968
+ Genesis: ContractAddr;
969
+ };
970
+ declare class VesuAdapter extends BaseAdapter {
971
+ VESU_SINGLETON: ContractAddr;
972
+ config: VesuAdapterConfig;
973
+ networkConfig: IConfig | undefined;
974
+ pricer: PricerBase | undefined;
975
+ cache: Record<string, any>;
976
+ constructor(config: VesuAdapterConfig);
977
+ getModifyPosition: () => AdapterLeafType<VesuModifyPositionCallParams>;
978
+ static getDefaultModifyPositionCallParams(params: {
979
+ collateralAmount: Web3Number;
980
+ isAddCollateral: boolean;
981
+ debtAmount: Web3Number;
982
+ isBorrow: boolean;
983
+ }): {
984
+ collateralAmount: {
985
+ amount_type: VesuAmountType;
986
+ denomination: VesuAmountDenomination;
987
+ value: {
988
+ abs: Web3Number;
989
+ is_negative: boolean;
990
+ };
991
+ };
992
+ debtAmount: {
993
+ amount_type: VesuAmountType;
994
+ denomination: VesuAmountDenomination;
995
+ value: {
996
+ abs: Web3Number;
997
+ is_negative: boolean;
998
+ };
999
+ };
1000
+ };
1001
+ getModifyPositionCall: (params: VesuModifyPositionCallParams) => ManageCall;
1002
+ formatAmountTypeEnum(amountType: VesuAmountType): CairoCustomEnum;
1003
+ formatAmountDenominationEnum(denomination: VesuAmountDenomination): CairoCustomEnum;
1004
+ getVesuSingletonContract(config: IConfig): Contract;
1005
+ getLTVConfig(config: IConfig): Promise<number>;
1006
+ getPositions(config: IConfig): Promise<VaultPosition[]>;
1007
+ static getVesuPools(retry?: number): Promise<VesuPoolsInfo>;
1008
+ }
1009
+
1010
+ interface UniversalStrategySettings {
1011
+ manager: ContractAddr;
1012
+ vaultAllocator: ContractAddr;
1013
+ redeemRequestNFT: ContractAddr;
1014
+ leafAdapters: LeafAdapterFn<any>[];
1015
+ adapters: {
1016
+ id: string;
1017
+ adapter: BaseAdapter;
1018
+ }[];
1019
+ }
1020
+ declare class UniversalStrategy<S extends UniversalStrategySettings> extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1021
+ /** Contract address of the strategy */
1022
+ readonly address: ContractAddr;
1023
+ /** Pricer instance for token price calculations */
1024
+ readonly pricer: PricerBase;
1025
+ /** Metadata containing strategy information */
1026
+ readonly metadata: IStrategyMetadata<S>;
1027
+ /** Contract instance for interacting with the strategy */
1028
+ readonly contract: Contract;
1029
+ readonly managerContract: Contract;
1030
+ merkleTree: StandardMerkleTree | undefined;
1031
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
1032
+ getMerkleTree(): StandardMerkleTree;
1033
+ getMerkleRoot(): string;
1034
+ getProofs<T>(id: string): {
1035
+ proofs: string[];
1036
+ callConstructor: GenerateCallFn<T>;
1037
+ };
1038
+ getAdapter(id: string): BaseAdapter;
1039
+ asset(): TokenInfo;
1040
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
1041
+ /**
1042
+ * Calculates the Total Value Locked (TVL) for a specific user.
1043
+ * @param user - Address of the user
1044
+ * @returns Object containing the amount in token units and USD value
1045
+ */
1046
+ getUserTVL(user: ContractAddr): Promise<{
1047
+ tokenInfo: TokenInfo;
1048
+ amount: Web3Number;
1049
+ usdValue: number;
1050
+ }>;
1051
+ /**
1052
+ * Calculates the weighted average APY across all pools based on USD value.
1053
+ * @returns {Promise<number>} The weighted average APY across all pools
1054
+ */
1055
+ netAPY(): Promise<number>;
1056
+ /**
1057
+ * Calculates the total TVL of the strategy.
1058
+ * @returns Object containing the total amount in token units and USD value
1059
+ */
1060
+ getTVL(): Promise<{
1061
+ tokenInfo: TokenInfo;
1062
+ amount: Web3Number;
1063
+ usdValue: number;
1064
+ }>;
1065
+ getAUM(): Promise<SingleTokenInfo>;
1066
+ getVesuAdapters(): VesuAdapter[];
1067
+ getVaultPositions(): Promise<VaultPosition[]>;
1068
+ getSetManagerCall(strategist: ContractAddr, root?: string): Call;
1069
+ getManageCall(proofIds: string[], manageCalls: ManageCall[]): Call;
1070
+ getVesuModifyPositionCalls(params: {
1071
+ isLeg1: boolean;
1072
+ isDeposit: boolean;
1073
+ depositAmount: Web3Number;
1074
+ debtAmount: Web3Number;
1075
+ }): {
1076
+ proofs: string[];
1077
+ manageCall: ManageCall;
1078
+ }[];
1079
+ getTag(): string;
1080
+ getVesuMultiplyCall(params: {
1081
+ isDeposit: boolean;
1082
+ leg1DepositAmount: Web3Number;
1083
+ }): Promise<Call>;
1084
+ getRebalanceCall(params: {
1085
+ isLeg1toLeg2: boolean;
1086
+ amount: Web3Number;
1087
+ }): Promise<Call>;
1088
+ }
1089
+ declare enum UNIVERSAL_MANAGE_IDS {
1090
+ FLASH_LOAN = "flash_loan_init",
1091
+ VESU_LEG1 = "vesu_leg1",
1092
+ VESU_LEG2 = "vesu_leg2",
1093
+ APPROVE_TOKEN1 = "approve_token1",
1094
+ APPROVE_TOKEN2 = "approve_token2"
1095
+ }
1096
+ declare enum UNIVERSAL_ADAPTERS {
1097
+ COMMON = "common_adapter",
1098
+ VESU_LEG1 = "vesu_leg1_adapter",
1099
+ VESU_LEG2 = "vesu_leg2_adapter"
1100
+ }
1101
+ declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[];
1102
+
1103
+ declare class TelegramNotif {
1104
+ private subscribers;
1105
+ readonly bot: TelegramBot;
1106
+ constructor(token: string, shouldPoll: boolean);
1107
+ activateChatBot(): void;
1108
+ sendMessage(msg: string): void;
1109
+ }
1110
+
848
1111
  declare class PricerRedis extends Pricer {
849
1112
  private redisClient;
850
1113
  constructor(config: IConfig, tokens: TokenInfo[]);
@@ -860,6 +1123,37 @@ declare class PricerRedis extends Pricer {
860
1123
 
861
1124
  declare function getAPIUsingHeadlessBrowser(url: string): Promise<any>;
862
1125
 
1126
+ declare function getAccount(accountKey: string, config: IConfig, password?: string | undefined, accountsFileName?: string, secretFileFolder?: string): Account;
1127
+ declare function myDeclare(contract_name: string, package_name: string | undefined, config: IConfig, acc: Account): Promise<{
1128
+ transaction_hash: string;
1129
+ class_hash: string;
1130
+ }>;
1131
+ declare function deployContract(contract_name: string, classHash: string, constructorData: RawArgs, config: IConfig, acc: Account): Promise<starknet.DeployContractUDCResponse>;
1132
+ interface DeployContractResult {
1133
+ contract_name: string;
1134
+ package_name: string;
1135
+ class_hash: string;
1136
+ call: Call;
1137
+ address: string;
1138
+ }
1139
+ declare function prepareMultiDeployContracts(contracts: Array<{
1140
+ contract_name: string;
1141
+ package_name: string;
1142
+ constructorData: RawArgs;
1143
+ }>, config: IConfig, acc: Account): Promise<DeployContractResult[]>;
1144
+ declare function executeDeployCalls(contractsInfo: DeployContractResult[], acc: Account, provider: RpcProvider): Promise<void>;
1145
+ declare function executeTransactions(calls: Call[], acc: Account, provider: RpcProvider, remarks?: string): Promise<{
1146
+ transaction_hash: string;
1147
+ }>;
1148
+ declare const Deployer: {
1149
+ getAccount: typeof getAccount;
1150
+ myDeclare: typeof myDeclare;
1151
+ deployContract: typeof deployContract;
1152
+ prepareMultiDeployContracts: typeof prepareMultiDeployContracts;
1153
+ executeDeployCalls: typeof executeDeployCalls;
1154
+ executeTransactions: typeof executeTransactions;
1155
+ };
1156
+
863
1157
  /**
864
1158
  * @description Config to manage storage of files on disk
865
1159
  * @param SECRET_FILE_FOLDER - Folder to store secret files (default: ~/.starknet-store)
@@ -938,4 +1232,4 @@ declare class PasswordJsonCryptoUtil {
938
1232
  decrypt(encryptedData: string, password: string): any;
939
1233
  }
940
1234
 
941
- export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, AvnuWrapper, BaseStrategy, type CLVaultStrategySettings, ContractAddr, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type FAQ, FatalError, FlowChartColors, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LendingToken, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, Store, type StoreConfig, type SwapInfo, TelegramNotif, type TokenInfo, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, highlightTextWithLinks, logger };
1235
+ export { type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, AvnuWrapper, BaseAdapter, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type SwapInfo, TelegramNotif, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuModifyPositionCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, highlightTextWithLinks, type i257, logger };