@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/dist/cli.js +236 -112
- package/dist/cli.mjs +241 -113
- package/dist/index.browser.global.js +869 -312
- package/dist/index.browser.mjs +870 -309
- package/dist/index.d.ts +9 -4
- package/dist/index.js +865 -308
- package/dist/index.mjs +870 -309
- package/package.json +1 -1
- package/src/interfaces/common.ts +111 -98
- package/src/strategies/ekubo-cl-vault.tsx +1434 -923
- package/src/strategies/vesu-rebalance.tsx +937 -610
package/package.json
CHANGED
package/src/interfaces/common.ts
CHANGED
|
@@ -1,60 +1,65 @@
|
|
|
1
|
-
import { ContractAddr, Web3Number } from "@/dataTypes"
|
|
2
|
-
import { BlockIdentifier, RpcProvider } from "starknet"
|
|
3
|
-
import React from
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
mainnet = "mainnet",
|
|
38
|
+
sepolia = "sepolia",
|
|
39
|
+
devnet = "devnet"
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export interface IConfig {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
provider: RpcProvider;
|
|
44
|
+
network: Network;
|
|
45
|
+
stage: "production" | "staging";
|
|
46
|
+
heartbeatUrl?: string;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export interface IProtocol {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
name: string;
|
|
51
|
+
logo: string;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export enum FlowChartColors {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
+
};
|