@defisaver/positions-sdk 1.0.13 → 1.0.15

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 (35) hide show
  1. package/cjs/config/contracts.d.ts +61 -21
  2. package/cjs/config/contracts.js +9 -1
  3. package/cjs/contracts.d.ts +1 -0
  4. package/cjs/contracts.js +2 -1
  5. package/cjs/liquityV2/index.js +38 -18
  6. package/cjs/markets/liquityV2/index.d.ts +6 -0
  7. package/cjs/markets/liquityV2/index.js +51 -4
  8. package/cjs/types/contracts/generated/LiquityV2LegacyView.d.ts +386 -0
  9. package/cjs/types/contracts/generated/LiquityV2LegacyView.js +5 -0
  10. package/cjs/types/contracts/generated/LiquityV2View.d.ts +4 -0
  11. package/cjs/types/contracts/generated/index.d.ts +1 -0
  12. package/cjs/types/liquityV2.d.ts +7 -1
  13. package/cjs/types/liquityV2.js +4 -0
  14. package/esm/config/contracts.d.ts +61 -21
  15. package/esm/config/contracts.js +9 -1
  16. package/esm/contracts.d.ts +1 -0
  17. package/esm/contracts.js +1 -0
  18. package/esm/liquityV2/index.js +40 -20
  19. package/esm/markets/liquityV2/index.d.ts +6 -0
  20. package/esm/markets/liquityV2/index.js +46 -2
  21. package/esm/types/contracts/generated/LiquityV2LegacyView.d.ts +386 -0
  22. package/esm/types/contracts/generated/LiquityV2LegacyView.js +4 -0
  23. package/esm/types/contracts/generated/LiquityV2View.d.ts +4 -0
  24. package/esm/types/contracts/generated/index.d.ts +1 -0
  25. package/esm/types/liquityV2.d.ts +7 -1
  26. package/esm/types/liquityV2.js +4 -0
  27. package/package.json +2 -2
  28. package/src/config/contracts.js +9 -1
  29. package/src/contracts.ts +2 -0
  30. package/src/liquityV2/index.ts +41 -18
  31. package/src/markets/liquityV2/index.ts +50 -2
  32. package/src/types/contracts/generated/LiquityV2LegacyView.ts +486 -0
  33. package/src/types/contracts/generated/LiquityV2View.ts +4 -0
  34. package/src/types/contracts/generated/index.ts +1 -0
  35. package/src/types/liquityV2.ts +7 -0
@@ -1102,7 +1102,7 @@ module.exports = {
1102
1102
  "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" }] }],
1103
1103
  "networks": {}
1104
1104
  },
1105
- "LiquityV2View": {
1105
+ "LiquityV2LegacyView": {
1106
1106
  "abi": [{ "inputs": [], "name": "InvalidMarketAddress", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_prevId", "type": "uint256" }, { "internalType": "uint256", "name": "_nextId", "type": "uint256" }], "name": "findInsertPosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getApproxHint", "outputs": [{ "internalType": "uint256", "name": "hintId", "type": "uint256" }, { "internalType": "uint256", "name": "diff", "type": "uint256" }, { "internalType": "uint256", "name": "latestRandomSeed", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_manager", "type": "address" }], "name": "getBatchManagerInfo", "outputs": [{ "components": [{ "internalType": "uint128", "name": "minInterestRate", "type": "uint128" }, { "internalType": "uint128", "name": "maxInterestRate", "type": "uint128" }, { "internalType": "uint256", "name": "minInterestRateChangePeriod", "type": "uint256" }], "internalType": "struct IBorrowerOperations.InterestBatchManager", "name": "managerData", "type": "tuple" }, { "components": [{ "internalType": "uint256", "name": "entireDebtWithoutRedistribution", "type": "uint256" }, { "internalType": "uint256", "name": "entireCollWithoutRedistribution", "type": "uint256" }, { "internalType": "uint256", "name": "accruedInterest", "type": "uint256" }, { "internalType": "uint256", "name": "recordedDebt", "type": "uint256" }, { "internalType": "uint256", "name": "annualInterestRate", "type": "uint256" }, { "internalType": "uint256", "name": "weightedRecordedDebt", "type": "uint256" }, { "internalType": "uint256", "name": "annualManagementFee", "type": "uint256" }, { "internalType": "uint256", "name": "accruedManagementFee", "type": "uint256" }, { "internalType": "uint256", "name": "weightedRecordedBatchManagementFee", "type": "uint256" }, { "internalType": "uint256", "name": "lastDebtUpdateTime", "type": "uint256" }, { "internalType": "uint256", "name": "lastInterestRateAdjTime", "type": "uint256" }], "internalType": "struct ITroveManager.LatestBatchData", "name": "batchData", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_acc", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }], "name": "getDebtInFront", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_acc", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }, { "internalType": "uint256", "name": "_targetIR", "type": "uint256" }], "name": "getDebtInFrontByInterestRate", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_numTroves", "type": "uint256" }], "name": "getDebtInFrontByTroveNum", "outputs": [{ "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_depositor", "type": "address" }], "name": "getDepositorInfo", "outputs": [{ "internalType": "uint256", "name": "compoundedBOLD", "type": "uint256" }, { "internalType": "uint256", "name": "collGain", "type": "uint256" }, { "internalType": "uint256", "name": "boldGain", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getInsertPosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getMarketData", "outputs": [{ "components": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "uint256", "name": "CCR", "type": "uint256" }, { "internalType": "uint256", "name": "MCR", "type": "uint256" }, { "internalType": "uint256", "name": "SCR", "type": "uint256" }, { "internalType": "uint256", "name": "LIQUIDATION_PENALTY_SP", "type": "uint256" }, { "internalType": "uint256", "name": "LIQUIDATION_PENALTY_REDISTRIBUTION", "type": "uint256" }, { "internalType": "uint256", "name": "entireSystemColl", "type": "uint256" }, { "internalType": "uint256", "name": "entireSystemDebt", "type": "uint256" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "address", "name": "troveNFT", "type": "address" }, { "internalType": "address", "name": "borrowerOperations", "type": "address" }, { "internalType": "address", "name": "troveManager", "type": "address" }, { "internalType": "address", "name": "stabilityPool", "type": "address" }, { "internalType": "address", "name": "sortedTroves", "type": "address" }, { "internalType": "address", "name": "collSurplusPool", "type": "address" }, { "internalType": "address", "name": "activePool", "type": "address" }, { "internalType": "address", "name": "hintHelpers", "type": "address" }, { "internalType": "address", "name": "priceFeed", "type": "address" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "bool", "name": "isShutDown", "type": "bool" }, { "internalType": "uint256", "name": "boldDepositInSp", "type": "uint256" }], "internalType": "struct LiquityV2View.MarketData", "name": "data", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "int256", "name": "_startIdx", "type": "int256" }, { "internalType": "uint256", "name": "_count", "type": "uint256" }], "name": "getMultipleSortedTroves", "outputs": [{ "components": [{ "internalType": "uint256", "name": "id", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }, { "internalType": "uint256", "name": "coll", "type": "uint256" }, { "internalType": "uint256", "name": "stake", "type": "uint256" }, { "internalType": "uint256", "name": "annualInterestRate", "type": "uint256" }, { "internalType": "uint256", "name": "lastDebtUpdateTime", "type": "uint256" }, { "internalType": "uint256", "name": "lastInterestRateAdjTime", "type": "uint256" }, { "internalType": "address", "name": "interestBatchManager", "type": "address" }, { "internalType": "uint256", "name": "batchDebtShares", "type": "uint256" }, { "internalType": "uint256", "name": "batchCollShares", "type": "uint256" }, { "internalType": "uint256", "name": "snapshotETH", "type": "uint256" }, { "internalType": "uint256", "name": "snapshotBoldDebt", "type": "uint256" }], "internalType": "struct IMultiTroveGetter.CombinedTroveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }], "name": "getNumOfTrovesInFrontOfTrove", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "numTroves", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }], "name": "getTroveInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "troveId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "enum ITroveManager.Status", "name": "status", "type": "uint8" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "uint256", "name": "TCRatio", "type": "uint256" }, { "internalType": "uint256", "name": "annualInterestRate", "type": "uint256" }, { "internalType": "address", "name": "interestBatchManager", "type": "address" }, { "internalType": "uint256", "name": "batchDebtShares", "type": "uint256" }, { "internalType": "uint256", "name": "lastInterestRateAdjTime", "type": "uint256" }], "internalType": "struct LiquityV2View.TroveData", "name": "trove", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getTrovePosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }, { "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_startIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_endIndex", "type": "uint256" }], "name": "getUserTroves", "outputs": [{ "components": [{ "internalType": "uint256", "name": "troveId", "type": "uint256" }, { "internalType": "bool", "name": "ownedByUser", "type": "bool" }], "internalType": "struct LiquityV2View.ExistingTrove[]", "name": "troves", "type": "tuple[]" }, { "internalType": "int256", "name": "nextFreeTroveIndex", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "isShutDown", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_debtIncrease", "type": "uint256" }], "name": "predictAdjustTroveUpfrontFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
1107
1107
  "networks": {
1108
1108
  "1": {
@@ -1117,6 +1117,14 @@ module.exports = {
1117
1117
  },
1118
1118
  },
1119
1119
  },
1120
+ "LiquityV2View": {
1121
+ "abi": [{ "inputs": [], "name": "InvalidMarketAddress", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_prevId", "type": "uint256" }, { "internalType": "uint256", "name": "_nextId", "type": "uint256" }], "name": "findInsertPosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getApproxHint", "outputs": [{ "internalType": "uint256", "name": "hintId", "type": "uint256" }, { "internalType": "uint256", "name": "diff", "type": "uint256" }, { "internalType": "uint256", "name": "latestRandomSeed", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_manager", "type": "address" }], "name": "getBatchManagerInfo", "outputs": [{ "components": [{ "internalType": "uint128", "name": "minInterestRate", "type": "uint128" }, { "internalType": "uint128", "name": "maxInterestRate", "type": "uint128" }, { "internalType": "uint256", "name": "minInterestRateChangePeriod", "type": "uint256" }], "internalType": "struct IBorrowerOperations.InterestBatchManager", "name": "managerData", "type": "tuple" }, { "components": [{ "internalType": "uint256", "name": "entireDebtWithoutRedistribution", "type": "uint256" }, { "internalType": "uint256", "name": "entireCollWithoutRedistribution", "type": "uint256" }, { "internalType": "uint256", "name": "accruedInterest", "type": "uint256" }, { "internalType": "uint256", "name": "recordedDebt", "type": "uint256" }, { "internalType": "uint256", "name": "annualInterestRate", "type": "uint256" }, { "internalType": "uint256", "name": "weightedRecordedDebt", "type": "uint256" }, { "internalType": "uint256", "name": "annualManagementFee", "type": "uint256" }, { "internalType": "uint256", "name": "accruedManagementFee", "type": "uint256" }, { "internalType": "uint256", "name": "weightedRecordedBatchManagementFee", "type": "uint256" }, { "internalType": "uint256", "name": "lastDebtUpdateTime", "type": "uint256" }, { "internalType": "uint256", "name": "lastInterestRateAdjTime", "type": "uint256" }], "internalType": "struct ITroveManager.LatestBatchData", "name": "batchData", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_acc", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }], "name": "getDebtInFront", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_acc", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }, { "internalType": "uint256", "name": "_targetIR", "type": "uint256" }], "name": "getDebtInFrontByInterestRate", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_numTroves", "type": "uint256" }], "name": "getDebtInFrontByTroveNum", "outputs": [{ "internalType": "uint256", "name": "debt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "address", "name": "_depositor", "type": "address" }], "name": "getDepositorInfo", "outputs": [{ "internalType": "uint256", "name": "compoundedBOLD", "type": "uint256" }, { "internalType": "uint256", "name": "collGain", "type": "uint256" }, { "internalType": "uint256", "name": "boldGain", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_interestRate", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getInsertPosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "getMarketData", "outputs": [{ "components": [{ "internalType": "address", "name": "market", "type": "address" }, { "internalType": "uint256", "name": "CCR", "type": "uint256" }, { "internalType": "uint256", "name": "MCR", "type": "uint256" }, { "internalType": "uint256", "name": "SCR", "type": "uint256" }, { "internalType": "uint256", "name": "BCR", "type": "uint256" }, { "internalType": "uint256", "name": "LIQUIDATION_PENALTY_SP", "type": "uint256" }, { "internalType": "uint256", "name": "LIQUIDATION_PENALTY_REDISTRIBUTION", "type": "uint256" }, { "internalType": "uint256", "name": "entireSystemColl", "type": "uint256" }, { "internalType": "uint256", "name": "entireSystemDebt", "type": "uint256" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "address", "name": "troveNFT", "type": "address" }, { "internalType": "address", "name": "borrowerOperations", "type": "address" }, { "internalType": "address", "name": "troveManager", "type": "address" }, { "internalType": "address", "name": "stabilityPool", "type": "address" }, { "internalType": "address", "name": "sortedTroves", "type": "address" }, { "internalType": "address", "name": "collSurplusPool", "type": "address" }, { "internalType": "address", "name": "activePool", "type": "address" }, { "internalType": "address", "name": "hintHelpers", "type": "address" }, { "internalType": "address", "name": "priceFeed", "type": "address" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "bool", "name": "isShutDown", "type": "bool" }, { "internalType": "uint256", "name": "boldDepositInSp", "type": "uint256" }], "internalType": "struct LiquityV2View.MarketData", "name": "data", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "int256", "name": "_startIdx", "type": "int256" }, { "internalType": "uint256", "name": "_count", "type": "uint256" }], "name": "getMultipleSortedTroves", "outputs": [{ "components": [{ "internalType": "uint256", "name": "id", "type": "uint256" }, { "internalType": "uint256", "name": "debt", "type": "uint256" }, { "internalType": "uint256", "name": "coll", "type": "uint256" }, { "internalType": "uint256", "name": "stake", "type": "uint256" }, { "internalType": "uint256", "name": "annualInterestRate", "type": "uint256" }, { "internalType": "uint256", "name": "lastDebtUpdateTime", "type": "uint256" }, { "internalType": "uint256", "name": "lastInterestRateAdjTime", "type": "uint256" }, { "internalType": "address", "name": "interestBatchManager", "type": "address" }, { "internalType": "uint256", "name": "batchDebtShares", "type": "uint256" }, { "internalType": "uint256", "name": "batchCollShares", "type": "uint256" }, { "internalType": "uint256", "name": "snapshotETH", "type": "uint256" }, { "internalType": "uint256", "name": "snapshotBoldDebt", "type": "uint256" }], "internalType": "struct IMultiTroveGetter.CombinedTroveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_iterations", "type": "uint256" }], "name": "getNumOfTrovesInFrontOfTrove", "outputs": [{ "internalType": "uint256", "name": "next", "type": "uint256" }, { "internalType": "uint256", "name": "numTroves", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }], "name": "getTroveInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "troveId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "enum ITroveManager.Status", "name": "status", "type": "uint8" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "uint256", "name": "TCRatio", "type": "uint256" }, { "internalType": "uint256", "name": "annualInterestRate", "type": "uint256" }, { "internalType": "address", "name": "interestBatchManager", "type": "address" }, { "internalType": "uint256", "name": "batchDebtShares", "type": "uint256" }, { "internalType": "uint256", "name": "lastInterestRateAdjTime", "type": "uint256" }], "internalType": "struct LiquityV2View.TroveData", "name": "trove", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_numTrials", "type": "uint256" }, { "internalType": "uint256", "name": "_inputRandomSeed", "type": "uint256" }], "name": "getTrovePosition", "outputs": [{ "internalType": "uint256", "name": "prevId", "type": "uint256" }, { "internalType": "uint256", "name": "nextId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }, { "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_startIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_endIndex", "type": "uint256" }], "name": "getUserTroves", "outputs": [{ "components": [{ "internalType": "uint256", "name": "troveId", "type": "uint256" }, { "internalType": "bool", "name": "ownedByUser", "type": "bool" }], "internalType": "struct LiquityV2View.ExistingTrove[]", "name": "troves", "type": "tuple[]" }, { "internalType": "int256", "name": "nextFreeTroveIndex", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }], "name": "isShutDown", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_market", "type": "address" }, { "internalType": "uint256", "name": "_collIndex", "type": "uint256" }, { "internalType": "uint256", "name": "_troveId", "type": "uint256" }, { "internalType": "uint256", "name": "_debtIncrease", "type": "uint256" }], "name": "predictAdjustTroveUpfrontFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
1122
+ "networks": {
1123
+ "1": {
1124
+ "address": "0xF1f3D940392ddAD78A5e2dE1b595aB529f63c365",
1125
+ }
1126
+ }
1127
+ },
1120
1128
  "LiquityV2CollSurplusPool": {
1121
1129
  "abi": [{ "inputs": [{ "internalType": "contract IAddressesRegistry", "name": "_addressesRegistry", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "_newBorrowerOperationsAddress", "type": "address" }], "name": "BorrowerOperationsAddressChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "_account", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "_newBalance", "type": "uint256" }], "name": "CollBalanceUpdated", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "_to", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "CollSent", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "_newTroveManagerAddress", "type": "address" }], "name": "TroveManagerAddressChanged", "type": "event" }, { "inputs": [], "name": "NAME", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_account", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "accountSurplus", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "borrowerOperationsAddress", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_account", "type": "address" }], "name": "claimColl", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "collToken", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getCollBalance", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_account", "type": "address" }], "name": "getCollateral", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "troveManagerAddress", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }],
1122
1130
  "networks": {}
@@ -48,5 +48,6 @@ export declare const DFSFeedRegistryContract: (web3: Web3, network: NetworkNumbe
48
48
  export declare const MorphoBlueViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.MorphoBlueView;
49
49
  export declare const LlamaLendViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LlamaLendView;
50
50
  export declare const LiquityV2ViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LiquityV2View;
51
+ export declare const LiquityV2LegacyViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LiquityV2LegacyView;
51
52
  export declare const EulerV2ViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.EulerV2View;
52
53
  export declare const FluidViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.FluidView;
package/esm/contracts.js CHANGED
@@ -80,5 +80,6 @@ export const DFSFeedRegistryContract = createContractFromConfigFunc('DFSFeedRegi
80
80
  export const MorphoBlueViewContract = createContractFromConfigFunc('MorphoBlueView');
81
81
  export const LlamaLendViewContract = createContractFromConfigFunc('LlamaLendView');
82
82
  export const LiquityV2ViewContract = createContractFromConfigFunc('LiquityV2View');
83
+ export const LiquityV2LegacyViewContract = createContractFromConfigFunc('LiquityV2LegacyView');
83
84
  export const EulerV2ViewContract = createContractFromConfigFunc('EulerV2View');
84
85
  export const FluidViewContract = createContractFromConfigFunc('FluidView');
@@ -9,16 +9,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import Dec from 'decimal.js';
11
11
  import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
12
- import { createContractWrapper, LiquityV2ViewContract } from '../contracts';
13
- import { LIQUITY_V2_TROVE_STATUS_ENUM, } from '../types';
12
+ import { createContractWrapper, LiquityV2LegacyViewContract, LiquityV2ViewContract } from '../contracts';
13
+ import { NetworkNumber } from '../types/common';
14
+ import { LIQUITY_V2_TROVE_STATUS_ENUM, LiquityV2Versions, } from '../types';
14
15
  import { getStakingApy, STAKING_ASSETS } from '../staking';
15
16
  import { getLiquityV2AggregatedPositionData } from '../helpers/liquityV2Helpers';
16
17
  import { compareAddresses, ethToWeth, MAXUINT } from '../services/utils';
17
18
  import { ZERO_ADDRESS } from '../constants';
18
19
  import { LiquityV2Markets } from '../markets';
20
+ const getLiquityV2ViewContract = (web3, network, isLegacy) => {
21
+ if (isLegacy)
22
+ return LiquityV2LegacyViewContract(web3, network);
23
+ return LiquityV2ViewContract(web3, network);
24
+ };
19
25
  export const getLiquityV2MarketData = (web3, network, selectedMarket, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
20
- const viewContract = LiquityV2ViewContract(web3, network);
21
- const { marketAddress, debtToken, collateralToken } = selectedMarket;
26
+ const { marketAddress, debtToken, collateralToken, isLegacy, } = selectedMarket;
27
+ const viewContract = getLiquityV2ViewContract(web3, network, isLegacy);
22
28
  const data = yield viewContract.methods.getMarketData(marketAddress).call();
23
29
  const hintHelperAddress = data.hintHelpers;
24
30
  const troveNFTAddress = data.troveNFT;
@@ -29,6 +35,7 @@ export const getLiquityV2MarketData = (web3, network, selectedMarket, mainnetWeb
29
35
  const activePoolAddress = data.activePool;
30
36
  const minCollRatio = new Dec(data.MCR).div(1e16).toString();
31
37
  const criticalCollRatio = new Dec(data.CCR).div(1e18).toString();
38
+ const batchCollRatio = new Dec(data.BCR || '0').div(1e16).toString();
32
39
  const totalMarketBorrow = assetAmountInEth(data.entireSystemDebt);
33
40
  const totalMarketSupply = assetAmountInEth(data.entireSystemColl);
34
41
  const collPrice = assetAmountInEth(data.collPrice);
@@ -70,6 +77,7 @@ export const getLiquityV2MarketData = (web3, network, selectedMarket, mainnetWeb
70
77
  minCollRatio,
71
78
  totalCollRatio: new Dec(totalCollRatio).mul(100).toString(),
72
79
  criticalCollRatio: new Dec(criticalCollRatio).mul(100).toString(),
80
+ batchCollRatio,
73
81
  isUnderCollateralized: new Dec(totalCollRatio).lt(criticalCollRatio),
74
82
  hintHelperAddress,
75
83
  troveNFTAddress,
@@ -93,20 +101,23 @@ const getUserTroves = (viewContract, account, marketAddress, startIndex = 0, end
93
101
  });
94
102
  const TransferEventSig = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
95
103
  const nftContractCreationBlockMapping = {
96
- ETH: 21686215,
97
- wstETH: 21686238,
98
- rETH: 21686257,
104
+ [LiquityV2Versions.LiquityV2Eth]: 22516079,
105
+ [LiquityV2Versions.LiquityV2WstEth]: 22516099,
106
+ [LiquityV2Versions.LiquityV2REth]: 22516118,
107
+ // legacy
108
+ [LiquityV2Versions.LiquityV2EthLegacy]: 21686215,
109
+ [LiquityV2Versions.LiquityV2WstEthLegacy]: 21686238,
110
+ [LiquityV2Versions.LiquityV2REthLegacy]: 21686257,
99
111
  };
100
- const getTransferredTroves = (web3, network, troveNFTAddress, limitBlocksForEventFetching, collAsset, account) => __awaiter(void 0, void 0, void 0, function* () {
112
+ const getTransferredTroves = (web3, network, troveNFTAddress, limitBlocksForEventFetching, market, account) => __awaiter(void 0, void 0, void 0, function* () {
101
113
  const nftContract = createContractWrapper(web3, network, 'LiquityV2TroveNFT', troveNFTAddress);
102
- // @ts-ignore
103
- const nftContractCreationBlock = nftContractCreationBlockMapping[collAsset];
114
+ const nftContractCreationBlock = nftContractCreationBlockMapping[market];
104
115
  const currentBlock = yield web3.eth.getBlockNumber();
105
116
  const events = yield nftContract.getPastEvents(TransferEventSig, {
106
117
  filter: { to: account },
107
118
  fromBlock: limitBlocksForEventFetching ? (currentBlock - 1000) : nftContractCreationBlock,
108
119
  });
109
- const userTransferredTroves = events.filter((event) => !compareAddresses(event.returnValues.from, ZERO_ADDRESS) && compareAddresses(event.returnValues.to, account));
120
+ const userTransferredTroves = events.filter((event) => compareAddresses(event.returnValues.to, account));
110
121
  // check if the last know transfer address is the user
111
122
  userTransferredTroves.forEach((event, index) => {
112
123
  const otherTransfers = events.filter((e) => event.blockNumber < e.blockNumber && e.returnValues.tokenId === event.returnValues.tokenId);
@@ -117,14 +128,18 @@ const getTransferredTroves = (web3, network, troveNFTAddress, limitBlocksForEven
117
128
  return userTransferredTroves.filter((event) => !event.invalid).map((event) => ({ troveId: event.returnValues.tokenId }));
118
129
  });
119
130
  export const getLiquityV2UserTroveIds = (web3, network, selectedMarket, troveNFTAddress, limitBlocksForEventFetching, account) => __awaiter(void 0, void 0, void 0, function* () {
120
- const viewContract = LiquityV2ViewContract(web3, network);
131
+ const viewContract = getLiquityV2ViewContract(web3, network, selectedMarket.isLegacy);
121
132
  const [{ troves: userTroves, nextFreeTroveIndex }, userTransferredTroves] = yield Promise.all([
122
133
  getUserTroves(viewContract, account, selectedMarket.marketAddress),
123
- getTransferredTroves(web3, network, troveNFTAddress, limitBlocksForEventFetching, selectedMarket.collateralToken, account),
134
+ getTransferredTroves(web3, network, troveNFTAddress, limitBlocksForEventFetching, selectedMarket.value, account),
124
135
  ]);
125
136
  const troves = [...userTroves.map(({ troveId }) => ({ troveId })), ...userTransferredTroves];
126
137
  const filteredTroves = troves.filter((value, index, self) => index === self.findIndex((t) => (t.troveId === value.troveId)));
127
- return { troves: filteredTroves, nextFreeTroveIndex };
138
+ const troveIds = filteredTroves.map((trove) => trove.troveId);
139
+ const troveIdsSet = new Set(troveIds);
140
+ const troveIdsArray = Array.from(troveIdsSet);
141
+ const trovesNoDuplicates = troveIdsArray.map((troveId) => troves.find((trove) => trove.troveId === troveId));
142
+ return { troves: trovesNoDuplicates, nextFreeTroveIndex };
128
143
  });
129
144
  const _getDebtInFrontForSingleMarket = (viewContract, marketAddress, troveId, accumulatedSum = '0', iterations = 2000) => __awaiter(void 0, void 0, void 0, function* () { return viewContract.methods.getDebtInFront(marketAddress, troveId, accumulatedSum, iterations).call(); });
130
145
  export const getDebtInFrontForSingleMarketLiquityV2 = (viewContract, marketAddress, troveId, accumulatedSum = '0', iterations = 2000) => __awaiter(void 0, void 0, void 0, function* () {
@@ -153,7 +168,8 @@ const getUnbackedDebtForSingleMarket = (totalBorrowed, web3, network, stabilityP
153
168
  export const getAllMarketsUnbackedDebts = (markets, web3, network) => __awaiter(void 0, void 0, void 0, function* () {
154
169
  const allMarketsUnbackedDebt = yield Promise.all(Object.entries(markets).map(([version, market]) => __awaiter(void 0, void 0, void 0, function* () {
155
170
  const { assetsData, marketData } = market;
156
- const unbackedDebt = yield getUnbackedDebtForSingleMarket(assetsData.BOLD.totalBorrow, web3, network, marketData.stabilityPoolAddress);
171
+ const { debtToken } = LiquityV2Markets(network)[version];
172
+ const unbackedDebt = yield getUnbackedDebtForSingleMarket(assetsData[debtToken].totalBorrow, web3, network, marketData.stabilityPoolAddress);
157
173
  return [version, unbackedDebt];
158
174
  })));
159
175
  return Object.fromEntries(allMarketsUnbackedDebt);
@@ -166,8 +182,9 @@ export const calculateDebtInFrontLiquityV2 = (markets, selectedMarket, allMarket
166
182
  if (version === selectedMarket)
167
183
  return new Dec(interestRateDebtInFront);
168
184
  const { assetsData } = market;
185
+ const { debtToken } = LiquityV2Markets(NetworkNumber.Eth)[version];
169
186
  const unbackedDebt = new Dec(allMarketsUnbackedDebts[version]);
170
- const totalBorrow = new Dec(assetsData.BOLD.totalBorrow);
187
+ const totalBorrow = new Dec(assetsData[debtToken].totalBorrow);
171
188
  const amountToReedem = new Dec(interestRateDebtInFront).mul(unbackedDebt).div(selectedMarketUnbackedDebt);
172
189
  return Dec.min(amountToReedem, totalBorrow);
173
190
  });
@@ -184,8 +201,8 @@ export const getDebtInFrontForInterestRateLiquityV2 = (markets, selectedMarket,
184
201
  return calculateDebtInFrontLiquityV2(markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
185
202
  });
186
203
  export const getLiquityV2TroveData = (web3, network, { selectedMarket, assetsData, troveId, allMarketsData, }) => __awaiter(void 0, void 0, void 0, function* () {
187
- const viewContract = LiquityV2ViewContract(web3, network);
188
- const { minCollRatio } = allMarketsData[selectedMarket.value].marketData;
204
+ const viewContract = getLiquityV2ViewContract(web3, network, selectedMarket.isLegacy);
205
+ const { minCollRatio, batchCollRatio } = allMarketsData[selectedMarket.value].marketData;
189
206
  const { collateralToken, marketAddress, debtToken } = selectedMarket;
190
207
  const [_data, debtInFront] = yield Promise.all([
191
208
  viewContract.methods.getTroveInfo(marketAddress, troveId).call(),
@@ -220,13 +237,16 @@ export const getLiquityV2TroveData = (web3, network, { selectedMarket, assetsDat
220
237
  const interestRate = new Dec(data.annualInterestRate).div(1e16).toString();
221
238
  const interestBatchManager = data.interestBatchManager;
222
239
  const lastInterestRateAdjTime = data.lastInterestRateAdjTime;
240
+ const hasInterestBatchManager = !compareAddresses(interestBatchManager, ZERO_ADDRESS);
241
+ const liqRatio = hasInterestBatchManager ? new Dec(minCollRatio).add(batchCollRatio).toString() : minCollRatio;
223
242
  const payload = Object.assign(Object.assign({ usedAssets,
224
243
  troveId,
225
244
  interestRate,
226
245
  interestBatchManager,
227
246
  debtInFront,
228
- lastInterestRateAdjTime, troveStatus: LIQUITY_V2_TROVE_STATUS_ENUM[parseInt(data.status, 10)] }, getLiquityV2AggregatedPositionData({
229
- usedAssets, assetsData, minCollRatio, interestRate,
247
+ lastInterestRateAdjTime,
248
+ liqRatio, troveStatus: LIQUITY_V2_TROVE_STATUS_ENUM[parseInt(data.status, 10)] }, getLiquityV2AggregatedPositionData({
249
+ usedAssets, assetsData, minCollRatio: liqRatio, interestRate,
230
250
  })), { collRatio });
231
251
  return payload;
232
252
  });
@@ -3,9 +3,15 @@ import { LiquityV2MarketInfo } from '../../types/liquityV2';
3
3
  export declare const LIQUITY_V2_ETH_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
4
4
  export declare const LIQUITY_V2_WSTETH_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
5
5
  export declare const LIQUITY_V2_RETH_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
6
+ export declare const LIQUITY_V2_ETH_LEGACY_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
7
+ export declare const LIQUITY_V2_WSTETH_LEGACY_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
8
+ export declare const LIQUITY_V2_RETH_LEGACY_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
6
9
  export declare const LiquityV2Markets: (networkId: NetworkNumber) => {
7
10
  readonly liquityv2eth: LiquityV2MarketInfo;
8
11
  readonly liquityv2wsteth: LiquityV2MarketInfo;
9
12
  readonly liquityv2reth: LiquityV2MarketInfo;
13
+ readonly liquityv2ethlegacy: LiquityV2MarketInfo;
14
+ readonly liquityv2wstethlegacy: LiquityV2MarketInfo;
15
+ readonly liquityv2rethlegacy: LiquityV2MarketInfo;
10
16
  };
11
17
  export declare const findLiquityV2MarketByAddress: (marketAddress: EthAddress) => LiquityV2MarketInfo | null;
@@ -9,8 +9,9 @@ export const LIQUITY_V2_ETH_MARKET = (networkId = NetworkNumber.Eth) => ({
9
9
  url: 'eth',
10
10
  debtToken: 'BOLD',
11
11
  collateralToken: 'ETH',
12
- marketAddress: '0x38e1f07b954cfab7239d7acab49997fbaad96476',
12
+ marketAddress: '0x20f7c9ad66983f6523a0881d0f82406541417526',
13
13
  protocolName: 'liquity-v2',
14
+ isLegacy: false,
14
15
  });
15
16
  export const LIQUITY_V2_WSTETH_MARKET = (networkId = NetworkNumber.Eth) => ({
16
17
  chainIds: [NetworkNumber.Eth],
@@ -20,8 +21,9 @@ export const LIQUITY_V2_WSTETH_MARKET = (networkId = NetworkNumber.Eth) => ({
20
21
  url: 'wsteth',
21
22
  debtToken: 'BOLD',
22
23
  collateralToken: 'wstETH',
23
- marketAddress: '0x2d4ef56cb626e9a4c90c156018ba9ce269573c61',
24
+ marketAddress: '0x8d733f7ea7c23cbea7c613b6ebd845d46d3aac54',
24
25
  protocolName: 'liquity-v2',
26
+ isLegacy: false,
25
27
  });
26
28
  export const LIQUITY_V2_RETH_MARKET = (networkId = NetworkNumber.Eth) => ({
27
29
  chainIds: [NetworkNumber.Eth],
@@ -31,13 +33,55 @@ export const LIQUITY_V2_RETH_MARKET = (networkId = NetworkNumber.Eth) => ({
31
33
  url: 'reth',
32
34
  debtToken: 'BOLD',
33
35
  collateralToken: 'rETH',
36
+ marketAddress: '0x6106046f031a22713697e04c08b330ddaf3e8789',
37
+ protocolName: 'liquity-v2',
38
+ isLegacy: false,
39
+ });
40
+ // Legacy markets
41
+ export const LIQUITY_V2_ETH_LEGACY_MARKET = (networkId = NetworkNumber.Eth) => ({
42
+ chainIds: [NetworkNumber.Eth],
43
+ label: 'Liquity V2 ETH Legacy',
44
+ shortLabel: 'ETH Legacy',
45
+ value: LiquityV2Versions.LiquityV2EthLegacy,
46
+ url: 'eth-legacy',
47
+ debtToken: 'BOLD Legacy',
48
+ collateralToken: 'ETH',
49
+ marketAddress: '0x38e1f07b954cfab7239d7acab49997fbaad96476',
50
+ protocolName: 'liquity-v2',
51
+ isLegacy: true,
52
+ });
53
+ export const LIQUITY_V2_WSTETH_LEGACY_MARKET = (networkId = NetworkNumber.Eth) => ({
54
+ chainIds: [NetworkNumber.Eth],
55
+ label: 'Liquity V2 wstETH Legacy',
56
+ shortLabel: 'wstETH Legacy',
57
+ value: LiquityV2Versions.LiquityV2WstEthLegacy,
58
+ url: 'wsteth-legacy',
59
+ debtToken: 'BOLD Legacy',
60
+ collateralToken: 'wstETH',
61
+ marketAddress: '0x2d4ef56cb626e9a4c90c156018ba9ce269573c61',
62
+ protocolName: 'liquity-v2',
63
+ isLegacy: true,
64
+ });
65
+ export const LIQUITY_V2_RETH_LEGACY_MARKET = (networkId = NetworkNumber.Eth) => ({
66
+ chainIds: [NetworkNumber.Eth],
67
+ label: 'Liquity V2 rETH Legacy',
68
+ shortLabel: 'rETH Legacy',
69
+ value: LiquityV2Versions.LiquityV2REthLegacy,
70
+ url: 'reth-legacy',
71
+ debtToken: 'BOLD Legacy',
72
+ collateralToken: 'rETH',
34
73
  marketAddress: '0x3b48169809dd827f22c9e0f2d71ff12ea7a94a2f',
35
74
  protocolName: 'liquity-v2',
75
+ isLegacy: true,
36
76
  });
37
77
  export const LiquityV2Markets = (networkId) => ({
38
78
  [LiquityV2Versions.LiquityV2Eth]: LIQUITY_V2_ETH_MARKET(networkId),
39
79
  [LiquityV2Versions.LiquityV2WstEth]: LIQUITY_V2_WSTETH_MARKET(networkId),
40
80
  [LiquityV2Versions.LiquityV2REth]: LIQUITY_V2_RETH_MARKET(networkId),
81
+ // Legacy
82
+ [LiquityV2Versions.LiquityV2EthLegacy]: LIQUITY_V2_ETH_LEGACY_MARKET(networkId),
83
+ [LiquityV2Versions.LiquityV2WstEthLegacy]: LIQUITY_V2_WSTETH_LEGACY_MARKET(networkId),
84
+ [LiquityV2Versions.LiquityV2REthLegacy]: LIQUITY_V2_RETH_LEGACY_MARKET(networkId),
41
85
  });
42
86
  export const findLiquityV2MarketByAddress = (marketAddress) => {
43
87
  const markets = LiquityV2Markets(NetworkNumber.Eth);