@strkfarm/sdk 2.0.0-staging.18 → 2.0.0-staging.19

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.
@@ -1,5 +1,6 @@
1
1
  import { logger } from "@/utils/logger";
2
2
  import BigNumber from "bignumber.js";
3
+ import { uint256 } from "starknet";
3
4
 
4
5
  export class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
5
6
  decimals: number;
@@ -107,6 +108,10 @@ export class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
107
108
  sign: sign,
108
109
  }
109
110
  }
111
+
112
+ toUint256() {
113
+ return uint256.bnToUint256(this.toWei());
114
+ }
110
115
  }
111
116
 
112
117
  BigNumber.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
@@ -302,7 +302,10 @@ export class EkuboCLVault extends BaseStrategy<
302
302
  return [this.contract.populate("handle_fees", [])];
303
303
  }
304
304
 
305
- async getFeeHistory(timePeriod: '24h' | '7d' | '30d' | '3m' = '24h'): Promise<{
305
+ async getFeeHistory(
306
+ timePeriod: '24h' | '7d' | '30d' | '3m' | '6m' = '24h',
307
+ range?: { startTimestamp?: number; endTimestamp?: number }
308
+ ): Promise<{
306
309
  summary: DualTokenInfo,
307
310
  history: FeeHistory[]
308
311
  }> {
@@ -311,8 +314,15 @@ export class EkuboCLVault extends BaseStrategy<
311
314
  query ContractFeeEarnings(
312
315
  $timeframe: String!
313
316
  $contract: String!
317
+ $startTimestamp: Float
318
+ $endTimestamp: Float
314
319
  ) {
315
- contractFeeEarnings(timeframe: $timeframe, contract: $contract) {
320
+ contractFeeEarnings(
321
+ timeframe: $timeframe
322
+ contract: $contract
323
+ startTimestamp: $startTimestamp
324
+ endTimestamp: $endTimestamp
325
+ ) {
316
326
  contract
317
327
  dailyEarnings {
318
328
  date
@@ -325,7 +335,9 @@ export class EkuboCLVault extends BaseStrategy<
325
335
  `,
326
336
  variables: {
327
337
  timeframe: timePeriod,
328
- contract: this.address.address
338
+ contract: this.address.address,
339
+ startTimestamp: range?.startTimestamp,
340
+ endTimestamp: range?.endTimestamp
329
341
  },
330
342
  fetchPolicy: 'no-cache',
331
343
  });
@@ -437,14 +437,14 @@ export class VesuAdapter extends BaseAdapter {
437
437
  }
438
438
  }
439
439
 
440
- getVesuModifyDelegationAdapter = (id: string): LeafAdapterFn<VesuModifyDelegationCallParams> => {
440
+ getVesuModifyDelegationAdapter = (id: string, delegatee: ContractAddr): LeafAdapterFn<VesuModifyDelegationCallParams> => {
441
441
  return () => {
442
442
  const { addr: VESU_SINGLETON, isV2 } = getVesuSingletonAddress(this.config.poolId);
443
443
  const packedArguments: bigint[] = isV2 ? [
444
- toBigInt(this.VESU_MULTIPLY.toString()), // v2
444
+ toBigInt(delegatee.toString()), // v2
445
445
  ] : [
446
446
  this.config.poolId.toBigInt(),
447
- toBigInt(this.VESU_MULTIPLY_V1.toString()), // v1
447
+ toBigInt(delegatee.toString()), // v1
448
448
  ];
449
449
  const output = this.constructSimpleLeafData({
450
450
  id: id,
@@ -453,29 +453,31 @@ export class VesuAdapter extends BaseAdapter {
453
453
  packedArguments
454
454
  }, isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS);
455
455
 
456
- return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
456
+ return { leaf: output, callConstructor: this.getVesuModifyDelegationCall(delegatee).bind(this) };
457
457
  }
458
458
  }
459
459
 
460
- getVesuModifyDelegationCall = (params: VesuModifyDelegationCallParams): ManageCall => {
461
- const VESU_SINGLETON = getVesuSingletonAddress(this.config.poolId).addr;
462
- const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
463
- const call = contract.populate('modify_delegation', isV2 ? {
464
- delegatee: this.VESU_MULTIPLY.toBigInt(),
465
- delegation: params.delegation,
466
- } : {
467
- pool_id: this.config.poolId.toBigInt(),
468
- delegatee: this.VESU_MULTIPLY_V1.toBigInt(),
469
- delegation: params.delegation,
470
- });
471
- return {
472
- sanitizer: isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
473
- call: {
474
- contractAddress: VESU_SINGLETON,
475
- selector: hash.getSelectorFromName('modify_delegation'),
476
- calldata: [
477
- ...call.calldata as bigint[]
478
- ]
460
+ getVesuModifyDelegationCall = (delegatee: ContractAddr) => {
461
+ return (params: VesuModifyDelegationCallParams) => {
462
+ const VESU_SINGLETON = getVesuSingletonAddress(this.config.poolId).addr;
463
+ const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
464
+ const call = contract.populate('modify_delegation', isV2 ? {
465
+ delegatee: delegatee.toBigInt(),
466
+ delegation: params.delegation,
467
+ } : {
468
+ pool_id: this.config.poolId.toBigInt(),
469
+ delegatee: delegatee.toBigInt(),
470
+ delegation: params.delegation,
471
+ });
472
+ return {
473
+ sanitizer: isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
474
+ call: {
475
+ contractAddress: VESU_SINGLETON,
476
+ selector: hash.getSelectorFromName('modify_delegation'),
477
+ calldata: [
478
+ ...call.calldata as bigint[]
479
+ ]
480
+ }
479
481
  }
480
482
  }
481
483
  }
@@ -759,7 +759,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
759
759
  const STEP2_ID = getVesuGenericLegId(params.poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_ON);
760
760
  const manage2Info = this.getProofs<VesuModifyDelegationCallParams>(STEP2_ID);
761
761
  const manageCall2 = manage2Info.callConstructor({
762
- delegation: true
762
+ delegation: true,
763
763
  });
764
764
 
765
765
  // deposit and borrow or repay and withdraw
@@ -915,10 +915,10 @@ function addVesuLeaves(
915
915
  vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, leafIdApprove).bind(commonAdapter));
916
916
 
917
917
  const leafIdDelegationOn = getVesuGenericLegId(poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_ON);
918
- vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn).bind(vesuAdapterLST));
918
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn, VESU_MULTIPLY).bind(vesuAdapterLST));
919
919
 
920
920
  const leafIdDelegationOff = getVesuGenericLegId(poolId.toString(), LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_OFF);
921
- vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff).bind(vesuAdapterLST));
921
+ vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
922
922
 
923
923
  const multiplID = getVesuLegId(LST_MULTIPLIER_MANAGE_IDS.MULTIPLY_VESU, underlyingToken.symbol, poolId.toString());
924
924
  vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
@@ -1071,6 +1071,7 @@ const hyperxSTRK: HyperLSTStrategySettings = {
1071
1071
  borrowable_assets: [
1072
1072
  ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
1073
1073
  ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Prime })),
1074
+ ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7STRK })), // v2, new alt for Re7xSTRK
1074
1075
  ],
1075
1076
  underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'STRK')!,
1076
1077
  defaultPoolId: VesuPools.Re7xSTRK,