@strkfarm/sdk 2.0.0-staging.27 → 2.0.0-staging.29

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.
@@ -20207,7 +20207,7 @@ ${r2}}` : "}", l2;
20207
20207
  toHexString: () => toHexString2,
20208
20208
  toStorageKey: () => toStorageKey2
20209
20209
  });
20210
- var import_utils147 = require_utils2();
20210
+ var import_utils146 = require_utils2();
20211
20211
  function isHex3(hex) {
20212
20212
  return /^0x[0-9a-f]*$/i.test(hex);
20213
20213
  }
@@ -20280,7 +20280,7 @@ ${r2}}` : "}", l2;
20280
20280
  if (adaptedValue.length % 2 !== 0) {
20281
20281
  adaptedValue = `0${adaptedValue}`;
20282
20282
  }
20283
- return (0, import_utils147.hexToBytes)(adaptedValue);
20283
+ return (0, import_utils146.hexToBytes)(adaptedValue);
20284
20284
  }
20285
20285
  function addPercent2(number22, percent) {
20286
20286
  const bigIntNum = BigInt(number22);
@@ -92121,6 +92121,12 @@ spurious results.`);
92121
92121
  async getPendingRewards() {
92122
92122
  return [];
92123
92123
  }
92124
+ getStrategyTooltip() {
92125
+ return {
92126
+ holdings: "Your Holdings",
92127
+ earnings: "Lifetime Earnings"
92128
+ };
92129
+ }
92124
92130
  async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
92125
92131
  throw new Error("Not implemented");
92126
92132
  }
@@ -116631,12 +116637,8 @@ spurious results.`);
116631
116637
  resolveWithdrawRequest(amountInfo, redeemableBaseTokenAmount, redeemableSecondaryTokenAmount) {
116632
116638
  const baseTokenAmountToWithdraw = Number(amountInfo.token0.amount.toWei());
116633
116639
  const secondaryTokenAmountToWithdraw = Number(amountInfo.token1.amount.toWei());
116634
- logger2.info(`baseTokenAmountToWithdraw: ${baseTokenAmountToWithdraw}`);
116635
- logger2.info(`secondaryTokenAmountToWithdraw: ${secondaryTokenAmountToWithdraw}`);
116636
- logger2.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
116637
- logger2.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
116638
116640
  if (baseTokenAmountToWithdraw > 0 && redeemableBaseTokenAmount.greaterThanOrEqualTo(baseTokenAmountToWithdraw)) {
116639
- const sharesUsedFactor = redeemableBaseTokenAmount.dividedBy(baseTokenAmountToWithdraw);
116641
+ const sharesUsedFactor = new Web3Number(baseTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableBaseTokenAmount);
116640
116642
  return {
116641
116643
  sharesUsedFactor: sharesUsedFactor.toNumber(),
116642
116644
  baseTokenAmountToWithdraw,
@@ -116646,8 +116648,9 @@ spurious results.`);
116646
116648
  if (secondaryTokenAmountToWithdraw > 0 && redeemableSecondaryTokenAmount.greaterThanOrEqualTo(
116647
116649
  secondaryTokenAmountToWithdraw
116648
116650
  )) {
116651
+ const sharesUsedFactor = new Web3Number(secondaryTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableSecondaryTokenAmount);
116649
116652
  return {
116650
- sharesUsedFactor: secondaryTokenAmountToWithdraw / Number(redeemableSecondaryTokenAmount),
116653
+ sharesUsedFactor: sharesUsedFactor.toNumber(),
116651
116654
  baseTokenAmountToWithdraw,
116652
116655
  secondaryTokenAmountToWithdraw
116653
116656
  };
@@ -116746,10 +116749,10 @@ spurious results.`);
116746
116749
  }
116747
116750
  async depositCall(amountInfo) {
116748
116751
  try {
116749
- const primaryToken = amountInfo.token0.tokenInfo;
116750
- const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.token0.amount);
116752
+ const primaryToken = amountInfo.tokenInfo;
116753
+ const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.amount);
116751
116754
  const depositCall = this.contract.populate("deposit", [
116752
- uint256_exports.bnToUint256(amountInfo.token0.amount.toWei())
116755
+ uint256_exports.bnToUint256(amountInfo.amount.toWei())
116753
116756
  ]);
116754
116757
  return [approvalCall, depositCall];
116755
116758
  } catch (err2) {
@@ -116762,9 +116765,9 @@ spurious results.`);
116762
116765
  return vaultStatus;
116763
116766
  }
116764
116767
  async matchInputAmounts(amountInfo, user) {
116765
- const { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
116766
- logger2.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
116767
- logger2.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
116768
+ let { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
116769
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
116770
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
116768
116771
  const withdrawRequest = this.resolveWithdrawRequest(
116769
116772
  amountInfo,
116770
116773
  redeemableBaseTokenAmount,
@@ -116779,7 +116782,7 @@ spurious results.`);
116779
116782
  secondaryTokenAmountToWithdraw
116780
116783
  } = withdrawRequest;
116781
116784
  if (baseTokenAmountToWithdraw > 0) {
116782
- const secondaryTokenAmount = redeemableSecondaryTokenAmount.multipliedBy(sharesUsedFactor);
116785
+ const secondaryTokenAmount = redeemableSecondaryTokenAmount.dividedBy(10 ** this.secondaryToken.decimals).multipliedBy(sharesUsedFactor);
116783
116786
  return {
116784
116787
  token0: {
116785
116788
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -116791,7 +116794,7 @@ spurious results.`);
116791
116794
  }
116792
116795
  };
116793
116796
  }
116794
- const baseTokenAmount = redeemableBaseTokenAmount.multipliedBy(sharesUsedFactor);
116797
+ const baseTokenAmount = redeemableBaseTokenAmount.dividedBy(10 ** this.primaryToken.decimals).multipliedBy(sharesUsedFactor);
116795
116798
  return {
116796
116799
  token0: {
116797
116800
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -116805,23 +116808,22 @@ spurious results.`);
116805
116808
  }
116806
116809
  async withdrawCall(amountInfo, receiver, owner) {
116807
116810
  try {
116808
- const {
116811
+ let {
116809
116812
  shares: userShares,
116810
116813
  primaryTokenBalance: redeemableBaseTokenAmount,
116811
116814
  claimableSecondaryTokens: redeemableSecondaryTokenAmount
116812
116815
  } = await this.getNormalizedUserInfo(receiver);
116813
- logger2.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
116814
- logger2.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
116816
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
116817
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
116815
116818
  const withdrawRequest = this.resolveWithdrawRequest(
116816
116819
  amountInfo,
116817
116820
  redeemableBaseTokenAmount,
116818
116821
  redeemableSecondaryTokenAmount
116819
116822
  );
116820
116823
  if (!withdrawRequest) {
116821
- return [];
116824
+ throw new Error("Invalid amount info");
116822
116825
  }
116823
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor);
116824
- logger2.info(`requiredShares: ${requiredShares.toString()}`);
116826
+ const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
116825
116827
  const withdrawCall = this.contract.populate("redeem", [
116826
116828
  uint256_exports.bnToUint256(requiredShares.toString())
116827
116829
  ]);
@@ -116832,36 +116834,13 @@ spurious results.`);
116832
116834
  }
116833
116835
  }
116834
116836
  async netAPY() {
116835
- try {
116836
- const vaultStatus = await this.getVaultStatus();
116837
- const {
116838
- remaining_base: remainingBase,
116839
- total_second_tokens: totalSecondTokens
116840
- } = vaultStatus;
116841
- const primaryTokenPrice = await this.pricer.getPrice(this.primaryToken.symbol);
116842
- const secondaryTokenPrice = await this.pricer.getPrice(this.secondaryToken.symbol);
116843
- const primaryTokenAmount = Web3Number.fromWei(remainingBase.toString(), this.primaryToken.decimals);
116844
- const secondaryTokenAmount = Web3Number.fromWei(totalSecondTokens.toString(), this.secondaryToken.decimals);
116845
- const primaryTokenUsd = primaryTokenAmount.multipliedBy(primaryTokenPrice.price).toNumber();
116846
- const secondaryTokenUsd = secondaryTokenAmount.multipliedBy(secondaryTokenPrice.price).toNumber();
116847
- const netUsd = primaryTokenUsd + secondaryTokenUsd;
116848
- return {
116849
- net: netUsd,
116850
- splits: [
116851
- {
116852
- apy: primaryTokenAmount.toNumber(),
116853
- id: this.primaryToken.symbol
116854
- },
116855
- {
116856
- apy: secondaryTokenAmount.toNumber(),
116857
- id: this.secondaryToken.symbol
116858
- }
116859
- ]
116860
- };
116861
- } catch (err2) {
116862
- console.error("Error fetching net APY:", err2);
116863
- return 0;
116864
- }
116837
+ return "YOLO";
116838
+ }
116839
+ getStrategyTooltip() {
116840
+ return {
116841
+ holdings: "USDC Left",
116842
+ earnings: "WBTC Accumulated"
116843
+ };
116865
116844
  }
116866
116845
  };
116867
116846
  var yoloVaultDescription = "Deposit USDC into YOLO Vault and gradually accumulate WBTC over fixed epochs, where a manager decides how much USDC to deploy each epoch.";
@@ -4890,6 +4890,12 @@ var BaseStrategy = class extends CacheClass {
4890
4890
  async getPendingRewards() {
4891
4891
  return [];
4892
4892
  }
4893
+ getStrategyTooltip() {
4894
+ return {
4895
+ holdings: "Your Holdings",
4896
+ earnings: "Lifetime Earnings"
4897
+ };
4898
+ }
4893
4899
  async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
4894
4900
  throw new Error("Not implemented");
4895
4901
  }
@@ -29424,12 +29430,8 @@ var YoLoVault = class extends BaseStrategy {
29424
29430
  resolveWithdrawRequest(amountInfo, redeemableBaseTokenAmount, redeemableSecondaryTokenAmount) {
29425
29431
  const baseTokenAmountToWithdraw = Number(amountInfo.token0.amount.toWei());
29426
29432
  const secondaryTokenAmountToWithdraw = Number(amountInfo.token1.amount.toWei());
29427
- logger.info(`baseTokenAmountToWithdraw: ${baseTokenAmountToWithdraw}`);
29428
- logger.info(`secondaryTokenAmountToWithdraw: ${secondaryTokenAmountToWithdraw}`);
29429
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29430
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29431
29433
  if (baseTokenAmountToWithdraw > 0 && redeemableBaseTokenAmount.greaterThanOrEqualTo(baseTokenAmountToWithdraw)) {
29432
- const sharesUsedFactor = redeemableBaseTokenAmount.dividedBy(baseTokenAmountToWithdraw);
29434
+ const sharesUsedFactor = new Web3Number(baseTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableBaseTokenAmount);
29433
29435
  return {
29434
29436
  sharesUsedFactor: sharesUsedFactor.toNumber(),
29435
29437
  baseTokenAmountToWithdraw,
@@ -29439,8 +29441,9 @@ var YoLoVault = class extends BaseStrategy {
29439
29441
  if (secondaryTokenAmountToWithdraw > 0 && redeemableSecondaryTokenAmount.greaterThanOrEqualTo(
29440
29442
  secondaryTokenAmountToWithdraw
29441
29443
  )) {
29444
+ const sharesUsedFactor = new Web3Number(secondaryTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableSecondaryTokenAmount);
29442
29445
  return {
29443
- sharesUsedFactor: secondaryTokenAmountToWithdraw / Number(redeemableSecondaryTokenAmount),
29446
+ sharesUsedFactor: sharesUsedFactor.toNumber(),
29444
29447
  baseTokenAmountToWithdraw,
29445
29448
  secondaryTokenAmountToWithdraw
29446
29449
  };
@@ -29539,10 +29542,10 @@ var YoLoVault = class extends BaseStrategy {
29539
29542
  }
29540
29543
  async depositCall(amountInfo) {
29541
29544
  try {
29542
- const primaryToken = amountInfo.token0.tokenInfo;
29543
- const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.token0.amount);
29545
+ const primaryToken = amountInfo.tokenInfo;
29546
+ const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.amount);
29544
29547
  const depositCall = this.contract.populate("deposit", [
29545
- uint25610.bnToUint256(amountInfo.token0.amount.toWei())
29548
+ uint25610.bnToUint256(amountInfo.amount.toWei())
29546
29549
  ]);
29547
29550
  return [approvalCall, depositCall];
29548
29551
  } catch (err) {
@@ -29555,9 +29558,9 @@ var YoLoVault = class extends BaseStrategy {
29555
29558
  return vaultStatus;
29556
29559
  }
29557
29560
  async matchInputAmounts(amountInfo, user) {
29558
- const { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
29559
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29560
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29561
+ let { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
29562
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
29563
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
29561
29564
  const withdrawRequest = this.resolveWithdrawRequest(
29562
29565
  amountInfo,
29563
29566
  redeemableBaseTokenAmount,
@@ -29572,7 +29575,7 @@ var YoLoVault = class extends BaseStrategy {
29572
29575
  secondaryTokenAmountToWithdraw
29573
29576
  } = withdrawRequest;
29574
29577
  if (baseTokenAmountToWithdraw > 0) {
29575
- const secondaryTokenAmount = redeemableSecondaryTokenAmount.multipliedBy(sharesUsedFactor);
29578
+ const secondaryTokenAmount = redeemableSecondaryTokenAmount.dividedBy(10 ** this.secondaryToken.decimals).multipliedBy(sharesUsedFactor);
29576
29579
  return {
29577
29580
  token0: {
29578
29581
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -29584,7 +29587,7 @@ var YoLoVault = class extends BaseStrategy {
29584
29587
  }
29585
29588
  };
29586
29589
  }
29587
- const baseTokenAmount = redeemableBaseTokenAmount.multipliedBy(sharesUsedFactor);
29590
+ const baseTokenAmount = redeemableBaseTokenAmount.dividedBy(10 ** this.primaryToken.decimals).multipliedBy(sharesUsedFactor);
29588
29591
  return {
29589
29592
  token0: {
29590
29593
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -29598,23 +29601,22 @@ var YoLoVault = class extends BaseStrategy {
29598
29601
  }
29599
29602
  async withdrawCall(amountInfo, receiver, owner) {
29600
29603
  try {
29601
- const {
29604
+ let {
29602
29605
  shares: userShares,
29603
29606
  primaryTokenBalance: redeemableBaseTokenAmount,
29604
29607
  claimableSecondaryTokens: redeemableSecondaryTokenAmount
29605
29608
  } = await this.getNormalizedUserInfo(receiver);
29606
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29607
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29609
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
29610
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
29608
29611
  const withdrawRequest = this.resolveWithdrawRequest(
29609
29612
  amountInfo,
29610
29613
  redeemableBaseTokenAmount,
29611
29614
  redeemableSecondaryTokenAmount
29612
29615
  );
29613
29616
  if (!withdrawRequest) {
29614
- return [];
29617
+ throw new Error("Invalid amount info");
29615
29618
  }
29616
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor);
29617
- logger.info(`requiredShares: ${requiredShares.toString()}`);
29619
+ const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
29618
29620
  const withdrawCall = this.contract.populate("redeem", [
29619
29621
  uint25610.bnToUint256(requiredShares.toString())
29620
29622
  ]);
@@ -29625,36 +29627,13 @@ var YoLoVault = class extends BaseStrategy {
29625
29627
  }
29626
29628
  }
29627
29629
  async netAPY() {
29628
- try {
29629
- const vaultStatus = await this.getVaultStatus();
29630
- const {
29631
- remaining_base: remainingBase,
29632
- total_second_tokens: totalSecondTokens
29633
- } = vaultStatus;
29634
- const primaryTokenPrice = await this.pricer.getPrice(this.primaryToken.symbol);
29635
- const secondaryTokenPrice = await this.pricer.getPrice(this.secondaryToken.symbol);
29636
- const primaryTokenAmount = Web3Number.fromWei(remainingBase.toString(), this.primaryToken.decimals);
29637
- const secondaryTokenAmount = Web3Number.fromWei(totalSecondTokens.toString(), this.secondaryToken.decimals);
29638
- const primaryTokenUsd = primaryTokenAmount.multipliedBy(primaryTokenPrice.price).toNumber();
29639
- const secondaryTokenUsd = secondaryTokenAmount.multipliedBy(secondaryTokenPrice.price).toNumber();
29640
- const netUsd = primaryTokenUsd + secondaryTokenUsd;
29641
- return {
29642
- net: netUsd,
29643
- splits: [
29644
- {
29645
- apy: primaryTokenAmount.toNumber(),
29646
- id: this.primaryToken.symbol
29647
- },
29648
- {
29649
- apy: secondaryTokenAmount.toNumber(),
29650
- id: this.secondaryToken.symbol
29651
- }
29652
- ]
29653
- };
29654
- } catch (err) {
29655
- console.error("Error fetching net APY:", err);
29656
- return 0;
29657
- }
29630
+ return "YOLO";
29631
+ }
29632
+ getStrategyTooltip() {
29633
+ return {
29634
+ holdings: "USDC Left",
29635
+ earnings: "WBTC Accumulated"
29636
+ };
29658
29637
  }
29659
29638
  };
29660
29639
  var yoloVaultDescription = "Deposit USDC into YOLO Vault and gradually accumulate WBTC over fixed epochs, where a manager decides how much USDC to deploy each epoch.";
package/dist/index.d.ts CHANGED
@@ -612,17 +612,21 @@ interface CacheData {
612
612
  ttl: number;
613
613
  data: any;
614
614
  }
615
- declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
615
+ declare class BaseStrategy<TVLInfo, DepositActionInfo, WithdrawActionInfo = DepositActionInfo> extends CacheClass {
616
616
  readonly config: IConfig;
617
617
  readonly cache: Map<string, CacheData>;
618
618
  constructor(config: IConfig);
619
619
  getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<TVLInfo>;
620
620
  getTVL(): Promise<TVLInfo>;
621
- depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
622
- withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
621
+ depositCall(amountInfo: DepositActionInfo, receiver: ContractAddr): Promise<Call[]>;
622
+ withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
623
623
  getVaultPositions(): Promise<VaultPosition[]>;
624
- netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | NetAPYDetails>;
624
+ netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | string | NetAPYDetails>;
625
625
  getPendingRewards(): Promise<HarvestInfo[]>;
626
+ getStrategyTooltip(): {
627
+ holdings: string;
628
+ earnings: string;
629
+ };
626
630
  getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
627
631
  /**
628
632
  * Calculate lifetime earnings for a user based on provided data from client
@@ -1190,7 +1194,7 @@ interface YoloVaultStatus {
1190
1194
  total_shares: bigint;
1191
1195
  base_token_assets_per_share: bigint;
1192
1196
  }
1193
- declare class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
1197
+ declare class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, DualActionAmount> {
1194
1198
  readonly address: ContractAddr;
1195
1199
  readonly metadata: IStrategyMetadata<YoloVaultSettings>;
1196
1200
  readonly pricer: PricerBase;
@@ -1202,12 +1206,16 @@ declare class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
1202
1206
  private resolveWithdrawRequest;
1203
1207
  getUserTVL(user: ContractAddr): Promise<DualTokenInfo>;
1204
1208
  getTVL(): Promise<DualTokenInfo>;
1205
- depositCall(amountInfo: DualActionAmount): Promise<Call[]>;
1209
+ depositCall(amountInfo: SingleActionAmount): Promise<Call[]>;
1206
1210
  getVaultStatus(): Promise<YoloVaultStatus>;
1207
1211
  matchInputAmounts(amountInfo: DualActionAmount, user: ContractAddr): Promise<DualActionAmount>;
1208
1212
  withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1209
- netAPY(): Promise<number | NetAPYDetails>;
1213
+ netAPY(): Promise<number | string | NetAPYDetails>;
1210
1214
  getSettings: () => Promise<starknet.CallResult>;
1215
+ getStrategyTooltip(): {
1216
+ holdings: string;
1217
+ earnings: string;
1218
+ };
1211
1219
  }
1212
1220
  declare const YoloVaultStrategies: IStrategyMetadata<YoloVaultSettings>[];
1213
1221
 
package/dist/index.js CHANGED
@@ -4932,6 +4932,12 @@ var BaseStrategy = class extends CacheClass {
4932
4932
  async getPendingRewards() {
4933
4933
  return [];
4934
4934
  }
4935
+ getStrategyTooltip() {
4936
+ return {
4937
+ holdings: "Your Holdings",
4938
+ earnings: "Lifetime Earnings"
4939
+ };
4940
+ }
4935
4941
  async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
4936
4942
  throw new Error("Not implemented");
4937
4943
  }
@@ -29563,12 +29569,8 @@ var YoLoVault = class extends BaseStrategy {
29563
29569
  resolveWithdrawRequest(amountInfo, redeemableBaseTokenAmount, redeemableSecondaryTokenAmount) {
29564
29570
  const baseTokenAmountToWithdraw = Number(amountInfo.token0.amount.toWei());
29565
29571
  const secondaryTokenAmountToWithdraw = Number(amountInfo.token1.amount.toWei());
29566
- logger.info(`baseTokenAmountToWithdraw: ${baseTokenAmountToWithdraw}`);
29567
- logger.info(`secondaryTokenAmountToWithdraw: ${secondaryTokenAmountToWithdraw}`);
29568
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29569
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29570
29572
  if (baseTokenAmountToWithdraw > 0 && redeemableBaseTokenAmount.greaterThanOrEqualTo(baseTokenAmountToWithdraw)) {
29571
- const sharesUsedFactor = redeemableBaseTokenAmount.dividedBy(baseTokenAmountToWithdraw);
29573
+ const sharesUsedFactor = new Web3Number(baseTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableBaseTokenAmount);
29572
29574
  return {
29573
29575
  sharesUsedFactor: sharesUsedFactor.toNumber(),
29574
29576
  baseTokenAmountToWithdraw,
@@ -29578,8 +29580,9 @@ var YoLoVault = class extends BaseStrategy {
29578
29580
  if (secondaryTokenAmountToWithdraw > 0 && redeemableSecondaryTokenAmount.greaterThanOrEqualTo(
29579
29581
  secondaryTokenAmountToWithdraw
29580
29582
  )) {
29583
+ const sharesUsedFactor = new Web3Number(secondaryTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableSecondaryTokenAmount);
29581
29584
  return {
29582
- sharesUsedFactor: secondaryTokenAmountToWithdraw / Number(redeemableSecondaryTokenAmount),
29585
+ sharesUsedFactor: sharesUsedFactor.toNumber(),
29583
29586
  baseTokenAmountToWithdraw,
29584
29587
  secondaryTokenAmountToWithdraw
29585
29588
  };
@@ -29678,10 +29681,10 @@ var YoLoVault = class extends BaseStrategy {
29678
29681
  }
29679
29682
  async depositCall(amountInfo) {
29680
29683
  try {
29681
- const primaryToken = amountInfo.token0.tokenInfo;
29682
- const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.token0.amount);
29684
+ const primaryToken = amountInfo.tokenInfo;
29685
+ const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.amount);
29683
29686
  const depositCall = this.contract.populate("deposit", [
29684
- import_starknet20.uint256.bnToUint256(amountInfo.token0.amount.toWei())
29687
+ import_starknet20.uint256.bnToUint256(amountInfo.amount.toWei())
29685
29688
  ]);
29686
29689
  return [approvalCall, depositCall];
29687
29690
  } catch (err) {
@@ -29694,9 +29697,9 @@ var YoLoVault = class extends BaseStrategy {
29694
29697
  return vaultStatus;
29695
29698
  }
29696
29699
  async matchInputAmounts(amountInfo, user) {
29697
- const { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
29698
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29699
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29700
+ let { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
29701
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
29702
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
29700
29703
  const withdrawRequest = this.resolveWithdrawRequest(
29701
29704
  amountInfo,
29702
29705
  redeemableBaseTokenAmount,
@@ -29711,7 +29714,7 @@ var YoLoVault = class extends BaseStrategy {
29711
29714
  secondaryTokenAmountToWithdraw
29712
29715
  } = withdrawRequest;
29713
29716
  if (baseTokenAmountToWithdraw > 0) {
29714
- const secondaryTokenAmount = redeemableSecondaryTokenAmount.multipliedBy(sharesUsedFactor);
29717
+ const secondaryTokenAmount = redeemableSecondaryTokenAmount.dividedBy(10 ** this.secondaryToken.decimals).multipliedBy(sharesUsedFactor);
29715
29718
  return {
29716
29719
  token0: {
29717
29720
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -29723,7 +29726,7 @@ var YoLoVault = class extends BaseStrategy {
29723
29726
  }
29724
29727
  };
29725
29728
  }
29726
- const baseTokenAmount = redeemableBaseTokenAmount.multipliedBy(sharesUsedFactor);
29729
+ const baseTokenAmount = redeemableBaseTokenAmount.dividedBy(10 ** this.primaryToken.decimals).multipliedBy(sharesUsedFactor);
29727
29730
  return {
29728
29731
  token0: {
29729
29732
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -29737,23 +29740,22 @@ var YoLoVault = class extends BaseStrategy {
29737
29740
  }
29738
29741
  async withdrawCall(amountInfo, receiver, owner) {
29739
29742
  try {
29740
- const {
29743
+ let {
29741
29744
  shares: userShares,
29742
29745
  primaryTokenBalance: redeemableBaseTokenAmount,
29743
29746
  claimableSecondaryTokens: redeemableSecondaryTokenAmount
29744
29747
  } = await this.getNormalizedUserInfo(receiver);
29745
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29746
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29748
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
29749
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
29747
29750
  const withdrawRequest = this.resolveWithdrawRequest(
29748
29751
  amountInfo,
29749
29752
  redeemableBaseTokenAmount,
29750
29753
  redeemableSecondaryTokenAmount
29751
29754
  );
29752
29755
  if (!withdrawRequest) {
29753
- return [];
29756
+ throw new Error("Invalid amount info");
29754
29757
  }
29755
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor);
29756
- logger.info(`requiredShares: ${requiredShares.toString()}`);
29758
+ const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
29757
29759
  const withdrawCall = this.contract.populate("redeem", [
29758
29760
  import_starknet20.uint256.bnToUint256(requiredShares.toString())
29759
29761
  ]);
@@ -29764,36 +29766,13 @@ var YoLoVault = class extends BaseStrategy {
29764
29766
  }
29765
29767
  }
29766
29768
  async netAPY() {
29767
- try {
29768
- const vaultStatus = await this.getVaultStatus();
29769
- const {
29770
- remaining_base: remainingBase,
29771
- total_second_tokens: totalSecondTokens
29772
- } = vaultStatus;
29773
- const primaryTokenPrice = await this.pricer.getPrice(this.primaryToken.symbol);
29774
- const secondaryTokenPrice = await this.pricer.getPrice(this.secondaryToken.symbol);
29775
- const primaryTokenAmount = Web3Number.fromWei(remainingBase.toString(), this.primaryToken.decimals);
29776
- const secondaryTokenAmount = Web3Number.fromWei(totalSecondTokens.toString(), this.secondaryToken.decimals);
29777
- const primaryTokenUsd = primaryTokenAmount.multipliedBy(primaryTokenPrice.price).toNumber();
29778
- const secondaryTokenUsd = secondaryTokenAmount.multipliedBy(secondaryTokenPrice.price).toNumber();
29779
- const netUsd = primaryTokenUsd + secondaryTokenUsd;
29780
- return {
29781
- net: netUsd,
29782
- splits: [
29783
- {
29784
- apy: primaryTokenAmount.toNumber(),
29785
- id: this.primaryToken.symbol
29786
- },
29787
- {
29788
- apy: secondaryTokenAmount.toNumber(),
29789
- id: this.secondaryToken.symbol
29790
- }
29791
- ]
29792
- };
29793
- } catch (err) {
29794
- console.error("Error fetching net APY:", err);
29795
- return 0;
29796
- }
29769
+ return "YOLO";
29770
+ }
29771
+ getStrategyTooltip() {
29772
+ return {
29773
+ holdings: "USDC Left",
29774
+ earnings: "WBTC Accumulated"
29775
+ };
29797
29776
  }
29798
29777
  };
29799
29778
  var yoloVaultDescription = "Deposit USDC into YOLO Vault and gradually accumulate WBTC over fixed epochs, where a manager decides how much USDC to deploy each epoch.";
package/dist/index.mjs CHANGED
@@ -4794,6 +4794,12 @@ var BaseStrategy = class extends CacheClass {
4794
4794
  async getPendingRewards() {
4795
4795
  return [];
4796
4796
  }
4797
+ getStrategyTooltip() {
4798
+ return {
4799
+ holdings: "Your Holdings",
4800
+ earnings: "Lifetime Earnings"
4801
+ };
4802
+ }
4797
4803
  async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
4798
4804
  throw new Error("Not implemented");
4799
4805
  }
@@ -29429,12 +29435,8 @@ var YoLoVault = class extends BaseStrategy {
29429
29435
  resolveWithdrawRequest(amountInfo, redeemableBaseTokenAmount, redeemableSecondaryTokenAmount) {
29430
29436
  const baseTokenAmountToWithdraw = Number(amountInfo.token0.amount.toWei());
29431
29437
  const secondaryTokenAmountToWithdraw = Number(amountInfo.token1.amount.toWei());
29432
- logger.info(`baseTokenAmountToWithdraw: ${baseTokenAmountToWithdraw}`);
29433
- logger.info(`secondaryTokenAmountToWithdraw: ${secondaryTokenAmountToWithdraw}`);
29434
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29435
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29436
29438
  if (baseTokenAmountToWithdraw > 0 && redeemableBaseTokenAmount.greaterThanOrEqualTo(baseTokenAmountToWithdraw)) {
29437
- const sharesUsedFactor = redeemableBaseTokenAmount.dividedBy(baseTokenAmountToWithdraw);
29439
+ const sharesUsedFactor = new Web3Number(baseTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableBaseTokenAmount);
29438
29440
  return {
29439
29441
  sharesUsedFactor: sharesUsedFactor.toNumber(),
29440
29442
  baseTokenAmountToWithdraw,
@@ -29444,8 +29446,9 @@ var YoLoVault = class extends BaseStrategy {
29444
29446
  if (secondaryTokenAmountToWithdraw > 0 && redeemableSecondaryTokenAmount.greaterThanOrEqualTo(
29445
29447
  secondaryTokenAmountToWithdraw
29446
29448
  )) {
29449
+ const sharesUsedFactor = new Web3Number(secondaryTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableSecondaryTokenAmount);
29447
29450
  return {
29448
- sharesUsedFactor: secondaryTokenAmountToWithdraw / Number(redeemableSecondaryTokenAmount),
29451
+ sharesUsedFactor: sharesUsedFactor.toNumber(),
29449
29452
  baseTokenAmountToWithdraw,
29450
29453
  secondaryTokenAmountToWithdraw
29451
29454
  };
@@ -29544,10 +29547,10 @@ var YoLoVault = class extends BaseStrategy {
29544
29547
  }
29545
29548
  async depositCall(amountInfo) {
29546
29549
  try {
29547
- const primaryToken = amountInfo.token0.tokenInfo;
29548
- const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.token0.amount);
29550
+ const primaryToken = amountInfo.tokenInfo;
29551
+ const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.amount);
29549
29552
  const depositCall = this.contract.populate("deposit", [
29550
- uint25611.bnToUint256(amountInfo.token0.amount.toWei())
29553
+ uint25611.bnToUint256(amountInfo.amount.toWei())
29551
29554
  ]);
29552
29555
  return [approvalCall, depositCall];
29553
29556
  } catch (err) {
@@ -29560,9 +29563,9 @@ var YoLoVault = class extends BaseStrategy {
29560
29563
  return vaultStatus;
29561
29564
  }
29562
29565
  async matchInputAmounts(amountInfo, user) {
29563
- const { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
29564
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29565
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29566
+ let { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } = await this.getNormalizedUserInfo(user);
29567
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
29568
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
29566
29569
  const withdrawRequest = this.resolveWithdrawRequest(
29567
29570
  amountInfo,
29568
29571
  redeemableBaseTokenAmount,
@@ -29577,7 +29580,7 @@ var YoLoVault = class extends BaseStrategy {
29577
29580
  secondaryTokenAmountToWithdraw
29578
29581
  } = withdrawRequest;
29579
29582
  if (baseTokenAmountToWithdraw > 0) {
29580
- const secondaryTokenAmount = redeemableSecondaryTokenAmount.multipliedBy(sharesUsedFactor);
29583
+ const secondaryTokenAmount = redeemableSecondaryTokenAmount.dividedBy(10 ** this.secondaryToken.decimals).multipliedBy(sharesUsedFactor);
29581
29584
  return {
29582
29585
  token0: {
29583
29586
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -29589,7 +29592,7 @@ var YoLoVault = class extends BaseStrategy {
29589
29592
  }
29590
29593
  };
29591
29594
  }
29592
- const baseTokenAmount = redeemableBaseTokenAmount.multipliedBy(sharesUsedFactor);
29595
+ const baseTokenAmount = redeemableBaseTokenAmount.dividedBy(10 ** this.primaryToken.decimals).multipliedBy(sharesUsedFactor);
29593
29596
  return {
29594
29597
  token0: {
29595
29598
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -29603,23 +29606,22 @@ var YoLoVault = class extends BaseStrategy {
29603
29606
  }
29604
29607
  async withdrawCall(amountInfo, receiver, owner) {
29605
29608
  try {
29606
- const {
29609
+ let {
29607
29610
  shares: userShares,
29608
29611
  primaryTokenBalance: redeemableBaseTokenAmount,
29609
29612
  claimableSecondaryTokens: redeemableSecondaryTokenAmount
29610
29613
  } = await this.getNormalizedUserInfo(receiver);
29611
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
29612
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
29614
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
29615
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
29613
29616
  const withdrawRequest = this.resolveWithdrawRequest(
29614
29617
  amountInfo,
29615
29618
  redeemableBaseTokenAmount,
29616
29619
  redeemableSecondaryTokenAmount
29617
29620
  );
29618
29621
  if (!withdrawRequest) {
29619
- return [];
29622
+ throw new Error("Invalid amount info");
29620
29623
  }
29621
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor);
29622
- logger.info(`requiredShares: ${requiredShares.toString()}`);
29624
+ const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
29623
29625
  const withdrawCall = this.contract.populate("redeem", [
29624
29626
  uint25611.bnToUint256(requiredShares.toString())
29625
29627
  ]);
@@ -29630,36 +29632,13 @@ var YoLoVault = class extends BaseStrategy {
29630
29632
  }
29631
29633
  }
29632
29634
  async netAPY() {
29633
- try {
29634
- const vaultStatus = await this.getVaultStatus();
29635
- const {
29636
- remaining_base: remainingBase,
29637
- total_second_tokens: totalSecondTokens
29638
- } = vaultStatus;
29639
- const primaryTokenPrice = await this.pricer.getPrice(this.primaryToken.symbol);
29640
- const secondaryTokenPrice = await this.pricer.getPrice(this.secondaryToken.symbol);
29641
- const primaryTokenAmount = Web3Number.fromWei(remainingBase.toString(), this.primaryToken.decimals);
29642
- const secondaryTokenAmount = Web3Number.fromWei(totalSecondTokens.toString(), this.secondaryToken.decimals);
29643
- const primaryTokenUsd = primaryTokenAmount.multipliedBy(primaryTokenPrice.price).toNumber();
29644
- const secondaryTokenUsd = secondaryTokenAmount.multipliedBy(secondaryTokenPrice.price).toNumber();
29645
- const netUsd = primaryTokenUsd + secondaryTokenUsd;
29646
- return {
29647
- net: netUsd,
29648
- splits: [
29649
- {
29650
- apy: primaryTokenAmount.toNumber(),
29651
- id: this.primaryToken.symbol
29652
- },
29653
- {
29654
- apy: secondaryTokenAmount.toNumber(),
29655
- id: this.secondaryToken.symbol
29656
- }
29657
- ]
29658
- };
29659
- } catch (err) {
29660
- console.error("Error fetching net APY:", err);
29661
- return 0;
29662
- }
29635
+ return "YOLO";
29636
+ }
29637
+ getStrategyTooltip() {
29638
+ return {
29639
+ holdings: "USDC Left",
29640
+ earnings: "WBTC Accumulated"
29641
+ };
29663
29642
  }
29664
29643
  };
29665
29644
  var yoloVaultDescription = "Deposit USDC into YOLO Vault and gradually accumulate WBTC over fixed epochs, where a manager decides how much USDC to deploy each epoch.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "2.0.0-staging.27",
3
+ "version": "2.0.0-staging.29",
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",
@@ -38,9 +38,13 @@ interface CacheData {
38
38
  ttl: number;
39
39
  data: any;
40
40
  }
41
- export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
42
- readonly config: IConfig;
43
- readonly cache: Map<string, CacheData> = new Map();
41
+ export class BaseStrategy<
42
+ TVLInfo,
43
+ DepositActionInfo,
44
+ WithdrawActionInfo = DepositActionInfo,
45
+ > extends CacheClass {
46
+ readonly config: IConfig;
47
+ readonly cache: Map<string, CacheData> = new Map();
44
48
 
45
49
  constructor(config: IConfig) {
46
50
  super();
@@ -55,11 +59,11 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
55
59
  throw new Error("Not implemented");
56
60
  }
57
61
 
58
- async depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]> {
62
+ async depositCall(amountInfo: DepositActionInfo, receiver: ContractAddr): Promise<Call[]> {
59
63
  throw new Error("Not implemented");
60
64
  }
61
65
 
62
- async withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
66
+ async withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
63
67
  throw new Error("Not implemented");
64
68
  }
65
69
 
@@ -71,7 +75,7 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
71
75
  blockIdentifier?: BlockIdentifier,
72
76
  sinceBlocks?: number,
73
77
  timeperiod?: "24h" | "7d" | "30d" | "3m"
74
- ): Promise<number | NetAPYDetails> {
78
+ ): Promise<number | string | NetAPYDetails> {
75
79
  throw new Error("Not implemented");
76
80
  }
77
81
 
@@ -79,6 +83,13 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
79
83
  return [];
80
84
  }
81
85
 
86
+ getStrategyTooltip(): {holdings: string, earnings: string} {
87
+ return {
88
+ holdings:"Your Holdings",
89
+ earnings:"Lifetime Earnings",
90
+ };
91
+ }
92
+
82
93
  async getUserRealizedAPY(
83
94
  blockIdentifier?: BlockIdentifier,
84
95
  sinceBlocks?: number
@@ -12,7 +12,7 @@ import {
12
12
  VaultType,
13
13
  } from "@/interfaces";
14
14
  import { logger } from "@/utils";
15
- import { NetAPYDetails } from "./base-strategy";
15
+ import { NetAPYDetails, SingleActionAmount } from "./base-strategy";
16
16
  import {
17
17
  BaseStrategy,
18
18
  DualTokenInfo,
@@ -32,6 +32,7 @@ export interface YoloVaultSettings {
32
32
  secondaryToken: TokenInfo;
33
33
  maxUnitsSpendPerEpoch: number;
34
34
  feeBps: number; // in bps
35
+ //feeRecipient?: ContractAddr;
35
36
  }
36
37
 
37
38
  export interface UserYoloInfo {
@@ -52,7 +53,7 @@ export interface YoloVaultStatus {
52
53
  base_token_assets_per_share: bigint;
53
54
  }
54
55
 
55
- export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
56
+ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, DualActionAmount> {
56
57
  readonly address: ContractAddr;
57
58
  readonly metadata: IStrategyMetadata<YoloVaultSettings>;
58
59
  readonly pricer: PricerBase;
@@ -126,19 +127,14 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
126
127
  | null {
127
128
  const baseTokenAmountToWithdraw = Number(amountInfo.token0.amount.toWei());
128
129
  const secondaryTokenAmountToWithdraw = Number(amountInfo.token1.amount.toWei());
129
- logger.info(`baseTokenAmountToWithdraw: ${baseTokenAmountToWithdraw}`);
130
- logger.info(`secondaryTokenAmountToWithdraw: ${secondaryTokenAmountToWithdraw}`);
131
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
132
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
133
130
  // if (baseTokenAmountToWithdraw > 0 && secondaryTokenAmountToWithdraw > 0) {
134
131
  // throw new Error("Cannot pass amounts for both base and secondary tokens at once");
135
132
  // }
136
-
137
133
  if (
138
134
  baseTokenAmountToWithdraw > 0 &&
139
135
  redeemableBaseTokenAmount.greaterThanOrEqualTo(baseTokenAmountToWithdraw)
140
136
  ) {
141
- const sharesUsedFactor = redeemableBaseTokenAmount.dividedBy(baseTokenAmountToWithdraw);
137
+ const sharesUsedFactor = new Web3Number(baseTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableBaseTokenAmount);
142
138
  return {
143
139
  sharesUsedFactor: sharesUsedFactor.toNumber(),
144
140
  baseTokenAmountToWithdraw,
@@ -152,10 +148,9 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
152
148
  secondaryTokenAmountToWithdraw,
153
149
  )
154
150
  ) {
151
+ const sharesUsedFactor = new Web3Number(secondaryTokenAmountToWithdraw.toString(), 0).dividedBy(redeemableSecondaryTokenAmount);
155
152
  return {
156
- sharesUsedFactor:
157
- secondaryTokenAmountToWithdraw /
158
- Number(redeemableSecondaryTokenAmount),
153
+ sharesUsedFactor: sharesUsedFactor.toNumber(),
159
154
  baseTokenAmountToWithdraw,
160
155
  secondaryTokenAmountToWithdraw,
161
156
  };
@@ -263,13 +258,13 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
263
258
  }
264
259
 
265
260
  async depositCall(
266
- amountInfo: DualActionAmount,
261
+ amountInfo: SingleActionAmount,
267
262
  ): Promise<Call[]> {
268
263
  try{
269
- const primaryToken = amountInfo.token0.tokenInfo;
270
- const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.token0.amount);
264
+ const primaryToken = amountInfo.tokenInfo;
265
+ const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.amount);
271
266
  const depositCall = this.contract.populate("deposit", [
272
- uint256.bnToUint256(amountInfo.token0.amount.toWei()),
267
+ uint256.bnToUint256(amountInfo.amount.toWei()),
273
268
  ]);
274
269
  return [approvalCall, depositCall];
275
270
  }catch(err){
@@ -287,10 +282,10 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
287
282
  amountInfo: DualActionAmount,
288
283
  user: ContractAddr,
289
284
  ): Promise<DualActionAmount> {
290
- const { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } =
285
+ let { primaryTokenBalance: redeemableBaseTokenAmount, claimableSecondaryTokens: redeemableSecondaryTokenAmount } =
291
286
  await this.getNormalizedUserInfo(user);
292
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
293
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
287
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
288
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
294
289
  const withdrawRequest = this.resolveWithdrawRequest(
295
290
  amountInfo,
296
291
  redeemableBaseTokenAmount,
@@ -308,8 +303,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
308
303
  } = withdrawRequest;
309
304
 
310
305
  if (baseTokenAmountToWithdraw > 0) {
311
- const secondaryTokenAmount =
312
- redeemableSecondaryTokenAmount.multipliedBy(sharesUsedFactor);
306
+ const secondaryTokenAmount = redeemableSecondaryTokenAmount.dividedBy(10 ** this.secondaryToken.decimals).multipliedBy(sharesUsedFactor);
313
307
  return {
314
308
  token0: {
315
309
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -321,8 +315,8 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
321
315
  },
322
316
  };
323
317
  }
324
-
325
- const baseTokenAmount = redeemableBaseTokenAmount.multipliedBy(sharesUsedFactor);
318
+
319
+ const baseTokenAmount = redeemableBaseTokenAmount.dividedBy(10 ** this.primaryToken.decimals).multipliedBy(sharesUsedFactor);
326
320
  return {
327
321
  token0: {
328
322
  tokenInfo: amountInfo.token0.tokenInfo,
@@ -341,23 +335,23 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
341
335
  owner: ContractAddr,
342
336
  ): Promise<Call[]> {
343
337
  try{
344
- const {
338
+ let {
345
339
  shares: userShares,
346
340
  primaryTokenBalance: redeemableBaseTokenAmount,
347
341
  claimableSecondaryTokens: redeemableSecondaryTokenAmount,
348
342
  } = await this.getNormalizedUserInfo(receiver);
349
- logger.info(`redeemableBaseTokenAmount: ${redeemableBaseTokenAmount.toString()}`);
350
- logger.info(`redeemableSecondaryTokenAmount: ${redeemableSecondaryTokenAmount.toString()}`);
343
+ redeemableBaseTokenAmount = new Web3Number(redeemableBaseTokenAmount.toWei().toString(), 0);
344
+ redeemableSecondaryTokenAmount = new Web3Number(redeemableSecondaryTokenAmount.toWei().toString(), 0);
351
345
  const withdrawRequest = this.resolveWithdrawRequest(
352
346
  amountInfo,
353
347
  redeemableBaseTokenAmount,
354
348
  redeemableSecondaryTokenAmount,
355
349
  );
350
+
356
351
  if (!withdrawRequest) {
357
- return [];
352
+ throw new Error("Invalid amount info");
358
353
  }
359
- const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor);
360
- logger.info(`requiredShares: ${requiredShares.toString()}`);
354
+ const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
361
355
  const withdrawCall = this.contract.populate("redeem", [
362
356
  uint256.bnToUint256(requiredShares.toString()),
363
357
  ]);
@@ -368,42 +362,20 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
368
362
  }
369
363
  }
370
364
 
371
- async netAPY(): Promise<number | NetAPYDetails> {
372
- try{
373
- const vaultStatus = await this.getVaultStatus();
374
- const {
375
- remaining_base: remainingBase,
376
- total_second_tokens: totalSecondTokens,
377
- } = vaultStatus as YoloVaultStatus;
378
- const primaryTokenPrice = await this.pricer.getPrice(this.primaryToken.symbol);
379
- const secondaryTokenPrice = await this.pricer.getPrice(this.secondaryToken.symbol);
380
- const primaryTokenAmount = Web3Number.fromWei(remainingBase.toString(), this.primaryToken.decimals);
381
- const secondaryTokenAmount = Web3Number.fromWei(totalSecondTokens.toString(), this.secondaryToken.decimals);
382
- const primaryTokenUsd = primaryTokenAmount.multipliedBy(primaryTokenPrice.price).toNumber();
383
- const secondaryTokenUsd = secondaryTokenAmount.multipliedBy(secondaryTokenPrice.price).toNumber();
384
- const netUsd = primaryTokenUsd + secondaryTokenUsd;
385
- return {
386
- net: netUsd,
387
- splits: [
388
- {
389
- apy: primaryTokenAmount.toNumber(),
390
- id: this.primaryToken.symbol,
391
- },
392
- {
393
- apy: secondaryTokenAmount.toNumber(),
394
- id: this.secondaryToken.symbol,
395
- },
396
- ],
397
- }
398
- }catch(err){
399
- console.error("Error fetching net APY:", err);
400
- return 0;
401
- }
365
+ async netAPY(): Promise<number | string | NetAPYDetails> {
366
+ return "YOLO"
402
367
  }
403
368
 
404
369
  getSettings = async () => {
405
370
  return this.contract.call("get_settings", []);
406
371
  };
372
+
373
+ getStrategyTooltip(): {holdings: string, earnings: string} {
374
+ return {
375
+ holdings:"USDC Left",
376
+ earnings:"WBTC Accumulated",
377
+ };
378
+ }
407
379
  }
408
380
 
409
381
  const yoloVaultDescription =