Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions abis/LendPool.json
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@
"internalType": "uint256",
"name": "maxTokenId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxCollateralCap",
"type": "uint256"
}
],
"internalType": "struct DataTypes.NftData",
Expand Down Expand Up @@ -1072,6 +1077,11 @@
"internalType": "uint8",
"name": "id",
"type": "uint8"
},
{
"internalType": "uint256",
"name": "maxUtilizationRate",
"type": "uint256"
}
],
"internalType": "struct DataTypes.ReserveData",
Expand Down Expand Up @@ -1380,6 +1390,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "maxCap",
"type": "uint256"
}
],
"name": "setNftMaxCollateralCap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -1470,6 +1498,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "maxUtilRate",
"type": "uint256"
}
],
"name": "setReserveMaxUtilizationRate",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
13 changes: 13 additions & 0 deletions abis/LendPoolAddressesProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@
"name": "WalletBalanceProviderUpdated",
"type": "event"
},
{
"inputs": [],
"name": "RISK_ADMIN",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
101 changes: 99 additions & 2 deletions abis/LendPoolConfigurator.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,25 @@
"name": "NftInitialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "maxCap",
"type": "uint256"
}
],
"name": "NftMaxCollateralCapChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -436,6 +455,25 @@
"name": "ReserveInterestRateChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "maxUtilRate",
"type": "uint256"
}
],
"name": "ReserveMaxUtilizationRateChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand All @@ -449,6 +487,19 @@
"name": "ReserveUnfrozen",
"type": "event"
},
{
"inputs": [],
"name": "RISK_ADMIN",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -543,9 +594,14 @@
"internalType": "uint256",
"name": "maxTokenId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxCollateralCap",
"type": "uint256"
}
],
"internalType": "struct ILendPoolConfigurator.ConfigNftInput[]",
"internalType": "struct ConfigTypes.ConfigNftInput[]",
"name": "inputs",
"type": "tuple[]"
}
Expand All @@ -568,9 +624,14 @@
"internalType": "uint256",
"name": "reserveFactor",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxUtilizationRate",
"type": "uint256"
}
],
"internalType": "struct ILendPoolConfigurator.ConfigReserveInput[]",
"internalType": "struct ConfigTypes.ConfigReserveInput[]",
"name": "inputs",
"type": "tuple[]"
}
Expand Down Expand Up @@ -920,6 +981,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "assets",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "maxCap",
"type": "uint256"
}
],
"name": "setNftMaxCollateralCap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -1046,6 +1125,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "assets",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "maxUtilRate",
"type": "uint256"
}
],
"name": "setReserveMaxUtilizationRate",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
4 changes: 4 additions & 0 deletions contracts/interfaces/ILendPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ interface ILendPool {

function setReserveConfiguration(address asset, uint256 configuration) external;

function setReserveMaxUtilizationRate(address asset, uint256 maxUtilRate) external;

function setNftConfiguration(address asset, uint256 configuration) external;

function setNftMaxSupplyAndTokenId(
Expand All @@ -472,6 +474,8 @@ interface ILendPool {
uint256 maxTokenId
) external;

function setNftMaxCollateralCap(address asset, uint256 maxCap) external;

function setMaxNumberOfReserves(uint256 val) external;

function setMaxNumberOfNfts(uint256 val) external;
Expand Down
23 changes: 4 additions & 19 deletions contracts/interfaces/ILendPoolConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,6 @@
pragma solidity 0.8.4;

interface ILendPoolConfigurator {
struct ConfigReserveInput {
address asset;
uint256 reserveFactor;
}

struct ConfigNftInput {
address asset;
uint256 baseLTV;
uint256 liquidationThreshold;
uint256 liquidationBonus;
uint256 redeemDuration;
uint256 auctionDuration;
uint256 redeemFine;
uint256 redeemThreshold;
uint256 minBidFine;
uint256 maxSupply;
uint256 maxTokenId;
}

/**
* @dev Emitted when a reserve is initialized.
* @param asset The address of the underlying asset of the reserve
Expand Down Expand Up @@ -92,6 +73,8 @@ interface ILendPoolConfigurator {
**/
event ReserveInterestRateChanged(address indexed asset, address strategy);

event ReserveMaxUtilizationRateChanged(address indexed asset, uint256 maxUtilRate);

/**
* @dev Emitted when a nft is initialized.
* @param asset The address of the underlying asset of the nft
Expand Down Expand Up @@ -152,6 +135,8 @@ interface ILendPoolConfigurator {

event NftMaxSupplyAndTokenIdChanged(address indexed asset, uint256 maxSupply, uint256 maxTokenId);

event NftMaxCollateralCapChanged(address indexed asset, uint256 maxCap);

event LoanRepaidInterceptorApproval(address indexed interceptor, bool approved);

event FlashLoanLockerApproval(address indexed locker, bool approved);
Expand Down
2 changes: 2 additions & 0 deletions contracts/libraries/helpers/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ library Errors {
string public constant VL_SPECIFIED_RESERVE_NOT_BORROWED_BY_USER = "318";
string public constant VL_HEALTH_FACTOR_HIGHER_THAN_LIQUIDATION_THRESHOLD = "319";
string public constant VL_PRICE_STALE = "320";
string public constant VL_EXCEED_MAX_UTILIZATION_RATE = "321";

//lend pool errors
string public constant LP_CALLER_NOT_LEND_POOL_CONFIGURATOR = "400"; // 'The caller of the function is not the lending pool configurator'
Expand All @@ -73,6 +74,7 @@ library Errors {
string public constant LP_NFT_SUPPLY_NUM_EXCEED_MAX_LIMIT = "418";
string public constant LP_CALLER_NOT_VALID_INTERCEPTOR = "419";
string public constant LP_CALLER_NOT_VALID_LOCKER = "420";
string public constant LP_NFT_COLLATERAL_NUM_EXCEED_CAP_LIMIT = "421";

//lend pool loan errors
string public constant LPL_INVALID_LOAN_STATE = "480";
Expand Down
4 changes: 4 additions & 0 deletions contracts/libraries/logic/BorrowLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ library BorrowLogic {
address nftOracle;
address loanAddress;
uint256 totalSupply;
uint256 bnftTotalSupply;
}

/**
Expand Down Expand Up @@ -183,6 +184,9 @@ library BorrowLogic {
);

if (vars.loanId == 0) {
vars.bnftTotalSupply = IERC721EnumerableUpgradeable(nftData.bNftAddress).totalSupply();
require(vars.bnftTotalSupply < nftData.maxCollateralCap, Errors.LP_NFT_COLLATERAL_NUM_EXCEED_CAP_LIMIT);

IERC721Upgradeable(params.nftAsset).safeTransferFrom(vars.initiator, address(this), params.nftTokenId);

vars.loanId = ILendPoolLoan(vars.loanAddress).createLoan(
Expand Down
Loading
Loading