Skip to content

Commit fe85c16

Browse files
authored
Merge pull request #56 from BendDAO/feature/auction-duration-hours
1. changing auction duration unit to hours; 2. support configure 100% liquidation bonus; 3. new interest contract for base rate 20%;
2 parents f007f19 + 1a80d20 commit fe85c16

20 files changed

+228
-81
lines changed

abis/LendPool.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,45 @@
697697
"stateMutability": "view",
698698
"type": "function"
699699
},
700+
{
701+
"inputs": [
702+
{
703+
"internalType": "address",
704+
"name": "nftAsset",
705+
"type": "address"
706+
},
707+
{
708+
"internalType": "uint256",
709+
"name": "nftTokenId",
710+
"type": "uint256"
711+
}
712+
],
713+
"name": "getNftAuctionEndTime",
714+
"outputs": [
715+
{
716+
"internalType": "uint256",
717+
"name": "loanId",
718+
"type": "uint256"
719+
},
720+
{
721+
"internalType": "uint256",
722+
"name": "bidStartTimestamp",
723+
"type": "uint256"
724+
},
725+
{
726+
"internalType": "uint256",
727+
"name": "bidEndTimestamp",
728+
"type": "uint256"
729+
},
730+
{
731+
"internalType": "uint256",
732+
"name": "redeemEndTimestamp",
733+
"type": "uint256"
734+
}
735+
],
736+
"stateMutability": "view",
737+
"type": "function"
738+
},
700739
{
701740
"inputs": [
702741
{
@@ -921,6 +960,24 @@
921960
"stateMutability": "view",
922961
"type": "function"
923962
},
963+
{
964+
"inputs": [],
965+
"name": "getPausedTime",
966+
"outputs": [
967+
{
968+
"internalType": "uint256",
969+
"name": "",
970+
"type": "uint256"
971+
},
972+
{
973+
"internalType": "uint256",
974+
"name": "",
975+
"type": "uint256"
976+
}
977+
],
978+
"stateMutability": "view",
979+
"type": "function"
980+
},
924981
{
925982
"inputs": [
926983
{

contracts/interfaces/ILendPool.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ interface ILendPool {
416416
uint256 bidFine
417417
);
418418

419+
function getNftAuctionEndTime(address nftAsset, uint256 nftTokenId)
420+
external
421+
view
422+
returns (
423+
uint256 loanId,
424+
uint256 bidStartTimestamp,
425+
uint256 bidEndTimestamp,
426+
uint256 redeemEndTimestamp
427+
);
428+
419429
function getNftLiquidatePrice(address nftAsset, uint256 nftTokenId)
420430
external
421431
view

contracts/libraries/logic/GenericLogic.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,27 @@ library GenericLogic {
303303

304304
return (vars.minBidFineInReserve, vars.bidFineInReserve);
305305
}
306+
307+
function calculateLoanAuctionEndTimestamp(
308+
DataTypes.NftData storage nftData,
309+
DataTypes.LoanData memory loanData,
310+
uint256 pauseStartTime,
311+
uint256 pauseDurationTime
312+
) internal view returns (uint256 auctionEndTimestamp, uint256 redeemEndTimestamp) {
313+
uint256 extraDuration = 0;
314+
315+
if ((pauseDurationTime > 0) && (loanData.bidStartTimestamp <= pauseStartTime)) {
316+
extraDuration = pauseDurationTime;
317+
}
318+
319+
auctionEndTimestamp =
320+
loanData.bidStartTimestamp +
321+
extraDuration +
322+
(nftData.configuration.getAuctionDuration() * 1 hours);
323+
324+
redeemEndTimestamp =
325+
loanData.bidStartTimestamp +
326+
extraDuration +
327+
(nftData.configuration.getRedeemDuration() * 1 hours);
328+
}
306329
}

contracts/libraries/logic/LiquidateLogic.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ library LiquidateLogic {
180180
vars.auctionEndTimestamp =
181181
loanData.bidStartTimestamp +
182182
vars.extraAuctionDuration +
183-
(nftData.configuration.getAuctionDuration() * 1 days);
183+
(nftData.configuration.getAuctionDuration() * 1 hours);
184184
require(block.timestamp <= vars.auctionEndTimestamp, Errors.LPL_BID_AUCTION_DURATION_HAS_END);
185185

186186
// bid price must greater than highest bid + delta
@@ -275,7 +275,7 @@ library LiquidateLogic {
275275
vars.redeemEndTimestamp = (loanData.bidStartTimestamp +
276276
vars.extraRedeemDuration +
277277
nftData.configuration.getRedeemDuration() *
278-
1 days);
278+
1 hours);
279279
require(block.timestamp <= vars.redeemEndTimestamp, Errors.LPL_BID_REDEEM_DURATION_HAS_END);
280280

281281
// update state MUST BEFORE get borrow amount which is depent on latest borrow index
@@ -411,7 +411,7 @@ library LiquidateLogic {
411411
vars.auctionEndTimestamp =
412412
loanData.bidStartTimestamp +
413413
vars.extraAuctionDuration +
414-
(nftData.configuration.getAuctionDuration() * 1 days);
414+
(nftData.configuration.getAuctionDuration() * 1 hours);
415415
require(block.timestamp > vars.auctionEndTimestamp, Errors.LPL_BID_AUCTION_DURATION_NOT_END);
416416

417417
// update state MUST BEFORE get borrow amount which is depent on latest borrow index

contracts/protocol/LendPool.sol

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,36 @@ contract LendPool is
582582
}
583583
}
584584

585+
function getNftAuctionEndTime(address nftAsset, uint256 nftTokenId)
586+
external
587+
view
588+
override
589+
returns (
590+
uint256 loanId,
591+
uint256 bidStartTimestamp,
592+
uint256 bidEndTimestamp,
593+
uint256 redeemEndTimestamp
594+
)
595+
{
596+
DataTypes.NftData storage nftData = _nfts[nftAsset];
597+
ILendPoolLoan poolLoan = ILendPoolLoan(_addressesProvider.getLendPoolLoan());
598+
599+
loanId = poolLoan.getCollateralLoanId(nftAsset, nftTokenId);
600+
if (loanId != 0) {
601+
DataTypes.LoanData memory loan = ILendPoolLoan(_addressesProvider.getLendPoolLoan()).getLoan(loanId);
602+
603+
bidStartTimestamp = loan.bidStartTimestamp;
604+
if (bidStartTimestamp > 0) {
605+
(bidEndTimestamp, redeemEndTimestamp) = GenericLogic.calculateLoanAuctionEndTimestamp(
606+
nftData,
607+
loan,
608+
_pauseStartTime,
609+
_pauseDurationTime
610+
);
611+
}
612+
}
613+
}
614+
585615
struct GetLiquidationPriceLocalVars {
586616
address poolLoan;
587617
uint256 loanId;

contracts/protocol/LendPoolConfigurator.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ contract LendPoolConfigurator is Initializable, ILendPoolConfigurator {
246246
require(ltv <= liquidationThreshold, Errors.LPC_INVALID_CONFIGURATION);
247247

248248
if (liquidationThreshold != 0) {
249-
//liquidation bonus must be smaller than 100.00%
250-
require(liquidationBonus < PercentageMath.PERCENTAGE_FACTOR, Errors.LPC_INVALID_CONFIGURATION);
249+
//liquidation bonus must be smaller than or equal 100.00%
250+
require(liquidationBonus <= PercentageMath.PERCENTAGE_FACTOR, Errors.LPC_INVALID_CONFIGURATION);
251251
} else {
252252
require(liquidationBonus == 0, Errors.LPC_INVALID_CONFIGURATION);
253253
}
@@ -342,8 +342,8 @@ contract LendPoolConfigurator is Initializable, ILendPoolConfigurator {
342342
require(inputs[i].baseLTV <= inputs[i].liquidationThreshold, Errors.LPC_INVALID_CONFIGURATION);
343343

344344
if (inputs[i].liquidationThreshold != 0) {
345-
//liquidation bonus must be smaller than 100.00%
346-
require(inputs[i].liquidationBonus < PercentageMath.PERCENTAGE_FACTOR, Errors.LPC_INVALID_CONFIGURATION);
345+
//liquidation bonus must be smaller than or equal 100.00%
346+
require(inputs[i].liquidationBonus <= PercentageMath.PERCENTAGE_FACTOR, Errors.LPC_INVALID_CONFIGURATION);
347347
} else {
348348
require(inputs[i].liquidationBonus == 0, Errors.LPC_INVALID_CONFIGURATION);
349349
}

deployments/deployed-contracts-main.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,39 @@
2929
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
3030
},
3131
"ReserveLogic": {
32-
"address": "0x3837BE5033B370894B37c511108Cf4b3CB2B2101",
32+
"address": "0x561bc6b912a677A29B799aCef65156D0e40eFcce",
3333
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
3434
},
3535
"NftLogic": {
36-
"address": "0x8ed4C0A0dEFF233F4789C8BD0E761Eb4ab06aE4F",
36+
"address": "0x6F6D907a4AD9b6Ab93c0dAd8668Df3C7a44777aA",
3737
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
3838
},
3939
"GenericLogic": {
40-
"address": "0x635120825aae07ecFE409708D3f20a66A4C52e55",
40+
"address": "0xa5C59eAAdCec1F2De31B509304ebB08bd25c39e4",
4141
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
4242
},
4343
"ValidationLogic": {
44-
"address": "0x363176A4B00a9d48fdB193A9Ed0F34E7cb835F35",
44+
"address": "0x883E3A1a1C7d1F0aaD28FE77E87a8F45C4D0ed76",
4545
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
4646
},
4747
"SupplyLogic": {
48-
"address": "0x0cf54d474Beaa0D29793D221365d935F1762885D",
48+
"address": "0x066A28d0f844aF0A51ACb80Fc9eF9c584d09b2c9",
4949
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
5050
},
5151
"BorrowLogic": {
52-
"address": "0xadc2cD054E4D94E76a976C59108112A066523C59",
52+
"address": "0x7EDF3f0d854CbB032f05B9ea640BBE99D9Ab4996",
5353
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
5454
},
5555
"LiquidateLogic": {
56-
"address": "0xFeae4174AD2e9155A0181C1Bd95bC442Cb32c04B",
56+
"address": "0xB7A7EfbFbAa052FEF35963c5EeA3f38fF39998EB",
5757
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
5858
},
5959
"ConfiguratorLogic": {
60-
"address": "0x3BC07a0C6af311b7532D39DD57A57a37d29d6770",
60+
"address": "0xA3A9fc3FB4026487C78773e400725EF086E8743A",
6161
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
6262
},
6363
"LendPoolImpl": {
64-
"address": "0xE240Cf264866c2b69fd72cdE2144aE149f82219b"
64+
"address": "0x290afB1f68131D39De177199b57Fb613a31066a4"
6565
},
6666
"LendPool": {
6767
"address": "0x70b97A0da65C15dfb0FFA02aEE6FA36e507C2762"
@@ -73,7 +73,7 @@
7373
"address": "0x5f6ac80CdB9E87f3Cfa6a90E5140B9a16A361d5C"
7474
},
7575
"LendPoolConfiguratorImpl": {
76-
"address": "0x0092c3f81BC7d630dD1f885D0be67047f54D5aF1"
76+
"address": "0x29aF464979A9AAE9da65B27692556A44eb48e26e"
7777
},
7878
"LendPoolConfigurator": {
7979
"address": "0x4f694372ced64B8Cf389A04f13E67ac0035A6449"
@@ -94,8 +94,8 @@
9494
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
9595
},
9696
"InterestRate": {
97-
"address": "0x710A2b4B5f267047728402F1594f440a2aCbaE02",
98-
"deployer": "0x8Bd671Ff94fCF7cAFF7e396A3aC38db2720DB3a7"
97+
"address": "0x9Dc361cbc7b2855424A534428eCe32084F54e2dc",
98+
"deployer": "0x868964fa49a6fd6e116FE82c8f4165904406f479"
9999
},
100100
"rateStrategyWETH": {
101101
"address": "0xBa061Eecd101dAEed3EB87504903702a6B5708Cd"

deployments/deployed-contracts-rinkeby.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,39 +65,39 @@
6565
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
6666
},
6767
"ReserveLogic": {
68-
"address": "0xD1e1B9aa5E555E8e47daD3FB4dD700Bd0b63DdcF",
68+
"address": "0xD84bED3a899d10aF89EB8c819C1B43505F490286",
6969
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
7070
},
7171
"NftLogic": {
72-
"address": "0x2e0A08A86B1a6F1ead19292bC9B5fD8194723B64",
72+
"address": "0x521cB2F2CDBaC1e84013b27Fa8E463e03C177Eae",
7373
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
7474
},
7575
"GenericLogic": {
76-
"address": "0xab98bB2Cb8f33300AC917a9CD0888289167c8126",
76+
"address": "0xeD6E5DcDa734d00FFc42BE5e2445d9BD108c82D7",
7777
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
7878
},
7979
"ValidationLogic": {
80-
"address": "0x33e9E61029F311D610d7490cAC5fc6375e3720EE",
80+
"address": "0x52Fc533CE927DA524A81841a1ab6e13A0c6EceD7",
8181
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
8282
},
8383
"SupplyLogic": {
84-
"address": "0xC7902D5B26aFB46a144a557e26d046025755275c",
84+
"address": "0xfDc4E4D9402b53A6aDD16Fd74b169505f0bB799C",
8585
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
8686
},
8787
"BorrowLogic": {
88-
"address": "0x88dC9d0f80A39c6d1B3815f3d759Fab85A719390",
88+
"address": "0x11CB57110945bb50788393ace9b4112E91BfD25B",
8989
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
9090
},
9191
"LiquidateLogic": {
92-
"address": "0xaf99e805C8Df7a55A3C80a5530e7CcE73E26af38",
92+
"address": "0x8b2FEd56Fad9BC09a9821125059Aa870521362e7",
9393
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
9494
},
9595
"ConfiguratorLogic": {
96-
"address": "0xfDE825Dd9622E0Dfc7230536fb18661548960fD4",
96+
"address": "0xB0ad8c9c221D27af3524511Cf7FAa917E8aDEfD5",
9797
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
9898
},
9999
"LendPoolImpl": {
100-
"address": "0x659ffD5dFcA5E1A8f080c7c60a3C70Cd0C06a483"
100+
"address": "0xeb5fAda5e0A7b8488652beEa073786eaDeA1A722"
101101
},
102102
"LendPool": {
103103
"address": "0xa8D0e90bCB533d70067EEc37601fa7D5C5b3F13E"
@@ -109,7 +109,7 @@
109109
"address": "0xbc622a62bAC3B7de0659A0Dc7b50E4d59aF11377"
110110
},
111111
"LendPoolConfiguratorImpl": {
112-
"address": "0xD738d9E7F6F26723Ba93a71f746Bd11B239931b0"
112+
"address": "0x08c73458a822d1b4f83E6fEbb5f80f0ccE608758"
113113
},
114114
"LendPoolConfigurator": {
115115
"address": "0x97987245f5Cb66c1EF4A1f750eb6865931486Fd6"
@@ -143,7 +143,7 @@
143143
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
144144
},
145145
"InterestRate": {
146-
"address": "0xcC99f8f4d833cD03763548E8F7a1AffA92C9F595",
146+
"address": "0xCb36e76418F774B7B584302d34B46Ae07579a062",
147147
"deployer": "0xafF5C36642385b6c7Aaf7585eC785aB2316b5db6"
148148
},
149149
"rateStrategyWETH": {

helper-hardhat-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
4747
[eEthereumNetwork.develop]: 65 * GWEI,
4848
[eEthereumNetwork.rinkeby]: 65 * GWEI,
4949
[eEthereumNetwork.kovan]: 65 * GWEI,
50-
[eEthereumNetwork.main]: 65 * GWEI,
50+
[eEthereumNetwork.main]: 25 * GWEI,
5151
[eEthereumNetwork.coverage]: 65 * GWEI,
5252
[eEthereumNetwork.hardhat]: 65 * GWEI,
5353
[eEthereumNetwork.localhost]: 65 * GWEI,

0 commit comments

Comments
 (0)