@strkfarm/sdk 1.0.16 → 1.0.18
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 +18 -5
- package/dist/cli.mjs +18 -11
- package/dist/index.browser.global.js +122 -2349
- package/dist/index.browser.mjs +2592 -0
- package/dist/index.d.ts +91 -42
- package/dist/index.js +129 -20
- package/dist/index.mjs +126 -26
- package/package.json +15 -8
- package/src/global.ts +2 -0
- package/src/interfaces/common.ts +41 -2
- package/src/modules/index.ts +2 -1
- package/src/modules/pricer-from-api.ts +61 -0
- package/src/modules/pricer.ts +7 -19
- package/src/modules/pricerBase.ts +15 -0
- package/src/modules/zkLend.ts +1 -0
- package/src/node/pricer-redis.ts +1 -0
- package/src/strategies/vesu-rebalance.ts +43 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
1
2
|
import * as starknet from 'starknet';
|
|
2
3
|
import { RpcProvider, BlockIdentifier, Contract, Account } from 'starknet';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
4
4
|
import * as util from 'util';
|
|
5
5
|
import TelegramBot from 'node-telegram-bot-api';
|
|
6
6
|
|
|
@@ -30,11 +30,25 @@ declare class ContractAddr {
|
|
|
30
30
|
static eqString(a: string, b: string): boolean;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
declare enum RiskType {
|
|
34
|
+
MARKET_RISK = "MARKET_RISK",
|
|
35
|
+
IMPERMANENT_LOSS = "IMPERMANENT_LOSS",
|
|
36
|
+
LIQUIDITY_RISK = "LIQUIDITY_RISK",
|
|
37
|
+
SMART_CONTRACT_RISK = "SMART_CONTRACT_RISK",
|
|
38
|
+
TECHNICAL_RISK = "TECHNICAL_RISK",
|
|
39
|
+
COUNTERPARTY_RISK = "COUNTERPARTY_RISK"
|
|
40
|
+
}
|
|
41
|
+
interface RiskFactor {
|
|
42
|
+
type: RiskType;
|
|
43
|
+
value: number;
|
|
44
|
+
weight: number;
|
|
45
|
+
}
|
|
33
46
|
interface TokenInfo {
|
|
34
47
|
name: string;
|
|
35
48
|
symbol: string;
|
|
36
49
|
address: string;
|
|
37
50
|
decimals: number;
|
|
51
|
+
logo: string;
|
|
38
52
|
coingeckId?: string;
|
|
39
53
|
}
|
|
40
54
|
declare enum Network {
|
|
@@ -52,6 +66,15 @@ interface IProtocol {
|
|
|
52
66
|
name: string;
|
|
53
67
|
logo: string;
|
|
54
68
|
}
|
|
69
|
+
declare enum FlowChartColors {
|
|
70
|
+
Green = "purple",
|
|
71
|
+
Blue = "#35484f",
|
|
72
|
+
Purple = "#6e53dc"
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
|
|
76
|
+
* @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
|
|
77
|
+
*/
|
|
55
78
|
interface IStrategyMetadata {
|
|
56
79
|
name: string;
|
|
57
80
|
description: string;
|
|
@@ -59,49 +82,23 @@ interface IStrategyMetadata {
|
|
|
59
82
|
type: 'ERC4626' | 'ERC721' | 'Other';
|
|
60
83
|
depositTokens: TokenInfo[];
|
|
61
84
|
protocols: IProtocol[];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
timestamp: Date;
|
|
68
|
-
}
|
|
69
|
-
declare abstract class PricerBase {
|
|
70
|
-
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
71
|
-
}
|
|
72
|
-
declare class Pricer implements PricerBase {
|
|
73
|
-
readonly config: IConfig;
|
|
74
|
-
readonly tokens: TokenInfo[];
|
|
75
|
-
protected prices: {
|
|
76
|
-
[key: string]: PriceInfo;
|
|
85
|
+
auditUrl?: string;
|
|
86
|
+
maxTVL: Web3Number;
|
|
87
|
+
risk: {
|
|
88
|
+
riskFactor: RiskFactor[];
|
|
89
|
+
netRisk: number;
|
|
77
90
|
};
|
|
78
|
-
private methodToUse;
|
|
79
|
-
/**
|
|
80
|
-
* TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
|
|
81
|
-
*/
|
|
82
|
-
protected PRICE_API: string;
|
|
83
|
-
protected EKUBO_API: string;
|
|
84
|
-
protected client: any;
|
|
85
|
-
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
86
|
-
isReady(): boolean;
|
|
87
|
-
waitTillReady(): Promise<void>;
|
|
88
|
-
start(): void;
|
|
89
|
-
isStale(timestamp: Date, tokenName: string): boolean;
|
|
90
|
-
assertNotStale(timestamp: Date, tokenName: string): void;
|
|
91
|
-
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
92
|
-
protected _loadPrices(onUpdate?: (tokenSymbol: string) => void): void;
|
|
93
|
-
_getPrice(token: TokenInfo, defaultMethod?: string): Promise<number>;
|
|
94
|
-
_getPriceCoinbase(token: TokenInfo): Promise<number>;
|
|
95
|
-
_getPriceCoinMarketCap(token: TokenInfo): Promise<number>;
|
|
96
|
-
_getPriceEkubo(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
|
|
97
91
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
interface IInvestmentFlow {
|
|
93
|
+
title: string;
|
|
94
|
+
subItems: {
|
|
95
|
+
key: string;
|
|
96
|
+
value: string;
|
|
97
|
+
}[];
|
|
98
|
+
linkedFlows: IInvestmentFlow[];
|
|
99
|
+
style?: any;
|
|
104
100
|
}
|
|
101
|
+
declare function getMainnetConfig(rpcUrl?: string, blockIdentifier?: BlockIdentifier): IConfig;
|
|
105
102
|
|
|
106
103
|
interface ILendingMetadata {
|
|
107
104
|
name: string;
|
|
@@ -155,6 +152,48 @@ declare abstract class Initializable {
|
|
|
155
152
|
waitForInitilisation(): Promise<void>;
|
|
156
153
|
}
|
|
157
154
|
|
|
155
|
+
declare abstract class PricerBase {
|
|
156
|
+
readonly config: IConfig;
|
|
157
|
+
readonly tokens: TokenInfo[];
|
|
158
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
159
|
+
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface PriceInfo {
|
|
163
|
+
price: number;
|
|
164
|
+
timestamp: Date;
|
|
165
|
+
}
|
|
166
|
+
declare class Pricer extends PricerBase {
|
|
167
|
+
protected prices: {
|
|
168
|
+
[key: string]: PriceInfo;
|
|
169
|
+
};
|
|
170
|
+
private methodToUse;
|
|
171
|
+
/**
|
|
172
|
+
* TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
|
|
173
|
+
*/
|
|
174
|
+
protected PRICE_API: string;
|
|
175
|
+
protected EKUBO_API: string;
|
|
176
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
177
|
+
isReady(): boolean;
|
|
178
|
+
waitTillReady(): Promise<void>;
|
|
179
|
+
start(): void;
|
|
180
|
+
isStale(timestamp: Date, tokenName: string): boolean;
|
|
181
|
+
assertNotStale(timestamp: Date, tokenName: string): void;
|
|
182
|
+
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
183
|
+
protected _loadPrices(onUpdate?: (tokenSymbol: string) => void): void;
|
|
184
|
+
_getPrice(token: TokenInfo, defaultMethod?: string): Promise<number>;
|
|
185
|
+
_getPriceCoinbase(token: TokenInfo): Promise<number>;
|
|
186
|
+
_getPriceCoinMarketCap(token: TokenInfo): Promise<number>;
|
|
187
|
+
_getPriceEkubo(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare class Pragma {
|
|
191
|
+
contractAddr: string;
|
|
192
|
+
readonly contract: Contract;
|
|
193
|
+
constructor(provider: RpcProvider);
|
|
194
|
+
getPrice(tokenAddr: string): Promise<number>;
|
|
195
|
+
}
|
|
196
|
+
|
|
158
197
|
declare class ZkLend extends ILending implements ILending {
|
|
159
198
|
readonly pricer: Pricer;
|
|
160
199
|
static readonly POOLS_URL = "https://app.zklend.com/api/pools";
|
|
@@ -186,6 +225,15 @@ declare class ZkLend extends ILending implements ILending {
|
|
|
186
225
|
getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
|
|
187
226
|
}
|
|
188
227
|
|
|
228
|
+
declare class PricerFromApi extends PricerBase {
|
|
229
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
230
|
+
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
231
|
+
getPriceFromMyAPI(tokenSymbol: string): Promise<{
|
|
232
|
+
price: number;
|
|
233
|
+
timestamp: Date;
|
|
234
|
+
}>;
|
|
235
|
+
}
|
|
236
|
+
|
|
189
237
|
declare const logger: {
|
|
190
238
|
verbose(message: string): void;
|
|
191
239
|
assert(condition?: boolean, ...data: any[]): void;
|
|
@@ -441,6 +489,7 @@ declare class VesuRebalance {
|
|
|
441
489
|
* @returns Populated contract call for rebalance
|
|
442
490
|
*/
|
|
443
491
|
getRebalanceCall(pools: Awaited<ReturnType<typeof this.getRebalancedPositions>>['changes'], isOverWeightAdjustment: boolean): Promise<starknet.Call | null>;
|
|
492
|
+
getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
|
|
444
493
|
}
|
|
445
494
|
/**
|
|
446
495
|
* Represents the Vesu Rebalance Strategies.
|
|
@@ -554,4 +603,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
554
603
|
decrypt(encryptedData: string, password: string): any;
|
|
555
604
|
}
|
|
556
605
|
|
|
557
|
-
export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, ContractAddr, FatalError, Global, type IConfig, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LendingToken, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer,
|
|
606
|
+
export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, ContractAddr, 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, Store, type StoreConfig, TelegramNotif, type TokenInfo, VesuRebalance, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getDefaultStoreConfig, getMainnetConfig, logger };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
AutoCompounderSTRK: () => AutoCompounderSTRK,
|
|
34
34
|
ContractAddr: () => ContractAddr,
|
|
35
35
|
FatalError: () => FatalError,
|
|
36
|
+
FlowChartColors: () => FlowChartColors,
|
|
36
37
|
Global: () => Global,
|
|
37
38
|
ILending: () => ILending,
|
|
38
39
|
Initializable: () => Initializable,
|
|
@@ -41,8 +42,9 @@ __export(src_exports, {
|
|
|
41
42
|
PasswordJsonCryptoUtil: () => PasswordJsonCryptoUtil,
|
|
42
43
|
Pragma: () => Pragma,
|
|
43
44
|
Pricer: () => Pricer,
|
|
44
|
-
|
|
45
|
+
PricerFromApi: () => PricerFromApi,
|
|
45
46
|
PricerRedis: () => PricerRedis,
|
|
47
|
+
RiskType: () => RiskType,
|
|
46
48
|
Store: () => Store,
|
|
47
49
|
TelegramNotif: () => TelegramNotif,
|
|
48
50
|
VesuRebalance: () => VesuRebalance,
|
|
@@ -79,6 +81,7 @@ var FatalError = class extends Error {
|
|
|
79
81
|
var tokens = [{
|
|
80
82
|
name: "Starknet",
|
|
81
83
|
symbol: "STRK",
|
|
84
|
+
logo: "https://assets.coingecko.com/coins/images/26433/small/starknet.png",
|
|
82
85
|
address: "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
83
86
|
decimals: 18,
|
|
84
87
|
coingeckId: "starknet"
|
|
@@ -111,6 +114,7 @@ var Global = class {
|
|
|
111
114
|
symbol: token.symbol,
|
|
112
115
|
address: token.address,
|
|
113
116
|
decimals: token.decimals,
|
|
117
|
+
logo: token.logoUri,
|
|
114
118
|
coingeckId: token.extensions.coingeckoId
|
|
115
119
|
});
|
|
116
120
|
});
|
|
@@ -190,16 +194,22 @@ var ContractAddr = class _ContractAddr {
|
|
|
190
194
|
}
|
|
191
195
|
};
|
|
192
196
|
|
|
193
|
-
// src/modules/
|
|
194
|
-
var CoinMarketCap = require("coinmarketcap-api");
|
|
197
|
+
// src/modules/pricerBase.ts
|
|
195
198
|
var PricerBase = class {
|
|
199
|
+
constructor(config, tokens2) {
|
|
200
|
+
this.config = config;
|
|
201
|
+
this.tokens = tokens2;
|
|
202
|
+
}
|
|
196
203
|
async getPrice(tokenSymbol) {
|
|
197
204
|
throw new Error("Method not implemented");
|
|
198
205
|
}
|
|
199
206
|
};
|
|
200
|
-
|
|
207
|
+
|
|
208
|
+
// src/modules/pricer.ts
|
|
209
|
+
var Pricer = class extends PricerBase {
|
|
210
|
+
// e.g. ETH/USDC
|
|
201
211
|
constructor(config, tokens2) {
|
|
202
|
-
|
|
212
|
+
super(config, tokens2);
|
|
203
213
|
this.prices = {};
|
|
204
214
|
// code populates this map during runtime to determine which method to use for a given token
|
|
205
215
|
// The method set will be the first one to try after first attempt
|
|
@@ -209,11 +219,6 @@ var Pricer = class {
|
|
|
209
219
|
*/
|
|
210
220
|
this.PRICE_API = `https://api.coinbase.com/v2/prices/{{PRICER_KEY}}/buy`;
|
|
211
221
|
this.EKUBO_API = "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_ADDRESS}}/0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8";
|
|
212
|
-
// e.g. ETH/USDC
|
|
213
|
-
// backup oracle001
|
|
214
|
-
this.client = new CoinMarketCap(process.env.COINMARKETCAP_KEY);
|
|
215
|
-
this.config = config;
|
|
216
|
-
this.tokens = tokens2;
|
|
217
222
|
}
|
|
218
223
|
isReady() {
|
|
219
224
|
const allPricesExist = Object.keys(this.prices).length === this.tokens.length;
|
|
@@ -345,10 +350,7 @@ var Pricer = class {
|
|
|
345
350
|
return Number(data.data.amount);
|
|
346
351
|
}
|
|
347
352
|
async _getPriceCoinMarketCap(token) {
|
|
348
|
-
|
|
349
|
-
if (result.data)
|
|
350
|
-
return result.data[token.symbol].quote.USD.price;
|
|
351
|
-
throw new Error(result);
|
|
353
|
+
throw new Error("Not implemented");
|
|
352
354
|
}
|
|
353
355
|
async _getPriceEkubo(token, amountIn = new Web3Number(1, token.decimals), retry = 0) {
|
|
354
356
|
const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address).replace("{{AMOUNT}}", amountIn.toWei());
|
|
@@ -542,6 +544,7 @@ var _ZkLend = class _ZkLend extends ILending {
|
|
|
542
544
|
name: pool.token.name,
|
|
543
545
|
symbol: pool.token.symbol,
|
|
544
546
|
address: savedTokenInfo?.address || "",
|
|
547
|
+
logo: "",
|
|
545
548
|
decimals: pool.token.decimals,
|
|
546
549
|
borrowFactor: Web3Number.fromWei(pool.borrow_factor.value, pool.borrow_factor.decimals),
|
|
547
550
|
collareralFactor
|
|
@@ -651,14 +654,84 @@ var _ZkLend = class _ZkLend extends ILending {
|
|
|
651
654
|
_ZkLend.POOLS_URL = "https://app.zklend.com/api/pools";
|
|
652
655
|
var ZkLend = _ZkLend;
|
|
653
656
|
|
|
657
|
+
// src/modules/pricer-from-api.ts
|
|
658
|
+
var import_axios4 = __toESM(require("axios"));
|
|
659
|
+
var PricerFromApi = class extends PricerBase {
|
|
660
|
+
constructor(config, tokens2) {
|
|
661
|
+
super(config, tokens2);
|
|
662
|
+
}
|
|
663
|
+
async getPrice(tokenSymbol) {
|
|
664
|
+
try {
|
|
665
|
+
return await this.getPriceFromMyAPI(tokenSymbol);
|
|
666
|
+
} catch (e) {
|
|
667
|
+
logger.warn("getPriceFromMyAPI error", e);
|
|
668
|
+
}
|
|
669
|
+
logger.log("getPrice coinbase", tokenSymbol);
|
|
670
|
+
let retry = 0;
|
|
671
|
+
const MAX_RETRIES = 5;
|
|
672
|
+
for (retry = 1; retry < MAX_RETRIES + 1; retry++) {
|
|
673
|
+
try {
|
|
674
|
+
const priceInfo = await import_axios4.default.get(
|
|
675
|
+
`https://api.coinbase.com/v2/prices/${tokenSymbol}-USDT/spot`
|
|
676
|
+
);
|
|
677
|
+
if (!priceInfo) {
|
|
678
|
+
throw new Error("Failed to fetch price");
|
|
679
|
+
}
|
|
680
|
+
const data = await priceInfo.data;
|
|
681
|
+
const price = Number(data.data.amount);
|
|
682
|
+
return {
|
|
683
|
+
price,
|
|
684
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
685
|
+
};
|
|
686
|
+
} catch (e) {
|
|
687
|
+
logger.warn("getPrice coinbase error", e, retry);
|
|
688
|
+
await new Promise((resolve) => setTimeout(resolve, retry * 1e3));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
throw new Error(`Failed to fetch price for ${tokenSymbol}`);
|
|
692
|
+
}
|
|
693
|
+
async getPriceFromMyAPI(tokenSymbol) {
|
|
694
|
+
logger.verbose(`getPrice from redis: ${tokenSymbol}`);
|
|
695
|
+
const endpoint = "https://app.strkfarm.com";
|
|
696
|
+
const url = `${endpoint}/api/price/${tokenSymbol}`;
|
|
697
|
+
const priceInfoRes = await fetch(url);
|
|
698
|
+
const priceInfo = await priceInfoRes.json();
|
|
699
|
+
const now = /* @__PURE__ */ new Date();
|
|
700
|
+
const priceTime = new Date(priceInfo.timestamp);
|
|
701
|
+
if (now.getTime() - priceTime.getTime() > 9e5) {
|
|
702
|
+
throw new Error("Price is stale");
|
|
703
|
+
}
|
|
704
|
+
const price = Number(priceInfo.price);
|
|
705
|
+
return {
|
|
706
|
+
price,
|
|
707
|
+
timestamp: new Date(priceInfo.timestamp)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
|
|
654
712
|
// src/interfaces/common.ts
|
|
655
713
|
var import_starknet3 = require("starknet");
|
|
714
|
+
var RiskType = /* @__PURE__ */ ((RiskType2) => {
|
|
715
|
+
RiskType2["MARKET_RISK"] = "MARKET_RISK";
|
|
716
|
+
RiskType2["IMPERMANENT_LOSS"] = "IMPERMANENT_LOSS";
|
|
717
|
+
RiskType2["LIQUIDITY_RISK"] = "LIQUIDITY_RISK";
|
|
718
|
+
RiskType2["SMART_CONTRACT_RISK"] = "SMART_CONTRACT_RISK";
|
|
719
|
+
RiskType2["TECHNICAL_RISK"] = "TECHNICAL_RISK";
|
|
720
|
+
RiskType2["COUNTERPARTY_RISK"] = "COUNTERPARTY_RISK";
|
|
721
|
+
return RiskType2;
|
|
722
|
+
})(RiskType || {});
|
|
656
723
|
var Network = /* @__PURE__ */ ((Network2) => {
|
|
657
724
|
Network2["mainnet"] = "mainnet";
|
|
658
725
|
Network2["sepolia"] = "sepolia";
|
|
659
726
|
Network2["devnet"] = "devnet";
|
|
660
727
|
return Network2;
|
|
661
728
|
})(Network || {});
|
|
729
|
+
var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
|
|
730
|
+
FlowChartColors2["Green"] = "purple";
|
|
731
|
+
FlowChartColors2["Blue"] = "#35484f";
|
|
732
|
+
FlowChartColors2["Purple"] = "#6e53dc";
|
|
733
|
+
return FlowChartColors2;
|
|
734
|
+
})(FlowChartColors || {});
|
|
662
735
|
function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = "pending") {
|
|
663
736
|
return {
|
|
664
737
|
provider: new import_starknet3.RpcProvider({
|
|
@@ -2234,7 +2307,7 @@ function assert(condition, message) {
|
|
|
2234
2307
|
}
|
|
2235
2308
|
|
|
2236
2309
|
// src/strategies/vesu-rebalance.ts
|
|
2237
|
-
var
|
|
2310
|
+
var import_axios5 = __toESM(require("axios"));
|
|
2238
2311
|
var VesuRebalance = class _VesuRebalance {
|
|
2239
2312
|
// 10000 bps = 100%
|
|
2240
2313
|
/**
|
|
@@ -2341,7 +2414,7 @@ var VesuRebalance = class _VesuRebalance {
|
|
|
2341
2414
|
let isErrorPositionsAPI = false;
|
|
2342
2415
|
let vesuPositions = [];
|
|
2343
2416
|
try {
|
|
2344
|
-
const res = await
|
|
2417
|
+
const res = await import_axios5.default.get(`https://api.vesu.xyz/positions?walletAddress=${this.address.address}`);
|
|
2345
2418
|
const data2 = await res.data;
|
|
2346
2419
|
vesuPositions = data2.data;
|
|
2347
2420
|
} catch (e) {
|
|
@@ -2351,7 +2424,7 @@ var VesuRebalance = class _VesuRebalance {
|
|
|
2351
2424
|
let isErrorPoolsAPI = false;
|
|
2352
2425
|
let pools = [];
|
|
2353
2426
|
try {
|
|
2354
|
-
const res = await
|
|
2427
|
+
const res = await import_axios5.default.get(`https://api.vesu.xyz/pools`);
|
|
2355
2428
|
const data2 = await res.data;
|
|
2356
2429
|
pools = data2.data;
|
|
2357
2430
|
} catch (e) {
|
|
@@ -2368,7 +2441,7 @@ var VesuRebalance = class _VesuRebalance {
|
|
|
2368
2441
|
const assets = await vTokenContract.convert_to_assets(import_starknet5.uint256.bnToUint256(bal.toString()));
|
|
2369
2442
|
const item = {
|
|
2370
2443
|
pool_id: p.pool_id,
|
|
2371
|
-
pool_name:
|
|
2444
|
+
pool_name: pool.name,
|
|
2372
2445
|
max_weight: p.max_weight,
|
|
2373
2446
|
current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
|
|
2374
2447
|
v_token: p.v_token,
|
|
@@ -2511,16 +2584,50 @@ var VesuRebalance = class _VesuRebalance {
|
|
|
2511
2584
|
}
|
|
2512
2585
|
return this.contract.populate("rebalance", [actions]);
|
|
2513
2586
|
}
|
|
2587
|
+
async getInvestmentFlows(pools) {
|
|
2588
|
+
const netYield = this.netAPYGivenPools(pools);
|
|
2589
|
+
const baseFlow = {
|
|
2590
|
+
title: "Your Deposit",
|
|
2591
|
+
subItems: [{ key: `Net yield`, value: `${(netYield * 100).toFixed(2)}%` }],
|
|
2592
|
+
linkedFlows: [],
|
|
2593
|
+
style: { backgroundColor: "#6e53dc" /* Purple */.valueOf() }
|
|
2594
|
+
};
|
|
2595
|
+
let _pools = [...pools];
|
|
2596
|
+
_pools = _pools.sort((a, b) => Number(b.amount.toString()) - Number(a.amount.toString()));
|
|
2597
|
+
_pools.forEach((p) => {
|
|
2598
|
+
const flow = {
|
|
2599
|
+
title: `Pool name: ${p.pool_name}`,
|
|
2600
|
+
subItems: [
|
|
2601
|
+
{ key: `APY`, value: `${(p.APY.netApy * 100).toFixed(2)}%` },
|
|
2602
|
+
{ key: "Weight", value: `${(p.current_weight * 100).toFixed(2)} / ${(p.max_weight * 100).toFixed(2)}%` }
|
|
2603
|
+
],
|
|
2604
|
+
linkedFlows: [],
|
|
2605
|
+
style: p.amount.greaterThan(0) ? { backgroundColor: "#35484f" /* Blue */.valueOf() } : { color: "gray" }
|
|
2606
|
+
};
|
|
2607
|
+
baseFlow.linkedFlows.push(flow);
|
|
2608
|
+
});
|
|
2609
|
+
return [baseFlow];
|
|
2610
|
+
}
|
|
2514
2611
|
};
|
|
2515
2612
|
var _description = "Automatically diversify {{TOKEN}} holdings into different Vesu pools while reducing risk and maximizing yield. Defi spring STRK Rewards are auto-compounded as well.";
|
|
2516
2613
|
var _protocol = { name: "Vesu", logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png" };
|
|
2614
|
+
var _riskFactor = [
|
|
2615
|
+
{ type: "SMART_CONTRACT_RISK" /* SMART_CONTRACT_RISK */, value: 0.5, weight: 25 },
|
|
2616
|
+
{ type: "TECHNICAL_RISK" /* TECHNICAL_RISK */, value: 0.5, weight: 25 },
|
|
2617
|
+
{ type: "COUNTERPARTY_RISK" /* COUNTERPARTY_RISK */, value: 1, weight: 50 }
|
|
2618
|
+
];
|
|
2517
2619
|
var VesuRebalanceStrategies = [{
|
|
2518
2620
|
name: "Vesu STRK",
|
|
2519
2621
|
description: _description.replace("{{TOKEN}}", "STRK"),
|
|
2520
2622
|
address: ContractAddr.from("0xeeb729d554ae486387147b13a9c8871bc7991d454e8b5ff570d4bf94de71e1"),
|
|
2521
2623
|
type: "ERC4626",
|
|
2522
2624
|
depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "STRK")],
|
|
2523
|
-
protocols: [_protocol]
|
|
2625
|
+
protocols: [_protocol],
|
|
2626
|
+
maxTVL: Web3Number.fromWei("0", 18),
|
|
2627
|
+
risk: {
|
|
2628
|
+
riskFactor: _riskFactor,
|
|
2629
|
+
netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / 100
|
|
2630
|
+
}
|
|
2524
2631
|
}];
|
|
2525
2632
|
|
|
2526
2633
|
// src/notifs/telegram.ts
|
|
@@ -2789,6 +2896,7 @@ var Store = class _Store {
|
|
|
2789
2896
|
AutoCompounderSTRK,
|
|
2790
2897
|
ContractAddr,
|
|
2791
2898
|
FatalError,
|
|
2899
|
+
FlowChartColors,
|
|
2792
2900
|
Global,
|
|
2793
2901
|
ILending,
|
|
2794
2902
|
Initializable,
|
|
@@ -2797,8 +2905,9 @@ var Store = class _Store {
|
|
|
2797
2905
|
PasswordJsonCryptoUtil,
|
|
2798
2906
|
Pragma,
|
|
2799
2907
|
Pricer,
|
|
2800
|
-
|
|
2908
|
+
PricerFromApi,
|
|
2801
2909
|
PricerRedis,
|
|
2910
|
+
RiskType,
|
|
2802
2911
|
Store,
|
|
2803
2912
|
TelegramNotif,
|
|
2804
2913
|
VesuRebalance,
|