@defisaver/positions-sdk 2.1.173 → 2.1.175-looping-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 (99) hide show
  1. package/cjs/aaveV3/index.d.ts +2 -12
  2. package/cjs/aaveV3/sgho.d.ts +2 -16
  3. package/cjs/aaveV4/lend.d.ts +2 -43
  4. package/cjs/claiming/aaveV3.d.ts +2 -2
  5. package/cjs/claiming/ethena.d.ts +2 -1
  6. package/cjs/claiming/king.d.ts +2 -1
  7. package/cjs/claiming/spark.d.ts +2 -2
  8. package/cjs/config/contracts.d.ts +4 -4
  9. package/cjs/config/contracts.js +4 -4
  10. package/cjs/fluid/index.d.ts +5 -49
  11. package/cjs/liquity/index.d.ts +2 -12
  12. package/cjs/liquityV2/index.d.ts +8 -23
  13. package/cjs/liquityV2/index.js +37 -19
  14. package/cjs/portfolio/index.d.ts +16 -8
  15. package/cjs/portfolio/index.js +458 -520
  16. package/cjs/portfolio/lendingProtocols.d.ts +184 -0
  17. package/cjs/portfolio/lendingProtocols.js +196 -0
  18. package/cjs/savings/index.d.ts +8 -2
  19. package/cjs/savings/index.js +33 -4
  20. package/cjs/types/aave.d.ts +98 -2
  21. package/cjs/types/aaveV4.d.ts +44 -0
  22. package/cjs/types/compound.d.ts +26 -2
  23. package/cjs/types/curveUsd.d.ts +9 -1
  24. package/cjs/types/fluid.d.ts +13 -0
  25. package/cjs/types/index.d.ts +1 -0
  26. package/cjs/types/index.js +1 -0
  27. package/cjs/types/liquity.d.ts +12 -0
  28. package/cjs/types/liquityV2.d.ts +24 -0
  29. package/cjs/types/llamaLend.d.ts +12 -1
  30. package/cjs/types/morphoBlue.d.ts +2 -0
  31. package/cjs/types/portfolio.d.ts +125 -5
  32. package/cjs/types/savings/index.d.ts +9 -1
  33. package/cjs/types/spark.d.ts +21 -1
  34. package/cjs/umbrella/index.d.ts +2 -3
  35. package/esm/aaveV3/index.d.ts +2 -12
  36. package/esm/aaveV3/sgho.d.ts +2 -16
  37. package/esm/aaveV4/lend.d.ts +2 -43
  38. package/esm/claiming/aaveV3.d.ts +2 -2
  39. package/esm/claiming/aaveV3.js +1 -1
  40. package/esm/claiming/ethena.d.ts +2 -1
  41. package/esm/claiming/king.d.ts +2 -1
  42. package/esm/claiming/spark.d.ts +2 -2
  43. package/esm/claiming/spark.js +1 -1
  44. package/esm/config/contracts.d.ts +4 -4
  45. package/esm/config/contracts.js +4 -4
  46. package/esm/fluid/index.d.ts +5 -49
  47. package/esm/liquity/index.d.ts +2 -12
  48. package/esm/liquityV2/index.d.ts +8 -23
  49. package/esm/liquityV2/index.js +35 -18
  50. package/esm/portfolio/index.d.ts +16 -8
  51. package/esm/portfolio/index.js +458 -522
  52. package/esm/portfolio/lendingProtocols.d.ts +184 -0
  53. package/esm/portfolio/lendingProtocols.js +189 -0
  54. package/esm/savings/index.d.ts +8 -2
  55. package/esm/savings/index.js +31 -3
  56. package/esm/types/aave.d.ts +98 -2
  57. package/esm/types/aaveV4.d.ts +44 -0
  58. package/esm/types/compound.d.ts +26 -2
  59. package/esm/types/curveUsd.d.ts +9 -1
  60. package/esm/types/fluid.d.ts +13 -0
  61. package/esm/types/index.d.ts +1 -0
  62. package/esm/types/index.js +1 -0
  63. package/esm/types/liquity.d.ts +12 -0
  64. package/esm/types/liquityV2.d.ts +24 -0
  65. package/esm/types/llamaLend.d.ts +12 -1
  66. package/esm/types/morphoBlue.d.ts +2 -0
  67. package/esm/types/portfolio.d.ts +125 -5
  68. package/esm/types/savings/index.d.ts +9 -1
  69. package/esm/types/spark.d.ts +21 -1
  70. package/esm/umbrella/index.d.ts +2 -3
  71. package/package.json +1 -1
  72. package/src/aaveV3/index.ts +2 -1
  73. package/src/aaveV3/sgho.ts +2 -17
  74. package/src/aaveV4/lend.ts +2 -48
  75. package/src/claiming/aaveV3.ts +4 -2
  76. package/src/claiming/ethena.ts +5 -5
  77. package/src/claiming/king.ts +3 -3
  78. package/src/claiming/spark.ts +6 -4
  79. package/src/config/contracts.ts +4 -4
  80. package/src/fluid/index.ts +4 -3
  81. package/src/liquity/index.ts +2 -2
  82. package/src/liquityV2/index.ts +48 -22
  83. package/src/portfolio/index.ts +306 -331
  84. package/src/portfolio/lendingProtocols.ts +281 -0
  85. package/src/savings/index.ts +41 -4
  86. package/src/types/aave.ts +104 -1
  87. package/src/types/aaveV4.ts +49 -0
  88. package/src/types/compound.ts +38 -2
  89. package/src/types/curveUsd.ts +17 -1
  90. package/src/types/fluid.ts +14 -0
  91. package/src/types/index.ts +1 -0
  92. package/src/types/liquity.ts +13 -1
  93. package/src/types/liquityV2.ts +26 -1
  94. package/src/types/llamaLend.ts +19 -1
  95. package/src/types/morphoBlue.ts +3 -0
  96. package/src/types/portfolio.ts +151 -5
  97. package/src/types/savings/index.ts +12 -1
  98. package/src/types/spark.ts +25 -1
  99. package/src/umbrella/index.ts +2 -1
@@ -97839,16 +97839,16 @@ export declare const FluidView: {
97839
97839
  }];
97840
97840
  readonly networks: {
97841
97841
  readonly "1": {
97842
- readonly address: "0x0cBa1CD5F88D40CE1aCFF9927e8Fea1111bC643d";
97842
+ readonly address: "0xDd71a9cd4902a0BA417e609b986FA6A96D465C57";
97843
97843
  };
97844
97844
  readonly "8453": {
97845
- readonly address: "0x6cd4D6af4F292817eA2A2311F099dF26cd015028";
97845
+ readonly address: "0x533C19808a1612c411fe8C1B5CBbee44bE1921B9";
97846
97846
  };
97847
97847
  readonly "9745": {
97848
- readonly address: "0x27C0BAe2338cE28097122393faF90375B9395dd1";
97848
+ readonly address: "0xBd2d2d4718C24B8D35168480553b1F5a11f9884b";
97849
97849
  };
97850
97850
  readonly "42161": {
97851
- readonly address: "0x7d80a45eFA1F9033D5390fC8A3Ccd26eF1C8463e";
97851
+ readonly address: "0xc63b7847202324E3F3746A2f1E275598e33D5404";
97852
97852
  };
97853
97853
  };
97854
97854
  };
@@ -1218,10 +1218,10 @@ export const LiquityV2StabilityPool = {
1218
1218
  export const FluidView = {
1219
1219
  "abi": [{ "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getAllUserEarnPositionsWithFTokens", "outputs": [{ "components": [{ "internalType": "uint256", "name": "fTokenShares", "type": "uint256" }, { "internalType": "uint256", "name": "underlyingAssets", "type": "uint256" }, { "internalType": "uint256", "name": "underlyingBalance", "type": "uint256" }, { "internalType": "uint256", "name": "allowance", "type": "uint256" }], "internalType": "struct FluidView.UserEarnPosition[]", "name": "userPositions", "type": "tuple[]" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "bool", "name": "isNativeUnderlying", "type": "bool" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "symbol", "type": "string" }, { "internalType": "uint256", "name": "decimals", "type": "uint256" }, { "internalType": "address", "name": "asset", "type": "address" }, { "internalType": "uint256", "name": "totalAssets", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "convertToShares", "type": "uint256" }, { "internalType": "uint256", "name": "convertToAssets", "type": "uint256" }, { "internalType": "uint256", "name": "rewardsRate", "type": "uint256" }, { "internalType": "uint256", "name": "supplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "bool", "name": "modeWithInterest", "type": "bool" }, { "internalType": "uint256", "name": "expandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "expandDuration", "type": "uint256" }], "internalType": "struct FluidView.FTokenData[]", "name": "fTokensData", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_fToken", "type": "address" }], "name": "getFTokenData", "outputs": [{ "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "bool", "name": "isNativeUnderlying", "type": "bool" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "symbol", "type": "string" }, { "internalType": "uint256", "name": "decimals", "type": "uint256" }, { "internalType": "address", "name": "asset", "type": "address" }, { "internalType": "uint256", "name": "totalAssets", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "convertToShares", "type": "uint256" }, { "internalType": "uint256", "name": "convertToAssets", "type": "uint256" }, { "internalType": "uint256", "name": "rewardsRate", "type": "uint256" }, { "internalType": "uint256", "name": "supplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "bool", "name": "modeWithInterest", "type": "bool" }, { "internalType": "uint256", "name": "expandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "expandDuration", "type": "uint256" }], "internalType": "struct FluidView.FTokenData", "name": "fTokenData", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_nftId", "type": "uint256" }], "name": "getPositionByNftId", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition", "name": "position", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }, { "components": [{ "internalType": "address", "name": "dexPool", "type": "address" }, { "internalType": "uint256", "name": "dexId", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "lastStoredPrice", "type": "uint256" }, { "internalType": "uint256", "name": "centerPrice", "type": "uint256" }, { "internalType": "uint256", "name": "token0Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "token1Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "maxSupplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "token0Supplied", "type": "uint256" }, { "internalType": "uint256", "name": "token1Supplied", "type": "uint256" }, { "internalType": "uint256", "name": "sharesWithdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token0Withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token1Withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token0PerSupplyShare", "type": "uint256" }, { "internalType": "uint256", "name": "token1PerSupplyShare", "type": "uint256" }, { "internalType": "uint256", "name": "token0SupplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "token1SupplyRate", "type": "uint256" }, { "internalType": "address", "name": "quoteToken", "type": "address" }, { "internalType": "uint256", "name": "quoteTokensPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken0Reserves", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Reserves", "type": "uint256" }], "internalType": "struct FluidView.DexSupplyData", "name": "dexSupplyData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "dexPool", "type": "address" }, { "internalType": "uint256", "name": "dexId", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "lastStoredPrice", "type": "uint256" }, { "internalType": "uint256", "name": "centerPrice", "type": "uint256" }, { "internalType": "uint256", "name": "token0Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "token1Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "token0Borrowed", "type": "uint256" }, { "internalType": "uint256", "name": "token1Borrowed", "type": "uint256" }, { "internalType": "uint256", "name": "sharesBorrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token0Borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token1Borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token0PerBorrowShare", "type": "uint256" }, { "internalType": "uint256", "name": "token1PerBorrowShare", "type": "uint256" }, { "internalType": "uint256", "name": "token0BorrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "token1BorrowRate", "type": "uint256" }, { "internalType": "address", "name": "quoteToken", "type": "address" }, { "internalType": "uint256", "name": "quoteTokensPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Reserves", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Reserves", "type": "uint256" }], "internalType": "struct FluidView.DexBorrowData", "name": "dexBorrowData", "type": "tuple" }], "internalType": "struct FluidView.VaultData", "name": "vault", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_fToken", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserEarnPosition", "outputs": [{ "components": [{ "internalType": "uint256", "name": "fTokenShares", "type": "uint256" }, { "internalType": "uint256", "name": "underlyingAssets", "type": "uint256" }, { "internalType": "uint256", "name": "underlyingBalance", "type": "uint256" }, { "internalType": "uint256", "name": "allowance", "type": "uint256" }], "internalType": "struct FluidView.UserEarnPosition", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_fToken", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserEarnPositionWithFToken", "outputs": [{ "components": [{ "internalType": "uint256", "name": "fTokenShares", "type": "uint256" }, { "internalType": "uint256", "name": "underlyingAssets", "type": "uint256" }, { "internalType": "uint256", "name": "underlyingBalance", "type": "uint256" }, { "internalType": "uint256", "name": "allowance", "type": "uint256" }], "internalType": "struct FluidView.UserEarnPosition", "name": "userPosition", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "bool", "name": "isNativeUnderlying", "type": "bool" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "symbol", "type": "string" }, { "internalType": "uint256", "name": "decimals", "type": "uint256" }, { "internalType": "address", "name": "asset", "type": "address" }, { "internalType": "uint256", "name": "totalAssets", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "convertToShares", "type": "uint256" }, { "internalType": "uint256", "name": "convertToAssets", "type": "uint256" }, { "internalType": "uint256", "name": "rewardsRate", "type": "uint256" }, { "internalType": "uint256", "name": "supplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "bool", "name": "modeWithInterest", "type": "bool" }, { "internalType": "uint256", "name": "expandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "expandDuration", "type": "uint256" }], "internalType": "struct FluidView.FTokenData", "name": "fTokenData", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserNftIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserPositions", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition[]", "name": "positions", "type": "tuple[]" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }, { "components": [{ "internalType": "address", "name": "dexPool", "type": "address" }, { "internalType": "uint256", "name": "dexId", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "lastStoredPrice", "type": "uint256" }, { "internalType": "uint256", "name": "centerPrice", "type": "uint256" }, { "internalType": "uint256", "name": "token0Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "token1Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "maxSupplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "token0Supplied", "type": "uint256" }, { "internalType": "uint256", "name": "token1Supplied", "type": "uint256" }, { "internalType": "uint256", "name": "sharesWithdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token0Withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token1Withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token0PerSupplyShare", "type": "uint256" }, { "internalType": "uint256", "name": "token1PerSupplyShare", "type": "uint256" }, { "internalType": "uint256", "name": "token0SupplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "token1SupplyRate", "type": "uint256" }, { "internalType": "address", "name": "quoteToken", "type": "address" }, { "internalType": "uint256", "name": "quoteTokensPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken0Reserves", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Reserves", "type": "uint256" }], "internalType": "struct FluidView.DexSupplyData", "name": "dexSupplyData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "dexPool", "type": "address" }, { "internalType": "uint256", "name": "dexId", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "lastStoredPrice", "type": "uint256" }, { "internalType": "uint256", "name": "centerPrice", "type": "uint256" }, { "internalType": "uint256", "name": "token0Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "token1Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "token0Borrowed", "type": "uint256" }, { "internalType": "uint256", "name": "token1Borrowed", "type": "uint256" }, { "internalType": "uint256", "name": "sharesBorrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token0Borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token1Borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token0PerBorrowShare", "type": "uint256" }, { "internalType": "uint256", "name": "token1PerBorrowShare", "type": "uint256" }, { "internalType": "uint256", "name": "token0BorrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "token1BorrowRate", "type": "uint256" }, { "internalType": "address", "name": "quoteToken", "type": "address" }, { "internalType": "uint256", "name": "quoteTokensPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Reserves", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Reserves", "type": "uint256" }], "internalType": "struct FluidView.DexBorrowData", "name": "dexBorrowData", "type": "tuple" }], "internalType": "struct FluidView.VaultData[]", "name": "vaults", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_vault", "type": "address" }], "name": "getVaultData", "outputs": [{ "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }, { "components": [{ "internalType": "address", "name": "dexPool", "type": "address" }, { "internalType": "uint256", "name": "dexId", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "lastStoredPrice", "type": "uint256" }, { "internalType": "uint256", "name": "centerPrice", "type": "uint256" }, { "internalType": "uint256", "name": "token0Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "token1Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "maxSupplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "token0Supplied", "type": "uint256" }, { "internalType": "uint256", "name": "token1Supplied", "type": "uint256" }, { "internalType": "uint256", "name": "sharesWithdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token0Withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token1Withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "token0PerSupplyShare", "type": "uint256" }, { "internalType": "uint256", "name": "token1PerSupplyShare", "type": "uint256" }, { "internalType": "uint256", "name": "token0SupplyRate", "type": "uint256" }, { "internalType": "uint256", "name": "token1SupplyRate", "type": "uint256" }, { "internalType": "address", "name": "quoteToken", "type": "address" }, { "internalType": "uint256", "name": "quoteTokensPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken0Reserves", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Reserves", "type": "uint256" }], "internalType": "struct FluidView.DexSupplyData", "name": "dexSupplyData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "dexPool", "type": "address" }, { "internalType": "uint256", "name": "dexId", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "lastStoredPrice", "type": "uint256" }, { "internalType": "uint256", "name": "centerPrice", "type": "uint256" }, { "internalType": "uint256", "name": "token0Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "token1Utilization", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "token0Borrowed", "type": "uint256" }, { "internalType": "uint256", "name": "token1Borrowed", "type": "uint256" }, { "internalType": "uint256", "name": "sharesBorrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token0Borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token1Borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "token0PerBorrowShare", "type": "uint256" }, { "internalType": "uint256", "name": "token1PerBorrowShare", "type": "uint256" }, { "internalType": "uint256", "name": "token0BorrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "token1BorrowRate", "type": "uint256" }, { "internalType": "address", "name": "quoteToken", "type": "address" }, { "internalType": "uint256", "name": "quoteTokensPerShare", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Reserves", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Reserves", "type": "uint256" }], "internalType": "struct FluidView.DexBorrowData", "name": "dexBorrowData", "type": "tuple" }], "internalType": "struct FluidView.VaultData", "name": "vaultData", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
1220
1220
  "networks": {
1221
- "1": { "address": "0x0cBa1CD5F88D40CE1aCFF9927e8Fea1111bC643d" },
1222
- "8453": { "address": "0x6cd4D6af4F292817eA2A2311F099dF26cd015028" },
1223
- "9745": { "address": "0x27C0BAe2338cE28097122393faF90375B9395dd1" },
1224
- "42161": { "address": "0x7d80a45eFA1F9033D5390fC8A3Ccd26eF1C8463e" }
1221
+ "1": { "address": "0xDd71a9cd4902a0BA417e609b986FA6A96D465C57" },
1222
+ "8453": { "address": "0x533C19808a1612c411fe8C1B5CBbee44bE1921B9" },
1223
+ "9745": { "address": "0xBd2d2d4718C24B8D35168480553b1F5a11f9884b" },
1224
+ "42161": { "address": "0xc63b7847202324E3F3746A2f1E275598e33D5404" }
1225
1225
  }
1226
1226
  };
1227
1227
  export const McdGetCdps = {
@@ -1,6 +1,6 @@
1
1
  import { Client, PublicClient } from 'viem';
2
2
  import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
3
- import { FluidAssetsData, FluidMarketData, FluidMarketInfo, FluidUsedAssets, FluidVaultData, InnerFluidMarketData } from '../types';
3
+ import { FluidAssetsData, FluidEarnPositionData, FluidMarketData, FluidMarketInfo, FluidUsedAssets, FluidVaultData, InnerFluidMarketData } from '../types';
4
4
  export { FluidMerklOpportunityType, buildFluidMerklRewardMap, getFluidMerklCampaigns, attachFluidMerklIncentives, } from './merkl';
5
5
  export declare const EMPTY_USED_ASSET: {
6
6
  isSupplied: boolean;
@@ -71,54 +71,10 @@ export declare const getFluidTokenData: (provider: EthereumProvider, network: Ne
71
71
  depositRate: string;
72
72
  withdrawRate: string;
73
73
  }>;
74
- export declare const _getFluidDepositData: (provider: Client, network: NetworkNumber, token: string, address: EthAddress) => Promise<{
75
- fTokenAddress: string | undefined;
76
- fTokenSymbol: string;
77
- decimals: string;
78
- totalDeposited: string;
79
- withdrawable: string;
80
- apy: string;
81
- depositRate: string;
82
- withdrawRate: string;
83
- deposited: string;
84
- depositedShares: string;
85
- }>;
86
- export declare const getFluidDepositData: (provider: EthereumProvider, network: NetworkNumber, token: string, address: EthAddress) => Promise<{
87
- fTokenAddress: string | undefined;
88
- fTokenSymbol: string;
89
- decimals: string;
90
- totalDeposited: string;
91
- withdrawable: string;
92
- apy: string;
93
- depositRate: string;
94
- withdrawRate: string;
95
- deposited: string;
96
- depositedShares: string;
97
- }>;
98
- export declare const _getAllUserEarnPositionsWithFTokens: (provider: Client, network: NetworkNumber, user: EthAddress) => Promise<{
99
- fTokenAddress: string | undefined;
100
- fTokenSymbol: string;
101
- decimals: string;
102
- totalDeposited: string;
103
- withdrawable: string;
104
- apy: string;
105
- depositRate: string;
106
- withdrawRate: string;
107
- deposited: string;
108
- depositedShares: string;
109
- }[]>;
110
- export declare const getAllUserEarnPositionsWithFTokens: (provider: EthereumProvider, network: NetworkNumber, user: EthAddress) => Promise<{
111
- fTokenAddress: string | undefined;
112
- fTokenSymbol: string;
113
- decimals: string;
114
- totalDeposited: string;
115
- withdrawable: string;
116
- apy: string;
117
- depositRate: string;
118
- withdrawRate: string;
119
- deposited: string;
120
- depositedShares: string;
121
- }[]>;
74
+ export declare const _getFluidDepositData: (provider: Client, network: NetworkNumber, token: string, address: EthAddress) => Promise<FluidEarnPositionData>;
75
+ export declare const getFluidDepositData: (provider: EthereumProvider, network: NetworkNumber, token: string, address: EthAddress) => Promise<FluidEarnPositionData>;
76
+ export declare const _getAllUserEarnPositionsWithFTokens: (provider: Client, network: NetworkNumber, user: EthAddress) => Promise<FluidEarnPositionData[]>;
77
+ export declare const getAllUserEarnPositionsWithFTokens: (provider: EthereumProvider, network: NetworkNumber, user: EthAddress) => Promise<FluidEarnPositionData[]>;
122
78
  export declare const _getUserPositions: (provider: PublicClient, network: NetworkNumber, user: EthAddress) => Promise<{
123
79
  marketData: FluidMarketData | undefined;
124
80
  userData: {
@@ -1,6 +1,6 @@
1
1
  import { Client } from 'viem';
2
2
  import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
3
- import { LiquityTroveInfo } from '../types';
3
+ import { LiquityStakingData, LiquityTroveInfo } from '../types';
4
4
  export declare const LIQUITY_NORMAL_MODE_RATIO = 110;
5
5
  export declare const LIQUITY_RECOVERY_MODE_RATIO = 150;
6
6
  export declare const _getLiquityAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
@@ -8,14 +8,4 @@ export declare const getLiquityAccountBalances: (provider: EthereumProvider, net
8
8
  export declare const getDebtInFront: (provider: EthereumProvider, address: EthAddress) => Promise<string>;
9
9
  export declare const _getLiquityTroveInfo: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<LiquityTroveInfo>;
10
10
  export declare const getLiquityTroveInfo: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress) => Promise<LiquityTroveInfo>;
11
- export declare const getLiquityStakingData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<{
12
- totalLUSDDeposited: string;
13
- totalLQTYStaked: string;
14
- stakedLQTY: string;
15
- stakedLUSDBalance: string;
16
- rewardETH: string;
17
- rewardLUSD: string;
18
- stabilityRewardETH: string;
19
- stabilityRewardLQTY: string;
20
- showStakingBalances: boolean;
21
- }>;
11
+ export declare const getLiquityStakingData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<LiquityStakingData>;
@@ -1,6 +1,6 @@
1
1
  import { Client, PublicClient } from 'viem';
2
2
  import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
3
- import { LiquityV2AssetsData, LiquityV2MarketData, LiquityV2MarketInfo, LiquityV2TroveData, LiquityV2Versions } from '../types';
3
+ import { LiquityV2AssetsData, LiquityV2MarketData, LiquityV2MarketInfo, LiquityV2SBoldYBoldData, LiquityV2StakingData, LiquityV2TroveData, LiquityV2Versions } from '../types';
4
4
  export type SPYieldGainParameters = {
5
5
  P: string;
6
6
  aggWeightedDebtSum: string;
@@ -19,6 +19,11 @@ export declare const nftContractCreationBlockMapping: {
19
19
  liquityv2wstethlegacy: number;
20
20
  liquityv2rethlegacy: number;
21
21
  };
22
+ /**
23
+ * The trove ids of several accounts in one market: the market's NFT transfers are read once for all of them, rather
24
+ * than once per account as _getLiquityV2UserTroveIds does.
25
+ */
26
+ export declare const _getLiquityV2UsersTroveIds: (provider: PublicClient, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo, troveNFTAddress: EthAddress, limitBlocksForEventFetching: boolean, accounts: EthAddress[]) => Promise<Record<EthAddress, string[]>>;
22
27
  export declare const _getLiquityV2UserTroveIds: (provider: PublicClient, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo, troveNFTAddress: EthAddress, limitBlocksForEventFetching: boolean, account: EthAddress) => Promise<{
23
28
  troves: {
24
29
  troveId: string;
@@ -52,25 +57,5 @@ export type sBoldYieldParameters = {
52
57
  wsETH: string;
53
58
  rETH: string;
54
59
  };
55
- export declare const getLiquityV2Staking: (provider: Client, network: NetworkNumber, market: LiquityV2Versions, user: EthAddress) => Promise<{
56
- totalBOLDDeposited: string;
57
- stakedBOLDBalance: string;
58
- stabilityRewardColl: string;
59
- stabilityRewardYield: string;
60
- showStakingBalances: boolean;
61
- debtTokenBalance: string;
62
- stabilityPoolApy: string;
63
- }>;
64
- export declare const getLiquitySAndYBold: (provider: Client, network: NetworkNumber, markets: any, user: EthAddress) => Promise<{
65
- spApy: string;
66
- yBoldApy: string;
67
- totalBoldDepositedSBold: string;
68
- boldRateSBold: string;
69
- maxWithdrawSBold: string;
70
- totalBoldDepositedYBold: string;
71
- boldRateYBold: string;
72
- maxWithdrawYBold: string;
73
- sBoldBalance: string;
74
- yBoldBalance: string;
75
- stYBoldBalance: string;
76
- }>;
60
+ export declare const getLiquityV2Staking: (provider: Client, network: NetworkNumber, market: LiquityV2Versions, user: EthAddress) => Promise<LiquityV2StakingData>;
61
+ export declare const getLiquitySAndYBold: (provider: Client, network: NetworkNumber, markets: any, user: EthAddress) => Promise<LiquityV2SBoldYBoldData>;
@@ -122,36 +122,53 @@ export const nftContractCreationBlockMapping = {
122
122
  [LiquityV2Versions.LiquityV2WstEthLegacy]: 21686238,
123
123
  [LiquityV2Versions.LiquityV2REthLegacy]: 21686257,
124
124
  };
125
- const getTransferredTroves = (provider, network, troveNFTAddress, limitBlocksForEventFetching, market, account) => __awaiter(void 0, void 0, void 0, function* () {
125
+ /** Every Transfer of a market's trove NFT since the contract was created (or, on a fork, in the last 1000 blocks). */
126
+ const getTroveTransfers = (provider, network, troveNFTAddress, limitBlocksForEventFetching, market) => __awaiter(void 0, void 0, void 0, function* () {
126
127
  const nftContract = createViemContractFromConfigFunc('LiquityV2TroveNFT', troveNFTAddress)(provider, network);
127
128
  const nftContractCreationBlock = nftContractCreationBlockMapping[market];
128
129
  const currentBlock = +(yield provider.getBlockNumber()).toString();
129
130
  const _events = yield nftContract.getEvents.Transfer({}, { fromBlock: limitBlocksForEventFetching ? BigInt(currentBlock - 1000) : BigInt(nftContractCreationBlock) });
130
- const events = _events.map((event) => ({
131
+ return _events.map((event) => ({
131
132
  from: event.args.from, to: event.args.to, tokenId: event.args.tokenId.toString(), blockNumber: +(event.blockNumber.toString()),
132
133
  }));
133
- const userTransferredTroves = events.filter((event) => compareAddresses(event.to, account));
134
- // check if the last know transfer address is the user
135
- userTransferredTroves.forEach((event, index) => {
136
- const otherTransfers = events.filter((e) => event.blockNumber < e.blockNumber && e.tokenId === event.tokenId);
137
- // @ts-ignore
138
- userTransferredTroves[index].invalid = !!otherTransfers.length;
139
- });
140
- // @ts-ignore
141
- return userTransferredTroves.filter((event) => !event.invalid).map((event) => ({ troveId: event.tokenId }));
142
134
  });
143
- export const _getLiquityV2UserTroveIds = (provider, network, selectedMarket, troveNFTAddress, limitBlocksForEventFetching, account) => __awaiter(void 0, void 0, void 0, function* () {
144
- const [{ troves: userTroves, nextFreeTroveIndex }, userTransferredTroves] = yield Promise.all([
145
- getUserTroves(provider, network, selectedMarket.isLegacy, account, selectedMarket.marketAddress),
146
- getTransferredTroves(provider, network, troveNFTAddress, limitBlocksForEventFetching, selectedMarket.value, account),
147
- ]);
135
+ /** The troves transferred to an account that it still holds: no later transfer of the same trove. */
136
+ const getAccountTransferredTroves = (events, account) => events
137
+ .filter((event) => compareAddresses(event.to, account))
138
+ .filter((event) => !events.some((e) => event.blockNumber < e.blockNumber && e.tokenId === event.tokenId))
139
+ .map((event) => ({ troveId: event.tokenId }));
140
+ const getTransferredTroves = (provider, network, troveNFTAddress, limitBlocksForEventFetching, market, account) => __awaiter(void 0, void 0, void 0, function* () {
141
+ return (getAccountTransferredTroves(yield getTroveTransfers(provider, network, troveNFTAddress, limitBlocksForEventFetching, market), account));
142
+ });
143
+ /** The troves an account opened and still owns, then the ones transferred to it, each once. */
144
+ const mergeTroveIds = (userTroves, userTransferredTroves) => {
148
145
  const troves = [...userTroves.map(({ troveId }) => ({ troveId })), ...userTransferredTroves];
149
146
  const filteredTroves = troves.filter((value, index, self) => index === self.findIndex((t) => (t.troveId === value.troveId)));
150
147
  const troveIds = filteredTroves.map((trove) => trove.troveId);
151
148
  const troveIdsSet = new Set(troveIds);
152
149
  const troveIdsArray = Array.from(troveIdsSet);
153
- const trovesNoDuplicates = troveIdsArray.map((troveId) => troves.find((trove) => trove.troveId === troveId));
154
- return { troves: trovesNoDuplicates, nextFreeTroveIndex };
150
+ return troveIdsArray.map((troveId) => troves.find((trove) => trove.troveId === troveId));
151
+ };
152
+ /**
153
+ * The trove ids of several accounts in one market: the market's NFT transfers are read once for all of them, rather
154
+ * than once per account as _getLiquityV2UserTroveIds does.
155
+ */
156
+ export const _getLiquityV2UsersTroveIds = (provider, network, selectedMarket, troveNFTAddress, limitBlocksForEventFetching, accounts) => __awaiter(void 0, void 0, void 0, function* () {
157
+ const [userTroves, events] = yield Promise.all([
158
+ Promise.all(accounts.map((account) => getUserTroves(provider, network, selectedMarket.isLegacy, account, selectedMarket.marketAddress))),
159
+ getTroveTransfers(provider, network, troveNFTAddress, limitBlocksForEventFetching, selectedMarket.value),
160
+ ]);
161
+ return Object.fromEntries(accounts.map((account, i) => [
162
+ account,
163
+ mergeTroveIds(userTroves[i].troves, getAccountTransferredTroves(events, account)).map(({ troveId }) => troveId),
164
+ ]));
165
+ });
166
+ export const _getLiquityV2UserTroveIds = (provider, network, selectedMarket, troveNFTAddress, limitBlocksForEventFetching, account) => __awaiter(void 0, void 0, void 0, function* () {
167
+ const [{ troves: userTroves, nextFreeTroveIndex }, userTransferredTroves] = yield Promise.all([
168
+ getUserTroves(provider, network, selectedMarket.isLegacy, account, selectedMarket.marketAddress),
169
+ getTransferredTroves(provider, network, troveNFTAddress, limitBlocksForEventFetching, selectedMarket.value, account),
170
+ ]);
171
+ return { troves: mergeTroveIds(userTroves, userTransferredTroves), nextFreeTroveIndex };
155
172
  });
156
173
  export const getLiquityV2UserTroveIds = (provider, network, selectedMarket, troveNFTAddress, limitBlocksForEventFetching, account) => __awaiter(void 0, void 0, void 0, function* () { return _getLiquityV2UserTroveIds(getViemProvider(provider, network), network, selectedMarket, troveNFTAddress, limitBlocksForEventFetching, account); });
157
174
  const getDebtInFrontForSingleMarketLiquityV2 = (provider_1, network_1, isLegacy_1, marketAddress_1, troveId_1, ...args_1) => __awaiter(void 0, [provider_1, network_1, isLegacy_1, marketAddress_1, troveId_1, ...args_1], void 0, function* (provider, network, isLegacy, marketAddress, troveId, accumulatedSum = '0', iterations = 2000) {
@@ -1,14 +1,22 @@
1
1
  import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
2
- import { PortfolioMarketsData, PortfolioPositionsData } from '../types';
3
- export declare function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim?: boolean): Promise<{
4
- positions: PortfolioPositionsData;
5
- stakingPositions: any;
6
- rewardsData: any;
7
- markets: any;
8
- }>;
2
+ import { PortfolioData, PortfolioDataOptions, PortfolioMarketsData, PortfolioMarketsResult, PortfolioPositionsData, PortfolioUserData, ShifterPortfolioMarketsData } from '../types';
3
+ /**
4
+ * Every market the portfolio reads on a network — the markets half of getPortfolioData, for a caller that keeps
5
+ * markets apart from what it reads per address (a cache shared by many addresses). A market that fails is left out
6
+ * of `markets` and named in `errors`.
7
+ */
8
+ export declare function getPortfolioMarketsData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, isSim?: boolean): Promise<PortfolioMarketsResult>;
9
+ /**
10
+ * What the portfolio reads per address — the other half of getPortfolioData — against `markets` from
11
+ * getPortfolioMarketsData. `markets` can be a promise: reads that do not need a market (Maker, Fluid, Liquity, staking,
12
+ * rewards) start at once, and each read on a market waits for it. A position on a market missing from `markets` is an
13
+ * entry with an error.
14
+ */
15
+ export declare function getPortfolioUserData(provider: EthereumProvider, network: NetworkNumber, addresses: EthAddress[], markets: PortfolioMarketsData | Promise<PortfolioMarketsData>, isSim?: boolean, options?: PortfolioDataOptions): Promise<PortfolioUserData>;
16
+ export declare function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim?: boolean, options?: PortfolioDataOptions): Promise<PortfolioData>;
9
17
  export declare function getShifterPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim?: boolean): Promise<{
10
18
  positions: PortfolioPositionsData;
11
- markets: PortfolioMarketsData;
19
+ markets: ShifterPortfolioMarketsData;
12
20
  }>;
13
21
  export * from './discovery';
14
22
  export { getWalletLendingSummaries } from './lendingSummaries';