@strkfarm/sdk 1.1.45 → 1.1.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.
@@ -55715,17 +55715,6 @@ ${JSON.stringify(data, null, 2)}`;
55715
55715
  return res.data;
55716
55716
  }
55717
55717
 
55718
- // src/strategies/constants.ts
55719
- var COMMON_CONTRACTS = [{
55720
- address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
55721
- name: "Access Controller",
55722
- sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
55723
- }];
55724
- var ENDPOINTS = {
55725
- VESU_BASE: "https://proxy.api.troves.fi/vesu",
55726
- VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
55727
- };
55728
-
55729
55718
  // src/modules/harvests.ts
55730
55719
  var Harvests = class _Harvests {
55731
55720
  constructor(config3) {
@@ -55783,17 +55772,19 @@ ${JSON.stringify(data, null, 2)}`;
55783
55772
  }
55784
55773
  };
55785
55774
  var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
55775
+ var VESU_REWARDS_ENDPOINT = "https://staging.api.vesu.xyz";
55786
55776
  var VesuHarvests = class _VesuHarvests extends Harvests {
55787
- async getHarvests(addr) {
55788
- const result2 = await fetch(`${ENDPOINTS.VESU_BASE}/users/${addr.address}/strk-rewards/calldata`);
55789
- const data = await result2.json();
55777
+ async getHarvests(addr, endpoint = VESU_REWARDS_ENDPOINT) {
55778
+ const result2 = await fetch(`${endpoint}/users/${addr.address}/rewards/calldata`);
55779
+ const _data = await result2.json();
55790
55780
  const rewardsContract = VESU_REWARDS_CONTRACT;
55791
55781
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
55792
55782
  const contract = new Contract({ abi: cls.abi, address: rewardsContract.address, providerOrAccount: this.config.provider });
55793
55783
  const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
55794
55784
  const claimed_amount = Web3Number.fromWei(_claimed_amount.toString(), 18);
55795
55785
  logger2.verbose(`${_VesuHarvests.name}: claimed_amount: ${claimed_amount.toString()}`);
55796
- const actualReward = Web3Number.fromWei(data.data.amount, 18).minus(claimed_amount);
55786
+ const data = _data.data["defiSpring"];
55787
+ const actualReward = Web3Number.fromWei(data.amount, 18).minus(claimed_amount);
55797
55788
  logger2.verbose(`${_VesuHarvests.name}: actualReward: ${actualReward.toString()}`);
55798
55789
  return [{
55799
55790
  rewardsContract,
@@ -55802,15 +55793,15 @@ ${JSON.stringify(data, null, 2)}`;
55802
55793
  endDate: /* @__PURE__ */ new Date(0),
55803
55794
  claim: {
55804
55795
  id: 0,
55805
- amount: Web3Number.fromWei(num_exports.getDecimalString(data.data.amount), 18),
55796
+ amount: Web3Number.fromWei(num_exports.getDecimalString(data.amount), 18),
55806
55797
  claimee: addr
55807
55798
  },
55808
55799
  actualReward,
55809
- proof: data.data.proof
55800
+ proof: data.proof
55810
55801
  }];
55811
55802
  }
55812
- async getUnHarvestedRewards(addr) {
55813
- return await this.getHarvests(addr);
55803
+ async getUnHarvestedRewards(addr, endpoint = VESU_REWARDS_ENDPOINT) {
55804
+ return await this.getHarvests(addr, endpoint);
55814
55805
  }
55815
55806
  };
55816
55807
 
@@ -61263,6 +61254,17 @@ ${JSON.stringify(data, null, 2)}`;
61263
61254
  ]
61264
61255
  };
61265
61256
 
61257
+ // src/strategies/constants.ts
61258
+ var COMMON_CONTRACTS = [{
61259
+ address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
61260
+ name: "Access Controller",
61261
+ sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
61262
+ }];
61263
+ var ENDPOINTS = {
61264
+ VESU_BASE: "https://proxy.api.troves.fi/vesu",
61265
+ VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
61266
+ };
61267
+
61266
61268
  // src/strategies/vesu-rebalance.tsx
61267
61269
  var import_jsx_runtime2 = __toESM(require_jsx_runtime());
61268
61270
  var VesuRebalance = class _VesuRebalance extends BaseStrategy {
@@ -61533,7 +61535,7 @@ ${JSON.stringify(data, null, 2)}`;
61533
61535
  let vesuPositions = [];
61534
61536
  try {
61535
61537
  const data2 = await getAPIUsingHeadlessBrowser(
61536
- `${ENDPOINTS.VESU_BASE_STAGING}/positions?walletAddress=${this.address.address}`
61538
+ `https://staging.api.vesu.xyz/positions?walletAddress=${this.address.address}`
61537
61539
  );
61538
61540
  vesuPositions = data2.data;
61539
61541
  } catch (e) {
@@ -4116,19 +4116,6 @@ async function getAPIUsingHeadlessBrowser(url) {
4116
4116
 
4117
4117
  // src/modules/harvests.ts
4118
4118
  import { Contract as Contract4, num as num3 } from "starknet";
4119
-
4120
- // src/strategies/constants.ts
4121
- var COMMON_CONTRACTS = [{
4122
- address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
4123
- name: "Access Controller",
4124
- sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
4125
- }];
4126
- var ENDPOINTS = {
4127
- VESU_BASE: "https://proxy.api.troves.fi/vesu",
4128
- VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
4129
- };
4130
-
4131
- // src/modules/harvests.ts
4132
4119
  var Harvests = class _Harvests {
4133
4120
  constructor(config) {
4134
4121
  this.config = config;
@@ -4185,17 +4172,19 @@ var EkuboHarvests = class extends Harvests {
4185
4172
  }
4186
4173
  };
4187
4174
  var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
4175
+ var VESU_REWARDS_ENDPOINT = "https://staging.api.vesu.xyz";
4188
4176
  var VesuHarvests = class _VesuHarvests extends Harvests {
4189
- async getHarvests(addr) {
4190
- const result = await fetch(`${ENDPOINTS.VESU_BASE}/users/${addr.address}/strk-rewards/calldata`);
4191
- const data = await result.json();
4177
+ async getHarvests(addr, endpoint = VESU_REWARDS_ENDPOINT) {
4178
+ const result = await fetch(`${endpoint}/users/${addr.address}/rewards/calldata`);
4179
+ const _data = await result.json();
4192
4180
  const rewardsContract = VESU_REWARDS_CONTRACT;
4193
4181
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
4194
4182
  const contract = new Contract4({ abi: cls.abi, address: rewardsContract.address, providerOrAccount: this.config.provider });
4195
4183
  const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
4196
4184
  const claimed_amount = Web3Number.fromWei(_claimed_amount.toString(), 18);
4197
4185
  logger.verbose(`${_VesuHarvests.name}: claimed_amount: ${claimed_amount.toString()}`);
4198
- const actualReward = Web3Number.fromWei(data.data.amount, 18).minus(claimed_amount);
4186
+ const data = _data.data["defiSpring"];
4187
+ const actualReward = Web3Number.fromWei(data.amount, 18).minus(claimed_amount);
4199
4188
  logger.verbose(`${_VesuHarvests.name}: actualReward: ${actualReward.toString()}`);
4200
4189
  return [{
4201
4190
  rewardsContract,
@@ -4204,15 +4193,15 @@ var VesuHarvests = class _VesuHarvests extends Harvests {
4204
4193
  endDate: /* @__PURE__ */ new Date(0),
4205
4194
  claim: {
4206
4195
  id: 0,
4207
- amount: Web3Number.fromWei(num3.getDecimalString(data.data.amount), 18),
4196
+ amount: Web3Number.fromWei(num3.getDecimalString(data.amount), 18),
4208
4197
  claimee: addr
4209
4198
  },
4210
4199
  actualReward,
4211
- proof: data.data.proof
4200
+ proof: data.proof
4212
4201
  }];
4213
4202
  }
4214
- async getUnHarvestedRewards(addr) {
4215
- return await this.getHarvests(addr);
4203
+ async getUnHarvestedRewards(addr, endpoint = VESU_REWARDS_ENDPOINT) {
4204
+ return await this.getHarvests(addr, endpoint);
4216
4205
  }
4217
4206
  };
4218
4207
 
@@ -9665,6 +9654,17 @@ var vesu_pools_default = {
9665
9654
  ]
9666
9655
  };
9667
9656
 
9657
+ // src/strategies/constants.ts
9658
+ var COMMON_CONTRACTS = [{
9659
+ address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
9660
+ name: "Access Controller",
9661
+ sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
9662
+ }];
9663
+ var ENDPOINTS = {
9664
+ VESU_BASE: "https://proxy.api.troves.fi/vesu",
9665
+ VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
9666
+ };
9667
+
9668
9668
  // src/strategies/vesu-rebalance.tsx
9669
9669
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
9670
9670
  var VesuRebalance = class _VesuRebalance extends BaseStrategy {
@@ -9935,7 +9935,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
9935
9935
  let vesuPositions = [];
9936
9936
  try {
9937
9937
  const data2 = await getAPIUsingHeadlessBrowser(
9938
- `${ENDPOINTS.VESU_BASE_STAGING}/positions?walletAddress=${this.address.address}`
9938
+ `https://staging.api.vesu.xyz/positions?walletAddress=${this.address.address}`
9939
9939
  );
9940
9940
  vesuPositions = data2.data;
9941
9941
  } catch (e) {
package/dist/index.js CHANGED
@@ -4120,19 +4120,6 @@ async function getAPIUsingHeadlessBrowser(url) {
4120
4120
 
4121
4121
  // src/modules/harvests.ts
4122
4122
  var import_starknet9 = require("starknet");
4123
-
4124
- // src/strategies/constants.ts
4125
- var COMMON_CONTRACTS = [{
4126
- address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
4127
- name: "Access Controller",
4128
- sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
4129
- }];
4130
- var ENDPOINTS = {
4131
- VESU_BASE: "https://proxy.api.troves.fi/vesu",
4132
- VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
4133
- };
4134
-
4135
- // src/modules/harvests.ts
4136
4123
  var Harvests = class _Harvests {
4137
4124
  constructor(config) {
4138
4125
  this.config = config;
@@ -4189,17 +4176,19 @@ var EkuboHarvests = class extends Harvests {
4189
4176
  }
4190
4177
  };
4191
4178
  var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
4179
+ var VESU_REWARDS_ENDPOINT = "https://staging.api.vesu.xyz";
4192
4180
  var VesuHarvests = class _VesuHarvests extends Harvests {
4193
- async getHarvests(addr) {
4194
- const result = await fetch(`${ENDPOINTS.VESU_BASE}/users/${addr.address}/strk-rewards/calldata`);
4195
- const data = await result.json();
4181
+ async getHarvests(addr, endpoint = VESU_REWARDS_ENDPOINT) {
4182
+ const result = await fetch(`${endpoint}/users/${addr.address}/rewards/calldata`);
4183
+ const _data = await result.json();
4196
4184
  const rewardsContract = VESU_REWARDS_CONTRACT;
4197
4185
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
4198
4186
  const contract = new import_starknet9.Contract({ abi: cls.abi, address: rewardsContract.address, providerOrAccount: this.config.provider });
4199
4187
  const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
4200
4188
  const claimed_amount = Web3Number.fromWei(_claimed_amount.toString(), 18);
4201
4189
  logger.verbose(`${_VesuHarvests.name}: claimed_amount: ${claimed_amount.toString()}`);
4202
- const actualReward = Web3Number.fromWei(data.data.amount, 18).minus(claimed_amount);
4190
+ const data = _data.data["defiSpring"];
4191
+ const actualReward = Web3Number.fromWei(data.amount, 18).minus(claimed_amount);
4203
4192
  logger.verbose(`${_VesuHarvests.name}: actualReward: ${actualReward.toString()}`);
4204
4193
  return [{
4205
4194
  rewardsContract,
@@ -4208,15 +4197,15 @@ var VesuHarvests = class _VesuHarvests extends Harvests {
4208
4197
  endDate: /* @__PURE__ */ new Date(0),
4209
4198
  claim: {
4210
4199
  id: 0,
4211
- amount: Web3Number.fromWei(import_starknet9.num.getDecimalString(data.data.amount), 18),
4200
+ amount: Web3Number.fromWei(import_starknet9.num.getDecimalString(data.amount), 18),
4212
4201
  claimee: addr
4213
4202
  },
4214
4203
  actualReward,
4215
- proof: data.data.proof
4204
+ proof: data.proof
4216
4205
  }];
4217
4206
  }
4218
- async getUnHarvestedRewards(addr) {
4219
- return await this.getHarvests(addr);
4207
+ async getUnHarvestedRewards(addr, endpoint = VESU_REWARDS_ENDPOINT) {
4208
+ return await this.getHarvests(addr, endpoint);
4220
4209
  }
4221
4210
  };
4222
4211
 
@@ -9669,6 +9658,17 @@ var vesu_pools_default = {
9669
9658
  ]
9670
9659
  };
9671
9660
 
9661
+ // src/strategies/constants.ts
9662
+ var COMMON_CONTRACTS = [{
9663
+ address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
9664
+ name: "Access Controller",
9665
+ sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
9666
+ }];
9667
+ var ENDPOINTS = {
9668
+ VESU_BASE: "https://proxy.api.troves.fi/vesu",
9669
+ VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
9670
+ };
9671
+
9672
9672
  // src/strategies/vesu-rebalance.tsx
9673
9673
  var import_jsx_runtime2 = require("react/jsx-runtime");
9674
9674
  var VesuRebalance = class _VesuRebalance extends BaseStrategy {
@@ -9939,7 +9939,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
9939
9939
  let vesuPositions = [];
9940
9940
  try {
9941
9941
  const data2 = await getAPIUsingHeadlessBrowser(
9942
- `${ENDPOINTS.VESU_BASE_STAGING}/positions?walletAddress=${this.address.address}`
9942
+ `https://staging.api.vesu.xyz/positions?walletAddress=${this.address.address}`
9943
9943
  );
9944
9944
  vesuPositions = data2.data;
9945
9945
  } catch (e) {
package/dist/index.mjs CHANGED
@@ -4014,19 +4014,6 @@ async function getAPIUsingHeadlessBrowser(url) {
4014
4014
 
4015
4015
  // src/modules/harvests.ts
4016
4016
  import { Contract as Contract4, num as num3 } from "starknet";
4017
-
4018
- // src/strategies/constants.ts
4019
- var COMMON_CONTRACTS = [{
4020
- address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
4021
- name: "Access Controller",
4022
- sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
4023
- }];
4024
- var ENDPOINTS = {
4025
- VESU_BASE: "https://proxy.api.troves.fi/vesu",
4026
- VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
4027
- };
4028
-
4029
- // src/modules/harvests.ts
4030
4017
  var Harvests = class _Harvests {
4031
4018
  constructor(config) {
4032
4019
  this.config = config;
@@ -4083,17 +4070,19 @@ var EkuboHarvests = class extends Harvests {
4083
4070
  }
4084
4071
  };
4085
4072
  var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
4073
+ var VESU_REWARDS_ENDPOINT = "https://staging.api.vesu.xyz";
4086
4074
  var VesuHarvests = class _VesuHarvests extends Harvests {
4087
- async getHarvests(addr) {
4088
- const result = await fetch(`${ENDPOINTS.VESU_BASE}/users/${addr.address}/strk-rewards/calldata`);
4089
- const data = await result.json();
4075
+ async getHarvests(addr, endpoint = VESU_REWARDS_ENDPOINT) {
4076
+ const result = await fetch(`${endpoint}/users/${addr.address}/rewards/calldata`);
4077
+ const _data = await result.json();
4090
4078
  const rewardsContract = VESU_REWARDS_CONTRACT;
4091
4079
  const cls = await this.config.provider.getClassAt(rewardsContract.address);
4092
4080
  const contract = new Contract4({ abi: cls.abi, address: rewardsContract.address, providerOrAccount: this.config.provider });
4093
4081
  const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
4094
4082
  const claimed_amount = Web3Number.fromWei(_claimed_amount.toString(), 18);
4095
4083
  logger.verbose(`${_VesuHarvests.name}: claimed_amount: ${claimed_amount.toString()}`);
4096
- const actualReward = Web3Number.fromWei(data.data.amount, 18).minus(claimed_amount);
4084
+ const data = _data.data["defiSpring"];
4085
+ const actualReward = Web3Number.fromWei(data.amount, 18).minus(claimed_amount);
4097
4086
  logger.verbose(`${_VesuHarvests.name}: actualReward: ${actualReward.toString()}`);
4098
4087
  return [{
4099
4088
  rewardsContract,
@@ -4102,15 +4091,15 @@ var VesuHarvests = class _VesuHarvests extends Harvests {
4102
4091
  endDate: /* @__PURE__ */ new Date(0),
4103
4092
  claim: {
4104
4093
  id: 0,
4105
- amount: Web3Number.fromWei(num3.getDecimalString(data.data.amount), 18),
4094
+ amount: Web3Number.fromWei(num3.getDecimalString(data.amount), 18),
4106
4095
  claimee: addr
4107
4096
  },
4108
4097
  actualReward,
4109
- proof: data.data.proof
4098
+ proof: data.proof
4110
4099
  }];
4111
4100
  }
4112
- async getUnHarvestedRewards(addr) {
4113
- return await this.getHarvests(addr);
4101
+ async getUnHarvestedRewards(addr, endpoint = VESU_REWARDS_ENDPOINT) {
4102
+ return await this.getHarvests(addr, endpoint);
4114
4103
  }
4115
4104
  };
4116
4105
 
@@ -9563,6 +9552,17 @@ var vesu_pools_default = {
9563
9552
  ]
9564
9553
  };
9565
9554
 
9555
+ // src/strategies/constants.ts
9556
+ var COMMON_CONTRACTS = [{
9557
+ address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
9558
+ name: "Access Controller",
9559
+ sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo"
9560
+ }];
9561
+ var ENDPOINTS = {
9562
+ VESU_BASE: "https://proxy.api.troves.fi/vesu",
9563
+ VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
9564
+ };
9565
+
9566
9566
  // src/strategies/vesu-rebalance.tsx
9567
9567
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
9568
9568
  var VesuRebalance = class _VesuRebalance extends BaseStrategy {
@@ -9833,7 +9833,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
9833
9833
  let vesuPositions = [];
9834
9834
  try {
9835
9835
  const data2 = await getAPIUsingHeadlessBrowser(
9836
- `${ENDPOINTS.VESU_BASE_STAGING}/positions?walletAddress=${this.address.address}`
9836
+ `https://staging.api.vesu.xyz/positions?walletAddress=${this.address.address}`
9837
9837
  );
9838
9838
  vesuPositions = data2.data;
9839
9839
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
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",
@@ -8,6 +8,7 @@
8
8
  "accountsecure": "dist/cli.js"
9
9
  },
10
10
  "exports": {
11
+
11
12
  ".": {
12
13
  "import": {
13
14
  "browser": "./dist/index.browser.mjs",
@@ -86,11 +86,11 @@ export class EkuboHarvests extends Harvests {
86
86
  }
87
87
 
88
88
  export const VESU_REWARDS_CONTRACT = ContractAddr.from('0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F');
89
-
89
+ export const VESU_REWARDS_ENDPOINT = 'https://staging.api.vesu.xyz';
90
90
  export class VesuHarvests extends Harvests {
91
- async getHarvests(addr: ContractAddr): Promise<HarvestInfo[]> {
92
- const result = await fetch(`${ENDPOINTS.VESU_BASE}/users/${addr.address}/strk-rewards/calldata`);
93
- const data = await result.json();
91
+ async getHarvests(addr: ContractAddr, endpoint = VESU_REWARDS_ENDPOINT): Promise<HarvestInfo[]> {
92
+ const result = await fetch(`${endpoint}/users/${addr.address}/rewards/calldata`);
93
+ const _data = await result.json();
94
94
  const rewardsContract = VESU_REWARDS_CONTRACT;
95
95
 
96
96
  // get already claimed amount
@@ -100,8 +100,10 @@ export class VesuHarvests extends Harvests {
100
100
  const claimed_amount = Web3Number.fromWei(_claimed_amount.toString(), 18);
101
101
  logger.verbose(`${VesuHarvests.name}: claimed_amount: ${claimed_amount.toString()}`);
102
102
 
103
+ const data = _data.data['defiSpring'];
104
+
103
105
  // get the actual reward
104
- const actualReward = Web3Number.fromWei(data.data.amount, 18).minus(claimed_amount);
106
+ const actualReward = Web3Number.fromWei(data.amount, 18).minus(claimed_amount);
105
107
  logger.verbose(`${VesuHarvests.name}: actualReward: ${actualReward.toString()}`);
106
108
  return [{
107
109
  rewardsContract,
@@ -110,15 +112,15 @@ export class VesuHarvests extends Harvests {
110
112
  endDate: new Date(0),
111
113
  claim: {
112
114
  id: 0,
113
- amount: Web3Number.fromWei(num.getDecimalString(data.data.amount), 18),
115
+ amount: Web3Number.fromWei(num.getDecimalString(data.amount), 18),
114
116
  claimee: addr
115
117
  },
116
118
  actualReward,
117
- proof: data.data.proof
119
+ proof: data.proof
118
120
  }]
119
121
  }
120
122
 
121
- async getUnHarvestedRewards(addr: ContractAddr) {
122
- return await this.getHarvests(addr);
123
+ async getUnHarvestedRewards(addr: ContractAddr, endpoint = VESU_REWARDS_ENDPOINT) {
124
+ return await this.getHarvests(addr, endpoint);
123
125
  }
124
126
  }
@@ -0,0 +1,159 @@
1
+ // import axios from 'axios';
2
+ // import { ContractAddr } from '../dataTypes';
3
+ // import { logger } from '../utils/logger';
4
+
5
+ // /**
6
+ // * Midas module for interacting with Midas API
7
+ // * Provides functions to get APY, price, and TVL data for Midas tokens
8
+ // */
9
+ // export class Midas {
10
+ // // Static mapping of contract addresses to Midas API symbols
11
+ // private static readonly CONTRACT_TO_SYMBOL: Record<string, string> = {
12
+ // '0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac': 'mre7btc', // mRe7BTC
13
+ // '0x4be8945e61dc3e19ebadd1579a6bd53b262f51ba89e6f8b0c4bc9a7e3c633fc': 'mre7', // mRe7YIELD
14
+ // };
15
+
16
+ // private static readonly BASE_URL = 'https://api-prod.midas.app/api/data';
17
+
18
+ // /**
19
+ // * Check if a contract address is supported by Midas
20
+ // * @param contractAddr The contract address to check
21
+ // * @returns True if the contract address is supported
22
+ // */
23
+ // static isSupported(contractAddr: ContractAddr): boolean {
24
+ // return contractAddr.address in Midas.CONTRACT_TO_SYMBOL;
25
+ // }
26
+
27
+ // /**
28
+ // * Get the Midas symbol for a given contract address
29
+ // * @param contractAddr The contract address to look up
30
+ // * @returns The Midas symbol for the contract
31
+ // * @throws Error if contract address is not found
32
+ // */
33
+ // static getSymbolFromContract(contractAddr: ContractAddr): string {
34
+ // const symbol = Midas.CONTRACT_TO_SYMBOL[contractAddr.address];
35
+ // if (!symbol) {
36
+ // throw new Error(`Contract address ${contractAddr.address} not found in Midas mapping`);
37
+ // }
38
+ // return symbol;
39
+ // }
40
+
41
+ // /**
42
+ // * Get APY data for all Midas tokens
43
+ // * @returns Object with token symbols as keys and APY values as numbers
44
+ // * @throws Error if API request fails
45
+ // */
46
+ // static async getAPYs(): Promise<Record<string, number>> {
47
+ // try {
48
+ // const response = await axios.get(`${Midas.BASE_URL}/apys`);
49
+ // return response.data;
50
+ // } catch (error) {
51
+ // logger.error('Failed to fetch APYs from Midas API:', error);
52
+ // throw new Error(`Failed to fetch APYs: ${error instanceof Error ? error.message : 'Unknown error'}`);
53
+ // }
54
+ // }
55
+
56
+ // /**
57
+ // * Get APY for a specific token by contract address
58
+ // * @param contractAddr The contract address of the token
59
+ // * @returns The APY value for the token
60
+ // * @throws Error if contract address not found or API request fails
61
+ // */
62
+ // static async getAPY(contractAddr: ContractAddr): Promise<number> {
63
+ // const symbol = Midas.getSymbolFromContract(contractAddr);
64
+ // const apys = await Midas.getAPYs();
65
+
66
+ // if (!(symbol in apys)) {
67
+ // throw new Error(`Symbol ${symbol} not found in APY data`);
68
+ // }
69
+
70
+ // return apys[symbol];
71
+ // }
72
+
73
+ // /**
74
+ // * Get price data for a specific token
75
+ // * @param contractAddr The contract address of the token
76
+ // * @param timestampFrom Optional start timestamp (defaults to 30 days ago)
77
+ // * @param timestampTo Optional end timestamp (defaults to now)
78
+ // * @param environment Environment (defaults to 'mainnet')
79
+ // * @returns The latest price for the token
80
+ // * @throws Error if contract address not found or API request fails
81
+ // */
82
+ // static async getPrice(
83
+ // contractAddr: ContractAddr,
84
+ // timestampFrom?: number,
85
+ // timestampTo?: number,
86
+ // environment: string = 'mainnet'
87
+ // ): Promise<number> {
88
+ // const symbol = Midas.getSymbolFromContract(contractAddr);
89
+
90
+ // // Default to 30 days ago if not provided
91
+ // const from = timestampFrom ?? Math.floor(Date.now() / 1000) - (30 * 24 * 60 * 60);
92
+ // // Default to now if not provided
93
+ // const to = timestampTo ?? Math.floor(Date.now() / 1000);
94
+
95
+ // try {
96
+ // const response = await axios.get(`${Midas.BASE_URL}/${symbol}/price`, {
97
+ // params: {
98
+ // timestampFrom: from,
99
+ // timestampTo: to,
100
+ // environment
101
+ // }
102
+ // });
103
+
104
+ // const priceData = response.data;
105
+ // if (!Array.isArray(priceData) || priceData.length === 0) {
106
+ // throw new Error(`No price data found for ${symbol}`);
107
+ // }
108
+
109
+ // // Return the latest price (first item in the array)
110
+ // return priceData[0].price;
111
+ // } catch (error) {
112
+ // logger.error(`Failed to fetch price for ${symbol}:`, error);
113
+ // throw new Error(`Failed to fetch price for ${symbol}: ${error instanceof Error ? error.message : 'Unknown error'}`);
114
+ // }
115
+ // }
116
+
117
+ // /**
118
+ // * Get TVL data for all tokens
119
+ // * @param environment Environment (defaults to 'mainnet')
120
+ // * @returns Object with TVL data including totalTvl and tokenTvl
121
+ // * @throws Error if API request fails
122
+ // */
123
+ // static async getTVLData(environment: string = 'mainnet'): Promise<{
124
+ // lastUpdatedAt: string;
125
+ // totalTvl: number;
126
+ // tokenTvl: Record<string, any>;
127
+ // }> {
128
+ // try {
129
+ // const response = await axios.get(`${Midas.BASE_URL}/tvl`, {
130
+ // params: { environment }
131
+ // });
132
+ // return response.data;
133
+ // } catch (error) {
134
+ // logger.error('Failed to fetch TVL data from Midas API:', error);
135
+ // throw new Error(`Failed to fetch TVL data: ${error instanceof Error ? error.message : 'Unknown error'}`);
136
+ // }
137
+ // }
138
+
139
+ // /**
140
+ // * Get TVL for a specific token by contract address
141
+ // * @param contractAddr The contract address of the token
142
+ // * @param environment Environment (defaults to 'mainnet')
143
+ // * @returns The TVL data for the token (USD and native amounts)
144
+ // * @throws Error if contract address not found or API request fails
145
+ // */
146
+ // static async getTVL(
147
+ // contractAddr: ContractAddr,
148
+ // environment: string = 'mainnet'
149
+ // ): Promise<{ usd: number; native: number } | number> {
150
+ // const symbol = Midas.getSymbolFromContract(contractAddr);
151
+ // const tvlData = await Midas.getTVLData(environment);
152
+
153
+ // if (!(symbol in tvlData.tokenTvl)) {
154
+ // throw new Error(`Symbol ${symbol} not found in TVL data`);
155
+ // }
156
+
157
+ // return tvlData.tokenTvl[symbol];
158
+ // }
159
+ // }
@@ -0,0 +1,202 @@
1
+ // import { ContractAddr, Web3Number } from '../dataTypes';
2
+ // import { TokenInfo, IConfig } from '../interfaces';
3
+ // import { PricerBase } from './pricerBase';
4
+ // import { LSTAPRService } from './lst-apr';
5
+ // import { Midas } from './midas';
6
+ // import { SingleTokenInfo } from '../strategies/base-strategy';
7
+ // import { logger } from '../utils/logger';
8
+ // import { Contract } from 'starknet';
9
+ // import { uint256 } from 'starknet';
10
+ // import ERC4626Abi from '../data/erc4626.abi.json';
11
+
12
+ // /**
13
+ // * TokenMarketData class that combines LST APR and Midas modules
14
+ // * to provide unified APY, price, and TVL functions for tokens
15
+ // */
16
+ // export class TokenMarketData {
17
+ // private pricer: PricerBase;
18
+ // private config: IConfig;
19
+
20
+ // constructor(pricer: PricerBase, config: IConfig) {
21
+ // this.pricer = pricer;
22
+ // this.config = config;
23
+ // }
24
+
25
+ // /**
26
+ // * Get APY for a token
27
+ // * - If it's an LST token, returns LST APY
28
+ // * - If it's a Midas token, returns Midas APY
29
+ // * - Otherwise returns 0
30
+ // * @param tokenInfo The token to get APY for
31
+ // * @returns APY in absolute terms (not percentage)
32
+ // */
33
+ // async getAPY(tokenInfo: TokenInfo): Promise<number> {
34
+ // try {
35
+ // // Check if it's an LST token
36
+ // if (LSTAPRService.isLST(tokenInfo.address)) {
37
+ // const underlying = LSTAPRService.getUnderlyingFromLST(tokenInfo.address);
38
+ // const lstApr = await LSTAPRService.getLSTAPR(underlying.address);
39
+ // logger.verbose(`TokenMarketData: LST APY for ${tokenInfo.symbol}: ${lstApr}`);
40
+ // return lstApr;
41
+ // }
42
+
43
+ // // Check if it's a Midas token by trying to get symbol
44
+ // if (Midas.isSupported(tokenInfo.address)) {
45
+ // const midasApy = await Midas.getAPY(tokenInfo.address);
46
+ // logger.verbose(`TokenMarketData: Midas APY for ${tokenInfo.symbol}: ${midasApy}`);
47
+ // return midasApy;
48
+ // }
49
+
50
+ // // Default to 0 for unsupported tokens
51
+ // logger.verbose(`TokenMarketData: No APY data available for ${tokenInfo.symbol}, returning 0`);
52
+ // return 0;
53
+ // } catch (error) {
54
+ // logger.error(`TokenMarketData: Error getting APY for ${tokenInfo.symbol}:`, error);
55
+ // return 0;
56
+ // }
57
+ // }
58
+
59
+ // /**
60
+ // * Get price for a token using the pricer module
61
+ // * @param tokenInfo The token to get price for
62
+ // * @returns Price as a number
63
+ // * @throws Error if price is 0 or unavailable
64
+ // */
65
+ // async getPrice(tokenInfo: TokenInfo): Promise<number> {
66
+ // try {
67
+ // const priceInfo = await this.pricer.getPrice(tokenInfo.symbol);
68
+
69
+ // if (priceInfo.price === 0) {
70
+ // throw new Error(`Price is 0 for token ${tokenInfo.symbol}`);
71
+ // }
72
+
73
+ // logger.verbose(`TokenMarketData: Price for ${tokenInfo.symbol}: ${priceInfo.price}`);
74
+ // return priceInfo.price;
75
+ // } catch (error) {
76
+ // logger.error(`TokenMarketData: Error getting price for ${tokenInfo.symbol}:`, error);
77
+ // throw new Error(`Failed to get price for ${tokenInfo.symbol}: ${error instanceof Error ? error.message : 'Unknown error'}`);
78
+ // }
79
+ // }
80
+
81
+ // /**
82
+ // * Get true price for a token
83
+ // * - For LST tokens: Uses convert_to_assets to get true exchange rate
84
+ // * - For Midas tokens: Uses Midas price API
85
+ // * - For other tokens: Falls back to regular pricer
86
+ // * @param tokenInfo The token to get true price for
87
+ // * @returns True price as a number
88
+ // * @throws Error if price is 0 or unavailable
89
+ // */
90
+ // async getTruePrice(tokenInfo: TokenInfo): Promise<number> {
91
+ // try {
92
+ // // For LST tokens, use convert_to_assets
93
+ // if (LSTAPRService.isLST(tokenInfo.address)) {
94
+ // const lstABI = new Contract({
95
+ // abi: ERC4626Abi,
96
+ // address: tokenInfo.address.address,
97
+ // providerOrAccount: this.config.provider
98
+ // });
99
+
100
+ // const price: any = await lstABI.call('convert_to_assets', [
101
+ // uint256.bnToUint256((new Web3Number(1, tokenInfo.decimals)).toWei())
102
+ // ]);
103
+ // const exchangeRate = Number(uint256.uint256ToBN(price).toString()) / Math.pow(10, tokenInfo.decimals);
104
+
105
+ // if (exchangeRate === 0) {
106
+ // throw new Error(`True price is 0 for LST token ${tokenInfo.symbol}`);
107
+ // }
108
+
109
+ // logger.verbose(`TokenMarketData: LST true price for ${tokenInfo.symbol}: ${exchangeRate}`);
110
+ // return exchangeRate;
111
+ // }
112
+
113
+ // // For Midas tokens, use Midas price API
114
+ // if (Midas.isSupported(tokenInfo.address)) {
115
+ // const midasPrice = await Midas.getPrice(tokenInfo.address);
116
+
117
+ // if (midasPrice === 0) {
118
+ // throw new Error(`True price is 0 for Midas token ${tokenInfo.symbol}`);
119
+ // }
120
+
121
+ // logger.verbose(`TokenMarketData: Midas true price for ${tokenInfo.symbol}: ${midasPrice}`);
122
+ // return midasPrice;
123
+ // }
124
+
125
+ // // For other tokens, fall back to regular pricer
126
+ // const price = await this.getPrice(tokenInfo);
127
+
128
+ // if (price === 0) {
129
+ // throw new Error(`True price is 0 for token ${tokenInfo.symbol}`);
130
+ // }
131
+
132
+ // logger.verbose(`TokenMarketData: Regular price for ${tokenInfo.symbol}: ${price}`);
133
+ // return price;
134
+ // } catch (error) {
135
+ // logger.error(`TokenMarketData: Error getting true price for ${tokenInfo.symbol}:`, error);
136
+ // throw new Error(`Failed to get true price for ${tokenInfo.symbol}: ${error instanceof Error ? error.message : 'Unknown error'}`);
137
+ // }
138
+ // }
139
+
140
+ // /**
141
+ // * Get TVL for a token
142
+ // * - If it's a Midas token, returns Midas TVL data
143
+ // * - Otherwise returns 0
144
+ // * @param tokenInfo The token to get TVL for
145
+ // * @returns TVL as SingleTokenInfo or 0
146
+ // */
147
+ // async getTVL(tokenInfo: TokenInfo): Promise<SingleTokenInfo> {
148
+ // // Check if it's a Midas token by trying to get TVL
149
+ // if (Midas.isSupported(tokenInfo.address)) {
150
+ // const midasTvl = await Midas.getTVL(tokenInfo.address);
151
+
152
+ // // Handle different TVL response formats
153
+ // let usdValue: number;
154
+ // let nativeAmount: number;
155
+
156
+ // if (typeof midasTvl === 'number') {
157
+ // // Simple number format (e.g., mre7: 18193466)
158
+ // usdValue = midasTvl;
159
+ // nativeAmount = 0; // We don't have native amount in this format
160
+ // } else if (typeof midasTvl === 'object' && 'usd' in midasTvl && 'native' in midasTvl) {
161
+ // // Object format with usd and native (e.g., mre7btc: {usd: 998826, native: 9.3228})
162
+ // usdValue = midasTvl.usd;
163
+ // nativeAmount = midasTvl.native;
164
+ // } else {
165
+ // throw new Error(`Unexpected TVL format for ${tokenInfo.symbol}`);
166
+ // }
167
+
168
+ // const tvlInfo: SingleTokenInfo = {
169
+ // tokenInfo,
170
+ // amount: Web3Number.fromWei(nativeAmount, tokenInfo.decimals),
171
+ // usdValue
172
+ // };
173
+
174
+ // logger.verbose(`TokenMarketData: Midas TVL for ${tokenInfo.symbol}: USD=${usdValue}, Native=${nativeAmount}`);
175
+ // return tvlInfo;
176
+ // }
177
+
178
+ // return {
179
+ // tokenInfo,
180
+ // amount: Web3Number.fromWei('0', tokenInfo.decimals),
181
+ // usdValue: 0
182
+ // }
183
+ // }
184
+
185
+ // /**
186
+ // * Check if a token is supported for APY data
187
+ // * @param tokenInfo The token to check
188
+ // * @returns True if the token has APY data available
189
+ // */
190
+ // isAPYSupported(tokenInfo: TokenInfo): boolean {
191
+ // return LSTAPRService.isLST(tokenInfo.address) || Midas.isSupported(tokenInfo.address);
192
+ // }
193
+
194
+ // /**
195
+ // * Check if a token is supported for TVL data
196
+ // * @param tokenInfo The token to check
197
+ // * @returns True if the token has TVL data available
198
+ // */
199
+ // isTVLSupported(tokenInfo: TokenInfo): boolean {
200
+ // return Midas.isSupported(tokenInfo.address);
201
+ // }
202
+ // }
@@ -448,7 +448,7 @@ export class VesuRebalance extends BaseStrategy<
448
448
  let vesuPositions: any[] = [];
449
449
  try {
450
450
  const data = await getAPIUsingHeadlessBrowser(
451
- `${ENDPOINTS.VESU_BASE_STAGING}/positions?walletAddress=${this.address.address}`
451
+ `https://staging.api.vesu.xyz/positions?walletAddress=${this.address.address}`
452
452
  );
453
453
  vesuPositions = data.data;
454
454
  } catch (e) {