@strkfarm/sdk 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -101,26 +101,26 @@ var _Web3Number = class extends import_bignumber.default {
101
101
  return this.mul(10 ** this.decimals).toFixed(0);
102
102
  }
103
103
  multipliedBy(value) {
104
- let _value = Number(value).toFixed(13);
104
+ let _value = Number(value).toFixed(this.maxToFixedDecimals());
105
105
  return this.construct(this.mul(_value).toString(), this.decimals);
106
106
  }
107
107
  dividedBy(value) {
108
- let _value = Number(value).toFixed(13);
108
+ let _value = Number(value).toFixed(this.maxToFixedDecimals());
109
109
  return this.construct(this.div(_value).toString(), this.decimals);
110
110
  }
111
111
  plus(value) {
112
- const _value = Number(value).toFixed(13);
112
+ const _value = Number(value).toFixed(this.maxToFixedDecimals());
113
113
  return this.construct(this.add(_value).toString(), this.decimals);
114
114
  }
115
115
  minus(n, base) {
116
- const _value = Number(n).toFixed(13);
116
+ const _value = Number(n).toFixed(this.maxToFixedDecimals());
117
117
  return this.construct(super.minus(_value, base).toString(), this.decimals);
118
118
  }
119
119
  construct(value, decimals) {
120
120
  return new this.constructor(value, decimals);
121
121
  }
122
- toString(base) {
123
- return super.toString(base);
122
+ toString(decimals = this.maxToFixedDecimals()) {
123
+ return super.toFixed(decimals);
124
124
  }
125
125
  toJSON() {
126
126
  return this.toString();
@@ -128,6 +128,9 @@ var _Web3Number = class extends import_bignumber.default {
128
128
  valueOf() {
129
129
  return this.toString();
130
130
  }
131
+ maxToFixedDecimals() {
132
+ return Math.min(this.decimals, 13);
133
+ }
131
134
  };
132
135
  import_bignumber.default.config({ DECIMAL_PLACES: 18 });
133
136
  _Web3Number.config({ DECIMAL_PLACES: 18 });
@@ -478,6 +481,23 @@ var import_avnu_sdk = require("@avnu/avnu-sdk");
478
481
 
479
482
  // src/interfaces/common.ts
480
483
  var import_starknet5 = require("starknet");
484
+ var RiskType = /* @__PURE__ */ ((RiskType2) => {
485
+ RiskType2["MARKET_RISK"] = "Market Risk";
486
+ RiskType2["IMPERMANENT_LOSS"] = "Impermanent Loss Risk";
487
+ RiskType2["LIQUIDATION_RISK"] = "Liquidation Risk";
488
+ RiskType2["LOW_LIQUIDITY_RISK"] = "Low Liquidity Risk";
489
+ RiskType2["SMART_CONTRACT_RISK"] = "Smart Contract Risk";
490
+ RiskType2["ORACLE_RISK"] = "Oracle Risk";
491
+ RiskType2["TECHNICAL_RISK"] = "Technical Risk";
492
+ RiskType2["COUNTERPARTY_RISK"] = "Counterparty Risk";
493
+ return RiskType2;
494
+ })(RiskType || {});
495
+ var getNoRiskTags = (risks) => {
496
+ const noRisks1 = risks.filter((risk) => risk.value === 0).map((risk) => risk.type);
497
+ const noRisks2 = Object.values(RiskType).filter((risk) => !risks.map((risk2) => risk2.type).includes(risk));
498
+ const mergedUnique = [.../* @__PURE__ */ new Set([...noRisks1, ...noRisks2])];
499
+ return mergedUnique.map((risk) => `No ${risk}`);
500
+ };
481
501
 
482
502
  // src/strategies/autoCompounderStrk.ts
483
503
  var import_starknet6 = require("starknet");
@@ -500,7 +520,7 @@ var AUDIT_URL = "https://assets.strkfarm.com/strkfarm/audit_report_vesu_and_ekub
500
520
  var VesuRebalanceStrategies = [{
501
521
  name: "Vesu Fusion STRK",
502
522
  description: _description.replace("{{TOKEN}}", "STRK"),
503
- address: ContractAddr.from("0x778007f8136a5b827325d21613803e796bda4d676fbe1e34aeab0b2a2ec027f"),
523
+ address: ContractAddr.from("0x7fb5bcb8525954a60fde4e8fb8220477696ce7117ef264775a1770e23571929"),
504
524
  type: "ERC4626",
505
525
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "STRK")],
506
526
  protocols: [_protocol],
@@ -508,7 +528,8 @@ var VesuRebalanceStrategies = [{
508
528
  maxTVL: Web3Number.fromWei("0", 18),
509
529
  risk: {
510
530
  riskFactor: _riskFactor,
511
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
531
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
532
+ notARisks: getNoRiskTags(_riskFactor)
512
533
  },
513
534
  additionalInfo: {
514
535
  feeBps: 1e3
@@ -516,7 +537,7 @@ var VesuRebalanceStrategies = [{
516
537
  }, {
517
538
  name: "Vesu Fusion ETH",
518
539
  description: _description.replace("{{TOKEN}}", "ETH"),
519
- address: ContractAddr.from("0x26ea414fdf74ace1df5bc5ac72cbac670d438ef19b31edf9d59f98718fc0ab2"),
540
+ address: ContractAddr.from("0x5eaf5ee75231cecf79921ff8ded4b5ffe96be718bcb3daf206690ad1a9ad0ca"),
520
541
  type: "ERC4626",
521
542
  auditUrl: AUDIT_URL,
522
543
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "ETH")],
@@ -524,7 +545,8 @@ var VesuRebalanceStrategies = [{
524
545
  maxTVL: Web3Number.fromWei("0", 18),
525
546
  risk: {
526
547
  riskFactor: _riskFactor,
527
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
548
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
549
+ notARisks: getNoRiskTags(_riskFactor)
528
550
  },
529
551
  additionalInfo: {
530
552
  feeBps: 1e3
@@ -532,7 +554,7 @@ var VesuRebalanceStrategies = [{
532
554
  }, {
533
555
  name: "Vesu Fusion USDC",
534
556
  description: _description.replace("{{TOKEN}}", "USDC"),
535
- address: ContractAddr.from("0x3a69adeb993cddb266962d9c995e3d0641dab627df22b825fa31bda460c3c14"),
557
+ address: ContractAddr.from("0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"),
536
558
  type: "ERC4626",
537
559
  auditUrl: AUDIT_URL,
538
560
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "USDC")],
@@ -540,26 +562,28 @@ var VesuRebalanceStrategies = [{
540
562
  maxTVL: Web3Number.fromWei("0", 6),
541
563
  risk: {
542
564
  riskFactor: _riskFactor,
543
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
565
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
566
+ notARisks: getNoRiskTags(_riskFactor)
567
+ },
568
+ additionalInfo: {
569
+ feeBps: 1e3
570
+ }
571
+ }, {
572
+ name: "Vesu Fusion USDT",
573
+ description: _description.replace("{{TOKEN}}", "USDT"),
574
+ address: ContractAddr.from("0x115e94e722cfc4c77a2f15c4aefb0928c1c0029e5a57570df24c650cb7cec2c"),
575
+ type: "ERC4626",
576
+ depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "USDT")],
577
+ protocols: [_protocol],
578
+ maxTVL: Web3Number.fromWei("0", 6),
579
+ risk: {
580
+ riskFactor: _riskFactor,
581
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
582
+ notARisks: getNoRiskTags(_riskFactor)
544
583
  },
545
584
  additionalInfo: {
546
585
  feeBps: 1e3
547
586
  }
548
- // }, {
549
- // name: 'Vesu Fusion USDT',
550
- // description: _description.replace('{{TOKEN}}', 'USDT'),
551
- // address: ContractAddr.from('0x778007f8136a5b827325d21613803e796bda4d676fbe1e34aeab0b2a2ec027f'),
552
- // type: 'ERC4626',
553
- // depositTokens: [Global.getDefaultTokens().find(t => t.symbol === 'USDT')!],
554
- // protocols: [_protocol],
555
- // maxTVL: Web3Number.fromWei('0', 6),
556
- // risk: {
557
- // riskFactor: _riskFactor,
558
- // netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
559
- // },
560
- // additionalInfo: {
561
- // feeBps: 1000,
562
- // },
563
587
  // }, {
564
588
  // name: 'Vesu Fusion WBTC',
565
589
  // description: _description.replace('{{TOKEN}}', 'WBTC'),
@@ -595,7 +619,8 @@ var EkuboCLVaultStrategies = [{
595
619
  maxTVL: Web3Number.fromWei("0", 18),
596
620
  risk: {
597
621
  riskFactor: _riskFactor2,
598
- netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0)
622
+ netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
623
+ notARisks: getNoRiskTags(_riskFactor2)
599
624
  },
600
625
  additionalInfo: {
601
626
  newBounds: {
package/dist/cli.mjs CHANGED
@@ -78,26 +78,26 @@ var _Web3Number = class extends BigNumber {
78
78
  return this.mul(10 ** this.decimals).toFixed(0);
79
79
  }
80
80
  multipliedBy(value) {
81
- let _value = Number(value).toFixed(13);
81
+ let _value = Number(value).toFixed(this.maxToFixedDecimals());
82
82
  return this.construct(this.mul(_value).toString(), this.decimals);
83
83
  }
84
84
  dividedBy(value) {
85
- let _value = Number(value).toFixed(13);
85
+ let _value = Number(value).toFixed(this.maxToFixedDecimals());
86
86
  return this.construct(this.div(_value).toString(), this.decimals);
87
87
  }
88
88
  plus(value) {
89
- const _value = Number(value).toFixed(13);
89
+ const _value = Number(value).toFixed(this.maxToFixedDecimals());
90
90
  return this.construct(this.add(_value).toString(), this.decimals);
91
91
  }
92
92
  minus(n, base) {
93
- const _value = Number(n).toFixed(13);
93
+ const _value = Number(n).toFixed(this.maxToFixedDecimals());
94
94
  return this.construct(super.minus(_value, base).toString(), this.decimals);
95
95
  }
96
96
  construct(value, decimals) {
97
97
  return new this.constructor(value, decimals);
98
98
  }
99
- toString(base) {
100
- return super.toString(base);
99
+ toString(decimals = this.maxToFixedDecimals()) {
100
+ return super.toFixed(decimals);
101
101
  }
102
102
  toJSON() {
103
103
  return this.toString();
@@ -105,6 +105,9 @@ var _Web3Number = class extends BigNumber {
105
105
  valueOf() {
106
106
  return this.toString();
107
107
  }
108
+ maxToFixedDecimals() {
109
+ return Math.min(this.decimals, 13);
110
+ }
108
111
  };
109
112
  BigNumber.config({ DECIMAL_PLACES: 18 });
110
113
  _Web3Number.config({ DECIMAL_PLACES: 18 });
@@ -455,6 +458,23 @@ import { fetchBuildExecuteTransaction, fetchQuotes } from "@avnu/avnu-sdk";
455
458
 
456
459
  // src/interfaces/common.ts
457
460
  import { RpcProvider as RpcProvider2 } from "starknet";
461
+ var RiskType = /* @__PURE__ */ ((RiskType2) => {
462
+ RiskType2["MARKET_RISK"] = "Market Risk";
463
+ RiskType2["IMPERMANENT_LOSS"] = "Impermanent Loss Risk";
464
+ RiskType2["LIQUIDATION_RISK"] = "Liquidation Risk";
465
+ RiskType2["LOW_LIQUIDITY_RISK"] = "Low Liquidity Risk";
466
+ RiskType2["SMART_CONTRACT_RISK"] = "Smart Contract Risk";
467
+ RiskType2["ORACLE_RISK"] = "Oracle Risk";
468
+ RiskType2["TECHNICAL_RISK"] = "Technical Risk";
469
+ RiskType2["COUNTERPARTY_RISK"] = "Counterparty Risk";
470
+ return RiskType2;
471
+ })(RiskType || {});
472
+ var getNoRiskTags = (risks) => {
473
+ const noRisks1 = risks.filter((risk) => risk.value === 0).map((risk) => risk.type);
474
+ const noRisks2 = Object.values(RiskType).filter((risk) => !risks.map((risk2) => risk2.type).includes(risk));
475
+ const mergedUnique = [.../* @__PURE__ */ new Set([...noRisks1, ...noRisks2])];
476
+ return mergedUnique.map((risk) => `No ${risk}`);
477
+ };
458
478
 
459
479
  // src/strategies/autoCompounderStrk.ts
460
480
  import { Contract as Contract3, uint256 as uint2562 } from "starknet";
@@ -477,7 +497,7 @@ var AUDIT_URL = "https://assets.strkfarm.com/strkfarm/audit_report_vesu_and_ekub
477
497
  var VesuRebalanceStrategies = [{
478
498
  name: "Vesu Fusion STRK",
479
499
  description: _description.replace("{{TOKEN}}", "STRK"),
480
- address: ContractAddr.from("0x778007f8136a5b827325d21613803e796bda4d676fbe1e34aeab0b2a2ec027f"),
500
+ address: ContractAddr.from("0x7fb5bcb8525954a60fde4e8fb8220477696ce7117ef264775a1770e23571929"),
481
501
  type: "ERC4626",
482
502
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "STRK")],
483
503
  protocols: [_protocol],
@@ -485,7 +505,8 @@ var VesuRebalanceStrategies = [{
485
505
  maxTVL: Web3Number.fromWei("0", 18),
486
506
  risk: {
487
507
  riskFactor: _riskFactor,
488
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
508
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
509
+ notARisks: getNoRiskTags(_riskFactor)
489
510
  },
490
511
  additionalInfo: {
491
512
  feeBps: 1e3
@@ -493,7 +514,7 @@ var VesuRebalanceStrategies = [{
493
514
  }, {
494
515
  name: "Vesu Fusion ETH",
495
516
  description: _description.replace("{{TOKEN}}", "ETH"),
496
- address: ContractAddr.from("0x26ea414fdf74ace1df5bc5ac72cbac670d438ef19b31edf9d59f98718fc0ab2"),
517
+ address: ContractAddr.from("0x5eaf5ee75231cecf79921ff8ded4b5ffe96be718bcb3daf206690ad1a9ad0ca"),
497
518
  type: "ERC4626",
498
519
  auditUrl: AUDIT_URL,
499
520
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "ETH")],
@@ -501,7 +522,8 @@ var VesuRebalanceStrategies = [{
501
522
  maxTVL: Web3Number.fromWei("0", 18),
502
523
  risk: {
503
524
  riskFactor: _riskFactor,
504
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
525
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
526
+ notARisks: getNoRiskTags(_riskFactor)
505
527
  },
506
528
  additionalInfo: {
507
529
  feeBps: 1e3
@@ -509,7 +531,7 @@ var VesuRebalanceStrategies = [{
509
531
  }, {
510
532
  name: "Vesu Fusion USDC",
511
533
  description: _description.replace("{{TOKEN}}", "USDC"),
512
- address: ContractAddr.from("0x3a69adeb993cddb266962d9c995e3d0641dab627df22b825fa31bda460c3c14"),
534
+ address: ContractAddr.from("0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"),
513
535
  type: "ERC4626",
514
536
  auditUrl: AUDIT_URL,
515
537
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "USDC")],
@@ -517,26 +539,28 @@ var VesuRebalanceStrategies = [{
517
539
  maxTVL: Web3Number.fromWei("0", 6),
518
540
  risk: {
519
541
  riskFactor: _riskFactor,
520
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
542
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
543
+ notARisks: getNoRiskTags(_riskFactor)
544
+ },
545
+ additionalInfo: {
546
+ feeBps: 1e3
547
+ }
548
+ }, {
549
+ name: "Vesu Fusion USDT",
550
+ description: _description.replace("{{TOKEN}}", "USDT"),
551
+ address: ContractAddr.from("0x115e94e722cfc4c77a2f15c4aefb0928c1c0029e5a57570df24c650cb7cec2c"),
552
+ type: "ERC4626",
553
+ depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "USDT")],
554
+ protocols: [_protocol],
555
+ maxTVL: Web3Number.fromWei("0", 6),
556
+ risk: {
557
+ riskFactor: _riskFactor,
558
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
559
+ notARisks: getNoRiskTags(_riskFactor)
521
560
  },
522
561
  additionalInfo: {
523
562
  feeBps: 1e3
524
563
  }
525
- // }, {
526
- // name: 'Vesu Fusion USDT',
527
- // description: _description.replace('{{TOKEN}}', 'USDT'),
528
- // address: ContractAddr.from('0x778007f8136a5b827325d21613803e796bda4d676fbe1e34aeab0b2a2ec027f'),
529
- // type: 'ERC4626',
530
- // depositTokens: [Global.getDefaultTokens().find(t => t.symbol === 'USDT')!],
531
- // protocols: [_protocol],
532
- // maxTVL: Web3Number.fromWei('0', 6),
533
- // risk: {
534
- // riskFactor: _riskFactor,
535
- // netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
536
- // },
537
- // additionalInfo: {
538
- // feeBps: 1000,
539
- // },
540
564
  // }, {
541
565
  // name: 'Vesu Fusion WBTC',
542
566
  // description: _description.replace('{{TOKEN}}', 'WBTC'),
@@ -572,7 +596,8 @@ var EkuboCLVaultStrategies = [{
572
596
  maxTVL: Web3Number.fromWei("0", 18),
573
597
  risk: {
574
598
  riskFactor: _riskFactor2,
575
- netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0)
599
+ netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
600
+ notARisks: getNoRiskTags(_riskFactor2)
576
601
  },
577
602
  additionalInfo: {
578
603
  newBounds: {
@@ -18507,26 +18507,26 @@ var strkfarm_risk_engine = (() => {
18507
18507
  return this.mul(10 ** this.decimals).toFixed(0);
18508
18508
  }
18509
18509
  multipliedBy(value) {
18510
- let _value = Number(value).toFixed(13);
18510
+ let _value = Number(value).toFixed(this.maxToFixedDecimals());
18511
18511
  return this.construct(this.mul(_value).toString(), this.decimals);
18512
18512
  }
18513
18513
  dividedBy(value) {
18514
- let _value = Number(value).toFixed(13);
18514
+ let _value = Number(value).toFixed(this.maxToFixedDecimals());
18515
18515
  return this.construct(this.div(_value).toString(), this.decimals);
18516
18516
  }
18517
18517
  plus(value) {
18518
- const _value = Number(value).toFixed(13);
18518
+ const _value = Number(value).toFixed(this.maxToFixedDecimals());
18519
18519
  return this.construct(this.add(_value).toString(), this.decimals);
18520
18520
  }
18521
18521
  minus(n, base2) {
18522
- const _value = Number(n).toFixed(13);
18522
+ const _value = Number(n).toFixed(this.maxToFixedDecimals());
18523
18523
  return this.construct(super.minus(_value, base2).toString(), this.decimals);
18524
18524
  }
18525
18525
  construct(value, decimals) {
18526
18526
  return new this.constructor(value, decimals);
18527
18527
  }
18528
- toString(base2) {
18529
- return super.toString(base2);
18528
+ toString(decimals = this.maxToFixedDecimals()) {
18529
+ return super.toFixed(decimals);
18530
18530
  }
18531
18531
  toJSON() {
18532
18532
  return this.toString();
@@ -18534,6 +18534,9 @@ var strkfarm_risk_engine = (() => {
18534
18534
  valueOf() {
18535
18535
  return this.toString();
18536
18536
  }
18537
+ maxToFixedDecimals() {
18538
+ return Math.min(this.decimals, 13);
18539
+ }
18537
18540
  };
18538
18541
  import_bignumber.default.config({ DECIMAL_PLACES: 18 });
18539
18542
  _Web3Number.config({ DECIMAL_PLACES: 18 });
@@ -38698,7 +38701,9 @@ var strkfarm_risk_engine = (() => {
38698
38701
  const totalAssets = (await this.getTVL()).amount;
38699
38702
  const info = allowedPools.map(async (p) => {
38700
38703
  const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num_exports.getDecimalString(p.pool_id.address.toString()));
38701
- const pool = pools.find((d) => d.id == num_exports.getDecimalString(p.pool_id.address));
38704
+ const pool = pools.find((d) => {
38705
+ return d.id == num_exports.getDecimalString(p.pool_id.address.toString());
38706
+ });
38702
38707
  const assetInfo = pool?.assets.find((d) => this.asset().address.eqString(d.address));
38703
38708
  let vTokenContract = new Contract(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
38704
38709
  const bal = await vTokenContract.balanceOf(this.address.address);
@@ -38746,11 +38751,13 @@ var strkfarm_risk_engine = (() => {
38746
38751
  * Calculates the weighted average APY across all pools based on USD value.
38747
38752
  * @returns {Promise<number>} The weighted average APY across all pools
38748
38753
  */
38749
- netAPYGivenPools(pools) {
38750
- const weightedApy = pools.reduce((acc, curr) => {
38754
+ async netAPYGivenPools(pools) {
38755
+ const weightedApyNumerator = pools.reduce((acc, curr) => {
38751
38756
  const weight = curr.current_weight;
38752
- return acc + curr.APY.netApy * weight;
38757
+ return acc + curr.APY.netApy * Number(curr.amount.toString());
38753
38758
  }, 0);
38759
+ const totalAssets = (await this.getTVL()).amount;
38760
+ const weightedApy = weightedApyNumerator / Number(totalAssets.toString());
38754
38761
  return weightedApy * (1 - this.metadata.additionalInfo.feeBps / 1e4);
38755
38762
  }
38756
38763
  /**
@@ -38779,14 +38786,21 @@ var strkfarm_risk_engine = (() => {
38779
38786
  finalPools: []
38780
38787
  };
38781
38788
  const sumPools = pools.reduce((acc, curr) => acc.plus(curr.amount.toString()), Web3Number.fromWei("0", this.decimals()));
38782
- assert3(sumPools.lte(totalAssets), "Sum of pools.amount must be less than or equal to totalAssets");
38789
+ logger.verbose(`Sum of pools: ${sumPools.toString()}`);
38790
+ logger.verbose(`Total assets: ${totalAssets.toString()}`);
38791
+ assert3(sumPools.lte(totalAssets.multipliedBy(1.00001).toString()), "Sum of pools.amount must be less than or equal to totalAssets");
38783
38792
  const sortedPools = [...pools].sort((a, b) => b.APY.netApy - a.APY.netApy);
38784
38793
  const targetAmounts = {};
38785
38794
  let remainingAssets = totalAssets;
38795
+ logger.verbose(`Remaining assets: ${remainingAssets.toString()}`);
38786
38796
  let isAnyPoolOverMaxWeight = false;
38787
38797
  for (const pool of sortedPools) {
38788
- const maxAmount = totalAssets.multipliedBy(pool.max_weight * 0.9);
38798
+ const maxAmount = totalAssets.multipliedBy(pool.max_weight * 0.98);
38789
38799
  const targetAmount = remainingAssets.gte(maxAmount) ? maxAmount : remainingAssets;
38800
+ logger.verbose(`Target amount: ${targetAmount.toString()}`);
38801
+ logger.verbose(`Remaining assets: ${remainingAssets.toString()}`);
38802
+ logger.verbose(`Max amount: ${maxAmount.toString()}`);
38803
+ logger.verbose(`pool.max_weight: ${pool.max_weight}`);
38790
38804
  targetAmounts[pool.pool_id.address.toString()] = targetAmount;
38791
38805
  remainingAssets = remainingAssets.minus(targetAmount.toString());
38792
38806
  if (pool.current_weight > pool.max_weight) {
@@ -38804,11 +38818,15 @@ var strkfarm_risk_engine = (() => {
38804
38818
  isDeposit: change.gt(0)
38805
38819
  };
38806
38820
  });
38821
+ logger.verbose(`Changes: ${JSON.stringify(changes)}`);
38807
38822
  const sumChanges = changes.reduce((sum, c) => sum.plus(c.changeAmt.toString()), Web3Number.fromWei("0", this.decimals()));
38808
38823
  const sumFinal = changes.reduce((sum, c) => sum.plus(c.finalAmt.toString()), Web3Number.fromWei("0", this.decimals()));
38809
38824
  const hasChanges = changes.some((c) => !c.changeAmt.eq(0));
38810
38825
  if (!sumChanges.eq(0)) throw new Error("Sum of changes must be zero");
38811
- if (!sumFinal.eq(totalAssets)) throw new Error("Sum of final amounts must equal total assets");
38826
+ logger.verbose(`Sum of changes: ${sumChanges.toString()}`);
38827
+ logger.verbose(`Sum of final: ${sumFinal.toString()}`);
38828
+ logger.verbose(`Total assets: ${totalAssets.toString()}`);
38829
+ if (!sumFinal.eq(totalAssets.toString())) throw new Error("Sum of final amounts must equal total assets");
38812
38830
  if (!hasChanges) throw new Error("No changes required");
38813
38831
  const finalPools = pools.map((p) => {
38814
38832
  const target = targetAmounts[p.pool_id.address.toString()] || Web3Number.fromWei("0", this.decimals());
@@ -38832,13 +38850,12 @@ var strkfarm_risk_engine = (() => {
38832
38850
  async getRebalanceCall(pools, isOverWeightAdjustment) {
38833
38851
  const actions = [];
38834
38852
  pools.sort((a, b) => b.isDeposit ? -1 : 1);
38835
- console.log("pools", pools);
38836
38853
  pools.forEach((p) => {
38837
38854
  if (p.changeAmt.eq(0)) return null;
38838
38855
  actions.push({
38839
38856
  pool_id: p.pool_id.address,
38840
38857
  feature: new CairoCustomEnum(p.isDeposit ? { DEPOSIT: {} } : { WITHDRAW: {} }),
38841
- token: this.asset().address,
38858
+ token: this.asset().address.address,
38842
38859
  amount: uint256_exports.bnToUint256(p.changeAmt.multipliedBy(p.isDeposit ? 1 : -1).toWei())
38843
38860
  });
38844
38861
  });
@@ -38849,7 +38866,7 @@ var strkfarm_risk_engine = (() => {
38849
38866
  return this.contract.populate("rebalance", [actions]);
38850
38867
  }
38851
38868
  async getInvestmentFlows(pools) {
38852
- const netYield = this.netAPYGivenPools(pools);
38869
+ const netYield = await this.netAPYGivenPools(pools);
38853
38870
  const baseFlow = {
38854
38871
  title: "Your Deposit",
38855
38872
  subItems: [{ key: `Net yield`, value: `${(netYield * 100).toFixed(2)}%` }],
@@ -38884,7 +38901,7 @@ var strkfarm_risk_engine = (() => {
38884
38901
  var VesuRebalanceStrategies = [{
38885
38902
  name: "Vesu Fusion STRK",
38886
38903
  description: _description.replace("{{TOKEN}}", "STRK"),
38887
- address: ContractAddr.from("0x778007f8136a5b827325d21613803e796bda4d676fbe1e34aeab0b2a2ec027f"),
38904
+ address: ContractAddr.from("0x7fb5bcb8525954a60fde4e8fb8220477696ce7117ef264775a1770e23571929"),
38888
38905
  type: "ERC4626",
38889
38906
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "STRK")],
38890
38907
  protocols: [_protocol],
@@ -38892,7 +38909,8 @@ var strkfarm_risk_engine = (() => {
38892
38909
  maxTVL: Web3Number.fromWei("0", 18),
38893
38910
  risk: {
38894
38911
  riskFactor: _riskFactor,
38895
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
38912
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
38913
+ notARisks: getNoRiskTags(_riskFactor)
38896
38914
  },
38897
38915
  additionalInfo: {
38898
38916
  feeBps: 1e3
@@ -38900,7 +38918,7 @@ var strkfarm_risk_engine = (() => {
38900
38918
  }, {
38901
38919
  name: "Vesu Fusion ETH",
38902
38920
  description: _description.replace("{{TOKEN}}", "ETH"),
38903
- address: ContractAddr.from("0x26ea414fdf74ace1df5bc5ac72cbac670d438ef19b31edf9d59f98718fc0ab2"),
38921
+ address: ContractAddr.from("0x5eaf5ee75231cecf79921ff8ded4b5ffe96be718bcb3daf206690ad1a9ad0ca"),
38904
38922
  type: "ERC4626",
38905
38923
  auditUrl: AUDIT_URL,
38906
38924
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "ETH")],
@@ -38908,7 +38926,8 @@ var strkfarm_risk_engine = (() => {
38908
38926
  maxTVL: Web3Number.fromWei("0", 18),
38909
38927
  risk: {
38910
38928
  riskFactor: _riskFactor,
38911
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
38929
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
38930
+ notARisks: getNoRiskTags(_riskFactor)
38912
38931
  },
38913
38932
  additionalInfo: {
38914
38933
  feeBps: 1e3
@@ -38916,7 +38935,7 @@ var strkfarm_risk_engine = (() => {
38916
38935
  }, {
38917
38936
  name: "Vesu Fusion USDC",
38918
38937
  description: _description.replace("{{TOKEN}}", "USDC"),
38919
- address: ContractAddr.from("0x3a69adeb993cddb266962d9c995e3d0641dab627df22b825fa31bda460c3c14"),
38938
+ address: ContractAddr.from("0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"),
38920
38939
  type: "ERC4626",
38921
38940
  auditUrl: AUDIT_URL,
38922
38941
  depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "USDC")],
@@ -38924,26 +38943,28 @@ var strkfarm_risk_engine = (() => {
38924
38943
  maxTVL: Web3Number.fromWei("0", 6),
38925
38944
  risk: {
38926
38945
  riskFactor: _riskFactor,
38927
- netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0)
38946
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
38947
+ notARisks: getNoRiskTags(_riskFactor)
38948
+ },
38949
+ additionalInfo: {
38950
+ feeBps: 1e3
38951
+ }
38952
+ }, {
38953
+ name: "Vesu Fusion USDT",
38954
+ description: _description.replace("{{TOKEN}}", "USDT"),
38955
+ address: ContractAddr.from("0x115e94e722cfc4c77a2f15c4aefb0928c1c0029e5a57570df24c650cb7cec2c"),
38956
+ type: "ERC4626",
38957
+ depositTokens: [Global.getDefaultTokens().find((t) => t.symbol === "USDT")],
38958
+ protocols: [_protocol],
38959
+ maxTVL: Web3Number.fromWei("0", 6),
38960
+ risk: {
38961
+ riskFactor: _riskFactor,
38962
+ netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
38963
+ notARisks: getNoRiskTags(_riskFactor)
38928
38964
  },
38929
38965
  additionalInfo: {
38930
38966
  feeBps: 1e3
38931
38967
  }
38932
- // }, {
38933
- // name: 'Vesu Fusion USDT',
38934
- // description: _description.replace('{{TOKEN}}', 'USDT'),
38935
- // address: ContractAddr.from('0x778007f8136a5b827325d21613803e796bda4d676fbe1e34aeab0b2a2ec027f'),
38936
- // type: 'ERC4626',
38937
- // depositTokens: [Global.getDefaultTokens().find(t => t.symbol === 'USDT')!],
38938
- // protocols: [_protocol],
38939
- // maxTVL: Web3Number.fromWei('0', 6),
38940
- // risk: {
38941
- // riskFactor: _riskFactor,
38942
- // netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
38943
- // },
38944
- // additionalInfo: {
38945
- // feeBps: 1000,
38946
- // },
38947
38968
  // }, {
38948
38969
  // name: 'Vesu Fusion WBTC',
38949
38970
  // description: _description.replace('{{TOKEN}}', 'WBTC'),
@@ -44239,7 +44260,8 @@ var strkfarm_risk_engine = (() => {
44239
44260
  maxTVL: Web3Number.fromWei("0", 18),
44240
44261
  risk: {
44241
44262
  riskFactor: _riskFactor2,
44242
- netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0)
44263
+ netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
44264
+ notARisks: getNoRiskTags(_riskFactor2)
44243
44265
  },
44244
44266
  additionalInfo: {
44245
44267
  newBounds: {