@strkfarm/sdk 1.2.0 → 2.0.0-dev-strategy2.1
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.browser.global.js +76556 -66640
- package/dist/index.browser.mjs +34235 -24392
- package/dist/index.d.ts +2372 -793
- package/dist/index.js +31967 -22084
- package/dist/index.mjs +25545 -15719
- package/package.json +86 -76
- package/readme.md +56 -1
- package/src/data/extended-deposit.abi.json +3613 -0
- package/src/data/universal-vault.abi.json +135 -20
- package/src/dataTypes/_bignumber.ts +11 -0
- package/src/dataTypes/address.ts +7 -0
- package/src/global.ts +240 -193
- package/src/interfaces/common.tsx +26 -2
- package/src/modules/ExtendedWrapperSDk/index.ts +62 -0
- package/src/modules/ExtendedWrapperSDk/types.ts +311 -0
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +448 -0
- package/src/modules/avnu.ts +17 -4
- package/src/modules/ekubo-quoter.ts +89 -10
- package/src/modules/erc20.ts +67 -21
- package/src/modules/harvests.ts +29 -43
- package/src/modules/index.ts +5 -1
- package/src/modules/lst-apr.ts +36 -0
- package/src/modules/midas.ts +159 -0
- package/src/modules/pricer-from-api.ts +2 -2
- package/src/modules/pricer-lst.ts +1 -1
- package/src/modules/pricer.ts +3 -38
- package/src/modules/token-market-data.ts +202 -0
- package/src/node/deployer.ts +1 -36
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/base-strategy.ts +20 -3
- package/src/strategies/btc-vesu-extended-strategy/core-strategy.tsx +1486 -0
- package/src/strategies/btc-vesu-extended-strategy/services/operationService.ts +32 -0
- package/src/strategies/btc-vesu-extended-strategy/utils/constants.ts +3 -0
- package/src/strategies/btc-vesu-extended-strategy/utils/helper.ts +396 -0
- package/src/strategies/btc-vesu-extended-strategy/utils/types.ts +5 -0
- package/src/strategies/ekubo-cl-vault.tsx +123 -306
- package/src/strategies/index.ts +7 -1
- package/src/strategies/svk-strategy.ts +247 -0
- package/src/strategies/universal-adapters/adapter-optimizer.ts +65 -0
- package/src/strategies/universal-adapters/adapter-utils.ts +5 -1
- package/src/strategies/universal-adapters/avnu-adapter.ts +432 -0
- package/src/strategies/universal-adapters/baseAdapter.ts +181 -153
- package/src/strategies/universal-adapters/common-adapter.ts +98 -77
- package/src/strategies/universal-adapters/extended-adapter.ts +976 -0
- package/src/strategies/universal-adapters/index.ts +7 -1
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +109 -0
- package/src/strategies/universal-adapters/vesu-adapter.ts +230 -230
- package/src/strategies/universal-adapters/vesu-borrow-adapter.ts +1247 -0
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +1306 -0
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +58 -51
- package/src/strategies/universal-lst-muliplier-strategy.tsx +716 -844
- package/src/strategies/universal-strategy.tsx +1103 -1181
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +34 -0
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +25 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +77 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +50 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +367 -0
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +1420 -0
- package/src/strategies/vesu-rebalance.tsx +16 -20
- package/src/utils/health-factor-math.ts +11 -5
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export * from "./baseAdapter";
|
|
2
2
|
export * from "./common-adapter";
|
|
3
3
|
export * from "./vesu-adapter";
|
|
4
|
-
export * from "./adapter
|
|
4
|
+
export * from "./vesu-supply-only-adapter";
|
|
5
|
+
export * from "./vesu-multiply-adapter";
|
|
6
|
+
export * from "./extended-adapter";
|
|
7
|
+
export * from "./adapter-utils";
|
|
8
|
+
export * from "./unused-balance-adapter";
|
|
9
|
+
export * from "./avnu-adapter";
|
|
10
|
+
export * from "./vesu-borrow-adapter";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ContractAddr, Web3Number } from "@/dataTypes";
|
|
2
|
+
import { APYType, BaseAdapter, BaseAdapterConfig, DepositParams, ManageCall, PositionAmount, PositionAPY, PositionInfo, SupportedPosition, WithdrawParams } from "./baseAdapter";
|
|
3
|
+
import { Contract, uint256 } from "starknet";
|
|
4
|
+
import erc20Abi from "@/data/erc20.abi.json";
|
|
5
|
+
import { ERC20, TokenMarketData } from "@/modules";
|
|
6
|
+
import { Protocols } from "@/interfaces";
|
|
7
|
+
|
|
8
|
+
export interface UnusedBalanceAdapterConfig extends BaseAdapterConfig {}
|
|
9
|
+
|
|
10
|
+
export class UnusedBalanceAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
11
|
+
readonly config: UnusedBalanceAdapterConfig;
|
|
12
|
+
readonly tokenMarketData: TokenMarketData;
|
|
13
|
+
|
|
14
|
+
constructor(config: UnusedBalanceAdapterConfig) {
|
|
15
|
+
super(config, UnusedBalanceAdapter.name, Protocols.NONE);
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.tokenMarketData = new TokenMarketData(this.config.pricer, this.config.networkConfig);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected async getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY> {
|
|
21
|
+
const isSupported = this.tokenMarketData.isAPYSupported(this.config.baseToken);
|
|
22
|
+
const apy = isSupported ? await this.tokenMarketData.getAPY(this.config.baseToken) : 0;
|
|
23
|
+
return { apy: apy, type: isSupported ? APYType.LST : APYType.BASE };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected async getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount> {
|
|
27
|
+
try {
|
|
28
|
+
const balance = await (new ERC20(this.config.networkConfig)).balanceOf(supportedPosition.asset.address, this.config.vaultAllocator.address, supportedPosition.asset.decimals);
|
|
29
|
+
return {
|
|
30
|
+
amount: balance,
|
|
31
|
+
remarks: "Unused balance"
|
|
32
|
+
}
|
|
33
|
+
} catch (_e) {
|
|
34
|
+
throw new Error(`${UnusedBalanceAdapter.name}: Failed to get position for ${supportedPosition.asset.symbol}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async maxDeposit(amount?: Web3Number): Promise<PositionInfo> {
|
|
39
|
+
const baseToken = this.config.baseToken;
|
|
40
|
+
if (!amount) {
|
|
41
|
+
const infinite = new Web3Number('999999999999999999999999999', baseToken.decimals);
|
|
42
|
+
return {
|
|
43
|
+
tokenInfo: baseToken,
|
|
44
|
+
amount: infinite,
|
|
45
|
+
usdValue: Number.POSITIVE_INFINITY,
|
|
46
|
+
remarks: "Max deposit (infinity)",
|
|
47
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
48
|
+
protocol: this.protocol
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const usdValue = await this.getUSDValue(baseToken, amount);
|
|
52
|
+
return {
|
|
53
|
+
tokenInfo: baseToken,
|
|
54
|
+
amount,
|
|
55
|
+
usdValue,
|
|
56
|
+
remarks: "Deposit amount",
|
|
57
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
58
|
+
protocol: this.protocol
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async maxWithdraw(): Promise<PositionInfo> {
|
|
63
|
+
const baseToken = this.config.baseToken;
|
|
64
|
+
const current = await this.getPosition({ asset: baseToken, isDebt: false });
|
|
65
|
+
const usdValue = await this.getUSDValue(baseToken, current.amount);
|
|
66
|
+
return {
|
|
67
|
+
tokenInfo: baseToken,
|
|
68
|
+
amount: current.amount,
|
|
69
|
+
usdValue,
|
|
70
|
+
remarks: "Max withdraw",
|
|
71
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
72
|
+
protocol: this.protocol
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected _getDepositLeaf(): {
|
|
77
|
+
target: ContractAddr,
|
|
78
|
+
method: string,
|
|
79
|
+
packedArguments: bigint[];
|
|
80
|
+
sanitizer: ContractAddr,
|
|
81
|
+
id: string
|
|
82
|
+
}[] {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected _getWithdrawLeaf(): {
|
|
87
|
+
target: ContractAddr,
|
|
88
|
+
method: string,
|
|
89
|
+
packedArguments: bigint[];
|
|
90
|
+
sanitizer: ContractAddr,
|
|
91
|
+
id: string
|
|
92
|
+
}[] {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async getHealthFactor(): Promise<number> {
|
|
97
|
+
return Promise.resolve(10);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getDepositCall(params: DepositParams): Promise<ManageCall[]> {
|
|
101
|
+
return Promise.resolve([]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]> {
|
|
105
|
+
return Promise.resolve([]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|