@strkfarm/sdk 1.0.45 → 1.0.47
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 +144 -99
- package/dist/index.browser.mjs +145 -100
- package/dist/index.d.ts +3 -3
- package/dist/index.js +144 -99
- package/dist/index.mjs +144 -99
- package/package.json +1 -1
- package/src/strategies/ekubo-cl-vault.tsx +166 -115
|
@@ -51477,7 +51477,9 @@ var strkfarm_risk_engine = (() => {
|
|
|
51477
51477
|
console.log(
|
|
51478
51478
|
`EkuboCLVault: getCurrentPrice: blockIdentifier: ${blockIdentifier}, sqrtRatio: ${sqrtRatio}, ${priceInfo.sqrt_ratio.toString()}`
|
|
51479
51479
|
);
|
|
51480
|
-
const
|
|
51480
|
+
const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
|
|
51481
|
+
const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
|
|
51482
|
+
const price = sqrtRatio * sqrtRatio * 10 ** token0Info.decimals / 10 ** token1Info.decimals;
|
|
51481
51483
|
const tick = _EkuboCLVault.priceToTick(
|
|
51482
51484
|
price,
|
|
51483
51485
|
true,
|
|
@@ -51502,7 +51504,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
51502
51504
|
};
|
|
51503
51505
|
}
|
|
51504
51506
|
static div2Power128(num) {
|
|
51505
|
-
return Number(BigInt(num.toString()) *
|
|
51507
|
+
return Number(BigInt(num.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
|
|
51506
51508
|
}
|
|
51507
51509
|
static priceToTick(price, isRoundDown, tickSpacing) {
|
|
51508
51510
|
const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
|
|
@@ -51523,18 +51525,15 @@ var strkfarm_risk_engine = (() => {
|
|
|
51523
51525
|
tick_spacing: result.pool_key.tick_spacing.toString(),
|
|
51524
51526
|
extension: result.pool_key.extension.toString()
|
|
51525
51527
|
};
|
|
51526
|
-
const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
|
|
51527
|
-
const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
|
|
51528
|
-
assert3(
|
|
51529
|
-
token0Info.decimals == token1Info.decimals,
|
|
51530
|
-
"Tested only for equal decimals"
|
|
51531
|
-
);
|
|
51532
51528
|
this.poolKey = poolKey;
|
|
51533
51529
|
return poolKey;
|
|
51534
51530
|
}
|
|
51535
51531
|
async getNewBounds() {
|
|
51536
51532
|
const poolKey = await this.getPoolKey();
|
|
51537
51533
|
const currentPrice = await this._getCurrentPrice(poolKey);
|
|
51534
|
+
if (typeof this.metadata.additionalInfo.newBounds === "string") {
|
|
51535
|
+
throw new Error(`New bounds are managed known, to be set manually/externally`);
|
|
51536
|
+
}
|
|
51538
51537
|
const newLower = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.lower) * Number(poolKey.tick_spacing);
|
|
51539
51538
|
const newUpper = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.upper) * Number(poolKey.tick_spacing);
|
|
51540
51539
|
return {
|
|
@@ -51549,8 +51548,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
51549
51548
|
* @param amount1: amount of token1
|
|
51550
51549
|
* @returns {amount0, amount1}
|
|
51551
51550
|
*/
|
|
51552
|
-
async _getExpectedAmountsForLiquidity(
|
|
51553
|
-
assert3(
|
|
51551
|
+
async _getExpectedAmountsForLiquidity(inputAmount0, inputAmount1, bounds, justUseInputAmount = true) {
|
|
51552
|
+
assert3(inputAmount0.greaterThan(0) || inputAmount1.greaterThan(0), "Amount is 0");
|
|
51554
51553
|
const sampleLiq = 1e20;
|
|
51555
51554
|
const { amount0: sampleAmount0, amount1: sampleAmount1 } = await this.getLiquidityToAmounts(
|
|
51556
51555
|
Web3Number.fromWei(sampleLiq.toString(), 18),
|
|
@@ -51564,39 +51563,37 @@ var strkfarm_risk_engine = (() => {
|
|
|
51564
51563
|
logger.verbose(
|
|
51565
51564
|
`${_EkuboCLVault.name}: _getExpectedAmountsForLiquidity => price: ${price}`
|
|
51566
51565
|
);
|
|
51567
|
-
if (
|
|
51566
|
+
if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
|
|
51568
51567
|
if (sampleAmount1.eq(0)) {
|
|
51569
51568
|
return {
|
|
51570
|
-
amount0,
|
|
51571
|
-
amount1: Web3Number.fromWei("0",
|
|
51569
|
+
amount0: inputAmount0,
|
|
51570
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals),
|
|
51572
51571
|
ratio: Infinity
|
|
51573
51572
|
};
|
|
51574
51573
|
} else if (sampleAmount0.eq(0)) {
|
|
51575
51574
|
return {
|
|
51576
|
-
amount0: Web3Number.fromWei("0",
|
|
51577
|
-
|
|
51575
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals),
|
|
51576
|
+
// to ensure decimal consistency, we start with 0
|
|
51577
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals).plus(inputAmount0.toString()).multipliedBy(price),
|
|
51578
51578
|
ratio: 0
|
|
51579
51579
|
};
|
|
51580
51580
|
}
|
|
51581
|
-
} else if (
|
|
51581
|
+
} else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
|
|
51582
51582
|
if (sampleAmount0.eq(0)) {
|
|
51583
51583
|
return {
|
|
51584
|
-
amount0: Web3Number.fromWei("0",
|
|
51585
|
-
amount1,
|
|
51584
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals),
|
|
51585
|
+
amount1: inputAmount1,
|
|
51586
51586
|
ratio: 0
|
|
51587
51587
|
};
|
|
51588
51588
|
} else if (sampleAmount1.eq(0)) {
|
|
51589
51589
|
return {
|
|
51590
|
-
|
|
51591
|
-
|
|
51590
|
+
// to ensure decimal consistency, we start with 0
|
|
51591
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals).plus(inputAmount1.toString()).dividedBy(price),
|
|
51592
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals),
|
|
51592
51593
|
ratio: Infinity
|
|
51593
51594
|
};
|
|
51594
51595
|
}
|
|
51595
51596
|
}
|
|
51596
|
-
assert3(
|
|
51597
|
-
sampleAmount0.decimals == sampleAmount1.decimals,
|
|
51598
|
-
"Sample amounts have different decimals"
|
|
51599
|
-
);
|
|
51600
51597
|
const ratioWeb3Number = sampleAmount0.multipliedBy(1e18).dividedBy(sampleAmount1.toString()).dividedBy(1e18);
|
|
51601
51598
|
const ratio = Number(ratioWeb3Number.toFixed(18));
|
|
51602
51599
|
logger.verbose(
|
|
@@ -51604,23 +51601,23 @@ var strkfarm_risk_engine = (() => {
|
|
|
51604
51601
|
);
|
|
51605
51602
|
if (justUseInputAmount)
|
|
51606
51603
|
return this._solveExpectedAmountsEq(
|
|
51607
|
-
|
|
51608
|
-
|
|
51604
|
+
inputAmount0,
|
|
51605
|
+
inputAmount1,
|
|
51609
51606
|
ratioWeb3Number,
|
|
51610
51607
|
price
|
|
51611
51608
|
);
|
|
51612
|
-
if (
|
|
51613
|
-
const _amount1 =
|
|
51609
|
+
if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
|
|
51610
|
+
const _amount1 = new Web3Number(inputAmount0.toString(), inputAmount1.decimals).dividedBy(ratioWeb3Number);
|
|
51614
51611
|
return {
|
|
51615
|
-
amount0,
|
|
51612
|
+
amount0: inputAmount0,
|
|
51616
51613
|
amount1: _amount1,
|
|
51617
51614
|
ratio
|
|
51618
51615
|
};
|
|
51619
|
-
} else if (
|
|
51620
|
-
const _amount0 =
|
|
51616
|
+
} else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
|
|
51617
|
+
const _amount0 = new Web3Number(inputAmount1.toString(), inputAmount0.decimals).multipliedBy(ratio);
|
|
51621
51618
|
return {
|
|
51622
51619
|
amount0: _amount0,
|
|
51623
|
-
amount1,
|
|
51620
|
+
amount1: inputAmount1,
|
|
51624
51621
|
ratio
|
|
51625
51622
|
};
|
|
51626
51623
|
} else {
|
|
@@ -51683,7 +51680,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
51683
51680
|
}
|
|
51684
51681
|
};
|
|
51685
51682
|
}
|
|
51686
|
-
async getSwapInfoToHandleUnused(considerRebalance = true) {
|
|
51683
|
+
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
|
|
51687
51684
|
const poolKey = await this.getPoolKey();
|
|
51688
51685
|
const unusedBalances = await this.unusedBalances(poolKey);
|
|
51689
51686
|
const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
|
|
@@ -51706,7 +51703,9 @@ var strkfarm_risk_engine = (() => {
|
|
|
51706
51703
|
`${_EkuboCLVault.name}: getSwapInfoToHandleUnused => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
|
|
51707
51704
|
);
|
|
51708
51705
|
let ekuboBounds;
|
|
51709
|
-
if (
|
|
51706
|
+
if (newBounds) {
|
|
51707
|
+
ekuboBounds = newBounds;
|
|
51708
|
+
} else if (considerRebalance) {
|
|
51710
51709
|
ekuboBounds = await this.getNewBounds();
|
|
51711
51710
|
} else {
|
|
51712
51711
|
ekuboBounds = await this.getCurrentBounds();
|
|
@@ -51947,6 +51946,10 @@ var strkfarm_risk_engine = (() => {
|
|
|
51947
51946
|
return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
|
|
51948
51947
|
}
|
|
51949
51948
|
static i129ToNumber(i129) {
|
|
51949
|
+
if (i129.sign == 0 || i129.sign == 1) {
|
|
51950
|
+
return _EkuboCLVault.i129ToNumber({ mag: i129.mag, sign: i129.sign == 1 ? "true" : "false" });
|
|
51951
|
+
}
|
|
51952
|
+
assert3(i129.sign.toString() == "false" || i129.sign.toString() == "true", "Invalid sign value");
|
|
51950
51953
|
return i129.mag * (i129.sign.toString() == "false" ? 1n : -1n);
|
|
51951
51954
|
}
|
|
51952
51955
|
static tickToPrice(tick) {
|
|
@@ -52125,7 +52128,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
52125
52128
|
subItems: [
|
|
52126
52129
|
{
|
|
52127
52130
|
key: "Range selection",
|
|
52128
|
-
value: `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
|
|
52131
|
+
value: typeof this.metadata.additionalInfo.newBounds == "string" ? this.metadata.additionalInfo.newBounds : `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
|
|
52129
52132
|
}
|
|
52130
52133
|
],
|
|
52131
52134
|
linkedFlows: [linkedFlow],
|
|
@@ -52177,73 +52180,74 @@ var strkfarm_risk_engine = (() => {
|
|
|
52177
52180
|
] })
|
|
52178
52181
|
}
|
|
52179
52182
|
];
|
|
52180
|
-
var
|
|
52181
|
-
|
|
52182
|
-
|
|
52183
|
-
|
|
52184
|
-
|
|
52185
|
-
|
|
52186
|
-
|
|
52187
|
-
{
|
|
52188
|
-
|
|
52189
|
-
|
|
52190
|
-
|
|
52191
|
-
|
|
52192
|
-
|
|
52193
|
-
children:
|
|
52194
|
-
|
|
52195
|
-
|
|
52196
|
-
]
|
|
52197
|
-
}
|
|
52198
|
-
)
|
|
52199
|
-
] }),
|
|
52200
|
-
address: ContractAddr.from(
|
|
52201
|
-
"0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
|
|
52202
|
-
),
|
|
52203
|
-
launchBlock: 1209881,
|
|
52204
|
-
type: "Other",
|
|
52205
|
-
// must be same order as poolKey token0 and token1
|
|
52206
|
-
depositTokens: [
|
|
52207
|
-
Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
|
|
52208
|
-
Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
52209
|
-
],
|
|
52210
|
-
protocols: [_protocol2],
|
|
52211
|
-
auditUrl: AUDIT_URL2,
|
|
52212
|
-
maxTVL: Web3Number.fromWei("0", 18),
|
|
52213
|
-
risk: {
|
|
52214
|
-
riskFactor: _riskFactor2,
|
|
52215
|
-
netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
|
|
52216
|
-
notARisks: getNoRiskTags(_riskFactor2)
|
|
52217
|
-
},
|
|
52218
|
-
apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
|
|
52219
|
-
additionalInfo: {
|
|
52220
|
-
newBounds: {
|
|
52221
|
-
lower: -1,
|
|
52222
|
-
upper: 1
|
|
52223
|
-
},
|
|
52224
|
-
lstContract: ContractAddr.from(
|
|
52225
|
-
"0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
|
|
52226
|
-
),
|
|
52227
|
-
feeBps: 1e3,
|
|
52228
|
-
rebalanceConditions: {
|
|
52229
|
-
customShouldRebalance: async (currentPrice) => true,
|
|
52230
|
-
minWaitHours: 24,
|
|
52231
|
-
direction: "uponly"
|
|
52183
|
+
var xSTRKSTRK = {
|
|
52184
|
+
name: "Ekubo xSTRK/STRK",
|
|
52185
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
52186
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
|
|
52187
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
52188
|
+
"ul",
|
|
52189
|
+
{
|
|
52190
|
+
style: {
|
|
52191
|
+
marginLeft: "20px",
|
|
52192
|
+
listStyle: "circle",
|
|
52193
|
+
fontSize: "12px"
|
|
52194
|
+
},
|
|
52195
|
+
children: [
|
|
52196
|
+
/* @__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." }),
|
|
52197
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { style: { marginTop: "10px" }, children: "Sometimes you might see a negative APY \u2014 this is usually not a big deal. It happens when xSTRK's price drops on DEXes, but things typically bounce back within a few days or a week." })
|
|
52198
|
+
]
|
|
52232
52199
|
}
|
|
52200
|
+
)
|
|
52201
|
+
] }),
|
|
52202
|
+
address: ContractAddr.from(
|
|
52203
|
+
"0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
|
|
52204
|
+
),
|
|
52205
|
+
launchBlock: 1209881,
|
|
52206
|
+
type: "Other",
|
|
52207
|
+
// must be same order as poolKey token0 and token1
|
|
52208
|
+
depositTokens: [
|
|
52209
|
+
Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
|
|
52210
|
+
Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
52211
|
+
],
|
|
52212
|
+
protocols: [_protocol2],
|
|
52213
|
+
auditUrl: AUDIT_URL2,
|
|
52214
|
+
maxTVL: Web3Number.fromWei("0", 18),
|
|
52215
|
+
risk: {
|
|
52216
|
+
riskFactor: _riskFactor2,
|
|
52217
|
+
netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
|
|
52218
|
+
notARisks: getNoRiskTags(_riskFactor2)
|
|
52219
|
+
},
|
|
52220
|
+
apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
|
|
52221
|
+
additionalInfo: {
|
|
52222
|
+
newBounds: {
|
|
52223
|
+
lower: -1,
|
|
52224
|
+
upper: 1
|
|
52233
52225
|
},
|
|
52234
|
-
|
|
52235
|
-
|
|
52236
|
-
|
|
52237
|
-
|
|
52238
|
-
|
|
52239
|
-
|
|
52240
|
-
|
|
52241
|
-
|
|
52242
|
-
|
|
52243
|
-
logo: "https://endur.fi/favicon.ico",
|
|
52244
|
-
toolTip: "This strategy holds xSTRK and STRK tokens. Earn 1x Endur points on your xSTRK portion of Liquidity. STRK portion will earn Endur's DEX Bonus points. Points can be found on endur.fi."
|
|
52245
|
-
}]
|
|
52226
|
+
lstContract: ContractAddr.from(
|
|
52227
|
+
"0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
|
|
52228
|
+
),
|
|
52229
|
+
feeBps: 1e3,
|
|
52230
|
+
rebalanceConditions: {
|
|
52231
|
+
customShouldRebalance: async (currentPrice) => true,
|
|
52232
|
+
minWaitHours: 24,
|
|
52233
|
+
direction: "uponly"
|
|
52234
|
+
}
|
|
52246
52235
|
},
|
|
52236
|
+
faqs: [
|
|
52237
|
+
...faqs2,
|
|
52238
|
+
{
|
|
52239
|
+
question: "Why might I see a negative APY?",
|
|
52240
|
+
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."
|
|
52241
|
+
}
|
|
52242
|
+
],
|
|
52243
|
+
points: [{
|
|
52244
|
+
multiplier: 1,
|
|
52245
|
+
logo: "https://endur.fi/favicon.ico",
|
|
52246
|
+
toolTip: "This strategy holds xSTRK and STRK tokens. Earn 1x Endur points on your xSTRK portion of Liquidity. STRK portion will earn Endur's DEX Bonus points. Points can be found on endur.fi."
|
|
52247
|
+
}]
|
|
52248
|
+
};
|
|
52249
|
+
var EkuboCLVaultStrategies = [
|
|
52250
|
+
xSTRKSTRK,
|
|
52247
52251
|
{
|
|
52248
52252
|
name: "Ekubo USDC/USDT",
|
|
52249
52253
|
description: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
@@ -52297,6 +52301,47 @@ var strkfarm_risk_engine = (() => {
|
|
|
52297
52301
|
},
|
|
52298
52302
|
faqs: [...faqs2]
|
|
52299
52303
|
}
|
|
52304
|
+
// {
|
|
52305
|
+
// ...xSTRKSTRK,
|
|
52306
|
+
// name: "Ekubo STRK/USDC",
|
|
52307
|
+
// description: (
|
|
52308
|
+
// <div>
|
|
52309
|
+
// <p>{_description.replace("{{POOL_NAME}}", "STRK/USDC")}</p>
|
|
52310
|
+
// <ul
|
|
52311
|
+
// style={{
|
|
52312
|
+
// marginLeft: "20px",
|
|
52313
|
+
// listStyle: "circle",
|
|
52314
|
+
// fontSize: "12px",
|
|
52315
|
+
// }}
|
|
52316
|
+
// >
|
|
52317
|
+
// <li style={{ marginTop: "10px" }}>
|
|
52318
|
+
// During withdrawal, you may receive either or both tokens depending
|
|
52319
|
+
// on market conditions and prevailing prices.
|
|
52320
|
+
// </li>
|
|
52321
|
+
// </ul>
|
|
52322
|
+
// </div>
|
|
52323
|
+
// ),
|
|
52324
|
+
// address: ContractAddr.from(
|
|
52325
|
+
// "0xb7bd37121041261446d8eedec618955a4490641034942da688e8cbddea7b23"
|
|
52326
|
+
// ),
|
|
52327
|
+
// launchBlock: 1492136,
|
|
52328
|
+
// // must be same order as poolKey token0 and token1
|
|
52329
|
+
// depositTokens: [
|
|
52330
|
+
// Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
|
|
52331
|
+
// Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
|
|
52332
|
+
// ],
|
|
52333
|
+
// maxTVL: Web3Number.fromWei("0", 6),
|
|
52334
|
+
// additionalInfo: {
|
|
52335
|
+
// newBounds: "Managed by Re7",
|
|
52336
|
+
// feeBps: 1000,
|
|
52337
|
+
// rebalanceConditions: {
|
|
52338
|
+
// customShouldRebalance: async (currentPrice: number) =>
|
|
52339
|
+
// true,
|
|
52340
|
+
// minWaitHours: 6,
|
|
52341
|
+
// direction: "any",
|
|
52342
|
+
// },
|
|
52343
|
+
// },
|
|
52344
|
+
// },
|
|
52300
52345
|
];
|
|
52301
52346
|
return __toCommonJS(index_browser_exports);
|
|
52302
52347
|
})();
|