@strkfarm/sdk 1.0.31 → 1.0.33
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 +11 -4
- package/dist/cli.mjs +11 -4
- package/dist/index.browser.global.js +1311 -26
- package/dist/index.browser.mjs +65 -28
- package/dist/index.d.ts +3 -2
- package/dist/index.js +65 -28
- package/dist/index.mjs +65 -28
- package/package.json +5 -1
- package/src/interfaces/common.ts +2 -1
- package/src/strategies/{ekubo-cl-vault.ts → ekubo-cl-vault.tsx} +62 -33
- package/src/strategies/{vesu-rebalance.ts → vesu-rebalance.tsx} +1 -1
|
@@ -702,16 +702,16 @@ export class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
702
702
|
swapInfo: SwapInfo,
|
|
703
703
|
acc: Account,
|
|
704
704
|
estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>,
|
|
705
|
+
isSellTokenToken0 = true,
|
|
705
706
|
retry = 0,
|
|
706
|
-
|
|
707
|
-
|
|
707
|
+
lowerLimit = 0n,
|
|
708
|
+
upperLimit = 0n,
|
|
708
709
|
): Promise<Call[]> {
|
|
709
|
-
const MAX_RETRIES =
|
|
710
|
-
const MIN_ADJUSTMENT = 0.001; // Minimum adjustment factor
|
|
710
|
+
const MAX_RETRIES = 40;
|
|
711
711
|
|
|
712
712
|
logger.verbose(
|
|
713
713
|
`Rebalancing ${this.metadata.name}: ` +
|
|
714
|
-
`retry=${retry},
|
|
714
|
+
`retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
|
|
715
715
|
);
|
|
716
716
|
|
|
717
717
|
const fromAmount = uint256.uint256ToBN(swapInfo.token_from_amount);
|
|
@@ -729,47 +729,70 @@ export class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
729
729
|
throw err;
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
if (adjustmentFactor < MIN_ADJUSTMENT) {
|
|
733
|
-
logger.error('Adjustment factor too small, likely oscillating');
|
|
734
|
-
throw new Error('Failed to converge on valid swap amount');
|
|
735
|
-
}
|
|
736
|
-
|
|
737
732
|
logger.error(`Rebalance attempt ${retry + 1} failed, adjusting swap amount...`);
|
|
738
733
|
|
|
739
734
|
const newSwapInfo = { ...swapInfo };
|
|
740
735
|
const currentAmount = Web3Number.fromWei(fromAmount.toString(), 18); // 18 is ok, as its toWei eventually anyways
|
|
741
|
-
|
|
736
|
+
logger.verbose(`Current amount: ${currentAmount.toString()}`);
|
|
742
737
|
if (err.message.includes('invalid token0 balance') || err.message.includes('invalid token0 amount')) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
738
|
+
if (!isSellTokenToken0) {
|
|
739
|
+
logger.verbose('Reducing swap amount - excess token0');
|
|
740
|
+
let nextAmount = (fromAmount + lowerLimit) / 2n;
|
|
741
|
+
upperLimit = fromAmount;
|
|
742
|
+
if (nextAmount <= lowerLimit) {
|
|
743
|
+
logger.error('Convergence failed: nextAmount <= lowerLimit');
|
|
744
|
+
throw err;
|
|
745
|
+
}
|
|
746
|
+
newSwapInfo.token_from_amount = uint256.bnToUint256(nextAmount);
|
|
747
|
+
} else {
|
|
748
|
+
logger.verbose('Increasing swap amount - deficit token0');
|
|
749
|
+
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
750
|
+
if (upperLimit == 0n) {
|
|
751
|
+
nextAmount = fromAmount * 2n;
|
|
752
|
+
}
|
|
753
|
+
lowerLimit = fromAmount;
|
|
754
|
+
if (upperLimit != 0n && nextAmount >= upperLimit) {
|
|
755
|
+
logger.error('Convergence failed: nextAmount >= upperLimit');
|
|
756
|
+
throw err;
|
|
757
|
+
}
|
|
758
|
+
newSwapInfo.token_from_amount = uint256.bnToUint256(nextAmount);
|
|
759
|
+
}
|
|
760
|
+
} else if (err.message.includes('invalid token1 amount') || err.message.includes('invalid token1 balance')) {
|
|
761
|
+
if (isSellTokenToken0) {
|
|
762
|
+
logger.verbose('Reducing swap amount - excess token1');
|
|
763
|
+
let nextAmount = (fromAmount + lowerLimit) / 2n;
|
|
764
|
+
upperLimit = fromAmount;
|
|
765
|
+
if (nextAmount <= lowerLimit) {
|
|
766
|
+
logger.error('Convergence failed: nextAmount <= lowerLimit');
|
|
767
|
+
throw err;
|
|
768
|
+
}
|
|
769
|
+
newSwapInfo.token_from_amount = uint256.bnToUint256(nextAmount);
|
|
770
|
+
} else {
|
|
771
|
+
logger.verbose('Increasing swap amount - deficit token1');
|
|
772
|
+
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
773
|
+
if (upperLimit == 0n) {
|
|
774
|
+
nextAmount = fromAmount * 2n;
|
|
775
|
+
}
|
|
776
|
+
lowerLimit = fromAmount;
|
|
777
|
+
if (upperLimit != 0n && nextAmount >= upperLimit) {
|
|
778
|
+
logger.error('Convergence failed: nextAmount >= upperLimit');
|
|
779
|
+
throw err;
|
|
780
|
+
}
|
|
781
|
+
newSwapInfo.token_from_amount = uint256.bnToUint256(nextAmount);
|
|
782
|
+
}
|
|
760
783
|
} else {
|
|
761
784
|
logger.error('Unexpected error:', err);
|
|
785
|
+
throw err;
|
|
762
786
|
}
|
|
763
|
-
|
|
764
787
|
newSwapInfo.token_to_min_amount = uint256.bnToUint256('0');
|
|
765
|
-
|
|
766
788
|
return this.rebalanceIter(
|
|
767
789
|
newSwapInfo,
|
|
768
790
|
acc,
|
|
769
791
|
estimateCall,
|
|
792
|
+
isSellTokenToken0,
|
|
770
793
|
retry + 1,
|
|
771
|
-
|
|
772
|
-
|
|
794
|
+
lowerLimit,
|
|
795
|
+
upperLimit,
|
|
773
796
|
);
|
|
774
797
|
}
|
|
775
798
|
}
|
|
@@ -933,7 +956,13 @@ const AUDIT_URL = 'https://assets.strkfarm.com/strkfarm/audit_report_vesu_and_ek
|
|
|
933
956
|
*/
|
|
934
957
|
export const EkuboCLVaultStrategies: IStrategyMetadata<CLVaultStrategySettings>[] = [{
|
|
935
958
|
name: 'Ekubo xSTRK/STRK',
|
|
936
|
-
description:
|
|
959
|
+
description: <div>
|
|
960
|
+
<p>{_description.replace('{{POOL_NAME}}', 'xSTRK/STRK')}</p>
|
|
961
|
+
<ul style={{marginLeft: '20px', listStyle: 'circle', fontSize: '12px'}}>
|
|
962
|
+
<li style={{marginTop: '10px'}}>During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices.</li>
|
|
963
|
+
<li style={{marginTop: '10px'}}>Sometimes you might see a negative APY — 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.</li>
|
|
964
|
+
</ul>
|
|
965
|
+
</div>,
|
|
937
966
|
address: ContractAddr.from('0x01f083b98674bc21effee29ef443a00c7b9a500fd92cf30341a3da12c73f2324'),
|
|
938
967
|
type: 'Other',
|
|
939
968
|
// must be same order as poolKey token0 and token1
|
|
@@ -567,7 +567,7 @@ export class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmo
|
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
const _description =
|
|
570
|
+
const _description = "Automatically diversify {{TOKEN}} holdings into different Vesu pools while reducing risk and maximizing yield. Defi spring STRK Rewards are auto-compounded as well."
|
|
571
571
|
const _protocol: IProtocol = {name: 'Vesu', logo: 'https://static-assets-8zct.onrender.com/integrations/vesu/logo.png'}
|
|
572
572
|
// need to fine tune better
|
|
573
573
|
const _riskFactor: RiskFactor[] = [
|