@strkfarm/sdk 1.0.37 → 1.0.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
@@ -1,60 +1,65 @@
1
- import { ContractAddr, Web3Number } from "@/dataTypes"
2
- import { BlockIdentifier, RpcProvider } from "starknet"
3
- import React from 'react';
1
+ import { ContractAddr, Web3Number } from "@/dataTypes";
2
+ import { BlockIdentifier, RpcProvider } from "starknet";
3
+ import React from "react";
4
4
 
5
5
  export enum RiskType {
6
- MARKET_RISK = 'Market Risk',
7
- // if non-correalted pairs, this is 3 (STRK/USDC)
8
- // if highly correalted pairs, this is 1 (e.g. xSTRK/STRK)
9
- // if correalted pairs, this is 2 (e.g. BTC/SOL)
10
- // If there is added leverage on top, can go till 5
11
- IMPERMANENT_LOSS = 'Impermanent Loss Risk',
12
- LIQUIDATION_RISK = 'Liquidation Risk',
13
- LOW_LIQUIDITY_RISK = 'Low Liquidity Risk',
14
- SMART_CONTRACT_RISK = 'Smart Contract Risk',
15
- ORACLE_RISK = 'Oracle Risk',
16
- TECHNICAL_RISK = 'Technical Risk',
17
- COUNTERPARTY_RISK = 'Counterparty Risk', // e.g. bad debt
6
+ MARKET_RISK = "Market Risk",
7
+ // if non-correalted pairs, this is 3 (STRK/USDC)
8
+ // if highly correalted pairs, this is 1 (e.g. xSTRK/STRK)
9
+ // if correalted pairs, this is 2 (e.g. BTC/SOL)
10
+ // If there is added leverage on top, can go till 5
11
+ IMPERMANENT_LOSS = "Impermanent Loss Risk",
12
+ LIQUIDATION_RISK = "Liquidation Risk",
13
+ LOW_LIQUIDITY_RISK = "Low Liquidity Risk",
14
+ SMART_CONTRACT_RISK = "Smart Contract Risk",
15
+ ORACLE_RISK = "Oracle Risk",
16
+ TECHNICAL_RISK = "Technical Risk",
17
+ COUNTERPARTY_RISK = "Counterparty Risk" // e.g. bad debt
18
18
  }
19
19
 
20
20
  export interface RiskFactor {
21
- type: RiskType,
22
- value: number, // 0 to 5
23
- weight: number // 0 to 100
21
+ type: RiskType;
22
+ value: number; // 0 to 5
23
+ weight: number; // 0 to 100
24
24
  }
25
25
 
26
26
  export interface TokenInfo {
27
- name: string,
28
- symbol: string,
29
- address: ContractAddr,
30
- decimals: number,
31
- logo: string,
32
- coingeckId?: string,
33
- displayDecimals: number
27
+ name: string;
28
+ symbol: string;
29
+ address: ContractAddr;
30
+ decimals: number;
31
+ logo: string;
32
+ coingeckId?: string;
33
+ displayDecimals: number;
34
34
  }
35
35
 
36
36
  export enum Network {
37
- mainnet = "mainnet",
38
- sepolia = "sepolia",
39
- devnet = "devnet"
37
+ mainnet = "mainnet",
38
+ sepolia = "sepolia",
39
+ devnet = "devnet"
40
40
  }
41
41
 
42
42
  export interface IConfig {
43
- provider: RpcProvider,
44
- network: Network,
45
- stage: 'production' | 'staging',
46
- heartbeatUrl?: string
43
+ provider: RpcProvider;
44
+ network: Network;
45
+ stage: "production" | "staging";
46
+ heartbeatUrl?: string;
47
47
  }
48
48
 
49
49
  export interface IProtocol {
50
- name: string,
51
- logo: string,
50
+ name: string;
51
+ logo: string;
52
52
  }
53
53
 
54
54
  export enum FlowChartColors {
55
- Green = 'purple',
56
- Blue = '#35484f',
57
- Purple = '#6e53dc',
55
+ Green = "purple",
56
+ Blue = "#35484f",
57
+ Purple = "#6e53dc"
58
+ }
59
+
60
+ export interface FAQ {
61
+ question: string | React.ReactNode;
62
+ answer: string | React.ReactNode;
58
63
  }
59
64
 
60
65
  /**
@@ -62,78 +67,86 @@ export enum FlowChartColors {
62
67
  * @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
63
68
  */
64
69
  export interface IStrategyMetadata<T> {
65
- name: string,
66
- description: string | React.ReactNode,
67
- address: ContractAddr,
68
- type: 'ERC4626' | 'ERC721' | 'Other',
69
- depositTokens: TokenInfo[],
70
- protocols: IProtocol[],
71
- auditUrl?: string,
72
- maxTVL: Web3Number,
73
- risk: {
74
- riskFactor: RiskFactor[],
75
- netRisk: number,
76
- notARisks: string[]
77
- },
78
- apyMethodology?: string,
79
- additionalInfo: T
70
+ name: string;
71
+ description: string | React.ReactNode;
72
+ address: ContractAddr;
73
+ type: "ERC4626" | "ERC721" | "Other";
74
+ depositTokens: TokenInfo[];
75
+ protocols: IProtocol[];
76
+ auditUrl?: string;
77
+ maxTVL: Web3Number;
78
+ risk: {
79
+ riskFactor: RiskFactor[];
80
+ netRisk: number;
81
+ notARisks: string[];
82
+ };
83
+ apyMethodology?: string;
84
+ additionalInfo: T;
85
+ faqs: FAQ[];
80
86
  }
81
87
 
82
88
  export interface IInvestmentFlow {
83
- id?: string, // used to link flows
84
- title: string,
85
- subItems: {key: string, value: string}[],
86
- linkedFlows: IInvestmentFlow[],
87
- style?: any
89
+ id?: string; // used to link flows
90
+ title: string;
91
+ subItems: { key: string; value: string }[];
92
+ linkedFlows: IInvestmentFlow[];
93
+ style?: any;
88
94
  }
89
95
 
90
- export function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier: BlockIdentifier = 'pending'): IConfig {
91
- return {
92
- provider: new RpcProvider({
93
- nodeUrl: rpcUrl,
94
- blockIdentifier: blockIdentifier
95
- }),
96
- stage: "production",
97
- network: Network.mainnet
98
- }
96
+ export function getMainnetConfig(
97
+ rpcUrl = "https://starknet-mainnet.public.blastapi.io",
98
+ blockIdentifier: BlockIdentifier = "pending"
99
+ ): IConfig {
100
+ return {
101
+ provider: new RpcProvider({
102
+ nodeUrl: rpcUrl,
103
+ blockIdentifier: blockIdentifier
104
+ }),
105
+ stage: "production",
106
+ network: Network.mainnet
107
+ };
99
108
  }
100
109
 
101
110
  export const getRiskExplaination = (riskType: RiskType) => {
102
- switch (riskType) {
103
- case RiskType.MARKET_RISK:
104
- return "The risk of the market moving against the position."
105
- case RiskType.IMPERMANENT_LOSS:
106
- return "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them."
107
- case RiskType.LIQUIDATION_RISK:
108
- return "The risk of losing funds due to the position being liquidated."
109
- case RiskType.LOW_LIQUIDITY_RISK:
110
- return "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position."
111
- case RiskType.ORACLE_RISK:
112
- return "The risk of the oracle being manipulated or incorrect."
113
- case RiskType.SMART_CONTRACT_RISK:
114
- return "The risk of the smart contract being vulnerable to attacks."
115
- case RiskType.TECHNICAL_RISK:
116
- return "The risk of technical issues e.g. backend failure."
117
- case RiskType.COUNTERPARTY_RISK:
118
- return "The risk of the counterparty defaulting e.g. bad debt on lending platforms."
119
- }
120
- }
111
+ switch (riskType) {
112
+ case RiskType.MARKET_RISK:
113
+ return "The risk of the market moving against the position.";
114
+ case RiskType.IMPERMANENT_LOSS:
115
+ return "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them.";
116
+ case RiskType.LIQUIDATION_RISK:
117
+ return "The risk of losing funds due to the position being liquidated.";
118
+ case RiskType.LOW_LIQUIDITY_RISK:
119
+ return "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position.";
120
+ case RiskType.ORACLE_RISK:
121
+ return "The risk of the oracle being manipulated or incorrect.";
122
+ case RiskType.SMART_CONTRACT_RISK:
123
+ return "The risk of the smart contract being vulnerable to attacks.";
124
+ case RiskType.TECHNICAL_RISK:
125
+ return "The risk of technical issues e.g. backend failure.";
126
+ case RiskType.COUNTERPARTY_RISK:
127
+ return "The risk of the counterparty defaulting e.g. bad debt on lending platforms.";
128
+ }
129
+ };
121
130
 
122
131
  export const getRiskColor = (risk: RiskFactor) => {
123
- const value = risk.value;
124
- if (value === 0) return 'green';
125
- if (value < 2.5) return 'yellow';
126
- return 'red';
127
- }
132
+ const value = risk.value;
133
+ if (value === 0) return "green";
134
+ if (value < 2.5) return "yellow";
135
+ return "red";
136
+ };
128
137
 
129
138
  export const getNoRiskTags = (risks: RiskFactor[]) => {
130
- const noRisks1 = risks.filter(risk => risk.value === 0).map(risk => risk.type);
139
+ const noRisks1 = risks
140
+ .filter((risk) => risk.value === 0)
141
+ .map((risk) => risk.type);
142
+
143
+ // const risks not present
144
+ const noRisks2 = Object.values(RiskType).filter(
145
+ (risk) => !risks.map((risk) => risk.type).includes(risk)
146
+ );
131
147
 
132
- // const risks not present
133
- const noRisks2 = Object.values(RiskType).filter(risk => !risks.map(risk => risk.type).includes(risk));
148
+ const mergedUnique = [...new Set([...noRisks1, ...noRisks2])];
134
149
 
135
- const mergedUnique = [...new Set([...noRisks1, ...noRisks2])];
136
-
137
- // add `No` to the start of each risk
138
- return mergedUnique.map(risk => `No ${risk}`);
139
- }
150
+ // add `No` to the start of each risk
151
+ return mergedUnique.map((risk) => `No ${risk}`);
152
+ };