@defisaver/positions-sdk 2.1.158 → 2.1.159-shifter-v2-dev

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 (118) hide show
  1. package/cjs/aaveV2/index.js +2 -0
  2. package/cjs/config/contracts.d.ts +516 -4
  3. package/cjs/config/contracts.js +17 -5
  4. package/cjs/contracts.d.ts +120 -0
  5. package/cjs/fluid/index.d.ts +5 -0
  6. package/cjs/fluid/index.js +36 -1
  7. package/cjs/helpers/aaveHelpers/index.js +3 -0
  8. package/cjs/helpers/aaveV4Helpers/index.js +1 -0
  9. package/cjs/helpers/compoundHelpers/index.js +2 -0
  10. package/cjs/helpers/curveUsdHelpers/index.js +2 -0
  11. package/cjs/helpers/fluidHelpers/index.js +1 -0
  12. package/cjs/helpers/liquityV2Helpers/index.js +1 -0
  13. package/cjs/helpers/llamaLendHelpers/index.js +2 -0
  14. package/cjs/helpers/makerHelpers/index.d.ts +1 -1
  15. package/cjs/helpers/makerHelpers/index.js +2 -2
  16. package/cjs/helpers/morphoBlueHelpers/index.js +2 -0
  17. package/cjs/helpers/morphoMidnightHelpers/index.js +2 -0
  18. package/cjs/helpers/sparkHelpers/index.js +1 -0
  19. package/cjs/liquity/index.js +8 -1
  20. package/cjs/maker/index.d.ts +7 -2
  21. package/cjs/maker/index.js +32 -12
  22. package/cjs/markets/index.d.ts +1 -0
  23. package/cjs/markets/index.js +3 -1
  24. package/cjs/markets/maker/index.d.ts +1 -0
  25. package/cjs/markets/maker/index.js +13 -0
  26. package/cjs/morphoMidnight/index.js +3 -0
  27. package/cjs/portfolio/index.d.ts +5 -1
  28. package/cjs/portfolio/index.js +276 -0
  29. package/cjs/savings/index.js +6 -6
  30. package/cjs/savings/morphoVaults/index.d.ts +15 -3
  31. package/cjs/savings/morphoVaults/index.js +97 -26
  32. package/cjs/types/aave.d.ts +2 -0
  33. package/cjs/types/aaveV4.d.ts +1 -0
  34. package/cjs/types/compound.d.ts +2 -0
  35. package/cjs/types/fluid.d.ts +1 -0
  36. package/cjs/types/liquity.d.ts +1 -0
  37. package/cjs/types/liquityV2.d.ts +2 -0
  38. package/cjs/types/maker.d.ts +1 -0
  39. package/cjs/types/morphoBlue.d.ts +2 -0
  40. package/cjs/types/morphoMidnight.d.ts +2 -0
  41. package/cjs/types/portfolio.d.ts +26 -10
  42. package/cjs/types/spark.d.ts +2 -0
  43. package/esm/aaveV2/index.js +2 -0
  44. package/esm/config/contracts.d.ts +516 -4
  45. package/esm/config/contracts.js +17 -5
  46. package/esm/contracts.d.ts +120 -0
  47. package/esm/fluid/index.d.ts +5 -0
  48. package/esm/fluid/index.js +33 -0
  49. package/esm/helpers/aaveHelpers/index.js +3 -0
  50. package/esm/helpers/aaveV4Helpers/index.js +1 -0
  51. package/esm/helpers/compoundHelpers/index.js +2 -0
  52. package/esm/helpers/curveUsdHelpers/index.js +2 -0
  53. package/esm/helpers/fluidHelpers/index.js +1 -0
  54. package/esm/helpers/liquityV2Helpers/index.js +1 -0
  55. package/esm/helpers/llamaLendHelpers/index.js +2 -0
  56. package/esm/helpers/makerHelpers/index.d.ts +1 -1
  57. package/esm/helpers/makerHelpers/index.js +2 -2
  58. package/esm/helpers/morphoBlueHelpers/index.js +2 -0
  59. package/esm/helpers/morphoMidnightHelpers/index.js +2 -0
  60. package/esm/helpers/sparkHelpers/index.js +1 -0
  61. package/esm/liquity/index.js +8 -1
  62. package/esm/maker/index.d.ts +7 -2
  63. package/esm/maker/index.js +31 -13
  64. package/esm/markets/index.d.ts +1 -0
  65. package/esm/markets/index.js +1 -0
  66. package/esm/markets/maker/index.d.ts +1 -0
  67. package/esm/markets/maker/index.js +10 -0
  68. package/esm/morphoMidnight/index.js +4 -1
  69. package/esm/portfolio/index.d.ts +5 -1
  70. package/esm/portfolio/index.js +278 -3
  71. package/esm/savings/index.js +6 -6
  72. package/esm/savings/morphoVaults/index.d.ts +15 -3
  73. package/esm/savings/morphoVaults/index.js +93 -24
  74. package/esm/types/aave.d.ts +2 -0
  75. package/esm/types/aaveV4.d.ts +1 -0
  76. package/esm/types/compound.d.ts +2 -0
  77. package/esm/types/fluid.d.ts +1 -0
  78. package/esm/types/liquity.d.ts +1 -0
  79. package/esm/types/liquityV2.d.ts +2 -0
  80. package/esm/types/maker.d.ts +1 -0
  81. package/esm/types/morphoBlue.d.ts +2 -0
  82. package/esm/types/morphoMidnight.d.ts +2 -0
  83. package/esm/types/portfolio.d.ts +26 -10
  84. package/esm/types/spark.d.ts +2 -0
  85. package/package.json +1 -1
  86. package/src/aaveV2/index.ts +2 -0
  87. package/src/config/contracts.ts +17 -5
  88. package/src/fluid/index.ts +40 -0
  89. package/src/helpers/aaveHelpers/index.ts +3 -0
  90. package/src/helpers/aaveV4Helpers/index.ts +1 -0
  91. package/src/helpers/compoundHelpers/index.ts +2 -0
  92. package/src/helpers/curveUsdHelpers/index.ts +2 -0
  93. package/src/helpers/fluidHelpers/index.ts +1 -0
  94. package/src/helpers/liquityV2Helpers/index.ts +1 -0
  95. package/src/helpers/llamaLendHelpers/index.ts +2 -0
  96. package/src/helpers/makerHelpers/index.ts +2 -1
  97. package/src/helpers/morphoBlueHelpers/index.ts +2 -0
  98. package/src/helpers/morphoMidnightHelpers/index.ts +2 -0
  99. package/src/helpers/sparkHelpers/index.ts +1 -0
  100. package/src/liquity/index.ts +8 -1
  101. package/src/maker/index.ts +62 -29
  102. package/src/markets/index.ts +2 -1
  103. package/src/markets/maker/index.ts +10 -0
  104. package/src/morphoMidnight/index.ts +4 -1
  105. package/src/portfolio/index.ts +259 -2
  106. package/src/savings/index.ts +6 -6
  107. package/src/savings/morphoVaults/index.ts +108 -27
  108. package/src/types/aave.ts +3 -0
  109. package/src/types/aaveV4.ts +1 -0
  110. package/src/types/compound.ts +2 -0
  111. package/src/types/fluid.ts +1 -0
  112. package/src/types/liquity.ts +2 -0
  113. package/src/types/liquityV2.ts +2 -0
  114. package/src/types/maker.ts +2 -0
  115. package/src/types/morphoBlue.ts +2 -0
  116. package/src/types/morphoMidnight.ts +2 -0
  117. package/src/types/portfolio.ts +31 -12
  118. package/src/types/spark.ts +2 -0
@@ -1124,15 +1124,27 @@ export const MorphoBlueView = {
1124
1124
  },
1125
1125
  };
1126
1126
  export const MidnightView = {
1127
- "abi": [{ "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "getMarketInfo", "outputs": [{ "components": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalUnits", "type": "uint128" }, { "internalType": "uint128", "name": "lossFactor", "type": "uint128" }, { "internalType": "uint128", "name": "withdrawable", "type": "uint128" }, { "internalType": "uint128", "name": "continuousFeeCredit", "type": "uint128" }, { "internalType": "uint16[7]", "name": "settlementFees", "type": "uint16[7]" }, { "internalType": "uint32", "name": "continuousFee", "type": "uint32" }, { "internalType": "uint8", "name": "tickSpacing", "type": "uint8" }, { "internalType": "uint256[]", "name": "prices", "type": "uint256[]" }], "internalType": "struct MidnightView.MarketInfo", "name": "info", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getPositionInfo", "outputs": [{ "components": [{ "internalType": "uint128", "name": "credit", "type": "uint128" }, { "internalType": "uint128", "name": "pendingFee", "type": "uint128" }, { "internalType": "uint128", "name": "debt", "type": "uint128" }, { "internalType": "uint128", "name": "collateralBitmap", "type": "uint128" }, { "internalType": "uint128[]", "name": "collateral", "type": "uint128[]" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }], "internalType": "struct MidnightView.PositionInfo", "name": "pos", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "_market", "type": "tuple" }], "name": "toId", "outputs": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "toMarket", "outputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "market", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
1127
+ "abi": [{ "inputs": [], "name": "InvalidCollateralIndex", "type": "error" }, { "inputs": [], "name": "InvalidOfferMarketId", "type": "error" }, { "inputs": [], "name": "InvalidOfferType", "type": "error" }, { "inputs": [], "name": "NoOrdersProvided", "type": "error" }, { "inputs": [], "name": "ZeroAmountRequested", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "getMarketInfo", "outputs": [{ "components": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalUnits", "type": "uint128" }, { "internalType": "uint128", "name": "lossFactor", "type": "uint128" }, { "internalType": "uint128", "name": "withdrawable", "type": "uint128" }, { "internalType": "uint128", "name": "continuousFeeCredit", "type": "uint128" }, { "internalType": "uint16[7]", "name": "settlementFees", "type": "uint16[7]" }, { "internalType": "uint32", "name": "continuousFee", "type": "uint32" }, { "internalType": "uint8", "name": "tickSpacing", "type": "uint8" }, { "internalType": "uint256[]", "name": "prices", "type": "uint256[]" }], "internalType": "struct MidnightView.MarketInfo", "name": "info", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getPositionInfo", "outputs": [{ "components": [{ "internalType": "uint128", "name": "credit", "type": "uint128" }, { "internalType": "uint128", "name": "pendingFee", "type": "uint128" }, { "internalType": "uint128", "name": "debt", "type": "uint128" }, { "internalType": "uint128", "name": "collateralBitmap", "type": "uint128" }, { "internalType": "uint128[]", "name": "collateral", "type": "uint128[]" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }], "internalType": "struct MidnightView.PositionInfo", "name": "pos", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "_market", "type": "tuple" }], "name": "toId", "outputs": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "toMarket", "outputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "market", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
1128
1128
  "networks": {
1129
1129
  "1": {
1130
- "address": "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0",
1131
- "createdBlock": 25938908,
1130
+ "address": "0xb8e1dAAd42e18203cfCED7193FE0e2E19d713A56",
1131
+ "createdBlock": 25983494,
1132
+ "oldVersions": {
1133
+ "25938908": {
1134
+ "abi": [{ "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "getMarketInfo", "outputs": [{ "components": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalUnits", "type": "uint128" }, { "internalType": "uint128", "name": "lossFactor", "type": "uint128" }, { "internalType": "uint128", "name": "withdrawable", "type": "uint128" }, { "internalType": "uint128", "name": "continuousFeeCredit", "type": "uint128" }, { "internalType": "uint16[7]", "name": "settlementFees", "type": "uint16[7]" }, { "internalType": "uint32", "name": "continuousFee", "type": "uint32" }, { "internalType": "uint8", "name": "tickSpacing", "type": "uint8" }, { "internalType": "uint256[]", "name": "prices", "type": "uint256[]" }], "internalType": "struct MidnightView.MarketInfo", "name": "info", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getPositionInfo", "outputs": [{ "components": [{ "internalType": "uint128", "name": "credit", "type": "uint128" }, { "internalType": "uint128", "name": "pendingFee", "type": "uint128" }, { "internalType": "uint128", "name": "debt", "type": "uint128" }, { "internalType": "uint128", "name": "collateralBitmap", "type": "uint128" }, { "internalType": "uint128[]", "name": "collateral", "type": "uint128[]" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }], "internalType": "struct MidnightView.PositionInfo", "name": "pos", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "_market", "type": "tuple" }], "name": "toId", "outputs": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "toMarket", "outputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "market", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
1135
+ "address": "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0",
1136
+ }
1137
+ },
1132
1138
  },
1133
1139
  "8453": {
1134
- "address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
1135
- "createdBlock": 48932293,
1140
+ "address": "0xdEab43eb1519bD4314bc99c4019866734103D3Ae",
1141
+ "createdBlock": 51346932,
1142
+ "oldVersions": {
1143
+ "48932293": {
1144
+ "abi": [{ "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "getMarketInfo", "outputs": [{ "components": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalUnits", "type": "uint128" }, { "internalType": "uint128", "name": "lossFactor", "type": "uint128" }, { "internalType": "uint128", "name": "withdrawable", "type": "uint128" }, { "internalType": "uint128", "name": "continuousFeeCredit", "type": "uint128" }, { "internalType": "uint16[7]", "name": "settlementFees", "type": "uint16[7]" }, { "internalType": "uint32", "name": "continuousFee", "type": "uint32" }, { "internalType": "uint8", "name": "tickSpacing", "type": "uint8" }, { "internalType": "uint256[]", "name": "prices", "type": "uint256[]" }], "internalType": "struct MidnightView.MarketInfo", "name": "info", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getPositionInfo", "outputs": [{ "components": [{ "internalType": "uint128", "name": "credit", "type": "uint128" }, { "internalType": "uint128", "name": "pendingFee", "type": "uint128" }, { "internalType": "uint128", "name": "debt", "type": "uint128" }, { "internalType": "uint128", "name": "collateralBitmap", "type": "uint128" }, { "internalType": "uint128[]", "name": "collateral", "type": "uint128[]" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }], "internalType": "struct MidnightView.PositionInfo", "name": "pos", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "_market", "type": "tuple" }], "name": "toId", "outputs": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "toMarket", "outputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "market", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
1145
+ "address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
1146
+ }
1147
+ },
1136
1148
  }
1137
1149
  },
1138
1150
  };
@@ -100745,6 +100745,26 @@ export declare const MorphoBlueViewContractViem: (client: Client, network: Netwo
100745
100745
  export declare const MorphoMidnightViewContractViem: (client: Client, network: NetworkNumber, block?: Blockish) => {
100746
100746
  read: {
100747
100747
  getRatio: (args: readonly [`0x${string}`, `0x${string}`], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
100748
+ readonly inputs: readonly [];
100749
+ readonly name: "InvalidCollateralIndex";
100750
+ readonly type: "error";
100751
+ }, {
100752
+ readonly inputs: readonly [];
100753
+ readonly name: "InvalidOfferMarketId";
100754
+ readonly type: "error";
100755
+ }, {
100756
+ readonly inputs: readonly [];
100757
+ readonly name: "InvalidOfferType";
100758
+ readonly type: "error";
100759
+ }, {
100760
+ readonly inputs: readonly [];
100761
+ readonly name: "NoOrdersProvided";
100762
+ readonly type: "error";
100763
+ }, {
100764
+ readonly inputs: readonly [];
100765
+ readonly name: "ZeroAmountRequested";
100766
+ readonly type: "error";
100767
+ }, {
100748
100768
  readonly inputs: readonly [{
100749
100769
  readonly internalType: "bytes32";
100750
100770
  readonly name: "_id";
@@ -100986,6 +101006,26 @@ export declare const MorphoMidnightViewContractViem: (client: Client, network: N
100986
101006
  readonly type: "function";
100987
101007
  }], "getRatio", readonly [`0x${string}`, `0x${string}`]>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
100988
101008
  getMarketInfo: (args: readonly [`0x${string}`], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
101009
+ readonly inputs: readonly [];
101010
+ readonly name: "InvalidCollateralIndex";
101011
+ readonly type: "error";
101012
+ }, {
101013
+ readonly inputs: readonly [];
101014
+ readonly name: "InvalidOfferMarketId";
101015
+ readonly type: "error";
101016
+ }, {
101017
+ readonly inputs: readonly [];
101018
+ readonly name: "InvalidOfferType";
101019
+ readonly type: "error";
101020
+ }, {
101021
+ readonly inputs: readonly [];
101022
+ readonly name: "NoOrdersProvided";
101023
+ readonly type: "error";
101024
+ }, {
101025
+ readonly inputs: readonly [];
101026
+ readonly name: "ZeroAmountRequested";
101027
+ readonly type: "error";
101028
+ }, {
100989
101029
  readonly inputs: readonly [{
100990
101030
  readonly internalType: "bytes32";
100991
101031
  readonly name: "_id";
@@ -101237,6 +101277,26 @@ export declare const MorphoMidnightViewContractViem: (client: Client, network: N
101237
101277
  prices: readonly bigint[];
101238
101278
  }>;
101239
101279
  getPositionInfo: (args: readonly [`0x${string}`, `0x${string}`], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
101280
+ readonly inputs: readonly [];
101281
+ readonly name: "InvalidCollateralIndex";
101282
+ readonly type: "error";
101283
+ }, {
101284
+ readonly inputs: readonly [];
101285
+ readonly name: "InvalidOfferMarketId";
101286
+ readonly type: "error";
101287
+ }, {
101288
+ readonly inputs: readonly [];
101289
+ readonly name: "InvalidOfferType";
101290
+ readonly type: "error";
101291
+ }, {
101292
+ readonly inputs: readonly [];
101293
+ readonly name: "NoOrdersProvided";
101294
+ readonly type: "error";
101295
+ }, {
101296
+ readonly inputs: readonly [];
101297
+ readonly name: "ZeroAmountRequested";
101298
+ readonly type: "error";
101299
+ }, {
101240
101300
  readonly inputs: readonly [{
101241
101301
  readonly internalType: "bytes32";
101242
101302
  readonly name: "_id";
@@ -101499,6 +101559,26 @@ export declare const MorphoMidnightViewContractViem: (client: Client, network: N
101499
101559
  enterGate: `0x${string}`;
101500
101560
  liquidatorGate: `0x${string}`;
101501
101561
  }], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
101562
+ readonly inputs: readonly [];
101563
+ readonly name: "InvalidCollateralIndex";
101564
+ readonly type: "error";
101565
+ }, {
101566
+ readonly inputs: readonly [];
101567
+ readonly name: "InvalidOfferMarketId";
101568
+ readonly type: "error";
101569
+ }, {
101570
+ readonly inputs: readonly [];
101571
+ readonly name: "InvalidOfferType";
101572
+ readonly type: "error";
101573
+ }, {
101574
+ readonly inputs: readonly [];
101575
+ readonly name: "NoOrdersProvided";
101576
+ readonly type: "error";
101577
+ }, {
101578
+ readonly inputs: readonly [];
101579
+ readonly name: "ZeroAmountRequested";
101580
+ readonly type: "error";
101581
+ }, {
101502
101582
  readonly inputs: readonly [{
101503
101583
  readonly internalType: "bytes32";
101504
101584
  readonly name: "_id";
@@ -101754,6 +101834,26 @@ export declare const MorphoMidnightViewContractViem: (client: Client, network: N
101754
101834
  liquidatorGate: `0x${string}`;
101755
101835
  }]>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<`0x${string}`>;
101756
101836
  toMarket: (args: readonly [`0x${string}`], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
101837
+ readonly inputs: readonly [];
101838
+ readonly name: "InvalidCollateralIndex";
101839
+ readonly type: "error";
101840
+ }, {
101841
+ readonly inputs: readonly [];
101842
+ readonly name: "InvalidOfferMarketId";
101843
+ readonly type: "error";
101844
+ }, {
101845
+ readonly inputs: readonly [];
101846
+ readonly name: "InvalidOfferType";
101847
+ readonly type: "error";
101848
+ }, {
101849
+ readonly inputs: readonly [];
101850
+ readonly name: "NoOrdersProvided";
101851
+ readonly type: "error";
101852
+ }, {
101853
+ readonly inputs: readonly [];
101854
+ readonly name: "ZeroAmountRequested";
101855
+ readonly type: "error";
101856
+ }, {
101757
101857
  readonly inputs: readonly [{
101758
101858
  readonly internalType: "bytes32";
101759
101859
  readonly name: "_id";
@@ -102011,6 +102111,26 @@ export declare const MorphoMidnightViewContractViem: (client: Client, network: N
102011
102111
  };
102012
102112
  address: `0x${string}`;
102013
102113
  abi: readonly [{
102114
+ readonly inputs: readonly [];
102115
+ readonly name: "InvalidCollateralIndex";
102116
+ readonly type: "error";
102117
+ }, {
102118
+ readonly inputs: readonly [];
102119
+ readonly name: "InvalidOfferMarketId";
102120
+ readonly type: "error";
102121
+ }, {
102122
+ readonly inputs: readonly [];
102123
+ readonly name: "InvalidOfferType";
102124
+ readonly type: "error";
102125
+ }, {
102126
+ readonly inputs: readonly [];
102127
+ readonly name: "NoOrdersProvided";
102128
+ readonly type: "error";
102129
+ }, {
102130
+ readonly inputs: readonly [];
102131
+ readonly name: "ZeroAmountRequested";
102132
+ readonly type: "error";
102133
+ }, {
102014
102134
  readonly inputs: readonly [{
102015
102135
  readonly internalType: "bytes32";
102016
102136
  readonly name: "_id";
@@ -133,6 +133,7 @@ export declare const _getUserPositions: (provider: PublicClient, network: Networ
133
133
  merklBorrowIncentives: import("../types").IncentiveData[];
134
134
  ratio: string;
135
135
  collRatio: string;
136
+ safetyRatio: string;
136
137
  minRatio: string;
137
138
  totalInterestUsd: string;
138
139
  leveragedType?: import("../types").LeverageType;
@@ -167,6 +168,7 @@ export declare const getUserPositions: (provider: EthereumProvider, network: Net
167
168
  merklBorrowIncentives: import("../types").IncentiveData[];
168
169
  ratio: string;
169
170
  collRatio: string;
171
+ safetyRatio: string;
170
172
  minRatio: string;
171
173
  totalInterestUsd: string;
172
174
  leveragedType?: import("../types").LeverageType;
@@ -201,6 +203,7 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
201
203
  merklBorrowIncentives: import("../types").IncentiveData[];
202
204
  ratio: string;
203
205
  collRatio: string;
206
+ safetyRatio: string;
204
207
  minRatio: string;
205
208
  totalInterestUsd: string;
206
209
  leveragedType?: import("../types").LeverageType;
@@ -221,3 +224,5 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
221
224
  nftId: string;
222
225
  } | undefined;
223
226
  }[]>;
227
+ export declare const _getAllFluidMarketDataPortfolio: (provider: PublicClient, network: NetworkNumber) => Promise<Record<string, FluidMarketData>>;
228
+ export declare const getAllFluidMarketDataPortfolio: (provider: EthereumProvider, network: NetworkNumber) => Promise<Record<string, FluidMarketData>>;
@@ -1381,3 +1381,36 @@ export const _getUserPositionsPortfolio = (provider, network, user) => __awaiter
1381
1381
  userData: userData[i],
1382
1382
  })).filter(md => md.marketData !== undefined);
1383
1383
  });
1384
+ export const _getAllFluidMarketDataPortfolio = (provider, network) => __awaiter(void 0, void 0, void 0, function* () {
1385
+ const versions = getFluidVersionsDataForNetwork(network);
1386
+ if (versions.length === 0)
1387
+ return {};
1388
+ const view = FluidViewContractViem(provider, network);
1389
+ const vaultsData = yield Promise.all(versions.map((version) => view.read.getVaultData([version.marketAddress])));
1390
+ const tokens = Array.from(new Set(vaultsData.map((vaultData) => {
1391
+ const vaultTokens = [getAssetInfoByAddress(vaultData.supplyToken0, network).symbol, getAssetInfoByAddress(vaultData.borrowToken0, network).symbol];
1392
+ if (vaultData.supplyToken1 && !compareAddresses(ZERO_ADDRESS, vaultData.supplyToken1))
1393
+ vaultTokens.push(getAssetInfoByAddress(vaultData.supplyToken1, network).symbol);
1394
+ if (vaultData.borrowToken1 && !compareAddresses(ZERO_ADDRESS, vaultData.borrowToken1))
1395
+ vaultTokens.push(getAssetInfoByAddress(vaultData.borrowToken1, network).symbol);
1396
+ return vaultTokens;
1397
+ }).flat()));
1398
+ // ETH and WBTC needed for other tokens prices
1399
+ if (!tokens.includes('ETH'))
1400
+ tokens.push('ETH');
1401
+ if (!tokens.includes('WBTC'))
1402
+ tokens.push('WBTC');
1403
+ const [tokenPrices, merklCampaigns] = yield Promise.all([
1404
+ getTokensPricesForPortfolio(tokens, provider, network),
1405
+ getFluidMerklCampaigns(network),
1406
+ ]);
1407
+ const parsedMarketsData = yield Promise.all(vaultsData.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(provider, vaultData, network, tokenPrices); })));
1408
+ const marketsData = {};
1409
+ parsedMarketsData.forEach((marketData, i) => {
1410
+ if (!marketData)
1411
+ return;
1412
+ marketsData[versions[i].value] = attachFluidMerklIncentives(marketData, merklCampaigns);
1413
+ });
1414
+ return marketsData;
1415
+ });
1416
+ export const getAllFluidMarketDataPortfolio = (provider, network) => __awaiter(void 0, void 0, void 0, function* () { return _getAllFluidMarketDataPortfolio(getViemProvider(provider, network, { batch: { multicall: true } }), network); });
@@ -125,6 +125,9 @@ export const aaveAnyGetAggregatedPositionData = (_a) => {
125
125
  return new Dec(suppliedUsd).mul(effectiveLtv);
126
126
  });
127
127
  payload.safetyRatioWithLtvZeroFallback = +payload.suppliedUsd ? new Dec(payload.borrowLimitWithLtvZeroFallbackUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
128
+ // Normalised safety ratio (100 = liquidation on every protocol): the automation ratio above, falling back
129
+ // to the regular ratio when the fallback carries its '0' placeholder.
130
+ payload.safetyRatio = +payload.safetyRatioWithLtvZeroFallback ? payload.safetyRatioWithLtvZeroFallback : payload.ratio;
128
131
  payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
129
132
  payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
130
133
  const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
@@ -208,6 +208,7 @@ export const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, networ
208
208
  payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
209
209
  payload.minRatio = '100';
210
210
  payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
211
+ payload.safetyRatio = payload.ratio;
211
212
  payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
212
213
  payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
213
214
  const { leveragedType, leveragedAsset } = isLeveragedPosAaveV4(usedAssets);
@@ -93,6 +93,7 @@ export const getCompoundV2AggregatedData = (_a) => {
93
93
  payload.collRatio = payload.borrowedUsd && payload.borrowedUsd !== '0'
94
94
  ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString()
95
95
  : '0';
96
+ payload.safetyRatio = payload.ratio;
96
97
  // Calculate borrow limits per asset
97
98
  Object.values(usedAssets).forEach((item) => {
98
99
  if (item.isBorrowed) {
@@ -134,6 +135,7 @@ export const getCompoundV3AggregatedData = (_a) => {
134
135
  payload.incentiveUsd = incentiveUsd;
135
136
  payload.totalInterestUsd = totalInterestUsd;
136
137
  payload.minRatio = '100';
138
+ payload.safetyRatio = payload.ratio;
137
139
  payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
138
140
  payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
139
141
  payload.minDebt = assetsData[selectedMarket.baseAsset].minDebt;
@@ -28,6 +28,8 @@ export const getCrvUsdAggregatedData = (_a) => {
28
28
  : '0';
29
29
  // this is all approximation
30
30
  payload.minAllowedRatio = mapRange(numOfBands, 4, 50, 115, 140); // collateral ratio
31
+ // Collateral ratio rebased so 100 sits on the band-derived minimum (normalised safety ratio, same scale as the other protocols).
32
+ payload.safetyRatio = loanExists && payload.minAllowedRatio ? new Dec(payload.ratio).div(payload.minAllowedRatio).mul(100).toString() : '0';
31
33
  payload.collFactor = new Dec(1).div(payload.minAllowedRatio).mul(100).toString(); // collateral factor = 1 / collateral ratio
32
34
  // only take in consideration collAsset
33
35
  payload.borrowLimitUsd = ((_b = usedAssets === null || usedAssets === void 0 ? void 0 : usedAssets[selectedMarket.collAsset]) === null || _b === void 0 ? void 0 : _b.isSupplied)
@@ -78,6 +78,7 @@ export const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, },
78
78
  payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
79
79
  payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
80
80
  payload.minRatio = marketData.minRatio;
81
+ payload.safetyRatio = payload.ratio;
81
82
  const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
82
83
  payload.leveragedType = leveragedType;
83
84
  payload.liquidationPrice = '';
@@ -41,6 +41,7 @@ export const getLiquityV2AggregatedPositionData = ({ usedAssets, assetsData, min
41
41
  payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
42
42
  payload.ratio = (+payload.suppliedUsd && +payload.borrowedUsd) ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
43
43
  payload.collRatio = (+payload.suppliedUsd && +payload.borrowedUsd) ? new Dec(payload.suppliedUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
44
+ payload.safetyRatio = payload.ratio;
44
45
  const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApyLiquityV2(usedAssets, assetsData, interestRate);
45
46
  payload.netApy = netApy;
46
47
  payload.incentiveUsd = incentiveUsd;
@@ -36,6 +36,8 @@ export const getLlamaLendAggregatedData = (_a) => {
36
36
  : '0';
37
37
  // this is all approximation
38
38
  payload.minAllowedRatio = mapRange(numOfBands, 4, 50, 115, 140); // collateral ratio
39
+ // Collateral ratio rebased so 100 sits on the band-derived minimum (normalised safety ratio, same scale as the other protocols).
40
+ payload.safetyRatio = loanExists && payload.minAllowedRatio ? new Dec(payload.ratio).div(payload.minAllowedRatio).mul(100).toString() : '0';
39
41
  payload.collFactor = new Dec(1).div(payload.minAllowedRatio).mul(100).toString(); // collateral factor = 1 / collateral ratio
40
42
  // only take in consideration collAsset
41
43
  payload.borrowLimitUsd = ((_b = usedAssets === null || usedAssets === void 0 ? void 0 : usedAssets[collAsset]) === null || _b === void 0 ? void 0 : _b.isSupplied)
@@ -1,4 +1,4 @@
1
- export declare const parseCollateralInfo: (ilk: string, _par: string, _mat: string, _art: string, _rate: string, _spot: string, _line: string, _duty: string, _futureRate: string, _chop: string) => {
1
+ export declare const parseCollateralInfo: (ilk: string, _par: string, _mat: string, _art: string, _rate: string, _spot: string, _line: string, _dust: string, _duty: string, _futureRate: string, _chop: string) => {
2
2
  ilkLabel: string;
3
3
  currentRate: string;
4
4
  futureRate: string;
@@ -1,14 +1,14 @@
1
1
  import Dec from 'decimal.js';
2
2
  import { SECONDS_PER_YEAR } from '../../constants';
3
3
  import { bytesToString } from '../../services/utils';
4
- export const parseCollateralInfo = (ilk, _par, _mat, _art, _rate, _spot, _line, _duty, _futureRate, _chop) => {
4
+ export const parseCollateralInfo = (ilk, _par, _mat, _art, _rate, _spot, _line, _dust, _duty, _futureRate, _chop) => {
5
5
  const par = new Dec(_par).div(1e27).toString();
6
6
  const mat = new Dec(_mat).div(1e27).toString();
7
7
  const art = new Dec(_art).toString();
8
8
  const rate = new Dec(_rate).toString();
9
9
  const spot = new Dec(_spot).div(1e27).toString();
10
10
  const line = new Dec(_line).div(1e45).toString();
11
- const dust = new Dec(_rate).div(1e45).toString();
11
+ const dust = new Dec(_dust).div(1e45).toString(); // Vat.ilks.dust, rad (1e45) -> DAI
12
12
  const duty = new Dec(_duty).toString();
13
13
  const futureRate = new Dec(_futureRate).toString();
14
14
  const chop = new Dec(_chop).div(1e18).toString();
@@ -40,6 +40,8 @@ export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, ma
40
40
  payload.ltv = new Dec(((_c = usedAssets[loanToken]) === null || _c === void 0 ? void 0 : _c.borrowed) || 0).div(oracle).div(((_d = usedAssets[collateralToken]) === null || _d === void 0 ? void 0 : _d.supplied) || 1).toString(); // default to 1 because can't div 0
41
41
  payload.ratio = new Dec(((_e = usedAssets[collateralToken]) === null || _e === void 0 ? void 0 : _e.supplied) || 0).mul(oracle).div(((_f = usedAssets[loanToken]) === null || _f === void 0 ? void 0 : _f.borrowed) || 1).mul(100)
42
42
  .toString();
43
+ // Borrow limit over debt, so 100 sits on the market's LLTV however low it is (`ratio` is the raw collateral ratio).
44
+ payload.safetyRatio = +payload.borrowedUsd > 0 ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
43
45
  const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
44
46
  payload.leveragedType = leveragedType;
45
47
  payload.liquidationPrice = '';
@@ -58,6 +58,8 @@ export const getMorphoMidnightAggregatedPositionData = ({ usedAssets, assetsData
58
58
  payload.ltv = new Dec(payload.suppliedCollateralUsd).eq(0) ? '0' : new Dec(payload.borrowedUsd).div(payload.suppliedCollateralUsd).toString();
59
59
  payload.ratio = new Dec(payload.borrowedUsd).eq(0) ? '0' : new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString();
60
60
  payload.healthRatio = new Dec(payload.borrowedUsd).eq(0) ? 'Infinity' : new Dec(payload.liquidationLimitUsd).div(payload.borrowedUsd).toDP(4).toString();
61
+ // Borrow limit over debt, so 100 sits on the market's LLTV however low it is (`ratio` is the raw collateral ratio).
62
+ payload.safetyRatio = +payload.borrowedUsd > 0 ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
61
63
  const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
62
64
  payload.leveragedType = leveragedType;
63
65
  payload.liquidationPrice = '';
@@ -70,6 +70,7 @@ export const sparkGetAggregatedPositionData = (_a) => {
70
70
  payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
71
71
  payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
72
72
  payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
73
+ payload.safetyRatio = payload.ratio;
73
74
  const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy({ usedAssets, assetsData });
74
75
  payload.netApy = netApy;
75
76
  payload.incentiveUsd = incentiveUsd;
@@ -68,6 +68,11 @@ export const _getLiquityTroveInfo = (provider, network, address) => __awaiter(vo
68
68
  _getDebtInFront(viewContract, address),
69
69
  ]);
70
70
  const recoveryMode = troveInfo[6];
71
+ const minCollateralRatio = recoveryMode ? LIQUITY_RECOVERY_MODE_RATIO : LIQUITY_NORMAL_MODE_RATIO;
72
+ const collateral = assetAmountInEth(troveInfo[1].toString());
73
+ const debtInAsset = assetAmountInEth(troveInfo[2].toString());
74
+ const collRatio = +debtInAsset ? new Dec(collateral).mul(assetAmountInEth(assetPrice.toString())).div(debtInAsset).mul(100)
75
+ .toString() : '0';
71
76
  const payload = {
72
77
  troveStatus: LIQUITY_TROVE_STATUS_ENUM[+(troveInfo[0].toString())],
73
78
  collateral: assetAmountInEth(troveInfo[1].toString()),
@@ -80,7 +85,9 @@ export const _getLiquityTroveInfo = (provider, network, address) => __awaiter(vo
80
85
  totalETH: totalETH.toString(),
81
86
  totalLUSD: totalLUSD.toString(),
82
87
  debtInFront: debtInFront.toString(),
83
- minCollateralRatio: recoveryMode ? LIQUITY_RECOVERY_MODE_RATIO : LIQUITY_NORMAL_MODE_RATIO,
88
+ minCollateralRatio,
89
+ // Collateral ratio rebased so 100 sits on the trove's minimum collateral ratio (normalised safety ratio).
90
+ safetyRatio: +minCollateralRatio > 0 ? new Dec(collRatio).div(minCollateralRatio).mul(100).toString() : '0',
84
91
  priceForRecovery: new Dec(recoveryMode ? LIQUITY_RECOVERY_MODE_RATIO : LIQUITY_NORMAL_MODE_RATIO).mul(totalLUSD).div(totalETH).div(100)
85
92
  .toString(),
86
93
  exposure: getExposure(assetAmountInEth(troveInfo[2].toString()), new Dec(assetAmountInEth(troveInfo[1].toString())).mul(assetPrice).toString()),
@@ -1,9 +1,14 @@
1
1
  import { Client, PublicClient } from 'viem';
2
2
  import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
3
- import { CdpData, CdpInfo } from '../types';
3
+ import { CdpData, CdpInfo, IlkInfo } from '../types';
4
4
  export declare const _getMakerAccountBalances: (provider: PublicClient, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress) => Promise<PositionBalances>;
5
5
  export declare const getMakerAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress) => Promise<PositionBalances>;
6
6
  export declare const _getUserCdps: (provider: Client, network: NetworkNumber, userAddress: EthAddress) => Promise<CdpInfo[]>;
7
7
  export declare const getUserCdps: (provider: EthereumProvider, network: NetworkNumber, userAddress: EthAddress) => Promise<CdpInfo[]>;
8
- export declare const _getMakerCdpData: (provider: Client, network: NetworkNumber, cdp: CdpInfo) => Promise<CdpData>;
8
+ export declare const _getMakerIlksData: (provider: Client, network: NetworkNumber, ilkLabels: string[]) => Promise<Record<string, IlkInfo>>;
9
+ export declare const getMakerIlksData: (provider: EthereumProvider, network: NetworkNumber, ilkLabels: string[]) => Promise<Record<string, IlkInfo>>;
10
+ /**
11
+ * @param ilkInfo optional precomputed ilk data (from `_getMakerIlksData`); when provided the per-ilk reads are skipped
12
+ */
13
+ export declare const _getMakerCdpData: (provider: Client, network: NetworkNumber, cdp: CdpInfo, ilkInfo?: IlkInfo) => Promise<CdpData>;
9
14
  export declare const getMakerCdpData: (provider: EthereumProvider, network: NetworkNumber, cdp: CdpInfo) => Promise<CdpData>;
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import Dec from 'decimal.js';
11
- import { assetAmountInEth, bytesToString, getAssetInfo, ilkToAsset, } from '@defisaver/tokens';
11
+ import { assetAmountInEth, bytesToString, getAssetInfo, ilkToAsset, stringToBytes, } from '@defisaver/tokens';
12
12
  import { getConfigContractAddress, McdDogContractViem, McdGetCdpsContractViem, McdJugContractViem, McdSpotterContractViem, McdVatContractViem, McdViewContractViem, } from '../contracts';
13
- import { CdpType } from '../types';
13
+ import { CdpType, } from '../types';
14
14
  import { wethToEth } from '../services/utils';
15
15
  import { parseCollateralInfo } from '../helpers/makerHelpers';
16
16
  import { getViemProvider, setViemBlockNumber } from '../services/viem';
@@ -38,7 +38,7 @@ export const _getMakerAccountBalances = (provider, network, block, addressMappin
38
38
  // [urn, owner, userAddr, ilk, collateral, debt]
39
39
  const cdpInfo = yield viewContract.read.getCdpInfo((needsIlk ? [managerAddress, cdpId, ilk] : [cdpId]), setViemBlockNumber(block));
40
40
  cdpInfo.ilk = cdpInfo[3];
41
- const [par, [_, mat], [artGlobal, rate, spot, line], [duty], futureRate, chop,] = yield Promise.all([
41
+ const [par, [_, mat], [artGlobal, rate, spot, line, dust], [duty], futureRate, chop,] = yield Promise.all([
42
42
  spotterContract.read.par(setViemBlockNumber(block)),
43
43
  spotterContract.read.ilks(needsIlk ? [ilk] : [cdpInfo.ilk], setViemBlockNumber(block)),
44
44
  vatContract.read.ilks(needsIlk ? [ilk] : [cdpInfo.ilk], setViemBlockNumber(block)),
@@ -46,7 +46,7 @@ export const _getMakerAccountBalances = (provider, network, block, addressMappin
46
46
  jugContract.read.drip(needsIlk ? [ilk] : [cdpInfo.ilk], setViemBlockNumber(block)),
47
47
  dogContract.read.chop(needsIlk ? [ilk] : [cdpInfo.ilk], setViemBlockNumber(block)),
48
48
  ]);
49
- const ilkInfo = parseCollateralInfo(needsIlk ? ilk : cdpInfo.ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), duty.toString(), futureRate.toString(), chop.toString());
49
+ const ilkInfo = parseCollateralInfo(needsIlk ? ilk : cdpInfo.ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), dust.toString(), duty.toString(), futureRate.toString(), chop.toString());
50
50
  const collateral = cdpInfo[4];
51
51
  const debt = cdpInfo[5];
52
52
  const asset = wethToEth(ilkToAsset(needsIlk ? ilk : cdpInfo.ilk));
@@ -80,22 +80,37 @@ export const _getUserCdps = (provider, network, userAddress) => __awaiter(void 0
80
80
  return parsedStandardCdps;
81
81
  });
82
82
  export const getUserCdps = (provider, network, userAddress) => __awaiter(void 0, void 0, void 0, function* () { return _getUserCdps(getViemProvider(provider, network), network, userAddress); });
83
- export const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, void 0, void 0, function* () {
83
+ export const _getMakerIlksData = (provider, network, ilkLabels) => __awaiter(void 0, void 0, void 0, function* () {
84
84
  const vatContract = McdVatContractViem(provider, network);
85
85
  const spotterContract = McdSpotterContractViem(provider, network);
86
86
  const dogContract = McdDogContractViem(provider, network);
87
87
  const jugContract = McdJugContractViem(provider, network);
88
- const [[ink, art], coll, par, [_, mat], [artGlobal, rate, spot, line], [duty], futureRate, chop,] = yield Promise.all([
88
+ const par = yield spotterContract.read.par();
89
+ const ilksInfo = yield Promise.all(ilkLabels.map((ilkLabel) => __awaiter(void 0, void 0, void 0, function* () {
90
+ const ilk = stringToBytes(ilkLabel);
91
+ const [[_, mat], [artGlobal, rate, spot, line, dust], [duty], futureRate, chop,] = yield Promise.all([
92
+ spotterContract.read.ilks([ilk]),
93
+ vatContract.read.ilks([ilk]),
94
+ jugContract.read.ilks([ilk]),
95
+ jugContract.read.drip([ilk]),
96
+ dogContract.read.chop([ilk]),
97
+ ]);
98
+ return parseCollateralInfo(ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), dust.toString(), duty.toString(), futureRate.toString(), chop.toString());
99
+ })));
100
+ return Object.fromEntries(ilksInfo.map((ilkInfo) => [ilkInfo.ilkLabel, ilkInfo]));
101
+ });
102
+ export const getMakerIlksData = (provider, network, ilkLabels) => __awaiter(void 0, void 0, void 0, function* () { return _getMakerIlksData(getViemProvider(provider, network, { batch: { multicall: true } }), network, ilkLabels); });
103
+ /**
104
+ * @param ilkInfo optional precomputed ilk data (from `_getMakerIlksData`); when provided the per-ilk reads are skipped
105
+ */
106
+ export const _getMakerCdpData = (provider, network, cdp, ilkInfo) => __awaiter(void 0, void 0, void 0, function* () {
107
+ const vatContract = McdVatContractViem(provider, network);
108
+ const [[ink, art], coll, fetchedIlkInfo,] = yield Promise.all([
89
109
  vatContract.read.urns([cdp.ilk, cdp.urn]),
90
110
  vatContract.read.gem([cdp.ilk, cdp.urn]),
91
- spotterContract.read.par(),
92
- spotterContract.read.ilks([cdp.ilk]),
93
- vatContract.read.ilks([cdp.ilk]),
94
- jugContract.read.ilks([cdp.ilk]),
95
- jugContract.read.drip([cdp.ilk]),
96
- dogContract.read.chop([cdp.ilk]),
111
+ ilkInfo || _getMakerIlksData(provider, network, [cdp.ilkLabel]).then((ilks) => ilks[cdp.ilkLabel]),
97
112
  ]);
98
- const collInfo = parseCollateralInfo(cdp.ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), duty.toString(), futureRate.toString(), chop.toString());
113
+ const collInfo = fetchedIlkInfo;
99
114
  const collateral = assetAmountInEth(ink.toString(), `MCD-${cdp.asset}`);
100
115
  const collateralUsd = new Dec(collateral).mul(collInfo.assetPrice).toString();
101
116
  const debt = new Dec(art).times(collInfo.currentRate).div(1e27).floor()
@@ -107,6 +122,8 @@ export const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, vo
107
122
  .toString();
108
123
  if (new Dec(debt).eq(0))
109
124
  ratio = '0';
125
+ // Collateral ratio rebased so 100 sits on the ilk's liquidation ratio (normalised safety ratio).
126
+ const safetyRatio = +collInfo.liqPercent > 0 ? new Dec(ratio).div(collInfo.liqPercent).mul(100).toString() : '0';
110
127
  const debtTooLow = new Dec(debt).gt(0) && new Dec(assetAmountInEth(debt, 'DAI')).lt(collInfo.minDebt);
111
128
  return {
112
129
  owner: cdp.owner,
@@ -126,6 +143,7 @@ export const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, vo
126
143
  debtAssetMarketPrice: '1',
127
144
  liquidationPrice,
128
145
  ratio,
146
+ safetyRatio,
129
147
  liqRatio: collInfo.liqRatio.toString(),
130
148
  liqPercent: parseFloat(collInfo.liqPercent.toString()),
131
149
  assetPrice: collInfo.assetPrice,
@@ -8,3 +8,4 @@ export { LlamaLendMarkets } from './llamaLend';
8
8
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
9
9
  export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
10
10
  export { AaveV4Spokes, findAaveV4SpokeByAddress } from './aaveV4';
11
+ export { MakerActiveIlks } from './maker';
@@ -8,3 +8,4 @@ export { LlamaLendMarkets } from './llamaLend';
8
8
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
9
9
  export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
10
10
  export { AaveV4Spokes, findAaveV4SpokeByAddress } from './aaveV4';
11
+ export { MakerActiveIlks } from './maker';
@@ -0,0 +1 @@
1
+ export declare const MakerActiveIlks: string[];