@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
package/dist/index.mjs
CHANGED
|
@@ -15320,7 +15320,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15320
15320
|
console.log(
|
|
15321
15321
|
`EkuboCLVault: getCurrentPrice: blockIdentifier: ${blockIdentifier}, sqrtRatio: ${sqrtRatio}, ${priceInfo.sqrt_ratio.toString()}`
|
|
15322
15322
|
);
|
|
15323
|
-
const
|
|
15323
|
+
const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
|
|
15324
|
+
const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
|
|
15325
|
+
const price = sqrtRatio * sqrtRatio * 10 ** token0Info.decimals / 10 ** token1Info.decimals;
|
|
15324
15326
|
const tick = _EkuboCLVault.priceToTick(
|
|
15325
15327
|
price,
|
|
15326
15328
|
true,
|
|
@@ -15345,7 +15347,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15345
15347
|
};
|
|
15346
15348
|
}
|
|
15347
15349
|
static div2Power128(num5) {
|
|
15348
|
-
return Number(BigInt(num5.toString()) *
|
|
15350
|
+
return Number(BigInt(num5.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
|
|
15349
15351
|
}
|
|
15350
15352
|
static priceToTick(price, isRoundDown, tickSpacing) {
|
|
15351
15353
|
const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
|
|
@@ -15366,18 +15368,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15366
15368
|
tick_spacing: result.pool_key.tick_spacing.toString(),
|
|
15367
15369
|
extension: result.pool_key.extension.toString()
|
|
15368
15370
|
};
|
|
15369
|
-
const token0Info = await Global.getTokenInfoFromAddr(poolKey.token0);
|
|
15370
|
-
const token1Info = await Global.getTokenInfoFromAddr(poolKey.token1);
|
|
15371
|
-
assert(
|
|
15372
|
-
token0Info.decimals == token1Info.decimals,
|
|
15373
|
-
"Tested only for equal decimals"
|
|
15374
|
-
);
|
|
15375
15371
|
this.poolKey = poolKey;
|
|
15376
15372
|
return poolKey;
|
|
15377
15373
|
}
|
|
15378
15374
|
async getNewBounds() {
|
|
15379
15375
|
const poolKey = await this.getPoolKey();
|
|
15380
15376
|
const currentPrice = await this._getCurrentPrice(poolKey);
|
|
15377
|
+
if (typeof this.metadata.additionalInfo.newBounds === "string") {
|
|
15378
|
+
throw new Error(`New bounds are managed known, to be set manually/externally`);
|
|
15379
|
+
}
|
|
15381
15380
|
const newLower = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.lower) * Number(poolKey.tick_spacing);
|
|
15382
15381
|
const newUpper = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.upper) * Number(poolKey.tick_spacing);
|
|
15383
15382
|
return {
|
|
@@ -15392,8 +15391,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15392
15391
|
* @param amount1: amount of token1
|
|
15393
15392
|
* @returns {amount0, amount1}
|
|
15394
15393
|
*/
|
|
15395
|
-
async _getExpectedAmountsForLiquidity(
|
|
15396
|
-
assert(
|
|
15394
|
+
async _getExpectedAmountsForLiquidity(inputAmount0, inputAmount1, bounds, justUseInputAmount = true) {
|
|
15395
|
+
assert(inputAmount0.greaterThan(0) || inputAmount1.greaterThan(0), "Amount is 0");
|
|
15397
15396
|
const sampleLiq = 1e20;
|
|
15398
15397
|
const { amount0: sampleAmount0, amount1: sampleAmount1 } = await this.getLiquidityToAmounts(
|
|
15399
15398
|
Web3Number.fromWei(sampleLiq.toString(), 18),
|
|
@@ -15407,39 +15406,37 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15407
15406
|
logger.verbose(
|
|
15408
15407
|
`${_EkuboCLVault.name}: _getExpectedAmountsForLiquidity => price: ${price}`
|
|
15409
15408
|
);
|
|
15410
|
-
if (
|
|
15409
|
+
if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
|
|
15411
15410
|
if (sampleAmount1.eq(0)) {
|
|
15412
15411
|
return {
|
|
15413
|
-
amount0,
|
|
15414
|
-
amount1: Web3Number.fromWei("0",
|
|
15412
|
+
amount0: inputAmount0,
|
|
15413
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals),
|
|
15415
15414
|
ratio: Infinity
|
|
15416
15415
|
};
|
|
15417
15416
|
} else if (sampleAmount0.eq(0)) {
|
|
15418
15417
|
return {
|
|
15419
|
-
amount0: Web3Number.fromWei("0",
|
|
15420
|
-
|
|
15418
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals),
|
|
15419
|
+
// to ensure decimal consistency, we start with 0
|
|
15420
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals).plus(inputAmount0.toString()).multipliedBy(price),
|
|
15421
15421
|
ratio: 0
|
|
15422
15422
|
};
|
|
15423
15423
|
}
|
|
15424
|
-
} else if (
|
|
15424
|
+
} else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
|
|
15425
15425
|
if (sampleAmount0.eq(0)) {
|
|
15426
15426
|
return {
|
|
15427
|
-
amount0: Web3Number.fromWei("0",
|
|
15428
|
-
amount1,
|
|
15427
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals),
|
|
15428
|
+
amount1: inputAmount1,
|
|
15429
15429
|
ratio: 0
|
|
15430
15430
|
};
|
|
15431
15431
|
} else if (sampleAmount1.eq(0)) {
|
|
15432
15432
|
return {
|
|
15433
|
-
|
|
15434
|
-
|
|
15433
|
+
// to ensure decimal consistency, we start with 0
|
|
15434
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals).plus(inputAmount1.toString()).dividedBy(price),
|
|
15435
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals),
|
|
15435
15436
|
ratio: Infinity
|
|
15436
15437
|
};
|
|
15437
15438
|
}
|
|
15438
15439
|
}
|
|
15439
|
-
assert(
|
|
15440
|
-
sampleAmount0.decimals == sampleAmount1.decimals,
|
|
15441
|
-
"Sample amounts have different decimals"
|
|
15442
|
-
);
|
|
15443
15440
|
const ratioWeb3Number = sampleAmount0.multipliedBy(1e18).dividedBy(sampleAmount1.toString()).dividedBy(1e18);
|
|
15444
15441
|
const ratio = Number(ratioWeb3Number.toFixed(18));
|
|
15445
15442
|
logger.verbose(
|
|
@@ -15447,23 +15444,23 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15447
15444
|
);
|
|
15448
15445
|
if (justUseInputAmount)
|
|
15449
15446
|
return this._solveExpectedAmountsEq(
|
|
15450
|
-
|
|
15451
|
-
|
|
15447
|
+
inputAmount0,
|
|
15448
|
+
inputAmount1,
|
|
15452
15449
|
ratioWeb3Number,
|
|
15453
15450
|
price
|
|
15454
15451
|
);
|
|
15455
|
-
if (
|
|
15456
|
-
const _amount1 =
|
|
15452
|
+
if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
|
|
15453
|
+
const _amount1 = new Web3Number(inputAmount0.toString(), inputAmount1.decimals).dividedBy(ratioWeb3Number);
|
|
15457
15454
|
return {
|
|
15458
|
-
amount0,
|
|
15455
|
+
amount0: inputAmount0,
|
|
15459
15456
|
amount1: _amount1,
|
|
15460
15457
|
ratio
|
|
15461
15458
|
};
|
|
15462
|
-
} else if (
|
|
15463
|
-
const _amount0 =
|
|
15459
|
+
} else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
|
|
15460
|
+
const _amount0 = new Web3Number(inputAmount1.toString(), inputAmount0.decimals).multipliedBy(ratio);
|
|
15464
15461
|
return {
|
|
15465
15462
|
amount0: _amount0,
|
|
15466
|
-
amount1,
|
|
15463
|
+
amount1: inputAmount1,
|
|
15467
15464
|
ratio
|
|
15468
15465
|
};
|
|
15469
15466
|
} else {
|
|
@@ -15526,7 +15523,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15526
15523
|
}
|
|
15527
15524
|
};
|
|
15528
15525
|
}
|
|
15529
|
-
async getSwapInfoToHandleUnused(considerRebalance = true) {
|
|
15526
|
+
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
|
|
15530
15527
|
const poolKey = await this.getPoolKey();
|
|
15531
15528
|
const unusedBalances = await this.unusedBalances(poolKey);
|
|
15532
15529
|
const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
|
|
@@ -15549,7 +15546,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15549
15546
|
`${_EkuboCLVault.name}: getSwapInfoToHandleUnused => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
|
|
15550
15547
|
);
|
|
15551
15548
|
let ekuboBounds;
|
|
15552
|
-
if (
|
|
15549
|
+
if (newBounds) {
|
|
15550
|
+
ekuboBounds = newBounds;
|
|
15551
|
+
} else if (considerRebalance) {
|
|
15553
15552
|
ekuboBounds = await this.getNewBounds();
|
|
15554
15553
|
} else {
|
|
15555
15554
|
ekuboBounds = await this.getCurrentBounds();
|
|
@@ -15790,6 +15789,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15790
15789
|
return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
|
|
15791
15790
|
}
|
|
15792
15791
|
static i129ToNumber(i129) {
|
|
15792
|
+
if (i129.sign == 0 || i129.sign == 1) {
|
|
15793
|
+
return _EkuboCLVault.i129ToNumber({ mag: i129.mag, sign: i129.sign == 1 ? "true" : "false" });
|
|
15794
|
+
}
|
|
15795
|
+
assert(i129.sign.toString() == "false" || i129.sign.toString() == "true", "Invalid sign value");
|
|
15793
15796
|
return i129.mag * (i129.sign.toString() == "false" ? 1n : -1n);
|
|
15794
15797
|
}
|
|
15795
15798
|
static tickToPrice(tick) {
|
|
@@ -15968,7 +15971,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15968
15971
|
subItems: [
|
|
15969
15972
|
{
|
|
15970
15973
|
key: "Range selection",
|
|
15971
|
-
value: `${this.metadata.additionalInfo.newBounds.lower * Number(poolKey.tick_spacing)} to ${this.metadata.additionalInfo.newBounds.upper * Number(poolKey.tick_spacing)} ticks`
|
|
15974
|
+
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`
|
|
15972
15975
|
}
|
|
15973
15976
|
],
|
|
15974
15977
|
linkedFlows: [linkedFlow],
|
|
@@ -16020,73 +16023,74 @@ var faqs2 = [
|
|
|
16020
16023
|
] })
|
|
16021
16024
|
}
|
|
16022
16025
|
];
|
|
16023
|
-
var
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
{
|
|
16031
|
-
|
|
16032
|
-
|
|
16033
|
-
|
|
16034
|
-
|
|
16035
|
-
|
|
16036
|
-
children:
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
]
|
|
16040
|
-
}
|
|
16041
|
-
)
|
|
16042
|
-
] }),
|
|
16043
|
-
address: ContractAddr.from(
|
|
16044
|
-
"0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
|
|
16045
|
-
),
|
|
16046
|
-
launchBlock: 1209881,
|
|
16047
|
-
type: "Other",
|
|
16048
|
-
// must be same order as poolKey token0 and token1
|
|
16049
|
-
depositTokens: [
|
|
16050
|
-
Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
|
|
16051
|
-
Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
16052
|
-
],
|
|
16053
|
-
protocols: [_protocol2],
|
|
16054
|
-
auditUrl: AUDIT_URL2,
|
|
16055
|
-
maxTVL: Web3Number.fromWei("0", 18),
|
|
16056
|
-
risk: {
|
|
16057
|
-
riskFactor: _riskFactor2,
|
|
16058
|
-
netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
|
|
16059
|
-
notARisks: getNoRiskTags(_riskFactor2)
|
|
16060
|
-
},
|
|
16061
|
-
apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
|
|
16062
|
-
additionalInfo: {
|
|
16063
|
-
newBounds: {
|
|
16064
|
-
lower: -1,
|
|
16065
|
-
upper: 1
|
|
16066
|
-
},
|
|
16067
|
-
lstContract: ContractAddr.from(
|
|
16068
|
-
"0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
|
|
16069
|
-
),
|
|
16070
|
-
feeBps: 1e3,
|
|
16071
|
-
rebalanceConditions: {
|
|
16072
|
-
customShouldRebalance: async (currentPrice) => true,
|
|
16073
|
-
minWaitHours: 24,
|
|
16074
|
-
direction: "uponly"
|
|
16026
|
+
var xSTRKSTRK = {
|
|
16027
|
+
name: "Ekubo xSTRK/STRK",
|
|
16028
|
+
description: /* @__PURE__ */ jsxs2("div", { children: [
|
|
16029
|
+
/* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
|
|
16030
|
+
/* @__PURE__ */ jsxs2(
|
|
16031
|
+
"ul",
|
|
16032
|
+
{
|
|
16033
|
+
style: {
|
|
16034
|
+
marginLeft: "20px",
|
|
16035
|
+
listStyle: "circle",
|
|
16036
|
+
fontSize: "12px"
|
|
16037
|
+
},
|
|
16038
|
+
children: [
|
|
16039
|
+
/* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
|
|
16040
|
+
/* @__PURE__ */ jsx2("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." })
|
|
16041
|
+
]
|
|
16075
16042
|
}
|
|
16043
|
+
)
|
|
16044
|
+
] }),
|
|
16045
|
+
address: ContractAddr.from(
|
|
16046
|
+
"0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324"
|
|
16047
|
+
),
|
|
16048
|
+
launchBlock: 1209881,
|
|
16049
|
+
type: "Other",
|
|
16050
|
+
// must be same order as poolKey token0 and token1
|
|
16051
|
+
depositTokens: [
|
|
16052
|
+
Global.getDefaultTokens().find((t) => t.symbol === "xSTRK"),
|
|
16053
|
+
Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
16054
|
+
],
|
|
16055
|
+
protocols: [_protocol2],
|
|
16056
|
+
auditUrl: AUDIT_URL2,
|
|
16057
|
+
maxTVL: Web3Number.fromWei("0", 18),
|
|
16058
|
+
risk: {
|
|
16059
|
+
riskFactor: _riskFactor2,
|
|
16060
|
+
netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
|
|
16061
|
+
notARisks: getNoRiskTags(_riskFactor2)
|
|
16062
|
+
},
|
|
16063
|
+
apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
|
|
16064
|
+
additionalInfo: {
|
|
16065
|
+
newBounds: {
|
|
16066
|
+
lower: -1,
|
|
16067
|
+
upper: 1
|
|
16076
16068
|
},
|
|
16077
|
-
|
|
16078
|
-
|
|
16079
|
-
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
logo: "https://endur.fi/favicon.ico",
|
|
16087
|
-
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."
|
|
16088
|
-
}]
|
|
16069
|
+
lstContract: ContractAddr.from(
|
|
16070
|
+
"0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
|
|
16071
|
+
),
|
|
16072
|
+
feeBps: 1e3,
|
|
16073
|
+
rebalanceConditions: {
|
|
16074
|
+
customShouldRebalance: async (currentPrice) => true,
|
|
16075
|
+
minWaitHours: 24,
|
|
16076
|
+
direction: "uponly"
|
|
16077
|
+
}
|
|
16089
16078
|
},
|
|
16079
|
+
faqs: [
|
|
16080
|
+
...faqs2,
|
|
16081
|
+
{
|
|
16082
|
+
question: "Why might I see a negative APY?",
|
|
16083
|
+
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."
|
|
16084
|
+
}
|
|
16085
|
+
],
|
|
16086
|
+
points: [{
|
|
16087
|
+
multiplier: 1,
|
|
16088
|
+
logo: "https://endur.fi/favicon.ico",
|
|
16089
|
+
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."
|
|
16090
|
+
}]
|
|
16091
|
+
};
|
|
16092
|
+
var EkuboCLVaultStrategies = [
|
|
16093
|
+
xSTRKSTRK,
|
|
16090
16094
|
{
|
|
16091
16095
|
name: "Ekubo USDC/USDT",
|
|
16092
16096
|
description: /* @__PURE__ */ jsxs2("div", { children: [
|
|
@@ -16140,6 +16144,47 @@ var EkuboCLVaultStrategies = [
|
|
|
16140
16144
|
},
|
|
16141
16145
|
faqs: [...faqs2]
|
|
16142
16146
|
}
|
|
16147
|
+
// {
|
|
16148
|
+
// ...xSTRKSTRK,
|
|
16149
|
+
// name: "Ekubo STRK/USDC",
|
|
16150
|
+
// description: (
|
|
16151
|
+
// <div>
|
|
16152
|
+
// <p>{_description.replace("{{POOL_NAME}}", "STRK/USDC")}</p>
|
|
16153
|
+
// <ul
|
|
16154
|
+
// style={{
|
|
16155
|
+
// marginLeft: "20px",
|
|
16156
|
+
// listStyle: "circle",
|
|
16157
|
+
// fontSize: "12px",
|
|
16158
|
+
// }}
|
|
16159
|
+
// >
|
|
16160
|
+
// <li style={{ marginTop: "10px" }}>
|
|
16161
|
+
// During withdrawal, you may receive either or both tokens depending
|
|
16162
|
+
// on market conditions and prevailing prices.
|
|
16163
|
+
// </li>
|
|
16164
|
+
// </ul>
|
|
16165
|
+
// </div>
|
|
16166
|
+
// ),
|
|
16167
|
+
// address: ContractAddr.from(
|
|
16168
|
+
// "0xb7bd37121041261446d8eedec618955a4490641034942da688e8cbddea7b23"
|
|
16169
|
+
// ),
|
|
16170
|
+
// launchBlock: 1492136,
|
|
16171
|
+
// // must be same order as poolKey token0 and token1
|
|
16172
|
+
// depositTokens: [
|
|
16173
|
+
// Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
|
|
16174
|
+
// Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
|
|
16175
|
+
// ],
|
|
16176
|
+
// maxTVL: Web3Number.fromWei("0", 6),
|
|
16177
|
+
// additionalInfo: {
|
|
16178
|
+
// newBounds: "Managed by Re7",
|
|
16179
|
+
// feeBps: 1000,
|
|
16180
|
+
// rebalanceConditions: {
|
|
16181
|
+
// customShouldRebalance: async (currentPrice: number) =>
|
|
16182
|
+
// true,
|
|
16183
|
+
// minWaitHours: 6,
|
|
16184
|
+
// direction: "any",
|
|
16185
|
+
// },
|
|
16186
|
+
// },
|
|
16187
|
+
// },
|
|
16143
16188
|
];
|
|
16144
16189
|
|
|
16145
16190
|
// src/notifs/telegram.ts
|