@defisaver/positions-sdk 0.0.46 → 0.0.48

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 (90) hide show
  1. package/cjs/aaveV2/index.js +1 -1
  2. package/cjs/config/contracts.d.ts +236 -0
  3. package/cjs/config/contracts.js +25 -1
  4. package/cjs/contracts.d.ts +1 -0
  5. package/cjs/contracts.js +2 -1
  6. package/cjs/helpers/index.d.ts +1 -0
  7. package/cjs/helpers/index.js +2 -1
  8. package/cjs/helpers/llamaLendHelpers/index.d.ts +9 -0
  9. package/cjs/helpers/llamaLendHelpers/index.js +53 -0
  10. package/cjs/index.d.ts +3 -1
  11. package/cjs/index.js +4 -1
  12. package/cjs/llamaLend/index.d.ts +7 -0
  13. package/cjs/llamaLend/index.js +232 -0
  14. package/cjs/markets/index.d.ts +1 -0
  15. package/cjs/markets/index.js +3 -1
  16. package/cjs/markets/llamaLend/index.d.ts +12 -0
  17. package/cjs/markets/llamaLend/index.js +53 -0
  18. package/cjs/morphoAaveV2/index.js +1 -1
  19. package/cjs/services/utils.d.ts +1 -0
  20. package/cjs/services/utils.js +3 -1
  21. package/cjs/setup.d.ts +1 -0
  22. package/cjs/setup.js +12 -0
  23. package/cjs/types/contracts/generated/LlamaLendCRVCrvUSDController.d.ts +209 -0
  24. package/cjs/types/contracts/generated/LlamaLendCRVCrvUSDController.js +5 -0
  25. package/cjs/types/contracts/generated/LlamaLendCrvUSDCRVDController.d.ts +209 -0
  26. package/cjs/types/contracts/generated/LlamaLendCrvUSDCRVDController.js +5 -0
  27. package/cjs/types/contracts/generated/LlamaLendView.d.ts +260 -0
  28. package/cjs/types/contracts/generated/LlamaLendView.js +5 -0
  29. package/cjs/types/contracts/generated/LlamaLendWstETHCrvUSDController.d.ts +209 -0
  30. package/cjs/types/contracts/generated/LlamaLendWstETHCrvUSDController.js +5 -0
  31. package/cjs/types/contracts/generated/index.d.ts +4 -0
  32. package/cjs/types/index.d.ts +1 -0
  33. package/cjs/types/index.js +1 -0
  34. package/cjs/types/llamaLend.d.ts +110 -0
  35. package/cjs/types/llamaLend.js +17 -0
  36. package/esm/aaveV2/index.js +1 -1
  37. package/esm/config/contracts.d.ts +236 -0
  38. package/esm/config/contracts.js +25 -1
  39. package/esm/contracts.d.ts +1 -0
  40. package/esm/contracts.js +1 -0
  41. package/esm/helpers/index.d.ts +1 -0
  42. package/esm/helpers/index.js +1 -0
  43. package/esm/helpers/llamaLendHelpers/index.d.ts +9 -0
  44. package/esm/helpers/llamaLendHelpers/index.js +46 -0
  45. package/esm/index.d.ts +3 -1
  46. package/esm/index.js +3 -1
  47. package/esm/llamaLend/index.d.ts +7 -0
  48. package/esm/llamaLend/index.js +222 -0
  49. package/esm/markets/index.d.ts +1 -0
  50. package/esm/markets/index.js +1 -0
  51. package/esm/markets/llamaLend/index.d.ts +12 -0
  52. package/esm/markets/llamaLend/index.js +45 -0
  53. package/esm/morphoAaveV2/index.js +1 -1
  54. package/esm/services/utils.d.ts +1 -0
  55. package/esm/services/utils.js +1 -0
  56. package/esm/setup.d.ts +1 -0
  57. package/esm/setup.js +7 -0
  58. package/esm/types/contracts/generated/LlamaLendCRVCrvUSDController.d.ts +209 -0
  59. package/esm/types/contracts/generated/LlamaLendCRVCrvUSDController.js +4 -0
  60. package/esm/types/contracts/generated/LlamaLendCrvUSDCRVDController.d.ts +209 -0
  61. package/esm/types/contracts/generated/LlamaLendCrvUSDCRVDController.js +4 -0
  62. package/esm/types/contracts/generated/LlamaLendView.d.ts +260 -0
  63. package/esm/types/contracts/generated/LlamaLendView.js +4 -0
  64. package/esm/types/contracts/generated/LlamaLendWstETHCrvUSDController.d.ts +209 -0
  65. package/esm/types/contracts/generated/LlamaLendWstETHCrvUSDController.js +4 -0
  66. package/esm/types/contracts/generated/index.d.ts +4 -0
  67. package/esm/types/index.d.ts +1 -0
  68. package/esm/types/index.js +1 -0
  69. package/esm/types/llamaLend.d.ts +110 -0
  70. package/esm/types/llamaLend.js +14 -0
  71. package/package.json +1 -1
  72. package/src/aaveV2/index.ts +2 -2
  73. package/src/config/contracts.js +25 -1
  74. package/src/contracts.ts +3 -1
  75. package/src/helpers/index.ts +2 -1
  76. package/src/helpers/llamaLendHelpers/index.ts +45 -0
  77. package/src/index.ts +4 -0
  78. package/src/llamaLend/index.ts +272 -0
  79. package/src/markets/index.ts +2 -1
  80. package/src/markets/llamaLend/index.ts +51 -0
  81. package/src/morphoAaveV2/index.ts +2 -2
  82. package/src/services/utils.ts +4 -1
  83. package/src/setup.ts +8 -0
  84. package/src/types/contracts/generated/LlamaLendCRVCrvUSDController.ts +416 -0
  85. package/src/types/contracts/generated/LlamaLendCrvUSDCRVDController.ts +416 -0
  86. package/src/types/contracts/generated/LlamaLendView.ts +335 -0
  87. package/src/types/contracts/generated/LlamaLendWstETHCrvUSDController.ts +416 -0
  88. package/src/types/contracts/generated/index.ts +4 -0
  89. package/src/types/index.ts +2 -1
  90. package/src/types/llamaLend.ts +118 -0
@@ -817,5 +817,29 @@ module.exports = {
817
817
  "networks": {
818
818
  "1": { "address": "0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf" }
819
819
  }
820
- }
820
+ },
821
+ "LlamaLendView": {
822
+ "abi": [{ "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "uint256", "name": "collateral", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }, { "internalType": "uint256", "name": "N", "type": "uint256" }], "name": "createLoanData", "outputs": [{ "components": [{ "internalType": "int256", "name": "health", "type": "int256" }, { "internalType": "uint256", "name": "minColl", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrow", "type": "uint256" }, { "components": [{ "internalType": "int256", "name": "id", "type": "int256" }, { "internalType": "uint256", "name": "lowPrice", "type": "uint256" }, { "internalType": "uint256", "name": "highPrice", "type": "uint256" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }], "internalType": "struct LlamaLendView.Band[]", "name": "bands", "type": "tuple[]" }], "internalType": "struct LlamaLendView.CreateLoanData", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "int256", "name": "n", "type": "int256" }], "name": "getBandData", "outputs": [{ "components": [{ "internalType": "int256", "name": "id", "type": "int256" }, { "internalType": "uint256", "name": "lowPrice", "type": "uint256" }, { "internalType": "uint256", "name": "highPrice", "type": "uint256" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }], "internalType": "struct LlamaLendView.Band", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "int256", "name": "from", "type": "int256" }, { "internalType": "int256", "name": "to", "type": "int256" }], "name": "getBandsData", "outputs": [{ "components": [{ "internalType": "int256", "name": "id", "type": "int256" }, { "internalType": "uint256", "name": "lowPrice", "type": "uint256" }, { "internalType": "uint256", "name": "highPrice", "type": "uint256" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }], "internalType": "struct LlamaLendView.Band[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "uint256", "name": "collateral", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }, { "internalType": "uint256", "name": "N", "type": "uint256" }], "name": "getBandsDataForPosition", "outputs": [{ "components": [{ "internalType": "int256", "name": "id", "type": "int256" }, { "internalType": "uint256", "name": "lowPrice", "type": "uint256" }, { "internalType": "uint256", "name": "highPrice", "type": "uint256" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }], "internalType": "struct LlamaLendView.Band[]", "name": "bands", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_controllerAddress", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getCollAmountsFromAMM", "outputs": [{ "internalType": "uint256", "name": "debtAssetCollAmount", "type": "uint256" }, { "internalType": "uint256", "name": "collAssetCollAmount", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }, { "internalType": "address", "name": "_controllerAddr", "type": "address" }], "name": "getCollateralRatio", "outputs": [{ "internalType": "uint256", "name": "collRatio", "type": "uint256" }, { "internalType": "bool", "name": "isInSoftLiquidation", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }], "name": "globalData", "outputs": [{ "components": [{ "internalType": "address", "name": "collateralToken", "type": "address" }, { "internalType": "address", "name": "debtToken", "type": "address" }, { "internalType": "uint256", "name": "decimals", "type": "uint256" }, { "internalType": "int256", "name": "activeBand", "type": "int256" }, { "internalType": "uint256", "name": "A", "type": "uint256" }, { "internalType": "uint256", "name": "totalDebt", "type": "uint256" }, { "internalType": "uint256", "name": "ammPrice", "type": "uint256" }, { "internalType": "uint256", "name": "basePrice", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePrice", "type": "uint256" }, { "internalType": "uint256", "name": "minted", "type": "uint256" }, { "internalType": "uint256", "name": "redeemed", "type": "uint256" }, { "internalType": "uint256", "name": "monetaryPolicyRate", "type": "uint256" }, { "internalType": "uint256", "name": "ammRate", "type": "uint256" }, { "internalType": "int256", "name": "minBand", "type": "int256" }, { "internalType": "int256", "name": "maxBand", "type": "int256" }, { "internalType": "uint256", "name": "borrowApr", "type": "uint256" }, { "internalType": "uint256", "name": "lendApr", "type": "uint256" }, { "internalType": "uint256", "name": "debtTokenTotalSupply", "type": "uint256" }, { "internalType": "uint256", "name": "debtTokenLeftToBorrow", "type": "uint256" }], "internalType": "struct LlamaLendView.GlobalData", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "address", "name": "user", "type": "address" }, { "internalType": "int256", "name": "collChange", "type": "int256" }, { "internalType": "int256", "name": "debtChange", "type": "int256" }, { "internalType": "bool", "name": "isFull", "type": "bool" }, { "internalType": "uint256", "name": "numBands", "type": "uint256" }], "name": "healthCalculator", "outputs": [{ "internalType": "int256", "name": "health", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "uint256", "name": "collateral", "type": "uint256" }, { "internalType": "uint256", "name": "N", "type": "uint256" }], "name": "maxBorrow", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }, { "internalType": "uint256", "name": "N", "type": "uint256" }], "name": "minCollateral", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "address", "name": "user", "type": "address" }], "name": "userData", "outputs": [{ "components": [{ "internalType": "bool", "name": "loanExists", "type": "bool" }, { "internalType": "uint256", "name": "collateralPrice", "type": "uint256" }, { "internalType": "uint256", "name": "marketCollateralAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtTokenCollateralAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }, { "internalType": "uint256", "name": "N", "type": "uint256" }, { "internalType": "uint256", "name": "priceLow", "type": "uint256" }, { "internalType": "uint256", "name": "priceHigh", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationDiscount", "type": "uint256" }, { "internalType": "int256", "name": "health", "type": "int256" }, { "internalType": "int256[2]", "name": "bandRange", "type": "int256[2]" }, { "internalType": "uint256[][2]", "name": "usersBands", "type": "uint256[][2]" }, { "internalType": "uint256", "name": "collRatio", "type": "uint256" }, { "internalType": "bool", "name": "isInSoftLiquidation", "type": "bool" }, { "internalType": "uint256", "name": "debtTokenSuppliedShares", "type": "uint256" }, { "internalType": "uint256", "name": "debtTokenSuppliedAssets", "type": "uint256" }], "internalType": "struct LlamaLendView.UserData", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_controllerAddress", "type": "address" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "userMaxWithdraw", "outputs": [{ "internalType": "uint256", "name": "maxWithdraw", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
823
+ "networks": {
824
+ "1": { "address": "0x27b97dc577af680435351cf4f3ccb9470d911e71" }
825
+ }
826
+ },
827
+ "LlamaLendWstETHCrvUSDController": {
828
+ "abi": [{ "name": "UserState", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }, { "name": "n1", "type": "int256", "indexed": false }, { "name": "n2", "type": "int256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Borrow", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_increase", "type": "uint256", "indexed": false }, { "name": "loan_increase", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Repay", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }, { "name": "loan_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "RemoveCollateral", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Liquidate", "inputs": [{ "name": "liquidator", "type": "address", "indexed": true }, { "name": "user", "type": "address", "indexed": true }, { "name": "collateral_received", "type": "uint256", "indexed": false }, { "name": "stablecoin_received", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetMonetaryPolicy", "inputs": [{ "name": "monetary_policy", "type": "address", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetBorrowingDiscounts", "inputs": [{ "name": "loan_discount", "type": "uint256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "CollectFees", "inputs": [{ "name": "amount", "type": "uint256", "indexed": false }, { "name": "new_supply", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "stateMutability": "nonpayable", "type": "constructor", "inputs": [{ "name": "collateral_token", "type": "address" }, { "name": "monetary_policy", "type": "address" }, { "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }, { "name": "amm", "type": "address" }], "outputs": [] }, { "stateMutability": "pure", "type": "function", "name": "factory", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "amm", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "collateral_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "borrowed_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "save_rate", "inputs": [], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "debt", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_exists", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "total_debt", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "current_debt", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "min_collateral", "inputs": [{ "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "calculate_debt_n1", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay_extended", "inputs": [{ "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate_extended", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "frac", "type": "uint256" }, { "name": "use_eth", "type": "bool" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "frac", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }, { "name": "_limit", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "amm_price", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "user_prices", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[2]" }] }, { "stateMutability": "view", "type": "function", "name": "user_state", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[4]" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_admin_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_monetary_policy", "inputs": [{ "name": "monetary_policy", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_borrowing_discounts", "inputs": [{ "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_callback", "inputs": [{ "name": "cb", "type": "address" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "admin_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "collect_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "check_lock", "inputs": [], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discounts", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loans", "inputs": [{ "name": "arg0", "type": "uint256" }], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "loan_ix", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "n_loans", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "minted", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "redeemed", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "monetary_policy", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }],
829
+ "networks": {
830
+ "1": { "address": "0x5E657c5227A596a860621C5551c9735d8f4A8BE3" }
831
+ }
832
+ },
833
+ "LlamaLendCRVCrvUSDController": {
834
+ "abi": [{ "name": "UserState", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }, { "name": "n1", "type": "int256", "indexed": false }, { "name": "n2", "type": "int256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Borrow", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_increase", "type": "uint256", "indexed": false }, { "name": "loan_increase", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Repay", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }, { "name": "loan_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "RemoveCollateral", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Liquidate", "inputs": [{ "name": "liquidator", "type": "address", "indexed": true }, { "name": "user", "type": "address", "indexed": true }, { "name": "collateral_received", "type": "uint256", "indexed": false }, { "name": "stablecoin_received", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetMonetaryPolicy", "inputs": [{ "name": "monetary_policy", "type": "address", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetBorrowingDiscounts", "inputs": [{ "name": "loan_discount", "type": "uint256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "CollectFees", "inputs": [{ "name": "amount", "type": "uint256", "indexed": false }, { "name": "new_supply", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "stateMutability": "nonpayable", "type": "constructor", "inputs": [{ "name": "collateral_token", "type": "address" }, { "name": "monetary_policy", "type": "address" }, { "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }, { "name": "amm", "type": "address" }], "outputs": [] }, { "stateMutability": "pure", "type": "function", "name": "factory", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "amm", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "collateral_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "borrowed_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "save_rate", "inputs": [], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "debt", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_exists", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "total_debt", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "current_debt", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "min_collateral", "inputs": [{ "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "calculate_debt_n1", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay_extended", "inputs": [{ "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate_extended", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "frac", "type": "uint256" }, { "name": "use_eth", "type": "bool" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "frac", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }, { "name": "_limit", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "amm_price", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "user_prices", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[2]" }] }, { "stateMutability": "view", "type": "function", "name": "user_state", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[4]" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_admin_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_monetary_policy", "inputs": [{ "name": "monetary_policy", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_borrowing_discounts", "inputs": [{ "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_callback", "inputs": [{ "name": "cb", "type": "address" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "admin_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "collect_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "check_lock", "inputs": [], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discounts", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loans", "inputs": [{ "name": "arg0", "type": "uint256" }], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "loan_ix", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "n_loans", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "minted", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "redeemed", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "monetary_policy", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }],
835
+ "networks": {
836
+ "1": { "address": "0x7443944962D04720f8c220C0D25f56F869d6EfD4" }
837
+ }
838
+ },
839
+ "LlamaLendCrvUSDCRVDController": {
840
+ "abi": [{ "name": "UserState", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }, { "name": "n1", "type": "int256", "indexed": false }, { "name": "n2", "type": "int256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Borrow", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_increase", "type": "uint256", "indexed": false }, { "name": "loan_increase", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Repay", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }, { "name": "loan_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "RemoveCollateral", "inputs": [{ "name": "user", "type": "address", "indexed": true }, { "name": "collateral_decrease", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "Liquidate", "inputs": [{ "name": "liquidator", "type": "address", "indexed": true }, { "name": "user", "type": "address", "indexed": true }, { "name": "collateral_received", "type": "uint256", "indexed": false }, { "name": "stablecoin_received", "type": "uint256", "indexed": false }, { "name": "debt", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetMonetaryPolicy", "inputs": [{ "name": "monetary_policy", "type": "address", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "SetBorrowingDiscounts", "inputs": [{ "name": "loan_discount", "type": "uint256", "indexed": false }, { "name": "liquidation_discount", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "name": "CollectFees", "inputs": [{ "name": "amount", "type": "uint256", "indexed": false }, { "name": "new_supply", "type": "uint256", "indexed": false }], "anonymous": false, "type": "event" }, { "stateMutability": "nonpayable", "type": "constructor", "inputs": [{ "name": "collateral_token", "type": "address" }, { "name": "monetary_policy", "type": "address" }, { "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }, { "name": "amm", "type": "address" }], "outputs": [] }, { "stateMutability": "pure", "type": "function", "name": "factory", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "amm", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "collateral_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "pure", "type": "function", "name": "borrowed_token", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "save_rate", "inputs": [], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "debt", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_exists", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "total_debt", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "max_borrowable", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "current_debt", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "min_collateral", "inputs": [{ "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "calculate_debt_n1", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "create_loan_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "N", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "add_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "remove_collateral", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "borrow_more_extended", "inputs": [{ "name": "collateral", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay", "inputs": [{ "name": "_d_debt", "type": "uint256" }, { "name": "_for", "type": "address" }, { "name": "max_active_band", "type": "int256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "repay_extended", "inputs": [{ "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health_calculator", "inputs": [{ "name": "user", "type": "address" }, { "name": "d_collateral", "type": "int256" }, { "name": "d_debt", "type": "int256" }, { "name": "full", "type": "bool" }, { "name": "N", "type": "uint256" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "use_eth", "type": "bool" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "liquidate_extended", "inputs": [{ "name": "user", "type": "address" }, { "name": "min_x", "type": "uint256" }, { "name": "frac", "type": "uint256" }, { "name": "use_eth", "type": "bool" }, { "name": "callbacker", "type": "address" }, { "name": "callback_args", "type": "uint256[]" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "tokens_to_liquidate", "inputs": [{ "name": "user", "type": "address" }, { "name": "frac", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "health", "inputs": [{ "name": "user", "type": "address" }, { "name": "full", "type": "bool" }], "outputs": [{ "name": "", "type": "int256" }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "users_to_liquidate", "inputs": [{ "name": "_from", "type": "uint256" }, { "name": "_limit", "type": "uint256" }], "outputs": [{ "name": "", "type": "tuple[]", "components": [{ "name": "user", "type": "address" }, { "name": "x", "type": "uint256" }, { "name": "y", "type": "uint256" }, { "name": "debt", "type": "uint256" }, { "name": "health", "type": "int256" }] }] }, { "stateMutability": "view", "type": "function", "name": "amm_price", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "user_prices", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[2]" }] }, { "stateMutability": "view", "type": "function", "name": "user_state", "inputs": [{ "name": "user", "type": "address" }], "outputs": [{ "name": "", "type": "uint256[4]" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_amm_admin_fee", "inputs": [{ "name": "fee", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_monetary_policy", "inputs": [{ "name": "monetary_policy", "type": "address" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_borrowing_discounts", "inputs": [{ "name": "loan_discount", "type": "uint256" }, { "name": "liquidation_discount", "type": "uint256" }], "outputs": [] }, { "stateMutability": "nonpayable", "type": "function", "name": "set_callback", "inputs": [{ "name": "cb", "type": "address" }], "outputs": [] }, { "stateMutability": "view", "type": "function", "name": "admin_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "nonpayable", "type": "function", "name": "collect_fees", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "check_lock", "inputs": [], "outputs": [{ "name": "", "type": "bool" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discounts", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loans", "inputs": [{ "name": "arg0", "type": "uint256" }], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "loan_ix", "inputs": [{ "name": "arg0", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "n_loans", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "minted", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "redeemed", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "monetary_policy", "inputs": [], "outputs": [{ "name": "", "type": "address" }] }, { "stateMutability": "view", "type": "function", "name": "liquidation_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "loan_discount", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }],
841
+ "networks": {
842
+ "1": { "address": "0x43fc0f246F952ff12B757341A91cF4040711dDE9" }
843
+ }
844
+ },
821
845
  };
@@ -44,3 +44,4 @@ export declare const COMPPriceFeedContract: (web3: Web3, network: NetworkNumber,
44
44
  export declare const USDCPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.USDCPriceFeed;
45
45
  export declare const FeedRegistryContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.FeedRegistry;
46
46
  export declare const MorphoBlueViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.MorphoBlueView;
47
+ export declare const LlamaLendViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LlamaLendView;
package/esm/contracts.js CHANGED
@@ -76,3 +76,4 @@ export const COMPPriceFeedContract = createContractFromConfigFunc('COMPPriceFeed
76
76
  export const USDCPriceFeedContract = createContractFromConfigFunc('USDCPriceFeed');
77
77
  export const FeedRegistryContract = createContractFromConfigFunc('FeedRegistry');
78
78
  export const MorphoBlueViewContract = createContractFromConfigFunc('MorphoBlueView');
79
+ export const LlamaLendViewContract = createContractFromConfigFunc('LlamaLendView');
@@ -5,3 +5,4 @@ export * as curveUsdHelpers from './curveUsdHelpers';
5
5
  export * as makerHelpers from './makerHelpers';
6
6
  export * as chickenBondsHelpers from './chickenBondsHelpers';
7
7
  export * as morphoBlueHelpers from './morphoBlueHelpers';
8
+ export * as llamaLendHelpers from './llamaLendHelpers';
@@ -5,3 +5,4 @@ export * as curveUsdHelpers from './curveUsdHelpers';
5
5
  export * as makerHelpers from './makerHelpers';
6
6
  export * as chickenBondsHelpers from './chickenBondsHelpers';
7
7
  export * as morphoBlueHelpers from './morphoBlueHelpers';
8
+ export * as llamaLendHelpers from './llamaLendHelpers';
@@ -0,0 +1,9 @@
1
+ import { LlamaLendAggregatedPositionData, LlamaLendMarketData, LlamaLendUsedAssets } from '../../types';
2
+ import { NetworkNumber } from '../../types/common';
3
+ export declare const getLlamaLendAggregatedData: ({ loanExists, usedAssets, network, selectedMarket, numOfBands, ...rest }: {
4
+ loanExists: boolean;
5
+ usedAssets: LlamaLendUsedAssets;
6
+ network: NetworkNumber;
7
+ selectedMarket: LlamaLendMarketData;
8
+ numOfBands: number | string;
9
+ }) => LlamaLendAggregatedPositionData;
@@ -0,0 +1,46 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import Dec from 'decimal.js';
13
+ import { calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos } from '../../moneymarket';
14
+ import { mapRange } from '../../services/utils';
15
+ export const getLlamaLendAggregatedData = (_a) => {
16
+ var _b;
17
+ var { loanExists, usedAssets, network, selectedMarket, numOfBands } = _a, rest = __rest(_a, ["loanExists", "usedAssets", "network", "selectedMarket", "numOfBands"]);
18
+ const collAsset = selectedMarket.collAsset;
19
+ const debtAsset = selectedMarket.baseAsset;
20
+ const payload = {};
21
+ // payload.supplied = getAssetsTotal(usedAssets, ({ isSupplied }: { isSupplied: boolean }) => isSupplied, ({ supplied }: { supplied: string }) => supplied);
22
+ // payload.borrowed = getAssetsTotal(usedAssets, ({ isBorrowed }: { isBorrowed: boolean }) => isBorrowed, ({ borrowed }: { borrowed: string }) => borrowed);
23
+ payload.suppliedUsd = getAssetsTotal(usedAssets, ({ collateral }) => collateral, ({ suppliedUsd }) => suppliedUsd);
24
+ payload.borrowedUsd = getAssetsTotal(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd);
25
+ payload.suppliedForYieldUsd = getAssetsTotal(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedForYield }) => suppliedForYield || '0');
26
+ payload.ratio = loanExists
27
+ ? new Dec(payload.suppliedUsd)
28
+ .dividedBy(payload.borrowedUsd)
29
+ .times(100)
30
+ .toString()
31
+ : '0';
32
+ // this is all approximation
33
+ payload.minAllowedRatio = mapRange(numOfBands, 4, 50, 115, 140); // collateral ratio
34
+ payload.collFactor = new Dec(1).div(payload.minAllowedRatio).mul(100).toString(); // collateral factor = 1 / collateral ratio
35
+ // only take in consideration collAsset
36
+ payload.borrowLimitUsd = ((_b = usedAssets === null || usedAssets === void 0 ? void 0 : usedAssets[collAsset]) === null || _b === void 0 ? void 0 : _b.isSupplied)
37
+ ? new Dec(usedAssets[collAsset].suppliedUsd).mul(payload.collFactor).toString()
38
+ : '0';
39
+ const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
40
+ payload.leveragedType = leveragedType;
41
+ if (leveragedType !== '') {
42
+ payload.leveragedAsset = leveragedAsset;
43
+ payload.liquidationPrice = calcLeverageLiqPrice(leveragedType, usedAssets[collAsset].price, payload.borrowedUsd, payload.borrowLimitUsd);
44
+ }
45
+ return payload;
46
+ };
package/esm/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import './setup';
1
2
  import * as aaveV3 from './aaveV3';
2
3
  import * as morphoAaveV3 from './morphoAaveV3';
3
4
  import * as aaveV2 from './aaveV2';
@@ -16,5 +17,6 @@ import * as helpers from './helpers';
16
17
  import * as chickenBonds from './chickenBonds';
17
18
  import * as exchange from './exchange';
18
19
  import * as morphoBlue from './morphoBlue';
20
+ import * as llamaLend from './llamaLend';
19
21
  export * from './types';
20
- export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, };
22
+ export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, llamaLend, };
package/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import './setup';
1
2
  import * as aaveV3 from './aaveV3';
2
3
  import * as morphoAaveV3 from './morphoAaveV3';
3
4
  import * as aaveV2 from './aaveV2';
@@ -16,5 +17,6 @@ import * as helpers from './helpers';
16
17
  import * as chickenBonds from './chickenBonds';
17
18
  import * as exchange from './exchange';
18
19
  import * as morphoBlue from './morphoBlue';
20
+ import * as llamaLend from './llamaLend';
19
21
  export * from './types';
20
- export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, };
22
+ export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, llamaLend, };
@@ -0,0 +1,7 @@
1
+ import Web3 from 'web3';
2
+ import { LlamaLendGlobalMarketData, LlamaLendMarketData, LlamaLendUserData } from '../types';
3
+ import { Blockish, EthAddress, NetworkNumber, PositionBalances } from '../types/common';
4
+ export declare const getLlamaLendGlobalData: (web3: Web3, network: NetworkNumber, selectedMarket: LlamaLendMarketData) => Promise<LlamaLendGlobalMarketData>;
5
+ export declare const getLlamaLendAccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, controllerAddress: EthAddress) => Promise<PositionBalances>;
6
+ export declare const getLlamaLendUserData: (web3: Web3, network: NetworkNumber, address: string, selectedMarket: LlamaLendMarketData, marketData: LlamaLendGlobalMarketData) => Promise<LlamaLendUserData>;
7
+ export declare const getLlamaLendFullPositionData: (web3: Web3, network: NetworkNumber, address: string, selectedMarket: LlamaLendMarketData) => Promise<LlamaLendUserData>;
@@ -0,0 +1,222 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import Dec from 'decimal.js';
11
+ import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
12
+ import { LlamaLendStatus, } from '../types';
13
+ import { multicall } from '../multicall';
14
+ import { NetworkNumber, } from '../types/common';
15
+ import { getConfigContractAbi, getConfigContractAddress, LlamaLendViewContract } from '../contracts';
16
+ import { getLlamaLendAggregatedData } from '../helpers/llamaLendHelpers';
17
+ import { getAbiItem, getEthAmountForDecimals, wethToEth } from '../services/utils';
18
+ import { LlamaLendMarkets } from '../markets/llamaLend';
19
+ import { USD_QUOTE } from '../constants';
20
+ const getAndFormatBands = (web3, network, selectedMarket, _minBand, _maxBand) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const contract = LlamaLendViewContract(web3, network);
22
+ const minBand = parseInt(_minBand, 10);
23
+ const maxBand = parseInt(_maxBand, 10);
24
+ const pivots = [];
25
+ // getBandsData uses a lot of gas to get all of the bands at once, so we use pagination and fetch 200 bands at a time
26
+ let i = minBand;
27
+ while (i < maxBand) {
28
+ i += 200;
29
+ if (i > maxBand) {
30
+ pivots.push(maxBand);
31
+ }
32
+ else {
33
+ pivots.push(i);
34
+ }
35
+ }
36
+ const bandsData = (yield Promise.all(pivots.map((pivot, index) => __awaiter(void 0, void 0, void 0, function* () {
37
+ let start = 0;
38
+ if (index === 0) {
39
+ start = minBand;
40
+ }
41
+ else {
42
+ start = pivots[index - 1] + 1;
43
+ }
44
+ // @ts-ignore
45
+ const pivotedBandsData = yield contract.methods.getBandsData(selectedMarket.controllerAddress, start, pivot).call();
46
+ return pivotedBandsData;
47
+ })))).flat();
48
+ return bandsData.map((band) => ({
49
+ id: band.id,
50
+ collAmount: assetAmountInEth(band.collAmount),
51
+ debtAmount: assetAmountInEth(band.debtAmount),
52
+ lowPrice: assetAmountInEth(band.lowPrice),
53
+ highPrice: assetAmountInEth(band.highPrice),
54
+ }));
55
+ });
56
+ export const getLlamaLendGlobalData = (web3, network, selectedMarket) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const contract = LlamaLendViewContract(web3, network);
58
+ const FeedRegistryAddress = getConfigContractAddress('FeedRegistry', network);
59
+ const FeedRegistryAbi = getConfigContractAbi('FeedRegistry');
60
+ const collAsset = selectedMarket.collAsset;
61
+ const debtAsset = selectedMarket.baseAsset;
62
+ console.log(selectedMarket.controllerAddress);
63
+ // if something else is needed
64
+ const multicallData = [
65
+ {
66
+ target: FeedRegistryAddress,
67
+ abiItem: getAbiItem(FeedRegistryAbi, 'latestAnswer'),
68
+ params: [getAssetInfo(debtAsset).address, USD_QUOTE],
69
+ },
70
+ {
71
+ target: contract.options.address,
72
+ abiItem: contract.options.jsonInterface.find(({ name }) => name === 'globalData'),
73
+ params: [selectedMarket.controllerAddress],
74
+ },
75
+ ];
76
+ const multiRes = yield multicall(multicallData, web3, network);
77
+ console.log(multiRes);
78
+ const data = multiRes[1][0];
79
+ const debtUsdPrice = getEthAmountForDecimals(multiRes[0][0], 8);
80
+ console.log('here');
81
+ // all prices are in 18 decimals
82
+ const totalDebt = assetAmountInEth(data.totalDebt, debtAsset);
83
+ const ammPrice = assetAmountInEth(data.ammPrice, debtAsset);
84
+ const oraclePrice = getEthAmountForDecimals(data.oraclePrice, 18);
85
+ const rate = assetAmountInEth(data.ammRate);
86
+ const futureRate = assetAmountInEth(data.monetaryPolicyRate);
87
+ const exponentRate = new Dec(rate).mul(365).mul(86400);
88
+ const exponentFutureRate = new Dec(futureRate).mul(365).mul(86400);
89
+ const borrowRate = new Dec(new Dec(2.718281828459).pow(exponentRate).minus(1)).mul(100)
90
+ .toString();
91
+ const futureBorrowRate = new Dec(new Dec(2.718281828459).pow(exponentFutureRate).minus(1)).mul(100)
92
+ .toString();
93
+ const bandsData = yield getAndFormatBands(web3, network, selectedMarket, data.minBand, data.maxBand);
94
+ const cap = assetAmountInEth(data.debtTokenTotalSupply, debtAsset);
95
+ const leftToBorrow = getEthAmountForDecimals(data.debtTokenLeftToBorrow, 18);
96
+ const debtInAYearBN = new Dec(totalDebt).mul(new Dec(2.718281828459).pow(exponentRate).toNumber());
97
+ const lendRate = debtInAYearBN.minus(totalDebt).div(cap).mul(100).toString();
98
+ const assetsData = {};
99
+ assetsData[debtAsset] = {
100
+ symbol: debtAsset,
101
+ address: data.debtToken,
102
+ price: debtUsdPrice,
103
+ supplyRate: lendRate,
104
+ borrowRate,
105
+ canBeSupplied: true,
106
+ canBeBorrowed: true,
107
+ };
108
+ assetsData[collAsset] = {
109
+ symbol: collAsset,
110
+ address: data.collateralToken,
111
+ price: new Dec(debtUsdPrice).mul(oraclePrice).toString(),
112
+ supplyRate: '0',
113
+ borrowRate: '0',
114
+ canBeSupplied: true,
115
+ canBeBorrowed: false,
116
+ };
117
+ return Object.assign(Object.assign({}, data), { assetsData,
118
+ totalDebt,
119
+ ammPrice, oraclePrice: assetAmountInEth(data.oraclePrice, debtAsset), basePrice: assetAmountInEth(data.basePrice, debtAsset), minted: assetAmountInEth(data.minted, debtAsset), redeemed: assetAmountInEth(data.redeemed, debtAsset), borrowRate,
120
+ lendRate,
121
+ futureBorrowRate, bands: bandsData, leftToBorrow });
122
+ });
123
+ const getStatusForUser = (bandRange, activeBand, debtSupplied, collSupplied) => {
124
+ // if bands are equal, that can only be [0,0] which means user doesn't have loan (min number of bands is 4)
125
+ if (new Dec(bandRange[0]).eq(bandRange[1]))
126
+ return LlamaLendStatus.Nonexistant;
127
+ // if user doesn't have debtAsset as collateral, then his position is not in soft liquidation
128
+ if (new Dec(debtSupplied).lte(0)) {
129
+ if (new Dec(bandRange[0]).minus(activeBand).lte(3))
130
+ return LlamaLendStatus.Risk; // if user band is less than 3 bands away from active band, his position is at risk
131
+ return LlamaLendStatus.Safe;
132
+ }
133
+ if (new Dec(bandRange[0]).lte(activeBand) && new Dec(bandRange[1]).gte(activeBand))
134
+ return LlamaLendStatus.SoftLiquidating; // user has debtAsset as coll so he is in soft liquidation
135
+ if (new Dec(collSupplied).lte(0) || new Dec(bandRange[1]).lte(activeBand))
136
+ return LlamaLendStatus.SoftLiquidated; // or is fully soft liquidated
137
+ return LlamaLendStatus.Nonexistant;
138
+ };
139
+ export const getLlamaLendAccountBalances = (web3, network, block, addressMapping, address, controllerAddress) => __awaiter(void 0, void 0, void 0, function* () {
140
+ let balances = {
141
+ collateral: {},
142
+ debt: {},
143
+ };
144
+ if (!address) {
145
+ return balances;
146
+ }
147
+ const contract = LlamaLendViewContract(web3, network, block);
148
+ const selectedMarket = Object.values(LlamaLendMarkets(network)).find(i => i.controllerAddress.toLowerCase() === controllerAddress.toLowerCase());
149
+ const data = yield contract.methods.userData(selectedMarket.controllerAddress, address).call({}, block);
150
+ balances = {
151
+ collateral: {
152
+ [addressMapping ? getAssetInfo(wethToEth(selectedMarket.collAsset), network).address.toLowerCase() : wethToEth(selectedMarket.collAsset)]: data.marketCollateralAmount,
153
+ },
154
+ debt: {
155
+ [addressMapping ? getAssetInfo(wethToEth(selectedMarket.baseAsset), network).address.toLowerCase() : wethToEth(selectedMarket.baseAsset)]: data.debtAmount,
156
+ },
157
+ };
158
+ return balances;
159
+ });
160
+ export const getLlamaLendUserData = (web3, network, address, selectedMarket, marketData) => __awaiter(void 0, void 0, void 0, function* () {
161
+ const contract = LlamaLendViewContract(web3, network);
162
+ const { assetsData } = marketData;
163
+ const data = yield contract.methods.userData(selectedMarket.controllerAddress, address).call();
164
+ const collAsset = selectedMarket.collAsset;
165
+ const debtAsset = selectedMarket.baseAsset;
166
+ const collPrice = assetsData[collAsset].price;
167
+ const debtPrice = assetsData[debtAsset].price;
168
+ const health = assetAmountInEth(data.health);
169
+ const healthPercent = new Dec(health).mul(100).toString();
170
+ const collSupplied = assetAmountInEth(data.marketCollateralAmount, collAsset);
171
+ const collSuppliedUsd = new Dec(collSupplied).mul(collPrice).toString();
172
+ const debtSupplied = assetAmountInEth(data.debtTokenCollateralAmount, debtAsset);
173
+ const debtSuppliedUsd = new Dec(debtSupplied).mul(debtPrice).toString();
174
+ const debtSuppliedForYield = assetAmountInEth(data.debtTokenSuppliedAssets, debtAsset);
175
+ const debtSuppliedForYieldUsd = new Dec(debtSupplied).mul(debtPrice).toString();
176
+ const debtBorrowed = assetAmountInEth(data.debtAmount, debtAsset);
177
+ const shares = assetAmountInEth(data.debtTokenSuppliedShares, debtAsset);
178
+ const usedAssets = {
179
+ [collAsset]: {
180
+ isSupplied: true,
181
+ supplied: collSupplied,
182
+ suppliedUsd: collSuppliedUsd,
183
+ borrowed: '0',
184
+ borrowedUsd: '0',
185
+ isBorrowed: false,
186
+ symbol: collAsset,
187
+ collateral: true,
188
+ price: collPrice,
189
+ },
190
+ [debtAsset]: {
191
+ isSupplied: new Dec(debtSupplied).gt('0') || new Dec(debtSuppliedForYield).gt('0'),
192
+ collateral: new Dec(debtSupplied).gt('0'),
193
+ supplied: debtSupplied,
194
+ suppliedUsd: debtSuppliedUsd,
195
+ suppliedForYield: debtSuppliedForYield,
196
+ suppliedForYieldUsd: debtSuppliedForYieldUsd,
197
+ borrowed: debtBorrowed,
198
+ borrowedUsd: debtBorrowed,
199
+ isBorrowed: new Dec(debtBorrowed).gt('0'),
200
+ symbol: debtAsset,
201
+ price: debtPrice,
202
+ shares,
203
+ },
204
+ };
205
+ const priceHigh = assetAmountInEth(data.priceHigh);
206
+ const priceLow = assetAmountInEth(data.priceLow);
207
+ const _userBands = data.loanExists ? (yield getAndFormatBands(web3, network, selectedMarket, data.bandRange[0], data.bandRange[1])) : [];
208
+ const status = data.loanExists ? getStatusForUser(data.bandRange, marketData.activeBand, debtSupplied, collSupplied) : LlamaLendStatus.Nonexistant;
209
+ const userBands = _userBands.map((band, index) => (Object.assign(Object.assign({}, band), { userDebtAmount: assetAmountInEth(data.usersBands[0][index], debtAsset), userCollAmount: assetAmountInEth(data.usersBands[1][index], collAsset) }))).sort((a, b) => parseInt(b.id, 10) - parseInt(a.id, 10));
210
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, data), { debtAmount: assetAmountInEth(data.debtAmount, debtAsset), health,
211
+ healthPercent,
212
+ priceHigh,
213
+ priceLow, liquidationDiscount: assetAmountInEth(data.liquidationDiscount), numOfBands: data.N, usedAssets,
214
+ status }), getLlamaLendAggregatedData({
215
+ loanExists: data.loanExists, usedAssets, network: NetworkNumber.Eth, selectedMarket, numOfBands: data.N,
216
+ })), { userBands });
217
+ });
218
+ export const getLlamaLendFullPositionData = (web3, network, address, selectedMarket) => __awaiter(void 0, void 0, void 0, function* () {
219
+ const marketData = yield getLlamaLendGlobalData(web3, network, selectedMarket);
220
+ const positionData = yield getLlamaLendUserData(web3, network, address, selectedMarket, marketData);
221
+ return positionData;
222
+ });
@@ -3,3 +3,4 @@ export { CompoundMarkets } from './compound';
3
3
  export { SparkMarkets } from './spark';
4
4
  export { CrvUsdMarkets } from './curveUsd';
5
5
  export { MorphoBlueMarkets } from './morphoBlue';
6
+ export { LlamaLendMarkets } from './llamaLend';
@@ -3,3 +3,4 @@ export { CompoundMarkets } from './compound';
3
3
  export { SparkMarkets } from './spark';
4
4
  export { CrvUsdMarkets } from './curveUsd';
5
5
  export { MorphoBlueMarkets } from './morphoBlue';
6
+ export { LlamaLendMarkets } from './llamaLend';
@@ -0,0 +1,12 @@
1
+ import { LlamaLendMarketData, LlamaLendVersions } from '../../types';
2
+ import { NetworkNumber } from '../../types/common';
3
+ export declare const LLAMALEND_WSTETH_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
4
+ export declare const LLAMALEND_CRVUSD_CRV_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
5
+ export declare const LLAMALEND_CRV_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
6
+ export declare const LlamaLendMarkets: (networkId: NetworkNumber) => {
7
+ readonly llamaLendwstETHcrvUSD: LlamaLendMarketData;
8
+ readonly llamaLendcrvUSDCRV: LlamaLendMarketData;
9
+ readonly llamaLendCRVcrvUSD: LlamaLendMarketData;
10
+ };
11
+ export declare const LLAMALEND_ALL_VERSIONS: LlamaLendVersions[];
12
+ export declare const getLlamaLendMarketData: (market: LlamaLendVersions, network?: NetworkNumber) => LlamaLendMarketData;