@defisaver/positions-sdk 0.0.30 → 0.0.32

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.
Files changed (113) hide show
  1. package/README.md +63 -63
  2. package/cjs/config/contracts.d.ts +115 -0
  3. package/cjs/config/contracts.js +14 -0
  4. package/cjs/constants/index.d.ts +2 -0
  5. package/cjs/constants/index.js +3 -1
  6. package/cjs/contracts.d.ts +2 -0
  7. package/cjs/contracts.js +3 -1
  8. package/cjs/helpers/index.d.ts +1 -0
  9. package/cjs/helpers/index.js +2 -1
  10. package/cjs/helpers/morphoBlueHelpers/index.d.ts +7 -0
  11. package/cjs/helpers/morphoBlueHelpers/index.js +41 -0
  12. package/cjs/index.d.ts +2 -1
  13. package/cjs/index.js +3 -1
  14. package/cjs/markets/index.d.ts +1 -0
  15. package/cjs/markets/index.js +3 -1
  16. package/cjs/markets/morphoBlue/index.d.ts +6 -0
  17. package/cjs/markets/morphoBlue/index.js +24 -0
  18. package/cjs/morphoBlue/index.d.ts +5 -0
  19. package/cjs/morphoBlue/index.js +153 -0
  20. package/cjs/types/common.d.ts +1 -1
  21. package/cjs/types/contracts/generated/FeedRegistry.d.ts +182 -0
  22. package/cjs/types/contracts/generated/FeedRegistry.js +5 -0
  23. package/cjs/types/contracts/generated/MorphoBlueView.d.ts +122 -0
  24. package/cjs/types/contracts/generated/MorphoBlueView.js +5 -0
  25. package/cjs/types/contracts/generated/index.d.ts +2 -0
  26. package/cjs/types/index.d.ts +1 -0
  27. package/cjs/types/index.js +1 -0
  28. package/cjs/types/morphoBlue.d.ts +74 -0
  29. package/cjs/types/morphoBlue.js +7 -0
  30. package/esm/config/contracts.d.ts +115 -0
  31. package/esm/config/contracts.js +14 -0
  32. package/esm/constants/index.d.ts +2 -0
  33. package/esm/constants/index.js +2 -0
  34. package/esm/contracts.d.ts +2 -0
  35. package/esm/contracts.js +2 -0
  36. package/esm/helpers/index.d.ts +1 -0
  37. package/esm/helpers/index.js +1 -0
  38. package/esm/helpers/morphoBlueHelpers/index.d.ts +7 -0
  39. package/esm/helpers/morphoBlueHelpers/index.js +34 -0
  40. package/esm/index.d.ts +2 -1
  41. package/esm/index.js +2 -1
  42. package/esm/markets/index.d.ts +1 -0
  43. package/esm/markets/index.js +1 -0
  44. package/esm/markets/morphoBlue/index.d.ts +6 -0
  45. package/esm/markets/morphoBlue/index.js +19 -0
  46. package/esm/morphoBlue/index.d.ts +5 -0
  47. package/esm/morphoBlue/index.js +145 -0
  48. package/esm/types/common.d.ts +1 -1
  49. package/esm/types/contracts/generated/FeedRegistry.d.ts +182 -0
  50. package/esm/types/contracts/generated/FeedRegistry.js +4 -0
  51. package/esm/types/contracts/generated/MorphoBlueView.d.ts +122 -0
  52. package/esm/types/contracts/generated/MorphoBlueView.js +4 -0
  53. package/esm/types/contracts/generated/index.d.ts +2 -0
  54. package/esm/types/index.d.ts +1 -0
  55. package/esm/types/index.js +1 -0
  56. package/esm/types/morphoBlue.d.ts +74 -0
  57. package/esm/types/morphoBlue.js +4 -0
  58. package/package.json +40 -40
  59. package/src/aaveV2/index.ts +226 -226
  60. package/src/aaveV3/index.ts +561 -561
  61. package/src/assets/index.ts +60 -60
  62. package/src/chickenBonds/index.ts +123 -123
  63. package/src/compoundV2/index.ts +219 -219
  64. package/src/compoundV3/index.ts +275 -275
  65. package/src/config/contracts.js +690 -676
  66. package/src/constants/index.ts +6 -4
  67. package/src/contracts.ts +131 -127
  68. package/src/curveUsd/index.ts +228 -228
  69. package/src/exchange/index.ts +17 -17
  70. package/src/helpers/aaveHelpers/index.ts +134 -134
  71. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  72. package/src/helpers/compoundHelpers/index.ts +181 -181
  73. package/src/helpers/curveUsdHelpers/index.ts +32 -32
  74. package/src/helpers/index.ts +7 -6
  75. package/src/helpers/makerHelpers/index.ts +94 -94
  76. package/src/helpers/morphoBlueHelpers/index.ts +47 -0
  77. package/src/helpers/sparkHelpers/index.ts +106 -106
  78. package/src/index.ts +42 -40
  79. package/src/liquity/index.ts +116 -116
  80. package/src/maker/index.ts +101 -101
  81. package/src/markets/aave/index.ts +80 -80
  82. package/src/markets/aave/marketAssets.ts +24 -24
  83. package/src/markets/compound/index.ts +141 -141
  84. package/src/markets/compound/marketsAssets.ts +48 -48
  85. package/src/markets/curveUsd/index.ts +69 -69
  86. package/src/markets/index.ts +5 -4
  87. package/src/markets/morphoBlue/index.ts +21 -0
  88. package/src/markets/spark/index.ts +29 -29
  89. package/src/markets/spark/marketAssets.ts +10 -10
  90. package/src/moneymarket/moneymarketCommonService.ts +75 -75
  91. package/src/morphoAaveV2/index.ts +255 -255
  92. package/src/morphoAaveV3/index.ts +619 -619
  93. package/src/morphoBlue/index.ts +166 -0
  94. package/src/multicall/index.ts +22 -22
  95. package/src/services/dsrService.ts +15 -15
  96. package/src/services/priceService.ts +21 -21
  97. package/src/services/utils.ts +34 -34
  98. package/src/spark/index.ts +422 -422
  99. package/src/staking/staking.ts +167 -167
  100. package/src/types/aave.ts +256 -256
  101. package/src/types/chickenBonds.ts +45 -45
  102. package/src/types/common.ts +83 -83
  103. package/src/types/compound.ts +128 -128
  104. package/src/types/contracts/generated/FeedRegistry.ts +337 -0
  105. package/src/types/contracts/generated/MorphoBlueView.ts +171 -0
  106. package/src/types/contracts/generated/index.ts +2 -0
  107. package/src/types/curveUsd.ts +112 -112
  108. package/src/types/index.ts +8 -7
  109. package/src/types/liquity.ts +30 -30
  110. package/src/types/maker.ts +50 -50
  111. package/src/types/morphoBlue.ts +80 -0
  112. package/src/types/spark.ts +106 -106
  113. package/src/morpho/markets.ts +0 -39
@@ -3617,3 +3617,118 @@ export namespace USDCPriceFeed {
3617
3617
  };
3618
3618
  export { networks_66 as networks };
3619
3619
  }
3620
+ export namespace MorphoBlueView {
3621
+ let abi_67: ({
3622
+ inputs: {
3623
+ components: {
3624
+ internalType: string;
3625
+ name: string;
3626
+ type: string;
3627
+ }[];
3628
+ internalType: string;
3629
+ name: string;
3630
+ type: string;
3631
+ }[];
3632
+ name: string;
3633
+ outputs: {
3634
+ internalType: string;
3635
+ name: string;
3636
+ type: string;
3637
+ }[];
3638
+ stateMutability: string;
3639
+ type: string;
3640
+ } | {
3641
+ inputs: ({
3642
+ components: {
3643
+ internalType: string;
3644
+ name: string;
3645
+ type: string;
3646
+ }[];
3647
+ internalType: string;
3648
+ name: string;
3649
+ type: string;
3650
+ } | {
3651
+ internalType: string;
3652
+ name: string;
3653
+ type: string;
3654
+ components?: undefined;
3655
+ })[];
3656
+ name: string;
3657
+ outputs: {
3658
+ components: {
3659
+ internalType: string;
3660
+ name: string;
3661
+ type: string;
3662
+ }[];
3663
+ internalType: string;
3664
+ name: string;
3665
+ type: string;
3666
+ }[];
3667
+ stateMutability: string;
3668
+ type: string;
3669
+ })[];
3670
+ export { abi_67 as abi };
3671
+ let networks_67: {
3672
+ "1": {
3673
+ address: string;
3674
+ };
3675
+ };
3676
+ export { networks_67 as networks };
3677
+ }
3678
+ export namespace FeedRegistry {
3679
+ let abi_68: ({
3680
+ anonymous: boolean;
3681
+ inputs: {
3682
+ indexed: boolean;
3683
+ internalType: string;
3684
+ name: string;
3685
+ type: string;
3686
+ }[];
3687
+ name: string;
3688
+ type: string;
3689
+ outputs?: undefined;
3690
+ stateMutability?: undefined;
3691
+ } | {
3692
+ inputs: {
3693
+ internalType: string;
3694
+ name: string;
3695
+ type: string;
3696
+ }[];
3697
+ name: string;
3698
+ outputs: {
3699
+ internalType: string;
3700
+ name: string;
3701
+ type: string;
3702
+ }[];
3703
+ stateMutability: string;
3704
+ type: string;
3705
+ anonymous?: undefined;
3706
+ } | {
3707
+ inputs: {
3708
+ internalType: string;
3709
+ name: string;
3710
+ type: string;
3711
+ }[];
3712
+ name: string;
3713
+ outputs: {
3714
+ components: {
3715
+ internalType: string;
3716
+ name: string;
3717
+ type: string;
3718
+ }[];
3719
+ internalType: string;
3720
+ name: string;
3721
+ type: string;
3722
+ }[];
3723
+ stateMutability: string;
3724
+ type: string;
3725
+ anonymous?: undefined;
3726
+ })[];
3727
+ export { abi_68 as abi };
3728
+ let networks_68: {
3729
+ "1": {
3730
+ address: string;
3731
+ };
3732
+ };
3733
+ export { networks_68 as networks };
3734
+ }
@@ -672,5 +672,19 @@ module.exports = {
672
672
  "networks": {
673
673
  "1": { "address": "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6" }
674
674
  }
675
+ },
676
+ "MorphoBlueView": {
677
+ "abi": [{ "inputs": [], "name": "MORPHO_BLUE_ADDRESS", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collateralToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "internalType": "struct MarketParams", "name": "marketParams", "type": "tuple" }], "name": "getMarketId", "outputs": [{ "internalType": "Id", "name": "id", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collateralToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "internalType": "struct MarketParams", "name": "marketParams", "type": "tuple" }], "name": "getMarketInfo", "outputs": [{ "components": [{ "internalType": "Id", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalSupplyAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalSupplyShares", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowShares", "type": "uint128" }, { "internalType": "uint256", "name": "lastUpdate", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "oracle", "type": "uint256" }], "internalType": "struct MorphoBlueView.MarketInfo", "name": "", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "name": "getMarketInfoNotTuple", "outputs": [{ "components": [{ "internalType": "Id", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalSupplyAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalSupplyShares", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowShares", "type": "uint128" }, { "internalType": "uint256", "name": "lastUpdate", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "oracle", "type": "uint256" }], "internalType": "struct MorphoBlueView.MarketInfo", "name": "", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collateralToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "internalType": "struct MarketParams", "name": "marketParams", "type": "tuple" }, { "internalType": "address", "name": "owner", "type": "address" }], "name": "getUserInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "supplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "suppliedInAssets", "type": "uint256" }, { "internalType": "uint256", "name": "borrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "borrowedInAssets", "type": "uint256" }, { "internalType": "uint256", "name": "collateral", "type": "uint256" }], "internalType": "struct MorphoBlueView.PositionInfo", "name": "", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "morphoBlue", "outputs": [{ "internalType": "contract IMorphoBlue", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }],
678
+ "networks": {
679
+ "1": {
680
+ "address": "0xE29175a86B60138403a9534A391acaDb19f1E9a6",
681
+ }
682
+ }
683
+ },
684
+ "FeedRegistry": {
685
+ "abi": [{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "accessController", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "AccessControllerSet", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, { "indexed": true, "internalType": "address", "name": "denomination", "type": "address" }, { "indexed": true, "internalType": "address", "name": "latestAggregator", "type": "address" }, { "indexed": false, "internalType": "address", "name": "previousAggregator", "type": "address" }, { "indexed": false, "internalType": "uint16", "name": "nextPhaseId", "type": "uint16" }, { "indexed": false, "internalType": "address", "name": "sender", "type": "address" }], "name": "FeedConfirmed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, { "indexed": true, "internalType": "address", "name": "denomination", "type": "address" }, { "indexed": true, "internalType": "address", "name": "proposedAggregator", "type": "address" }, { "indexed": false, "internalType": "address", "name": "currentAggregator", "type": "address" }, { "indexed": false, "internalType": "address", "name": "sender", "type": "address" }], "name": "FeedProposed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferRequested", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "address", "name": "aggregator", "type": "address" }], "name": "confirmFeed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "description", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getAccessController", "outputs": [{ "internalType": "contract AccessControllerInterface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint256", "name": "roundId", "type": "uint256" }], "name": "getAnswer", "outputs": [{ "internalType": "int256", "name": "answer", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getCurrentPhaseId", "outputs": [{ "internalType": "uint16", "name": "currentPhaseId", "type": "uint16" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "getNextRoundId", "outputs": [{ "internalType": "uint80", "name": "nextRoundId", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint16", "name": "phaseId", "type": "uint16" }], "name": "getPhase", "outputs": [{ "components": [{ "internalType": "uint16", "name": "phaseId", "type": "uint16" }, { "internalType": "uint80", "name": "startingAggregatorRoundId", "type": "uint80" }, { "internalType": "uint80", "name": "endingAggregatorRoundId", "type": "uint80" }], "internalType": "struct FeedRegistryInterface.Phase", "name": "phase", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint16", "name": "phaseId", "type": "uint16" }], "name": "getPhaseFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint16", "name": "phaseId", "type": "uint16" }], "name": "getPhaseRange", "outputs": [{ "internalType": "uint80", "name": "startingRoundId", "type": "uint80" }, { "internalType": "uint80", "name": "endingRoundId", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "getPreviousRoundId", "outputs": [{ "internalType": "uint80", "name": "previousRoundId", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getProposedFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "proposedAggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "getRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "getRoundFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint256", "name": "roundId", "type": "uint256" }], "name": "getTimestamp", "outputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "aggregator", "type": "address" }], "name": "isFeedEnabled", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestAnswer", "outputs": [{ "internalType": "int256", "name": "answer", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestRound", "outputs": [{ "internalType": "uint256", "name": "roundId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestTimestamp", "outputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "address", "name": "aggregator", "type": "address" }], "name": "proposeFeed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "proposedGetRoundData", "outputs": [{ "internalType": "uint80", "name": "id", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "proposedLatestRoundData", "outputs": [{ "internalType": "uint80", "name": "id", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract AccessControllerInterface", "name": "_accessController", "type": "address" }], "name": "setAccessController", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "typeAndVersion", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "version", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
686
+ "networks": {
687
+ "1": { "address": "0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf" }
688
+ }
675
689
  }
676
690
  };
@@ -2,3 +2,5 @@ export declare const SECONDS_PER_YEAR: number;
2
2
  export declare const AVG_BLOCK_TIME = 12;
3
3
  export declare const BLOCKS_IN_A_YEAR: number;
4
4
  export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
5
+ export declare const WAD = 1000000000000000000;
6
+ export declare const USD_QUOTE = "0x0000000000000000000000000000000000000348";
@@ -2,3 +2,5 @@ export const SECONDS_PER_YEAR = 365 * 24 * 60 * 60;
2
2
  export const AVG_BLOCK_TIME = 12;
3
3
  export const BLOCKS_IN_A_YEAR = SECONDS_PER_YEAR / AVG_BLOCK_TIME;
4
4
  export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
5
+ export const WAD = 1e18;
6
+ export const USD_QUOTE = '0x0000000000000000000000000000000000000348';
@@ -42,3 +42,5 @@ export declare const ChickenBondsManagerContract: (web3: Web3, network: NetworkN
42
42
  export declare const ETHPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.ETHPriceFeed;
43
43
  export declare const COMPPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.COMPPriceFeed;
44
44
  export declare const USDCPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.USDCPriceFeed;
45
+ export declare const FeedRegistryContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.FeedRegistry;
46
+ export declare const MorphoBlueViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.MorphoBlueView;
package/esm/contracts.js CHANGED
@@ -80,3 +80,5 @@ export const ChickenBondsManagerContract = createContractFromConfigFunc('Chicken
80
80
  export const ETHPriceFeedContract = createContractFromConfigFunc('ETHPriceFeed');
81
81
  export const COMPPriceFeedContract = createContractFromConfigFunc('COMPPriceFeed');
82
82
  export const USDCPriceFeedContract = createContractFromConfigFunc('USDCPriceFeed');
83
+ export const FeedRegistryContract = createContractFromConfigFunc('FeedRegistry');
84
+ export const MorphoBlueViewContract = createContractFromConfigFunc('MorphoBlueView');
@@ -4,3 +4,4 @@ export * as sparkHelpers from './sparkHelpers';
4
4
  export * as curveUsdHelpers from './curveUsdHelpers';
5
5
  export * as makerHelpers from './makerHelpers';
6
6
  export * as chickenBondsHelpers from './chickenBondsHelpers';
7
+ export * as morphoBlueHelpers from './morphoBlueHelpers';
@@ -4,3 +4,4 @@ export * as sparkHelpers from './sparkHelpers';
4
4
  export * as curveUsdHelpers from './curveUsdHelpers';
5
5
  export * as makerHelpers from './makerHelpers';
6
6
  export * as chickenBondsHelpers from './chickenBondsHelpers';
7
+ export * as morphoBlueHelpers from './morphoBlueHelpers';
@@ -0,0 +1,7 @@
1
+ import { MMUsedAssets } from '../../types/common';
2
+ import { MorphoBlueAggregatedPositionData, MorphoBlueAssetsData } from '../../types';
3
+ export declare const getMorphoBlueAggregatedPositionData: ({ usedAssets, assetsData, lltv }: {
4
+ usedAssets: MMUsedAssets;
5
+ assetsData: MorphoBlueAssetsData;
6
+ lltv: string;
7
+ }) => MorphoBlueAggregatedPositionData;
@@ -0,0 +1,34 @@
1
+ import Dec from 'decimal.js';
2
+ import { calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos } from '../../moneymarket';
3
+ import { calculateNetApy } from '../../staking';
4
+ export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, lltv }) => {
5
+ const payload = {};
6
+ payload.suppliedUsd = getAssetsTotal(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd);
7
+ payload.suppliedCollateralUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ suppliedUsd }) => suppliedUsd);
8
+ payload.borrowedUsd = getAssetsTotal(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd);
9
+ payload.borrowLimitUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ symbol, suppliedUsd }) => {
10
+ const suppliedUsdAmount = suppliedUsd;
11
+ return new Dec(suppliedUsdAmount).mul(lltv);
12
+ });
13
+ payload.liquidationLimitUsd = payload.borrowLimitUsd;
14
+ const leftToBorrowUsd = new Dec(payload.borrowLimitUsd).sub(payload.borrowedUsd);
15
+ payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
16
+ const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy(usedAssets, assetsData);
17
+ payload.netApy = netApy;
18
+ payload.incentiveUsd = incentiveUsd;
19
+ payload.totalInterestUsd = totalInterestUsd;
20
+ payload.ltv = new Dec(payload.borrowedUsd).div(payload.suppliedCollateralUsd).toString();
21
+ const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
22
+ payload.leveragedType = leveragedType;
23
+ if (leveragedType !== '') {
24
+ payload.leveragedAsset = leveragedAsset;
25
+ let assetPrice = assetsData[leveragedAsset].price;
26
+ if (leveragedType === 'lsd-leverage') {
27
+ // Treat ETH like a stablecoin in a long stETH position
28
+ payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toDP(18).toString();
29
+ assetPrice = new Dec(assetPrice).div(assetsData.ETH.price).toString();
30
+ }
31
+ payload.liquidationPrice = calcLeverageLiqPrice(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
32
+ }
33
+ return payload;
34
+ };
package/esm/index.d.ts CHANGED
@@ -15,5 +15,6 @@ import * as markets from './markets';
15
15
  import * as helpers from './helpers';
16
16
  import * as chickenBonds from './chickenBonds';
17
17
  import * as exchange from './exchange';
18
+ import * as morphoBlue from './morphoBlue';
18
19
  export * from './types';
19
- export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, };
20
+ export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, };
package/esm/index.js CHANGED
@@ -15,5 +15,6 @@ import * as markets from './markets';
15
15
  import * as helpers from './helpers';
16
16
  import * as chickenBonds from './chickenBonds';
17
17
  import * as exchange from './exchange';
18
+ import * as morphoBlue from './morphoBlue';
18
19
  export * from './types';
19
- export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, };
20
+ export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, };
@@ -2,3 +2,4 @@ export { AaveMarkets } from './aave';
2
2
  export { CompoundMarkets } from './compound';
3
3
  export { SparkMarkets } from './spark';
4
4
  export { CrvUsdMarkets } from './curveUsd';
5
+ export { MorphoBlueMarkets } from './morphoBlue';
@@ -2,3 +2,4 @@ export { AaveMarkets } from './aave';
2
2
  export { CompoundMarkets } from './compound';
3
3
  export { SparkMarkets } from './spark';
4
4
  export { CrvUsdMarkets } from './curveUsd';
5
+ export { MorphoBlueMarkets } from './morphoBlue';
@@ -0,0 +1,6 @@
1
+ import { MorphoBlueMarketData } from '../../types';
2
+ import { NetworkNumber } from '../../types/common';
3
+ export declare const MORPHO_BLUE_WSTETH_ETH: (networkId?: NetworkNumber) => MorphoBlueMarketData;
4
+ export declare const MorphoBlueMarkets: (networkId: NetworkNumber) => {
5
+ readonly morphobluewstetheth: MorphoBlueMarketData;
6
+ };
@@ -0,0 +1,19 @@
1
+ import { MorphoBlueVersions } from '../../types';
2
+ import { NetworkNumber } from '../../types/common';
3
+ export const MORPHO_BLUE_WSTETH_ETH = (networkId = NetworkNumber.Eth) => ({
4
+ chainIds: [1],
5
+ label: 'Morpho Blue',
6
+ shortLabel: 'wstETH/ETH',
7
+ value: MorphoBlueVersions.MorphoBlueWstEthEth,
8
+ url: 'default',
9
+ loanToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
10
+ collateralToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
11
+ oracle: '0x2a01eb9496094da03c4e364def50f5ad1280ad72',
12
+ irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
13
+ lltv: 0.945,
14
+ // icon: SvgAdapter(protocolIcons.spark),
15
+ protocolName: 'morpho-blue',
16
+ });
17
+ export const MorphoBlueMarkets = (networkId) => ({
18
+ [MorphoBlueVersions.MorphoBlueWstEthEth]: MORPHO_BLUE_WSTETH_ETH(networkId),
19
+ });
@@ -0,0 +1,5 @@
1
+ import Web3 from 'web3';
2
+ import { NetworkNumber } from '../types/common';
3
+ import { MorphoBlueMarketData, MorphoBlueMarketInfo, MorphoBluePositionData } from '../types';
4
+ export declare function getMorphoBlueMarketData(web3: Web3, network: NetworkNumber, selectedMarket: MorphoBlueMarketData, mainnetWeb3: Web3): Promise<MorphoBlueMarketInfo>;
5
+ export declare function getMorphoBlueAccountData(web3: Web3, network: NetworkNumber, account: string, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBluePositionData>;
@@ -0,0 +1,145 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import Dec from 'decimal.js';
11
+ import { getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
12
+ import { MorphoBlueViewContract, getConfigContractAbi, getConfigContractAddress, } from '../contracts';
13
+ import { WAD, SECONDS_PER_YEAR, USD_QUOTE } from '../constants';
14
+ import { getStakingApy } from '../staking';
15
+ import { getAbiItem, wethToEth } from '../services/utils';
16
+ import { multicall } from '../multicall';
17
+ import { getMorphoBlueAggregatedPositionData } from '../helpers/morphoBlueHelpers';
18
+ const compound = (ratePerSeconds) => {
19
+ const compounding = new Dec(ratePerSeconds).mul(SECONDS_PER_YEAR).toString();
20
+ const apyNumber = Math.expm1(new Dec(compounding).div(WAD).toNumber());
21
+ return new Dec(apyNumber).mul(WAD).floor().toString();
22
+ };
23
+ const getSupplyRate = (totalSupplyAssets, totalBorrowAssets, borrowRate, fee) => {
24
+ if (totalBorrowAssets === '0' || totalSupplyAssets === '0') {
25
+ return 0;
26
+ }
27
+ const utillization = new Dec(totalBorrowAssets).mul(WAD).div(totalSupplyAssets).ceil()
28
+ .toString();
29
+ const supplyRate = new Dec(utillization).mul(borrowRate).div(WAD).ceil()
30
+ .toString();
31
+ const ratePerSecond = new Dec(supplyRate).mul(new Dec(WAD).minus(fee)).div(WAD).ceil()
32
+ .toString();
33
+ return compound(ratePerSecond);
34
+ };
35
+ const getBorrowRate = (borrowRate, totalBorrowShares) => {
36
+ if (totalBorrowShares === '0') {
37
+ return 0;
38
+ }
39
+ return compound(borrowRate);
40
+ };
41
+ export function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const { loanToken, collateralToken, oracle, irm, lltv, } = selectedMarket;
44
+ const lltvInWei = new Dec(lltv).mul(WAD).toString();
45
+ const loanTokenInfo = getAssetInfoByAddress(loanToken);
46
+ const collateralTokenInfo = getAssetInfoByAddress(collateralToken);
47
+ let loanTokenFeedAddress = loanToken;
48
+ if (loanTokenInfo.symbol === 'WETH') {
49
+ const ethAddress = getAssetInfo('ETH').address;
50
+ loanTokenFeedAddress = ethAddress;
51
+ }
52
+ const FeedRegistryAddress = getConfigContractAddress('FeedRegistry', network);
53
+ const FeedRegistryAbi = getConfigContractAbi('FeedRegistry');
54
+ const viewContractAddress = getConfigContractAddress('MorphoBlueView', network);
55
+ const viewContractAbi = getConfigContractAbi('MorphoBlueView');
56
+ const multicallCallsObject = [
57
+ {
58
+ target: FeedRegistryAddress,
59
+ abiItem: getAbiItem(FeedRegistryAbi, 'latestAnswer'),
60
+ params: [loanTokenFeedAddress, USD_QUOTE],
61
+ },
62
+ {
63
+ target: viewContractAddress,
64
+ abiItem: getAbiItem(viewContractAbi, 'getMarketInfoNotTuple'),
65
+ params: [loanToken, collateralToken, oracle, irm, lltvInWei],
66
+ },
67
+ ];
68
+ const multicallData = yield multicall(multicallCallsObject, web3, network);
69
+ const loanTokenPrice = multicallData[0][0];
70
+ const marketInfo = multicallData[1][0];
71
+ const supplyRate = getSupplyRate(marketInfo.totalSupplyAssets, marketInfo.totalBorrowAssets, marketInfo.borrowRate, marketInfo.fee);
72
+ const compoundedBorrowRate = getBorrowRate(marketInfo.borrowRate, marketInfo.totalBorrowShares);
73
+ const utillization = new Dec(marketInfo.totalBorrowAssets).div(marketInfo.totalSupplyAssets).mul(100).toString();
74
+ const oracleRate = new Dec(marketInfo.oracle).div(1e36).toString();
75
+ const assetsData = {};
76
+ assetsData[wethToEth(loanTokenInfo.symbol)] = {
77
+ symbol: wethToEth(loanTokenInfo.symbol),
78
+ address: loanToken,
79
+ price: new Dec(loanTokenPrice).div(1e8).toString(),
80
+ supplyRate: new Dec(supplyRate).div(WAD).mul(100).toString(),
81
+ borrowRate: new Dec(compoundedBorrowRate).div(WAD).mul(100).toString(),
82
+ totalSupply: new Dec(marketInfo.totalSupplyAssets).div(WAD).toString(),
83
+ totalBorrow: new Dec(marketInfo.totalBorrowAssets).div(WAD).toString(),
84
+ };
85
+ assetsData[wethToEth(collateralTokenInfo.symbol)] = {
86
+ symbol: wethToEth(collateralTokenInfo.symbol),
87
+ address: collateralToken,
88
+ price: new Dec(loanTokenPrice).div(1e8).mul(oracleRate).toString(),
89
+ supplyRate: '0',
90
+ borrowRate: '0',
91
+ };
92
+ if (['wstETH', 'cbETH', 'rETH'].includes(collateralTokenInfo.symbol)) {
93
+ assetsData[collateralTokenInfo.symbol].incentiveSupplyApy = yield getStakingApy(collateralTokenInfo.symbol, mainnetWeb3);
94
+ assetsData[collateralTokenInfo.symbol].incentiveSupplyToken = collateralTokenInfo.symbol;
95
+ }
96
+ return {
97
+ id: marketInfo.id,
98
+ fee: new Dec(marketInfo.fee).div(WAD).toString(),
99
+ loanToken: wethToEth(loanTokenInfo.symbol),
100
+ collateralToken: wethToEth(collateralTokenInfo.symbol),
101
+ utillization,
102
+ oracle: oracleRate,
103
+ lltv: new Dec(lltv).toString(),
104
+ assetsData,
105
+ };
106
+ });
107
+ }
108
+ export function getMorphoBlueAccountData(web3, network, account, selectedMarket, marketInfo) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const { loanToken, collateralToken, oracle, irm, lltv, } = selectedMarket;
111
+ const lltvInWei = new Dec(lltv).mul(WAD).toString();
112
+ const marketObject = {
113
+ loanToken, collateralToken, oracle, irm, lltv: lltvInWei,
114
+ };
115
+ const viewContract = MorphoBlueViewContract(web3, network);
116
+ const loanInfo = yield viewContract.methods.getUserInfo(marketObject, account).call();
117
+ const usedAssets = {};
118
+ const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
119
+ const loanTokenSupplied = new Dec(loanInfo.suppliedInAssets).div(WAD).toString();
120
+ const loanTokenBorrowed = new Dec(loanInfo.borrowedInAssets).div(WAD).toString();
121
+ usedAssets[marketInfo.loanToken] = {
122
+ symbol: loanTokenInfo.symbol,
123
+ supplied: loanTokenSupplied,
124
+ borrowed: loanTokenBorrowed,
125
+ isSupplied: new Dec(loanInfo.suppliedInAssets).gt(0),
126
+ isBorrowed: new Dec(loanInfo.borrowedInAssets).gt(0),
127
+ collateral: false,
128
+ suppliedUsd: new Dec(loanTokenSupplied).mul(loanTokenInfo.price).toString(),
129
+ borrowedUsd: new Dec(loanTokenBorrowed).mul(loanTokenInfo.price).toString(),
130
+ };
131
+ const collateralTokenInfo = marketInfo.assetsData[marketInfo.collateralToken];
132
+ const collateralTokenSupplied = new Dec(loanInfo.collateral).div(WAD).toString();
133
+ usedAssets[marketInfo.collateralToken] = {
134
+ symbol: collateralTokenInfo.symbol,
135
+ supplied: collateralTokenSupplied,
136
+ borrowed: '0',
137
+ isSupplied: new Dec(loanInfo.collateral).gt(0),
138
+ isBorrowed: false,
139
+ collateral: true,
140
+ suppliedUsd: new Dec(collateralTokenSupplied).mul(collateralTokenInfo.price).toString(),
141
+ borrowedUsd: '0',
142
+ };
143
+ return Object.assign({ usedAssets }, getMorphoBlueAggregatedPositionData({ usedAssets, assetsData: marketInfo.assetsData, lltv: marketInfo.lltv }));
144
+ });
145
+ }
@@ -44,7 +44,7 @@ export interface MMUsedAsset {
44
44
  borrowed: string;
45
45
  borrowedUsd: string;
46
46
  isBorrowed: boolean;
47
- debt: string;
47
+ debt?: string;
48
48
  supplyRate?: string;
49
49
  borrowRate?: string;
50
50
  discountedBorrowRate?: string;