@strkfarm/sdk 1.0.38 → 1.0.40
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 +38 -712
- package/dist/cli.mjs +37 -715
- package/dist/index.browser.global.js +93 -20
- package/dist/index.browser.mjs +93 -20
- package/dist/index.d.ts +19 -50
- package/dist/index.js +126 -23
- package/dist/index.mjs +126 -23
- package/package.json +3 -3
- package/src/dataTypes/_bignumber.ts +49 -47
- package/src/global.ts +1 -33
- package/src/interfaces/common.ts +1 -0
- package/src/interfaces/lending.ts +1 -2
- package/src/modules/avnu.ts +1 -1
- package/src/modules/erc20.ts +6 -0
- package/src/modules/harvests.ts +1 -1
- package/src/modules/pragma.ts +1 -1
- package/src/modules/pricer-from-api.ts +3 -3
- package/src/modules/pricer.ts +2 -1
- package/src/modules/zkLend.ts +2 -1
- package/src/node/pricer-redis.ts +2 -1
- package/src/notifs/telegram.ts +1 -1
- package/src/strategies/ekubo-cl-vault.tsx +91 -19
- package/src/strategies/vesu-rebalance.tsx +6 -1
- package/src/utils/index.ts +2 -0
- package/src/utils/logger.browser.ts +20 -0
- package/src/utils/logger.node.ts +35 -0
- package/src/utils/logger.ts +1 -0
- package/src/utils/store.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -105,8 +105,8 @@ var _Web3Number = class extends import_bignumber.default {
|
|
|
105
105
|
construct(value, decimals) {
|
|
106
106
|
return new this.constructor(value, decimals);
|
|
107
107
|
}
|
|
108
|
-
toString(
|
|
109
|
-
return super.
|
|
108
|
+
toString() {
|
|
109
|
+
return super.toString();
|
|
110
110
|
}
|
|
111
111
|
toJSON() {
|
|
112
112
|
return this.toString();
|
|
@@ -175,13 +175,44 @@ var ContractAddr = class _ContractAddr {
|
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
// src/
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
// src/utils/logger.node.ts
|
|
179
|
+
var import_winston = __toESM(require("winston"));
|
|
180
|
+
var colors = {
|
|
181
|
+
error: "red",
|
|
182
|
+
warn: "yellow",
|
|
183
|
+
info: "blue",
|
|
184
|
+
verbose: "white",
|
|
185
|
+
debug: "white"
|
|
184
186
|
};
|
|
187
|
+
import_winston.default.addColors(colors);
|
|
188
|
+
var logger = import_winston.default.createLogger({
|
|
189
|
+
level: "verbose",
|
|
190
|
+
// Set the minimum logging level
|
|
191
|
+
format: import_winston.format.combine(
|
|
192
|
+
import_winston.format.colorize({ all: true }),
|
|
193
|
+
// Apply custom colors
|
|
194
|
+
import_winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
|
195
|
+
// Add timestamp to log messages
|
|
196
|
+
import_winston.format.printf(({ timestamp, level, message, ...meta }) => {
|
|
197
|
+
let msg = `${timestamp} ${level}: ${message}`;
|
|
198
|
+
if (meta && meta[Symbol.for("splat")]) {
|
|
199
|
+
for (const arg of meta[Symbol.for("splat")]) {
|
|
200
|
+
if (arg instanceof Error) {
|
|
201
|
+
msg += `
|
|
202
|
+
${arg.stack}`;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return msg;
|
|
207
|
+
})
|
|
208
|
+
),
|
|
209
|
+
transports: [
|
|
210
|
+
new import_winston.default.transports.Console()
|
|
211
|
+
// Output logs to the console
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// src/global.ts
|
|
185
216
|
var FatalError = class extends Error {
|
|
186
217
|
constructor(message, err) {
|
|
187
218
|
super(message);
|
|
@@ -775,7 +806,7 @@ var PricerFromApi = class extends PricerBase {
|
|
|
775
806
|
} catch (e) {
|
|
776
807
|
logger.warn("getPriceFromMyAPI error", JSON.stringify(e.message || e));
|
|
777
808
|
}
|
|
778
|
-
logger.
|
|
809
|
+
logger.info("getPrice coinbase", tokenSymbol);
|
|
779
810
|
let retry = 0;
|
|
780
811
|
const MAX_RETRIES = 5;
|
|
781
812
|
for (retry = 1; retry < MAX_RETRIES + 1; retry++) {
|
|
@@ -1956,6 +1987,11 @@ var ERC20 = class {
|
|
|
1956
1987
|
const balance = await contract.call("balanceOf", [address.toString()]);
|
|
1957
1988
|
return Web3Number.fromWei(balance.toString(), tokenDecimals);
|
|
1958
1989
|
}
|
|
1990
|
+
async allowance(token, owner, spender, tokenDecimals) {
|
|
1991
|
+
const contract = this.contract(token);
|
|
1992
|
+
const allowance = await contract.call("allowance", [owner.toString(), spender.toString()]);
|
|
1993
|
+
return Web3Number.fromWei(allowance.toString(), tokenDecimals);
|
|
1994
|
+
}
|
|
1959
1995
|
};
|
|
1960
1996
|
|
|
1961
1997
|
// src/modules/avnu.ts
|
|
@@ -13484,6 +13520,7 @@ var VesuRebalanceStrategies = [
|
|
|
13484
13520
|
address: ContractAddr.from(
|
|
13485
13521
|
"0x7fb5bcb8525954a60fde4e8fb8220477696ce7117ef264775a1770e23571929"
|
|
13486
13522
|
),
|
|
13523
|
+
launchBlock: 0,
|
|
13487
13524
|
type: "ERC4626",
|
|
13488
13525
|
depositTokens: [
|
|
13489
13526
|
Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
@@ -13507,6 +13544,7 @@ var VesuRebalanceStrategies = [
|
|
|
13507
13544
|
address: ContractAddr.from(
|
|
13508
13545
|
"0x5eaf5ee75231cecf79921ff8ded4b5ffe96be718bcb3daf206690ad1a9ad0ca"
|
|
13509
13546
|
),
|
|
13547
|
+
launchBlock: 0,
|
|
13510
13548
|
type: "ERC4626",
|
|
13511
13549
|
auditUrl: AUDIT_URL,
|
|
13512
13550
|
depositTokens: [
|
|
@@ -13530,6 +13568,7 @@ var VesuRebalanceStrategies = [
|
|
|
13530
13568
|
address: ContractAddr.from(
|
|
13531
13569
|
"0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
|
|
13532
13570
|
),
|
|
13571
|
+
launchBlock: 0,
|
|
13533
13572
|
type: "ERC4626",
|
|
13534
13573
|
auditUrl: AUDIT_URL,
|
|
13535
13574
|
depositTokens: [
|
|
@@ -13553,6 +13592,7 @@ var VesuRebalanceStrategies = [
|
|
|
13553
13592
|
address: ContractAddr.from(
|
|
13554
13593
|
"0x115e94e722cfc4c77a2f15c4aefb0928c1c0029e5a57570df24c650cb7cec2c"
|
|
13555
13594
|
),
|
|
13595
|
+
launchBlock: 0,
|
|
13556
13596
|
type: "ERC4626",
|
|
13557
13597
|
depositTokens: [
|
|
13558
13598
|
Global.getDefaultTokens().find((t) => t.symbol === "USDT")
|
|
@@ -18515,11 +18555,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18515
18555
|
this.address.address,
|
|
18516
18556
|
this.config.provider
|
|
18517
18557
|
);
|
|
18518
|
-
this.lstContract
|
|
18519
|
-
|
|
18520
|
-
|
|
18521
|
-
|
|
18522
|
-
|
|
18558
|
+
if (this.metadata.additionalInfo.lstContract) {
|
|
18559
|
+
this.lstContract = new import_starknet9.Contract(
|
|
18560
|
+
erc4626_abi_default,
|
|
18561
|
+
this.metadata.additionalInfo.lstContract.address,
|
|
18562
|
+
this.config.provider
|
|
18563
|
+
);
|
|
18564
|
+
} else {
|
|
18565
|
+
this.lstContract = null;
|
|
18566
|
+
}
|
|
18523
18567
|
const EKUBO_POSITION = "0x02e0af29598b407c8716b17f6d2795eca1b471413fa03fb145a5e33722184067";
|
|
18524
18568
|
this.ekuboPositionsContract = new import_starknet9.Contract(
|
|
18525
18569
|
ekubo_positions_abi_default,
|
|
@@ -18653,7 +18697,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18653
18697
|
const priceNow = await this.getCurrentPrice(blockIdentifier);
|
|
18654
18698
|
let blockNow = typeof blockIdentifier == "number" ? blockIdentifier : (await this.config.provider.getBlockLatestAccepted()).block_number;
|
|
18655
18699
|
const blockNowTime = typeof blockIdentifier == "number" ? (await this.config.provider.getBlockWithTxs(blockIdentifier)).timestamp : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
18656
|
-
const blockBefore = blockNow - sinceBlocks;
|
|
18700
|
+
const blockBefore = Math.max(blockNow - sinceBlocks, this.metadata.launchBlock);
|
|
18657
18701
|
const adjustedSupplyNow = supplyNow.minus(
|
|
18658
18702
|
await this.getHarvestRewardShares(blockBefore, blockNow)
|
|
18659
18703
|
);
|
|
@@ -18664,9 +18708,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18664
18708
|
const supplyBefore = await this.totalSupply(blockBefore);
|
|
18665
18709
|
const priceBefore = await this.getCurrentPrice(blockBefore);
|
|
18666
18710
|
const tvlInToken0Now = tvlNow.amount0.multipliedBy(priceNow.price).plus(tvlNow.amount1);
|
|
18667
|
-
const tvlPerShareNow = tvlInToken0Now.multipliedBy(1e18).dividedBy(adjustedSupplyNow);
|
|
18711
|
+
const tvlPerShareNow = tvlInToken0Now.multipliedBy(1e18).dividedBy(adjustedSupplyNow.toString());
|
|
18668
18712
|
const tvlInToken0Bf = tvlBefore.amount0.multipliedBy(priceBefore.price).plus(tvlBefore.amount1);
|
|
18669
|
-
const tvlPerShareBf = tvlInToken0Bf.multipliedBy(1e18).dividedBy(supplyBefore);
|
|
18713
|
+
const tvlPerShareBf = tvlInToken0Bf.multipliedBy(1e18).dividedBy(supplyBefore.toString());
|
|
18670
18714
|
const timeDiffSeconds = blockNowTime - blockBeforeInfo.timestamp;
|
|
18671
18715
|
logger.verbose(`tvlInToken0Now: ${tvlInToken0Now.toString()}`);
|
|
18672
18716
|
logger.verbose(`tvlInToken0Bf: ${tvlInToken0Bf.toString()}`);
|
|
@@ -18704,7 +18748,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18704
18748
|
return shares;
|
|
18705
18749
|
}
|
|
18706
18750
|
async balanceOf(user, blockIdentifier = "pending") {
|
|
18707
|
-
let bal = await this.contract.call("balance_of", [user.address]
|
|
18751
|
+
let bal = await this.contract.call("balance_of", [user.address], {
|
|
18752
|
+
blockIdentifier
|
|
18753
|
+
});
|
|
18708
18754
|
return Web3Number.fromWei(bal.toString(), 18);
|
|
18709
18755
|
}
|
|
18710
18756
|
async getUserTVL(user, blockIdentifier = "pending") {
|
|
@@ -18852,11 +18898,16 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18852
18898
|
return Number(result.salt.toString());
|
|
18853
18899
|
}
|
|
18854
18900
|
async truePrice() {
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
|
|
18858
|
-
|
|
18859
|
-
|
|
18901
|
+
if (this.metadata.additionalInfo.truePrice) {
|
|
18902
|
+
return this.metadata.additionalInfo.truePrice;
|
|
18903
|
+
} else if (this.lstContract) {
|
|
18904
|
+
const result = await this.lstContract.call("convert_to_assets", [
|
|
18905
|
+
import_starknet9.uint256.bnToUint256(BigInt(1e18).toString())
|
|
18906
|
+
]);
|
|
18907
|
+
const truePrice = Number(BigInt(result.toString()) * BigInt(1e9) / BigInt(1e18)) / 1e9;
|
|
18908
|
+
return truePrice;
|
|
18909
|
+
}
|
|
18910
|
+
throw new Error("No true price available");
|
|
18860
18911
|
}
|
|
18861
18912
|
async getCurrentPrice(blockIdentifier = "pending") {
|
|
18862
18913
|
const poolKey = await this.getPoolKey(blockIdentifier);
|
|
@@ -19410,6 +19461,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
19410
19461
|
const swap1Amount = Web3Number.fromWei(
|
|
19411
19462
|
import_starknet9.uint256.uint256ToBN(swapInfo1.token_from_amount).toString(),
|
|
19412
19463
|
18
|
|
19464
|
+
// cause its always STRK?
|
|
19413
19465
|
);
|
|
19414
19466
|
const remainingAmount = postFeeAmount.minus(swap1Amount);
|
|
19415
19467
|
const swapInfo2 = {
|
|
@@ -19500,6 +19552,9 @@ var _riskFactor2 = [
|
|
|
19500
19552
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 0.5, weight: 25 },
|
|
19501
19553
|
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1, weight: 75 }
|
|
19502
19554
|
];
|
|
19555
|
+
var _riskFactorStable = [
|
|
19556
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 0.5, weight: 25 }
|
|
19557
|
+
];
|
|
19503
19558
|
var AUDIT_URL2 = "https://assets.strkfarm.com/strkfarm/audit_report_vesu_and_ekubo_strats.pdf";
|
|
19504
19559
|
var faqs2 = [
|
|
19505
19560
|
{
|
|
@@ -19546,6 +19601,7 @@ var EkuboCLVaultStrategies = [
|
|
|
19546
19601
|
address: ContractAddr.from(
|
|
19547
19602
|
"0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
|
|
19548
19603
|
),
|
|
19604
|
+
launchBlock: 1209881,
|
|
19549
19605
|
type: "Other",
|
|
19550
19606
|
// must be same order as poolKey token0 and token1
|
|
19551
19607
|
depositTokens: [
|
|
@@ -19578,6 +19634,53 @@ var EkuboCLVaultStrategies = [
|
|
|
19578
19634
|
answer: "A negative APY can occur when xSTRK's price drops on DEXes. This is usually temporary and tends to recover within a few days or a week."
|
|
19579
19635
|
}
|
|
19580
19636
|
]
|
|
19637
|
+
},
|
|
19638
|
+
{
|
|
19639
|
+
name: "Ekubo USDC/USDT",
|
|
19640
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
19641
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: _description2.replace("{{POOL_NAME}}", "USDC/USDT") }),
|
|
19642
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
19643
|
+
"ul",
|
|
19644
|
+
{
|
|
19645
|
+
style: {
|
|
19646
|
+
marginLeft: "20px",
|
|
19647
|
+
listStyle: "circle",
|
|
19648
|
+
fontSize: "12px"
|
|
19649
|
+
},
|
|
19650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." })
|
|
19651
|
+
}
|
|
19652
|
+
)
|
|
19653
|
+
] }),
|
|
19654
|
+
address: ContractAddr.from(
|
|
19655
|
+
"0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
|
|
19656
|
+
),
|
|
19657
|
+
launchBlock: 1385576,
|
|
19658
|
+
type: "Other",
|
|
19659
|
+
// must be same order as poolKey token0 and token1
|
|
19660
|
+
depositTokens: [
|
|
19661
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
|
|
19662
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDT")
|
|
19663
|
+
],
|
|
19664
|
+
protocols: [_protocol2],
|
|
19665
|
+
auditUrl: AUDIT_URL2,
|
|
19666
|
+
maxTVL: Web3Number.fromWei("0", 6),
|
|
19667
|
+
risk: {
|
|
19668
|
+
riskFactor: _riskFactorStable,
|
|
19669
|
+
netRisk: _riskFactorStable.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
|
|
19670
|
+
notARisks: getNoRiskTags(_riskFactorStable)
|
|
19671
|
+
},
|
|
19672
|
+
apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
|
|
19673
|
+
additionalInfo: {
|
|
19674
|
+
newBounds: {
|
|
19675
|
+
lower: -1,
|
|
19676
|
+
upper: 1
|
|
19677
|
+
},
|
|
19678
|
+
truePrice: 1,
|
|
19679
|
+
feeBps: 1e3
|
|
19680
|
+
},
|
|
19681
|
+
faqs: [
|
|
19682
|
+
...faqs2
|
|
19683
|
+
]
|
|
19581
19684
|
}
|
|
19582
19685
|
];
|
|
19583
19686
|
|
package/dist/index.mjs
CHANGED
|
@@ -36,8 +36,8 @@ var _Web3Number = class extends BigNumber {
|
|
|
36
36
|
construct(value, decimals) {
|
|
37
37
|
return new this.constructor(value, decimals);
|
|
38
38
|
}
|
|
39
|
-
toString(
|
|
40
|
-
return super.
|
|
39
|
+
toString() {
|
|
40
|
+
return super.toString();
|
|
41
41
|
}
|
|
42
42
|
toJSON() {
|
|
43
43
|
return this.toString();
|
|
@@ -106,13 +106,44 @@ var ContractAddr = class _ContractAddr {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
// src/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
// src/utils/logger.node.ts
|
|
110
|
+
import winston, { format } from "winston";
|
|
111
|
+
var colors = {
|
|
112
|
+
error: "red",
|
|
113
|
+
warn: "yellow",
|
|
114
|
+
info: "blue",
|
|
115
|
+
verbose: "white",
|
|
116
|
+
debug: "white"
|
|
115
117
|
};
|
|
118
|
+
winston.addColors(colors);
|
|
119
|
+
var logger = winston.createLogger({
|
|
120
|
+
level: "verbose",
|
|
121
|
+
// Set the minimum logging level
|
|
122
|
+
format: format.combine(
|
|
123
|
+
format.colorize({ all: true }),
|
|
124
|
+
// Apply custom colors
|
|
125
|
+
format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
|
126
|
+
// Add timestamp to log messages
|
|
127
|
+
format.printf(({ timestamp, level, message, ...meta }) => {
|
|
128
|
+
let msg = `${timestamp} ${level}: ${message}`;
|
|
129
|
+
if (meta && meta[Symbol.for("splat")]) {
|
|
130
|
+
for (const arg of meta[Symbol.for("splat")]) {
|
|
131
|
+
if (arg instanceof Error) {
|
|
132
|
+
msg += `
|
|
133
|
+
${arg.stack}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return msg;
|
|
138
|
+
})
|
|
139
|
+
),
|
|
140
|
+
transports: [
|
|
141
|
+
new winston.transports.Console()
|
|
142
|
+
// Output logs to the console
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// src/global.ts
|
|
116
147
|
var FatalError = class extends Error {
|
|
117
148
|
constructor(message, err) {
|
|
118
149
|
super(message);
|
|
@@ -706,7 +737,7 @@ var PricerFromApi = class extends PricerBase {
|
|
|
706
737
|
} catch (e) {
|
|
707
738
|
logger.warn("getPriceFromMyAPI error", JSON.stringify(e.message || e));
|
|
708
739
|
}
|
|
709
|
-
logger.
|
|
740
|
+
logger.info("getPrice coinbase", tokenSymbol);
|
|
710
741
|
let retry = 0;
|
|
711
742
|
const MAX_RETRIES = 5;
|
|
712
743
|
for (retry = 1; retry < MAX_RETRIES + 1; retry++) {
|
|
@@ -1887,6 +1918,11 @@ var ERC20 = class {
|
|
|
1887
1918
|
const balance = await contract.call("balanceOf", [address.toString()]);
|
|
1888
1919
|
return Web3Number.fromWei(balance.toString(), tokenDecimals);
|
|
1889
1920
|
}
|
|
1921
|
+
async allowance(token, owner, spender, tokenDecimals) {
|
|
1922
|
+
const contract = this.contract(token);
|
|
1923
|
+
const allowance = await contract.call("allowance", [owner.toString(), spender.toString()]);
|
|
1924
|
+
return Web3Number.fromWei(allowance.toString(), tokenDecimals);
|
|
1925
|
+
}
|
|
1890
1926
|
};
|
|
1891
1927
|
|
|
1892
1928
|
// src/modules/avnu.ts
|
|
@@ -13415,6 +13451,7 @@ var VesuRebalanceStrategies = [
|
|
|
13415
13451
|
address: ContractAddr.from(
|
|
13416
13452
|
"0x7fb5bcb8525954a60fde4e8fb8220477696ce7117ef264775a1770e23571929"
|
|
13417
13453
|
),
|
|
13454
|
+
launchBlock: 0,
|
|
13418
13455
|
type: "ERC4626",
|
|
13419
13456
|
depositTokens: [
|
|
13420
13457
|
Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
@@ -13438,6 +13475,7 @@ var VesuRebalanceStrategies = [
|
|
|
13438
13475
|
address: ContractAddr.from(
|
|
13439
13476
|
"0x5eaf5ee75231cecf79921ff8ded4b5ffe96be718bcb3daf206690ad1a9ad0ca"
|
|
13440
13477
|
),
|
|
13478
|
+
launchBlock: 0,
|
|
13441
13479
|
type: "ERC4626",
|
|
13442
13480
|
auditUrl: AUDIT_URL,
|
|
13443
13481
|
depositTokens: [
|
|
@@ -13461,6 +13499,7 @@ var VesuRebalanceStrategies = [
|
|
|
13461
13499
|
address: ContractAddr.from(
|
|
13462
13500
|
"0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
|
|
13463
13501
|
),
|
|
13502
|
+
launchBlock: 0,
|
|
13464
13503
|
type: "ERC4626",
|
|
13465
13504
|
auditUrl: AUDIT_URL,
|
|
13466
13505
|
depositTokens: [
|
|
@@ -13484,6 +13523,7 @@ var VesuRebalanceStrategies = [
|
|
|
13484
13523
|
address: ContractAddr.from(
|
|
13485
13524
|
"0x115e94e722cfc4c77a2f15c4aefb0928c1c0029e5a57570df24c650cb7cec2c"
|
|
13486
13525
|
),
|
|
13526
|
+
launchBlock: 0,
|
|
13487
13527
|
type: "ERC4626",
|
|
13488
13528
|
depositTokens: [
|
|
13489
13529
|
Global.getDefaultTokens().find((t) => t.symbol === "USDT")
|
|
@@ -18450,11 +18490,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18450
18490
|
this.address.address,
|
|
18451
18491
|
this.config.provider
|
|
18452
18492
|
);
|
|
18453
|
-
this.lstContract
|
|
18454
|
-
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18493
|
+
if (this.metadata.additionalInfo.lstContract) {
|
|
18494
|
+
this.lstContract = new Contract6(
|
|
18495
|
+
erc4626_abi_default,
|
|
18496
|
+
this.metadata.additionalInfo.lstContract.address,
|
|
18497
|
+
this.config.provider
|
|
18498
|
+
);
|
|
18499
|
+
} else {
|
|
18500
|
+
this.lstContract = null;
|
|
18501
|
+
}
|
|
18458
18502
|
const EKUBO_POSITION = "0x02e0af29598b407c8716b17f6d2795eca1b471413fa03fb145a5e33722184067";
|
|
18459
18503
|
this.ekuboPositionsContract = new Contract6(
|
|
18460
18504
|
ekubo_positions_abi_default,
|
|
@@ -18588,7 +18632,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18588
18632
|
const priceNow = await this.getCurrentPrice(blockIdentifier);
|
|
18589
18633
|
let blockNow = typeof blockIdentifier == "number" ? blockIdentifier : (await this.config.provider.getBlockLatestAccepted()).block_number;
|
|
18590
18634
|
const blockNowTime = typeof blockIdentifier == "number" ? (await this.config.provider.getBlockWithTxs(blockIdentifier)).timestamp : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
18591
|
-
const blockBefore = blockNow - sinceBlocks;
|
|
18635
|
+
const blockBefore = Math.max(blockNow - sinceBlocks, this.metadata.launchBlock);
|
|
18592
18636
|
const adjustedSupplyNow = supplyNow.minus(
|
|
18593
18637
|
await this.getHarvestRewardShares(blockBefore, blockNow)
|
|
18594
18638
|
);
|
|
@@ -18599,9 +18643,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18599
18643
|
const supplyBefore = await this.totalSupply(blockBefore);
|
|
18600
18644
|
const priceBefore = await this.getCurrentPrice(blockBefore);
|
|
18601
18645
|
const tvlInToken0Now = tvlNow.amount0.multipliedBy(priceNow.price).plus(tvlNow.amount1);
|
|
18602
|
-
const tvlPerShareNow = tvlInToken0Now.multipliedBy(1e18).dividedBy(adjustedSupplyNow);
|
|
18646
|
+
const tvlPerShareNow = tvlInToken0Now.multipliedBy(1e18).dividedBy(adjustedSupplyNow.toString());
|
|
18603
18647
|
const tvlInToken0Bf = tvlBefore.amount0.multipliedBy(priceBefore.price).plus(tvlBefore.amount1);
|
|
18604
|
-
const tvlPerShareBf = tvlInToken0Bf.multipliedBy(1e18).dividedBy(supplyBefore);
|
|
18648
|
+
const tvlPerShareBf = tvlInToken0Bf.multipliedBy(1e18).dividedBy(supplyBefore.toString());
|
|
18605
18649
|
const timeDiffSeconds = blockNowTime - blockBeforeInfo.timestamp;
|
|
18606
18650
|
logger.verbose(`tvlInToken0Now: ${tvlInToken0Now.toString()}`);
|
|
18607
18651
|
logger.verbose(`tvlInToken0Bf: ${tvlInToken0Bf.toString()}`);
|
|
@@ -18639,7 +18683,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18639
18683
|
return shares;
|
|
18640
18684
|
}
|
|
18641
18685
|
async balanceOf(user, blockIdentifier = "pending") {
|
|
18642
|
-
let bal = await this.contract.call("balance_of", [user.address]
|
|
18686
|
+
let bal = await this.contract.call("balance_of", [user.address], {
|
|
18687
|
+
blockIdentifier
|
|
18688
|
+
});
|
|
18643
18689
|
return Web3Number.fromWei(bal.toString(), 18);
|
|
18644
18690
|
}
|
|
18645
18691
|
async getUserTVL(user, blockIdentifier = "pending") {
|
|
@@ -18787,11 +18833,16 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18787
18833
|
return Number(result.salt.toString());
|
|
18788
18834
|
}
|
|
18789
18835
|
async truePrice() {
|
|
18790
|
-
|
|
18791
|
-
|
|
18792
|
-
|
|
18793
|
-
|
|
18794
|
-
|
|
18836
|
+
if (this.metadata.additionalInfo.truePrice) {
|
|
18837
|
+
return this.metadata.additionalInfo.truePrice;
|
|
18838
|
+
} else if (this.lstContract) {
|
|
18839
|
+
const result = await this.lstContract.call("convert_to_assets", [
|
|
18840
|
+
uint2564.bnToUint256(BigInt(1e18).toString())
|
|
18841
|
+
]);
|
|
18842
|
+
const truePrice = Number(BigInt(result.toString()) * BigInt(1e9) / BigInt(1e18)) / 1e9;
|
|
18843
|
+
return truePrice;
|
|
18844
|
+
}
|
|
18845
|
+
throw new Error("No true price available");
|
|
18795
18846
|
}
|
|
18796
18847
|
async getCurrentPrice(blockIdentifier = "pending") {
|
|
18797
18848
|
const poolKey = await this.getPoolKey(blockIdentifier);
|
|
@@ -19345,6 +19396,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
19345
19396
|
const swap1Amount = Web3Number.fromWei(
|
|
19346
19397
|
uint2564.uint256ToBN(swapInfo1.token_from_amount).toString(),
|
|
19347
19398
|
18
|
|
19399
|
+
// cause its always STRK?
|
|
19348
19400
|
);
|
|
19349
19401
|
const remainingAmount = postFeeAmount.minus(swap1Amount);
|
|
19350
19402
|
const swapInfo2 = {
|
|
@@ -19435,6 +19487,9 @@ var _riskFactor2 = [
|
|
|
19435
19487
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 0.5, weight: 25 },
|
|
19436
19488
|
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1, weight: 75 }
|
|
19437
19489
|
];
|
|
19490
|
+
var _riskFactorStable = [
|
|
19491
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 0.5, weight: 25 }
|
|
19492
|
+
];
|
|
19438
19493
|
var AUDIT_URL2 = "https://assets.strkfarm.com/strkfarm/audit_report_vesu_and_ekubo_strats.pdf";
|
|
19439
19494
|
var faqs2 = [
|
|
19440
19495
|
{
|
|
@@ -19481,6 +19536,7 @@ var EkuboCLVaultStrategies = [
|
|
|
19481
19536
|
address: ContractAddr.from(
|
|
19482
19537
|
"0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
|
|
19483
19538
|
),
|
|
19539
|
+
launchBlock: 1209881,
|
|
19484
19540
|
type: "Other",
|
|
19485
19541
|
// must be same order as poolKey token0 and token1
|
|
19486
19542
|
depositTokens: [
|
|
@@ -19513,6 +19569,53 @@ var EkuboCLVaultStrategies = [
|
|
|
19513
19569
|
answer: "A negative APY can occur when xSTRK's price drops on DEXes. This is usually temporary and tends to recover within a few days or a week."
|
|
19514
19570
|
}
|
|
19515
19571
|
]
|
|
19572
|
+
},
|
|
19573
|
+
{
|
|
19574
|
+
name: "Ekubo USDC/USDT",
|
|
19575
|
+
description: /* @__PURE__ */ jsxs2("div", { children: [
|
|
19576
|
+
/* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "USDC/USDT") }),
|
|
19577
|
+
/* @__PURE__ */ jsx2(
|
|
19578
|
+
"ul",
|
|
19579
|
+
{
|
|
19580
|
+
style: {
|
|
19581
|
+
marginLeft: "20px",
|
|
19582
|
+
listStyle: "circle",
|
|
19583
|
+
fontSize: "12px"
|
|
19584
|
+
},
|
|
19585
|
+
children: /* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." })
|
|
19586
|
+
}
|
|
19587
|
+
)
|
|
19588
|
+
] }),
|
|
19589
|
+
address: ContractAddr.from(
|
|
19590
|
+
"0xd647ed735f0db52f2a5502b6e06ed21dc4284a43a36af4b60d3c80fbc56c91"
|
|
19591
|
+
),
|
|
19592
|
+
launchBlock: 1385576,
|
|
19593
|
+
type: "Other",
|
|
19594
|
+
// must be same order as poolKey token0 and token1
|
|
19595
|
+
depositTokens: [
|
|
19596
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
|
|
19597
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDT")
|
|
19598
|
+
],
|
|
19599
|
+
protocols: [_protocol2],
|
|
19600
|
+
auditUrl: AUDIT_URL2,
|
|
19601
|
+
maxTVL: Web3Number.fromWei("0", 6),
|
|
19602
|
+
risk: {
|
|
19603
|
+
riskFactor: _riskFactorStable,
|
|
19604
|
+
netRisk: _riskFactorStable.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactorStable.reduce((acc, curr) => acc + curr.weight, 0),
|
|
19605
|
+
notARisks: getNoRiskTags(_riskFactorStable)
|
|
19606
|
+
},
|
|
19607
|
+
apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
|
|
19608
|
+
additionalInfo: {
|
|
19609
|
+
newBounds: {
|
|
19610
|
+
lower: -1,
|
|
19611
|
+
upper: 1
|
|
19612
|
+
},
|
|
19613
|
+
truePrice: 1,
|
|
19614
|
+
feeBps: 1e3
|
|
19615
|
+
},
|
|
19616
|
+
faqs: [
|
|
19617
|
+
...faqs2
|
|
19618
|
+
]
|
|
19516
19619
|
}
|
|
19517
19620
|
];
|
|
19518
19621
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strkfarm/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
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",
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"typescript": "^5.5.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"react": "19.1.0"
|
|
54
|
+
"react": "19.1.0",
|
|
55
|
+
"starknet": "^6.11.0"
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
58
|
"@avnu/avnu-sdk": "^3.0.2",
|
|
@@ -67,7 +68,6 @@
|
|
|
67
68
|
"proxy-from-env": "^1.1.0",
|
|
68
69
|
"redis": "^4.7.0",
|
|
69
70
|
"stacktrace-js": "^2.0.2",
|
|
70
|
-
"starknet": "^6.11.0",
|
|
71
71
|
"winston": "^3.13.0"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -1,65 +1,67 @@
|
|
|
1
|
-
import { logger } from "@/
|
|
1
|
+
import { logger } from "@/utils/logger";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
|
|
4
4
|
export class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
|
|
5
|
-
|
|
5
|
+
decimals: number;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
constructor(value: string | number, decimals: number) {
|
|
8
|
+
super(value);
|
|
9
|
+
this.decimals = decimals;
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
toWei() {
|
|
13
|
+
return this.mul(10 ** this.decimals).toFixed(0);
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
multipliedBy(value: string | number | T): T {
|
|
17
|
+
const _value = this.getStandardString(value);
|
|
18
|
+
return this.construct(this.mul(_value).toString(), this.decimals);
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
dividedBy(value: string | number | T): T {
|
|
22
|
+
const _value = this.getStandardString(value);
|
|
23
|
+
return this.construct(this.div(_value).toString(), this.decimals);
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
plus(value: string | number | T): T {
|
|
27
|
+
const _value = this.getStandardString(value);
|
|
28
|
+
return this.construct(this.add(_value).toString(), this.decimals);
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
minus(n: number | string | T, base?: number): T {
|
|
32
|
+
const _value = this.getStandardString(n);
|
|
33
|
+
return this.construct(super.minus(_value, base).toString(), this.decimals);
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
protected construct(value: string | number, decimals: number): T {
|
|
37
|
+
return new (this.constructor as {
|
|
38
|
+
new (value: string | number, decimals: number): T;
|
|
39
|
+
})(value, decimals);
|
|
40
|
+
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
toString(): string {
|
|
43
|
+
return super.toString();
|
|
44
|
+
}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
toJSON() {
|
|
47
|
+
return this.toString();
|
|
48
|
+
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
valueOf() {
|
|
51
|
+
return this.toString();
|
|
52
|
+
}
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
private maxToFixedDecimals() {
|
|
55
|
+
return Math.min(this.decimals, 18);
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
return value.toFixed(this.maxToFixedDecimals())
|
|
58
|
+
private getStandardString(value: string | number | T): string {
|
|
59
|
+
if (typeof value == "string") {
|
|
60
|
+
return value;
|
|
61
61
|
}
|
|
62
|
+
return value.toFixed(this.maxToFixedDecimals());
|
|
63
|
+
}
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
BigNumber.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN })
|
|
65
|
-
_Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN })
|
|
66
|
+
BigNumber.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
67
|
+
_Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|