@strkfarm/sdk 1.0.45 → 1.0.46
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 +141 -98
- package/dist/index.browser.mjs +142 -99
- package/dist/index.d.ts +3 -3
- package/dist/index.js +141 -98
- package/dist/index.mjs +141 -98
- package/package.json +1 -1
- package/src/strategies/ekubo-cl-vault.tsx +165 -114
package/dist/index.mjs
CHANGED
|
@@ -15345,7 +15345,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15345
15345
|
};
|
|
15346
15346
|
}
|
|
15347
15347
|
static div2Power128(num5) {
|
|
15348
|
-
return Number(BigInt(num5.toString()) *
|
|
15348
|
+
return Number(BigInt(num5.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
|
|
15349
15349
|
}
|
|
15350
15350
|
static priceToTick(price, isRoundDown, tickSpacing) {
|
|
15351
15351
|
const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
|
|
@@ -15366,18 +15366,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15366
15366
|
tick_spacing: result.pool_key.tick_spacing.toString(),
|
|
15367
15367
|
extension: result.pool_key.extension.toString()
|
|
15368
15368
|
};
|
|
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
15369
|
this.poolKey = poolKey;
|
|
15376
15370
|
return poolKey;
|
|
15377
15371
|
}
|
|
15378
15372
|
async getNewBounds() {
|
|
15379
15373
|
const poolKey = await this.getPoolKey();
|
|
15380
15374
|
const currentPrice = await this._getCurrentPrice(poolKey);
|
|
15375
|
+
if (typeof this.metadata.additionalInfo.newBounds === "string") {
|
|
15376
|
+
throw new Error(`New bounds are managed known, to be set manually/externally`);
|
|
15377
|
+
}
|
|
15381
15378
|
const newLower = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.lower) * Number(poolKey.tick_spacing);
|
|
15382
15379
|
const newUpper = currentPrice.tick + Number(this.metadata.additionalInfo.newBounds.upper) * Number(poolKey.tick_spacing);
|
|
15383
15380
|
return {
|
|
@@ -15392,8 +15389,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15392
15389
|
* @param amount1: amount of token1
|
|
15393
15390
|
* @returns {amount0, amount1}
|
|
15394
15391
|
*/
|
|
15395
|
-
async _getExpectedAmountsForLiquidity(
|
|
15396
|
-
assert(
|
|
15392
|
+
async _getExpectedAmountsForLiquidity(inputAmount0, inputAmount1, bounds, justUseInputAmount = true) {
|
|
15393
|
+
assert(inputAmount0.greaterThan(0) || inputAmount1.greaterThan(0), "Amount is 0");
|
|
15397
15394
|
const sampleLiq = 1e20;
|
|
15398
15395
|
const { amount0: sampleAmount0, amount1: sampleAmount1 } = await this.getLiquidityToAmounts(
|
|
15399
15396
|
Web3Number.fromWei(sampleLiq.toString(), 18),
|
|
@@ -15407,39 +15404,37 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15407
15404
|
logger.verbose(
|
|
15408
15405
|
`${_EkuboCLVault.name}: _getExpectedAmountsForLiquidity => price: ${price}`
|
|
15409
15406
|
);
|
|
15410
|
-
if (
|
|
15407
|
+
if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
|
|
15411
15408
|
if (sampleAmount1.eq(0)) {
|
|
15412
15409
|
return {
|
|
15413
|
-
amount0,
|
|
15414
|
-
amount1: Web3Number.fromWei("0",
|
|
15410
|
+
amount0: inputAmount0,
|
|
15411
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals),
|
|
15415
15412
|
ratio: Infinity
|
|
15416
15413
|
};
|
|
15417
15414
|
} else if (sampleAmount0.eq(0)) {
|
|
15418
15415
|
return {
|
|
15419
|
-
amount0: Web3Number.fromWei("0",
|
|
15420
|
-
|
|
15416
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals),
|
|
15417
|
+
// to ensure decimal consistency, we start with 0
|
|
15418
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals).plus(inputAmount0.toString()).multipliedBy(price),
|
|
15421
15419
|
ratio: 0
|
|
15422
15420
|
};
|
|
15423
15421
|
}
|
|
15424
|
-
} else if (
|
|
15422
|
+
} else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
|
|
15425
15423
|
if (sampleAmount0.eq(0)) {
|
|
15426
15424
|
return {
|
|
15427
|
-
amount0: Web3Number.fromWei("0",
|
|
15428
|
-
amount1,
|
|
15425
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals),
|
|
15426
|
+
amount1: inputAmount1,
|
|
15429
15427
|
ratio: 0
|
|
15430
15428
|
};
|
|
15431
15429
|
} else if (sampleAmount1.eq(0)) {
|
|
15432
15430
|
return {
|
|
15433
|
-
|
|
15434
|
-
|
|
15431
|
+
// to ensure decimal consistency, we start with 0
|
|
15432
|
+
amount0: Web3Number.fromWei("0", inputAmount0.decimals).plus(inputAmount1.toString()).dividedBy(price),
|
|
15433
|
+
amount1: Web3Number.fromWei("0", inputAmount1.decimals),
|
|
15435
15434
|
ratio: Infinity
|
|
15436
15435
|
};
|
|
15437
15436
|
}
|
|
15438
15437
|
}
|
|
15439
|
-
assert(
|
|
15440
|
-
sampleAmount0.decimals == sampleAmount1.decimals,
|
|
15441
|
-
"Sample amounts have different decimals"
|
|
15442
|
-
);
|
|
15443
15438
|
const ratioWeb3Number = sampleAmount0.multipliedBy(1e18).dividedBy(sampleAmount1.toString()).dividedBy(1e18);
|
|
15444
15439
|
const ratio = Number(ratioWeb3Number.toFixed(18));
|
|
15445
15440
|
logger.verbose(
|
|
@@ -15447,23 +15442,23 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15447
15442
|
);
|
|
15448
15443
|
if (justUseInputAmount)
|
|
15449
15444
|
return this._solveExpectedAmountsEq(
|
|
15450
|
-
|
|
15451
|
-
|
|
15445
|
+
inputAmount0,
|
|
15446
|
+
inputAmount1,
|
|
15452
15447
|
ratioWeb3Number,
|
|
15453
15448
|
price
|
|
15454
15449
|
);
|
|
15455
|
-
if (
|
|
15456
|
-
const _amount1 =
|
|
15450
|
+
if (inputAmount1.eq(0) && inputAmount0.greaterThan(0)) {
|
|
15451
|
+
const _amount1 = new Web3Number(inputAmount0.toString(), inputAmount1.decimals).dividedBy(ratioWeb3Number);
|
|
15457
15452
|
return {
|
|
15458
|
-
amount0,
|
|
15453
|
+
amount0: inputAmount0,
|
|
15459
15454
|
amount1: _amount1,
|
|
15460
15455
|
ratio
|
|
15461
15456
|
};
|
|
15462
|
-
} else if (
|
|
15463
|
-
const _amount0 =
|
|
15457
|
+
} else if (inputAmount0.eq(0) && inputAmount1.greaterThan(0)) {
|
|
15458
|
+
const _amount0 = new Web3Number(inputAmount1.toString(), inputAmount0.decimals).multipliedBy(ratio);
|
|
15464
15459
|
return {
|
|
15465
15460
|
amount0: _amount0,
|
|
15466
|
-
amount1,
|
|
15461
|
+
amount1: inputAmount1,
|
|
15467
15462
|
ratio
|
|
15468
15463
|
};
|
|
15469
15464
|
} else {
|
|
@@ -15526,7 +15521,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15526
15521
|
}
|
|
15527
15522
|
};
|
|
15528
15523
|
}
|
|
15529
|
-
async getSwapInfoToHandleUnused(considerRebalance = true) {
|
|
15524
|
+
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null) {
|
|
15530
15525
|
const poolKey = await this.getPoolKey();
|
|
15531
15526
|
const unusedBalances = await this.unusedBalances(poolKey);
|
|
15532
15527
|
const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
|
|
@@ -15549,7 +15544,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15549
15544
|
`${_EkuboCLVault.name}: getSwapInfoToHandleUnused => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
|
|
15550
15545
|
);
|
|
15551
15546
|
let ekuboBounds;
|
|
15552
|
-
if (
|
|
15547
|
+
if (newBounds) {
|
|
15548
|
+
ekuboBounds = newBounds;
|
|
15549
|
+
} else if (considerRebalance) {
|
|
15553
15550
|
ekuboBounds = await this.getNewBounds();
|
|
15554
15551
|
} else {
|
|
15555
15552
|
ekuboBounds = await this.getCurrentBounds();
|
|
@@ -15790,6 +15787,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15790
15787
|
return BigInt(Math.floor(Math.sqrt(price) * 10 ** 9)) * BigInt(2 ** 128) / BigInt(1e9);
|
|
15791
15788
|
}
|
|
15792
15789
|
static i129ToNumber(i129) {
|
|
15790
|
+
if (i129.sign == 0 || i129.sign == 1) {
|
|
15791
|
+
return _EkuboCLVault.i129ToNumber({ mag: i129.mag, sign: i129.sign == 1 ? "true" : "false" });
|
|
15792
|
+
}
|
|
15793
|
+
assert(i129.sign.toString() == "false" || i129.sign.toString() == "true", "Invalid sign value");
|
|
15793
15794
|
return i129.mag * (i129.sign.toString() == "false" ? 1n : -1n);
|
|
15794
15795
|
}
|
|
15795
15796
|
static tickToPrice(tick) {
|
|
@@ -15968,7 +15969,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15968
15969
|
subItems: [
|
|
15969
15970
|
{
|
|
15970
15971
|
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`
|
|
15972
|
+
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
15973
|
}
|
|
15973
15974
|
],
|
|
15974
15975
|
linkedFlows: [linkedFlow],
|
|
@@ -16020,73 +16021,74 @@ var faqs2 = [
|
|
|
16020
16021
|
] })
|
|
16021
16022
|
}
|
|
16022
16023
|
];
|
|
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"
|
|
16024
|
+
var xSTRKSTRK = {
|
|
16025
|
+
name: "Ekubo xSTRK/STRK",
|
|
16026
|
+
description: /* @__PURE__ */ jsxs2("div", { children: [
|
|
16027
|
+
/* @__PURE__ */ jsx2("p", { children: _description2.replace("{{POOL_NAME}}", "xSTRK/STRK") }),
|
|
16028
|
+
/* @__PURE__ */ jsxs2(
|
|
16029
|
+
"ul",
|
|
16030
|
+
{
|
|
16031
|
+
style: {
|
|
16032
|
+
marginLeft: "20px",
|
|
16033
|
+
listStyle: "circle",
|
|
16034
|
+
fontSize: "12px"
|
|
16035
|
+
},
|
|
16036
|
+
children: [
|
|
16037
|
+
/* @__PURE__ */ jsx2("li", { style: { marginTop: "10px" }, children: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices." }),
|
|
16038
|
+
/* @__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." })
|
|
16039
|
+
]
|
|
16075
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
|
|
16076
16066
|
},
|
|
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
|
-
}]
|
|
16067
|
+
lstContract: ContractAddr.from(
|
|
16068
|
+
"0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
|
|
16069
|
+
),
|
|
16070
|
+
feeBps: 1e3,
|
|
16071
|
+
rebalanceConditions: {
|
|
16072
|
+
customShouldRebalance: async (currentPrice) => true,
|
|
16073
|
+
minWaitHours: 24,
|
|
16074
|
+
direction: "uponly"
|
|
16075
|
+
}
|
|
16089
16076
|
},
|
|
16077
|
+
faqs: [
|
|
16078
|
+
...faqs2,
|
|
16079
|
+
{
|
|
16080
|
+
question: "Why might I see a negative APY?",
|
|
16081
|
+
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."
|
|
16082
|
+
}
|
|
16083
|
+
],
|
|
16084
|
+
points: [{
|
|
16085
|
+
multiplier: 1,
|
|
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
|
+
}]
|
|
16089
|
+
};
|
|
16090
|
+
var EkuboCLVaultStrategies = [
|
|
16091
|
+
xSTRKSTRK,
|
|
16090
16092
|
{
|
|
16091
16093
|
name: "Ekubo USDC/USDT",
|
|
16092
16094
|
description: /* @__PURE__ */ jsxs2("div", { children: [
|
|
@@ -16140,6 +16142,47 @@ var EkuboCLVaultStrategies = [
|
|
|
16140
16142
|
},
|
|
16141
16143
|
faqs: [...faqs2]
|
|
16142
16144
|
}
|
|
16145
|
+
// {
|
|
16146
|
+
// ...xSTRKSTRK,
|
|
16147
|
+
// name: "Ekubo STRK/USDC",
|
|
16148
|
+
// description: (
|
|
16149
|
+
// <div>
|
|
16150
|
+
// <p>{_description.replace("{{POOL_NAME}}", "STRK/USDC")}</p>
|
|
16151
|
+
// <ul
|
|
16152
|
+
// style={{
|
|
16153
|
+
// marginLeft: "20px",
|
|
16154
|
+
// listStyle: "circle",
|
|
16155
|
+
// fontSize: "12px",
|
|
16156
|
+
// }}
|
|
16157
|
+
// >
|
|
16158
|
+
// <li style={{ marginTop: "10px" }}>
|
|
16159
|
+
// During withdrawal, you may receive either or both tokens depending
|
|
16160
|
+
// on market conditions and prevailing prices.
|
|
16161
|
+
// </li>
|
|
16162
|
+
// </ul>
|
|
16163
|
+
// </div>
|
|
16164
|
+
// ),
|
|
16165
|
+
// address: ContractAddr.from(
|
|
16166
|
+
// "0xb7bd37121041261446d8eedec618955a4490641034942da688e8cbddea7b23"
|
|
16167
|
+
// ),
|
|
16168
|
+
// launchBlock: 1492136,
|
|
16169
|
+
// // must be same order as poolKey token0 and token1
|
|
16170
|
+
// depositTokens: [
|
|
16171
|
+
// Global.getDefaultTokens().find((t) => t.symbol === "STRK")!,
|
|
16172
|
+
// Global.getDefaultTokens().find((t) => t.symbol === "USDC")!,
|
|
16173
|
+
// ],
|
|
16174
|
+
// maxTVL: Web3Number.fromWei("0", 6),
|
|
16175
|
+
// additionalInfo: {
|
|
16176
|
+
// newBounds: "Managed by Re7",
|
|
16177
|
+
// feeBps: 1000,
|
|
16178
|
+
// rebalanceConditions: {
|
|
16179
|
+
// customShouldRebalance: async (currentPrice: number) =>
|
|
16180
|
+
// true,
|
|
16181
|
+
// minWaitHours: 6,
|
|
16182
|
+
// direction: "any",
|
|
16183
|
+
// },
|
|
16184
|
+
// },
|
|
16185
|
+
// },
|
|
16143
16186
|
];
|
|
16144
16187
|
|
|
16145
16188
|
// src/notifs/telegram.ts
|