@strkfarm/sdk 1.0.17 → 1.0.18

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.
@@ -13943,6 +13943,7 @@ var strkfarm_risk_engine = (() => {
13943
13943
  AutoCompounderSTRK: () => AutoCompounderSTRK,
13944
13944
  ContractAddr: () => ContractAddr,
13945
13945
  FatalError: () => FatalError,
13946
+ FlowChartColors: () => FlowChartColors,
13946
13947
  Global: () => Global,
13947
13948
  ILending: () => ILending,
13948
13949
  Initializable: () => Initializable,
@@ -33240,6 +33241,12 @@ var strkfarm_risk_engine = (() => {
33240
33241
  Network2["devnet"] = "devnet";
33241
33242
  return Network2;
33242
33243
  })(Network || {});
33244
+ var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
33245
+ FlowChartColors2["Green"] = "purple";
33246
+ FlowChartColors2["Blue"] = "#35484f";
33247
+ FlowChartColors2["Purple"] = "#6e53dc";
33248
+ return FlowChartColors2;
33249
+ })(FlowChartColors || {});
33243
33250
  function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = "pending") {
33244
33251
  return {
33245
33252
  provider: new RpcProvider2({
@@ -34944,7 +34951,7 @@ var strkfarm_risk_engine = (() => {
34944
34951
  const assets = await vTokenContract.convert_to_assets(uint256_exports.bnToUint256(bal.toString()));
34945
34952
  const item = {
34946
34953
  pool_id: p.pool_id,
34947
- pool_name: vesuPosition?.pool.name,
34954
+ pool_name: pool.name,
34948
34955
  max_weight: p.max_weight,
34949
34956
  current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
34950
34957
  v_token: p.v_token,
@@ -35090,19 +35097,22 @@ var strkfarm_risk_engine = (() => {
35090
35097
  async getInvestmentFlows(pools) {
35091
35098
  const netYield = this.netAPYGivenPools(pools);
35092
35099
  const baseFlow = {
35093
- title: "Deposit $1000",
35094
- subItems: [`Net yield: ${(netYield * 100).toFixed(2)}%`],
35095
- linkedFlows: []
35100
+ title: "Your Deposit",
35101
+ subItems: [{ key: `Net yield`, value: `${(netYield * 100).toFixed(2)}%` }],
35102
+ linkedFlows: [],
35103
+ style: { backgroundColor: "#6e53dc" /* Purple */.valueOf() }
35096
35104
  };
35097
- pools.forEach((p) => {
35098
- if (p.amount.eq(0)) return;
35105
+ let _pools = [...pools];
35106
+ _pools = _pools.sort((a, b) => Number(b.amount.toString()) - Number(a.amount.toString()));
35107
+ _pools.forEach((p) => {
35099
35108
  const flow = {
35100
- title: `${p.pool_name} - $${(p.current_weight * 1e3).toFixed(2)}`,
35109
+ title: `Pool name: ${p.pool_name}`,
35101
35110
  subItems: [
35102
- `APY: ${(p.APY.netApy * 100).toFixed(2)}%`,
35103
- `Weight: ${(p.current_weight * 100).toFixed(2)}% / ${(p.max_weight * 100).toFixed(2)}%`
35111
+ { key: `APY`, value: `${(p.APY.netApy * 100).toFixed(2)}%` },
35112
+ { key: "Weight", value: `${(p.current_weight * 100).toFixed(2)} / ${(p.max_weight * 100).toFixed(2)}%` }
35104
35113
  ],
35105
- linkedFlows: []
35114
+ linkedFlows: [],
35115
+ style: p.amount.greaterThan(0) ? { backgroundColor: "#35484f" /* Blue */.valueOf() } : { color: "gray" }
35106
35116
  };
35107
35117
  baseFlow.linkedFlows.push(flow);
35108
35118
  });
@@ -666,6 +666,12 @@ var Network = /* @__PURE__ */ ((Network2) => {
666
666
  Network2["devnet"] = "devnet";
667
667
  return Network2;
668
668
  })(Network || {});
669
+ var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
670
+ FlowChartColors2["Green"] = "purple";
671
+ FlowChartColors2["Blue"] = "#35484f";
672
+ FlowChartColors2["Purple"] = "#6e53dc";
673
+ return FlowChartColors2;
674
+ })(FlowChartColors || {});
669
675
  function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = "pending") {
670
676
  return {
671
677
  provider: new RpcProvider2({
@@ -2375,7 +2381,7 @@ var VesuRebalance = class _VesuRebalance {
2375
2381
  const assets = await vTokenContract.convert_to_assets(uint2562.bnToUint256(bal.toString()));
2376
2382
  const item = {
2377
2383
  pool_id: p.pool_id,
2378
- pool_name: vesuPosition?.pool.name,
2384
+ pool_name: pool.name,
2379
2385
  max_weight: p.max_weight,
2380
2386
  current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
2381
2387
  v_token: p.v_token,
@@ -2521,19 +2527,22 @@ var VesuRebalance = class _VesuRebalance {
2521
2527
  async getInvestmentFlows(pools) {
2522
2528
  const netYield = this.netAPYGivenPools(pools);
2523
2529
  const baseFlow = {
2524
- title: "Deposit $1000",
2525
- subItems: [`Net yield: ${(netYield * 100).toFixed(2)}%`],
2526
- linkedFlows: []
2530
+ title: "Your Deposit",
2531
+ subItems: [{ key: `Net yield`, value: `${(netYield * 100).toFixed(2)}%` }],
2532
+ linkedFlows: [],
2533
+ style: { backgroundColor: "#6e53dc" /* Purple */.valueOf() }
2527
2534
  };
2528
- pools.forEach((p) => {
2529
- if (p.amount.eq(0)) return;
2535
+ let _pools = [...pools];
2536
+ _pools = _pools.sort((a, b) => Number(b.amount.toString()) - Number(a.amount.toString()));
2537
+ _pools.forEach((p) => {
2530
2538
  const flow = {
2531
- title: `${p.pool_name} - $${(p.current_weight * 1e3).toFixed(2)}`,
2539
+ title: `Pool name: ${p.pool_name}`,
2532
2540
  subItems: [
2533
- `APY: ${(p.APY.netApy * 100).toFixed(2)}%`,
2534
- `Weight: ${(p.current_weight * 100).toFixed(2)}% / ${(p.max_weight * 100).toFixed(2)}%`
2541
+ { key: `APY`, value: `${(p.APY.netApy * 100).toFixed(2)}%` },
2542
+ { key: "Weight", value: `${(p.current_weight * 100).toFixed(2)} / ${(p.max_weight * 100).toFixed(2)}%` }
2535
2543
  ],
2536
- linkedFlows: []
2544
+ linkedFlows: [],
2545
+ style: p.amount.greaterThan(0) ? { backgroundColor: "#35484f" /* Blue */.valueOf() } : { color: "gray" }
2537
2546
  };
2538
2547
  baseFlow.linkedFlows.push(flow);
2539
2548
  });
@@ -2564,6 +2573,7 @@ export {
2564
2573
  AutoCompounderSTRK,
2565
2574
  ContractAddr,
2566
2575
  FatalError,
2576
+ FlowChartColors,
2567
2577
  Global,
2568
2578
  ILending,
2569
2579
  Initializable,
package/dist/index.d.ts CHANGED
@@ -66,6 +66,11 @@ interface IProtocol {
66
66
  name: string;
67
67
  logo: string;
68
68
  }
69
+ declare enum FlowChartColors {
70
+ Green = "purple",
71
+ Blue = "#35484f",
72
+ Purple = "#6e53dc"
73
+ }
69
74
  /**
70
75
  * @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
71
76
  * @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
@@ -86,8 +91,12 @@ interface IStrategyMetadata {
86
91
  }
87
92
  interface IInvestmentFlow {
88
93
  title: string;
89
- subItems: string[];
94
+ subItems: {
95
+ key: string;
96
+ value: string;
97
+ }[];
90
98
  linkedFlows: IInvestmentFlow[];
99
+ style?: any;
91
100
  }
92
101
  declare function getMainnetConfig(rpcUrl?: string, blockIdentifier?: BlockIdentifier): IConfig;
93
102
 
@@ -594,4 +603,4 @@ declare class PasswordJsonCryptoUtil {
594
603
  decrypt(encryptedData: string, password: string): any;
595
604
  }
596
605
 
597
- export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, ContractAddr, FatalError, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LendingToken, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, Store, type StoreConfig, TelegramNotif, type TokenInfo, VesuRebalance, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getDefaultStoreConfig, getMainnetConfig, logger };
606
+ export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, ContractAddr, FatalError, FlowChartColors, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LendingToken, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, Store, type StoreConfig, TelegramNotif, type TokenInfo, VesuRebalance, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getDefaultStoreConfig, getMainnetConfig, logger };
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ __export(src_exports, {
33
33
  AutoCompounderSTRK: () => AutoCompounderSTRK,
34
34
  ContractAddr: () => ContractAddr,
35
35
  FatalError: () => FatalError,
36
+ FlowChartColors: () => FlowChartColors,
36
37
  Global: () => Global,
37
38
  ILending: () => ILending,
38
39
  Initializable: () => Initializable,
@@ -725,6 +726,12 @@ var Network = /* @__PURE__ */ ((Network2) => {
725
726
  Network2["devnet"] = "devnet";
726
727
  return Network2;
727
728
  })(Network || {});
729
+ var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
730
+ FlowChartColors2["Green"] = "purple";
731
+ FlowChartColors2["Blue"] = "#35484f";
732
+ FlowChartColors2["Purple"] = "#6e53dc";
733
+ return FlowChartColors2;
734
+ })(FlowChartColors || {});
728
735
  function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = "pending") {
729
736
  return {
730
737
  provider: new import_starknet3.RpcProvider({
@@ -2434,7 +2441,7 @@ var VesuRebalance = class _VesuRebalance {
2434
2441
  const assets = await vTokenContract.convert_to_assets(import_starknet5.uint256.bnToUint256(bal.toString()));
2435
2442
  const item = {
2436
2443
  pool_id: p.pool_id,
2437
- pool_name: vesuPosition?.pool.name,
2444
+ pool_name: pool.name,
2438
2445
  max_weight: p.max_weight,
2439
2446
  current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
2440
2447
  v_token: p.v_token,
@@ -2580,19 +2587,22 @@ var VesuRebalance = class _VesuRebalance {
2580
2587
  async getInvestmentFlows(pools) {
2581
2588
  const netYield = this.netAPYGivenPools(pools);
2582
2589
  const baseFlow = {
2583
- title: "Deposit $1000",
2584
- subItems: [`Net yield: ${(netYield * 100).toFixed(2)}%`],
2585
- linkedFlows: []
2590
+ title: "Your Deposit",
2591
+ subItems: [{ key: `Net yield`, value: `${(netYield * 100).toFixed(2)}%` }],
2592
+ linkedFlows: [],
2593
+ style: { backgroundColor: "#6e53dc" /* Purple */.valueOf() }
2586
2594
  };
2587
- pools.forEach((p) => {
2588
- if (p.amount.eq(0)) return;
2595
+ let _pools = [...pools];
2596
+ _pools = _pools.sort((a, b) => Number(b.amount.toString()) - Number(a.amount.toString()));
2597
+ _pools.forEach((p) => {
2589
2598
  const flow = {
2590
- title: `${p.pool_name} - $${(p.current_weight * 1e3).toFixed(2)}`,
2599
+ title: `Pool name: ${p.pool_name}`,
2591
2600
  subItems: [
2592
- `APY: ${(p.APY.netApy * 100).toFixed(2)}%`,
2593
- `Weight: ${(p.current_weight * 100).toFixed(2)}% / ${(p.max_weight * 100).toFixed(2)}%`
2601
+ { key: `APY`, value: `${(p.APY.netApy * 100).toFixed(2)}%` },
2602
+ { key: "Weight", value: `${(p.current_weight * 100).toFixed(2)} / ${(p.max_weight * 100).toFixed(2)}%` }
2594
2603
  ],
2595
- linkedFlows: []
2604
+ linkedFlows: [],
2605
+ style: p.amount.greaterThan(0) ? { backgroundColor: "#35484f" /* Blue */.valueOf() } : { color: "gray" }
2596
2606
  };
2597
2607
  baseFlow.linkedFlows.push(flow);
2598
2608
  });
@@ -2886,6 +2896,7 @@ var Store = class _Store {
2886
2896
  AutoCompounderSTRK,
2887
2897
  ContractAddr,
2888
2898
  FatalError,
2899
+ FlowChartColors,
2889
2900
  Global,
2890
2901
  ILending,
2891
2902
  Initializable,
package/dist/index.mjs CHANGED
@@ -666,6 +666,12 @@ var Network = /* @__PURE__ */ ((Network2) => {
666
666
  Network2["devnet"] = "devnet";
667
667
  return Network2;
668
668
  })(Network || {});
669
+ var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
670
+ FlowChartColors2["Green"] = "purple";
671
+ FlowChartColors2["Blue"] = "#35484f";
672
+ FlowChartColors2["Purple"] = "#6e53dc";
673
+ return FlowChartColors2;
674
+ })(FlowChartColors || {});
669
675
  function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = "pending") {
670
676
  return {
671
677
  provider: new RpcProvider2({
@@ -2375,7 +2381,7 @@ var VesuRebalance = class _VesuRebalance {
2375
2381
  const assets = await vTokenContract.convert_to_assets(uint2562.bnToUint256(bal.toString()));
2376
2382
  const item = {
2377
2383
  pool_id: p.pool_id,
2378
- pool_name: vesuPosition?.pool.name,
2384
+ pool_name: pool.name,
2379
2385
  max_weight: p.max_weight,
2380
2386
  current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
2381
2387
  v_token: p.v_token,
@@ -2521,19 +2527,22 @@ var VesuRebalance = class _VesuRebalance {
2521
2527
  async getInvestmentFlows(pools) {
2522
2528
  const netYield = this.netAPYGivenPools(pools);
2523
2529
  const baseFlow = {
2524
- title: "Deposit $1000",
2525
- subItems: [`Net yield: ${(netYield * 100).toFixed(2)}%`],
2526
- linkedFlows: []
2530
+ title: "Your Deposit",
2531
+ subItems: [{ key: `Net yield`, value: `${(netYield * 100).toFixed(2)}%` }],
2532
+ linkedFlows: [],
2533
+ style: { backgroundColor: "#6e53dc" /* Purple */.valueOf() }
2527
2534
  };
2528
- pools.forEach((p) => {
2529
- if (p.amount.eq(0)) return;
2535
+ let _pools = [...pools];
2536
+ _pools = _pools.sort((a, b) => Number(b.amount.toString()) - Number(a.amount.toString()));
2537
+ _pools.forEach((p) => {
2530
2538
  const flow = {
2531
- title: `${p.pool_name} - $${(p.current_weight * 1e3).toFixed(2)}`,
2539
+ title: `Pool name: ${p.pool_name}`,
2532
2540
  subItems: [
2533
- `APY: ${(p.APY.netApy * 100).toFixed(2)}%`,
2534
- `Weight: ${(p.current_weight * 100).toFixed(2)}% / ${(p.max_weight * 100).toFixed(2)}%`
2541
+ { key: `APY`, value: `${(p.APY.netApy * 100).toFixed(2)}%` },
2542
+ { key: "Weight", value: `${(p.current_weight * 100).toFixed(2)} / ${(p.max_weight * 100).toFixed(2)}%` }
2535
2543
  ],
2536
- linkedFlows: []
2544
+ linkedFlows: [],
2545
+ style: p.amount.greaterThan(0) ? { backgroundColor: "#35484f" /* Blue */.valueOf() } : { color: "gray" }
2537
2546
  };
2538
2547
  baseFlow.linkedFlows.push(flow);
2539
2548
  });
@@ -2826,6 +2835,7 @@ export {
2826
2835
  AutoCompounderSTRK,
2827
2836
  ContractAddr,
2828
2837
  FatalError,
2838
+ FlowChartColors,
2829
2839
  Global,
2830
2840
  ILending,
2831
2841
  Initializable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
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",
@@ -55,6 +55,7 @@
55
55
  "browser-assert": "^1.2.1",
56
56
  "chalk": "^4.1.2",
57
57
  "commander": "^12.1.0",
58
+ "form-data": "^4.0.2",
58
59
  "inquirer": "^10.1.2",
59
60
  "node-telegram-bot-api": "^0.66.0",
60
61
  "proxy-from-env": "^1.1.0",
@@ -43,6 +43,12 @@ export interface IProtocol {
43
43
  logo: string,
44
44
  }
45
45
 
46
+ export enum FlowChartColors {
47
+ Green = 'purple',
48
+ Blue = '#35484f',
49
+ Purple = '#6e53dc',
50
+ }
51
+
46
52
  /**
47
53
  * @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
48
54
  * @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
@@ -64,8 +70,9 @@ export interface IStrategyMetadata {
64
70
 
65
71
  export interface IInvestmentFlow {
66
72
  title: string,
67
- subItems: string[],
73
+ subItems: {key: string, value: string}[],
68
74
  linkedFlows: IInvestmentFlow[],
75
+ style?: any
69
76
  }
70
77
 
71
78
  export function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier: BlockIdentifier = 'pending'): IConfig {
@@ -1,5 +1,5 @@
1
1
  import { ContractAddr, Web3Number } from "@/dataTypes";
2
- import { IConfig, IInvestmentFlow, IProtocol, IStrategyMetadata, RiskFactor, RiskType } from "@/interfaces";
2
+ import { FlowChartColors, IConfig, IInvestmentFlow, IProtocol, IStrategyMetadata, RiskFactor, RiskType } from "@/interfaces";
3
3
  import { Pricer } from "@/modules";
4
4
  import { CairoCustomEnum, Contract, num, uint256 } from "starknet";
5
5
  import VesuRebalanceAbi from '@/data/vesu-rebalance.abi.json';
@@ -248,7 +248,7 @@ export class VesuRebalance {
248
248
  const assets = await vTokenContract.convert_to_assets(uint256.bnToUint256(bal.toString()));
249
249
  const item = {
250
250
  pool_id: p.pool_id,
251
- pool_name: vesuPosition?.pool.name,
251
+ pool_name: pool.name,
252
252
  max_weight: p.max_weight,
253
253
  current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
254
254
  v_token: p.v_token,
@@ -418,24 +418,26 @@ export class VesuRebalance {
418
418
  const netYield = this.netAPYGivenPools(pools);
419
419
 
420
420
  const baseFlow: IInvestmentFlow = {
421
- title: "Deposit $1000",
422
- subItems: [`Net yield: ${(netYield * 100).toFixed(2)}%`],
421
+ title: "Your Deposit",
422
+ subItems: [{key: `Net yield`, value: `${(netYield * 100).toFixed(2)}%`}],
423
423
  linkedFlows: [],
424
+ style: {backgroundColor: FlowChartColors.Purple.valueOf()},
424
425
  };
425
426
 
426
- pools.forEach((p) => {
427
- if (p.amount.eq(0)) return;
427
+ let _pools = [...pools];
428
+ _pools = _pools.sort((a, b) => Number(b.amount.toString()) - Number(a.amount.toString()));
429
+ _pools.forEach((p) => {
428
430
  const flow: IInvestmentFlow = {
429
- title: `${p.pool_name} - $${(p.current_weight * 1000).toFixed(2)}`,
431
+ title: `Pool name: ${p.pool_name}`,
430
432
  subItems: [
431
- `APY: ${(p.APY.netApy * 100).toFixed(2)}%`,
432
- `Weight: ${(p.current_weight * 100).toFixed(2)}% / ${(p.max_weight * 100).toFixed(2)}%`,
433
+ {key: `APY`, value: `${(p.APY.netApy * 100).toFixed(2)}%`},
434
+ {key: 'Weight', value: `${(p.current_weight * 100).toFixed(2)} / ${(p.max_weight * 100).toFixed(2)}%`}
433
435
  ],
434
436
  linkedFlows: [],
437
+ style: p.amount.greaterThan(0) ? {backgroundColor: FlowChartColors.Blue.valueOf()} : {color: 'gray'},
435
438
  };
436
439
  baseFlow.linkedFlows.push(flow);
437
440
  });
438
-
439
441
  return [baseFlow];
440
442
  }
441
443
  }