mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Adapted test suite and added some tests for LP market
This commit is contained in:
parent
94cdefb2e9
commit
d0a1ea7171
|
@ -462,7 +462,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
|
||||
const reserveData = await pool.getReserveData(weth.address);
|
||||
|
||||
const stableDebtToken = await getVariableDebtToken(reserveData.stableDebtTokenAddress);
|
||||
const stableDebtToken = await getStableDebtToken(reserveData.stableDebtTokenAddress);
|
||||
|
||||
// Deposited for onBehalfOf user already, delegate borrow allowance
|
||||
await stableDebtToken.connect(onBehalfOf.signer).approveDelegation(caller.address, flashAmount);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"description": "Test cases for the borrow function, stable mode.",
|
||||
"stories": [
|
||||
{
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1 deposits 1 WETH as collateral and borrows 100 LPDAI at stable rate",
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1 deposits 1 WETH as collateral and tries to borrow 100 LPDAI at stable rate (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -67,7 +67,7 @@
|
|||
"user": "1",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -83,12 +83,43 @@
|
|||
"user": "1"
|
||||
},
|
||||
"expected": "revert",
|
||||
"revertMessage": "There is not enough collateral to cover a new borrow"
|
||||
"revertMessage": "12"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 repays half of the LPDAI borrow after one year",
|
||||
"description": "User 1 tries to borrow 100 LPDAI at variable",
|
||||
"actions": [
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "100",
|
||||
"borrowRateMode": "variable",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 tries to borrow the rest of the LPDAI liquidity at stable (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "900",
|
||||
"borrowRateMode": "stable",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "revert",
|
||||
"revertMessage": "12"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 repays half of the LPDAI borrow at stable after one year (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -117,12 +148,28 @@
|
|||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "revert"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 repays half of the variable LPDAI borrow after one year",
|
||||
"actions": [
|
||||
{
|
||||
"name": "repay",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "50",
|
||||
"user": "1",
|
||||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "variable"
|
||||
},
|
||||
"expected": "success"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 repays the rest of the LPDAI borrow after one year",
|
||||
"description": "User 1 repays the rest of the LPDAI borrow at stable after one year (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -151,6 +198,22 @@
|
|||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "revert"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 repays the rest of the LPDAI borrow after one year at variable",
|
||||
"actions": [
|
||||
{
|
||||
"name": "repay",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "-1",
|
||||
"user": "1",
|
||||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "variable"
|
||||
},
|
||||
"expected": "success"
|
||||
}
|
||||
]
|
||||
|
@ -221,7 +284,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1,2,3,4 deposit 1 WETH each and borrow 100 LPDAI at stable rate. Everything is repaid, user 0 withdraws",
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1,2,3,4 deposit 1 WETH each and borrow 100 LPDAI at stable rate (revert expected) user 0 withdraws",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -284,7 +347,7 @@
|
|||
"user": "1",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -321,7 +384,7 @@
|
|||
"user": "2",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -358,7 +421,7 @@
|
|||
"user": "3",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -395,7 +458,7 @@
|
|||
"user": "4",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -424,7 +487,7 @@
|
|||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -453,7 +516,7 @@
|
|||
"onBehalfOf": "2",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -482,7 +545,7 @@
|
|||
"onBehalfOf": "3",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -511,7 +574,7 @@
|
|||
"onBehalfOf": "4",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "withdraw",
|
||||
|
@ -525,7 +588,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1 deposits 2 WETH and borrow 100 LPDAI at stable rate first, then 100 LPDAI at variable rate, repays everything. User 0 withdraws",
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1 deposits 2 WETH and borrow 100 LPDAI at stable rate first (revert expected), then 100 LPDAI at variable rate twice, repays everything. User 0 withdraws",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -588,6 +651,17 @@
|
|||
"user": "1",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "100",
|
||||
"borrowRateMode": "variable",
|
||||
"user": "1",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
|
@ -628,7 +702,7 @@
|
|||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "repay",
|
||||
|
|
|
@ -814,7 +814,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 deposits 1000 LPDAI, user 6 deposits 2 WETH and borrow 100 LPDAI at variable rate first, then 100 LPDAI at stable rate, repays everything. User 0 withdraws",
|
||||
"description": "User 0 deposits 1000 LPDAI, user 6 deposits 2 WETH and borrow 100 LPDAI at variable rate first, then 100 LPDAI at stable rate (revert expected), then 100 LPDAI at variable again, repays everything. User 0 withdraws",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -888,6 +888,17 @@
|
|||
"user": "6",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "100",
|
||||
"borrowRateMode": "variable",
|
||||
"user": "6",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
|
@ -917,7 +928,7 @@
|
|||
"onBehalfOf": "6",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "repay",
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 4 trying to borrow 1 WETH stable on behalf of user 0, revert expected",
|
||||
"description": "User 4 trying to borrow 1 WETH stable on behalf of user 0, (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "borrow",
|
||||
|
@ -99,7 +99,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 delegates borrowing of 1 WETH to user 4, user 4 borrows 3 WETH variable on behalf of user 0, revert expected",
|
||||
"description": "User 0 delegates borrowing of 1 WETH to user 4, user 4 borrows 3 WETH variable on behalf of user 0, (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "delegateBorrowAllowance",
|
||||
|
@ -127,7 +127,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 delegates borrowing of 1 WETH on stable to user 2, user 2 borrows 1 WETH stable on behalf of user 0",
|
||||
"description": "User 0 delegates borrowing of 1 WETH on stable to user 2, user 2 borrows 1 WETH stable on behalf of user 0 (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "delegateBorrowAllowance",
|
||||
|
@ -149,6 +149,33 @@
|
|||
"onBehalfOf": "0",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "revert"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 delegates borrowing of 1 WETH on variable to user 2, user 2 borrows 1 WETH variable on behalf of user 0",
|
||||
"actions": [
|
||||
{
|
||||
"name": "delegateBorrowAllowance",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"amount": "1",
|
||||
"user": "0",
|
||||
"borrowRateMode": "variable",
|
||||
"toUser": "2"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"amount": "1",
|
||||
"user": "2",
|
||||
"onBehalfOf": "0",
|
||||
"borrowRateMode": "variable"
|
||||
},
|
||||
"expected": "success"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 deposits 1000 LPUSDC, user 1 deposits 7 WETH, borrows 250 LPUSDC at a stable rate, user 0 rebalances user 1 (revert expected)",
|
||||
"description": "User 0 deposits 1000 LPUSDC, user 1 deposits 7 WETH, borrows 250 LPUSDC at a variable rate, user 0 rebalances user 1 (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -77,7 +77,7 @@
|
|||
"args": {
|
||||
"reserve": "LPUSDC",
|
||||
"amount": "250",
|
||||
"borrowRateMode": "stable",
|
||||
"borrowRateMode": "variable",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
|
@ -171,7 +171,7 @@
|
|||
},
|
||||
|
||||
{
|
||||
"description": "User 1 borrows the remaining LPUSDC (usage ratio = 100%) at variable. User 0 rebalances user 1",
|
||||
"description": "User 1 borrows the remaining LPUSDC (usage ratio = 100%) at variable. User 0 rebalances user 1, fails since there are no stable borrows (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "borrow",
|
||||
|
@ -190,7 +190,7 @@
|
|||
"user": "0",
|
||||
"target": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1 deposits 2 WETH as collateral, borrows 100 LPDAI at variable rate and swaps to stable after one year",
|
||||
"description": "User 0 deposits 1000 LPDAI, user 1 deposits 2 WETH as collateral, borrows 100 LPDAI at variable rate and swaps to stable after one year, fails because stable borrowing is disabled (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -105,12 +105,12 @@
|
|||
"user": "1",
|
||||
"borrowRateMode": "variable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 borrows another 100 LPDAI, and swaps back to variable after one year, repays the loan",
|
||||
"description": "User 1 borrows another 100 LPDAI at stable (revert expected), and swaps back to variable after one year (revert expected), repays the loan",
|
||||
"actions": [
|
||||
{
|
||||
"name": "borrow",
|
||||
|
@ -121,6 +121,60 @@
|
|||
"user": "1",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "swapBorrowRateMode",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"user": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
"description": "Mint 50 LPDAI to cover the interest",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "50",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "approve",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "repay",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "-1",
|
||||
"user": "1",
|
||||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "variable"
|
||||
},
|
||||
"expected": "success"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "User 1 borrows another 100 LPDAI at variable, and tries to swap to stable after one year (revert expected), repays the loan",
|
||||
"actions": [
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "100",
|
||||
"borrowRateMode": "variable",
|
||||
"user": "1",
|
||||
"timeTravel": "365"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
|
@ -130,7 +184,7 @@
|
|||
"user": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "Users 1 deposits 1 WETH, borrows 100 LPDAI, tries to redeem the 1 WETH deposited (revert expected)",
|
||||
"description": "Users 1 deposits 1 WETH, borrows 100 LPDAI stable (revert expected), redeems the 1 WETH deposited",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
|
@ -96,6 +96,56 @@
|
|||
"user": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "withdraw",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"amount": "-1",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Users 1 deposits 1 WETH, borrows 100 LPDAI at variable rate, tries to redeem the 1 WETH deposited (revert expected)",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"amount": "1",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "approve",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "deposit",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"amount": "1",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "100",
|
||||
"user": "1",
|
||||
"borrowRateMode": "variable"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -238,7 +238,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"description": "Users 0 deposits 1000 LPDAI, user 1 Deposit 1000 LPUSDC and 1 WETH, borrows 100 LPDAI. User 1 tries to withdraw all the LPUSDC",
|
||||
"description": "Users 0 deposits 1000 LPDAI, user 1 Deposit 1000 LPUSDC and 1 WETH, borrows 100 LPDAI at stable rate (revert expected). User 1 tries to withdraw all the LPUSDC",
|
||||
"actions": [
|
||||
{
|
||||
"name": "deposit",
|
||||
|
@ -309,6 +309,100 @@
|
|||
"user": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "revert"
|
||||
},
|
||||
{
|
||||
"name": "withdraw",
|
||||
"args": {
|
||||
"reserve": "LPUSDC",
|
||||
"amount": "-1",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Users 0 deposits 1000 LPDAI, user 1 Deposit 1000 LPUSDC and 1 WETH, borrows 100 LPDAI at variable rate. User 1 tries to withdraw all the LPUSDC",
|
||||
"actions": [
|
||||
{
|
||||
"name": "mint",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "1000",
|
||||
"user": "0"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "deposit",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "1000",
|
||||
"user": "0"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
"args": {
|
||||
"reserve": "LPUSDC",
|
||||
"amount": "10000",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "approve",
|
||||
"args": {
|
||||
"reserve": "LPUSDC",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "deposit",
|
||||
"args": {
|
||||
"reserve": "LPUSDC",
|
||||
"amount": "1000",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"amount": "1",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "approve",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "deposit",
|
||||
"args": {
|
||||
"reserve": "WETH",
|
||||
"amount": "1",
|
||||
"user": "1"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
"name": "borrow",
|
||||
"args": {
|
||||
"reserve": "LPDAI",
|
||||
"amount": "100",
|
||||
"user": "1",
|
||||
"borrowRateMode": "variable"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -142,7 +142,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
borrower.address
|
||||
);
|
||||
|
||||
const amountToLiquidate = userReserveDataBefore.currentStableDebt.div(2).toFixed(0);
|
||||
const amountToLiquidate = userReserveDataBefore.currentVariableDebt.div(2).toFixed(0);
|
||||
|
||||
await increaseTime(100);
|
||||
|
||||
|
@ -193,7 +193,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
txTimestamp
|
||||
);
|
||||
|
||||
expect(userReserveDataAfter.currentStableDebt.toString()).to.be.bignumber.almostEqual(
|
||||
expect(userReserveDataAfter.currentVariableDebt.toString()).to.be.bignumber.almostEqual(
|
||||
variableDebtBeforeTx.minus(amountToLiquidate).toFixed(0),
|
||||
'Invalid user debt after liquidation'
|
||||
);
|
||||
|
@ -301,7 +301,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
const ethReserveDataBefore = await helpersContract.getReserveData(weth.address);
|
||||
|
||||
const amountToLiquidate = DRE.ethers.BigNumber.from(
|
||||
userReserveDataBefore.currentStableDebt.toString()
|
||||
userReserveDataBefore.currentVariableDebt.toString()
|
||||
)
|
||||
.div(2)
|
||||
.toString();
|
||||
|
@ -344,8 +344,8 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
'Invalid health factor'
|
||||
);
|
||||
|
||||
expect(userReserveDataAfter.currentStableDebt.toString()).to.be.bignumber.almostEqual(
|
||||
new BigNumber(userReserveDataBefore.currentStableDebt.toString())
|
||||
expect(userReserveDataAfter.currentVariableDebt.toString()).to.be.bignumber.almostEqual(
|
||||
new BigNumber(userReserveDataBefore.currentVariableDebt.toString())
|
||||
.minus(amountToLiquidate)
|
||||
.toFixed(0),
|
||||
'Invalid user borrow balance after liquidation'
|
||||
|
@ -421,7 +421,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
const usdcReserveDataBefore = await helpersContract.getReserveData(usdc.address);
|
||||
const aaveReserveDataBefore = await helpersContract.getReserveData(aave.address);
|
||||
|
||||
const amountToLiquidate = new BigNumber(userReserveDataBefore.currentStableDebt.toString())
|
||||
const amountToLiquidate = new BigNumber(userReserveDataBefore.currentVariableDebt.toString())
|
||||
.div(2)
|
||||
.decimalPlaces(0, BigNumber.ROUND_DOWN)
|
||||
.toFixed(0);
|
||||
|
@ -468,8 +468,8 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
'Invalid health factor'
|
||||
);
|
||||
|
||||
expect(userReserveDataAfter.currentStableDebt.toString()).to.be.bignumber.almostEqual(
|
||||
new BigNumber(userReserveDataBefore.currentStableDebt.toString())
|
||||
expect(userReserveDataAfter.currentVariableDebt.toString()).to.be.bignumber.almostEqual(
|
||||
new BigNumber(userReserveDataBefore.currentVariableDebt.toString())
|
||||
.minus(expectedPrincipal)
|
||||
.toFixed(0),
|
||||
'Invalid user borrow balance after liquidation'
|
||||
|
|
|
@ -131,7 +131,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
|
||||
// Try to execute liquidation
|
||||
await expect(
|
||||
pool.connect(user.signer).borrow(dai.address, '1', '1', '0', user.address)
|
||||
pool.connect(user.signer).borrow(dai.address, '1', '2', '0', user.address)
|
||||
).revertedWith(LP_IS_PAUSED);
|
||||
|
||||
// Unpause the pool
|
||||
|
@ -146,7 +146,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
await configurator.connect(users[1].signer).setPoolPause(true);
|
||||
|
||||
// Try to execute liquidation
|
||||
await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith(
|
||||
await expect(pool.connect(user.signer).repay(dai.address, '1', '2', user.address)).revertedWith(
|
||||
LP_IS_PAUSED
|
||||
);
|
||||
|
||||
|
@ -173,7 +173,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
_mockFlashLoanReceiver.address,
|
||||
[weth.address],
|
||||
[flashAmount],
|
||||
[1],
|
||||
[2],
|
||||
caller.address,
|
||||
'0x10',
|
||||
'0'
|
||||
|
@ -232,7 +232,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
|
||||
await pool
|
||||
.connect(borrower.signer)
|
||||
.borrow(usdc.address, amountUSDCToBorrow, RateMode.Stable, '0', borrower.address);
|
||||
.borrow(usdc.address, amountUSDCToBorrow, RateMode.Variable, '0', borrower.address);
|
||||
|
||||
// Drops HF below 1
|
||||
await oracle.setAssetPrice(
|
||||
|
@ -249,7 +249,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
borrower.address
|
||||
);
|
||||
|
||||
const amountToLiquidate = new BigNumber(userReserveDataBefore.currentStableDebt.toString())
|
||||
const amountToLiquidate = new BigNumber(userReserveDataBefore.currentVariableDebt.toString())
|
||||
.multipliedBy(0.5)
|
||||
.toFixed(0);
|
||||
|
||||
|
@ -265,7 +265,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
await configurator.connect(users[1].signer).setPoolPause(false);
|
||||
});
|
||||
|
||||
it('SwapBorrowRateMode', async () => {
|
||||
it('SwapBorrowRateMode should fail because pool is paused', async () => {
|
||||
const { pool, weth, dai, usdc, users, configurator } = testEnv;
|
||||
const user = users[1];
|
||||
const amountWETHToDeposit = parseEther('10');
|
||||
|
@ -294,7 +294,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
|
|||
await configurator.connect(users[1].signer).setPoolPause(false);
|
||||
});
|
||||
|
||||
it('RebalanceStableBorrowRate', async () => {
|
||||
it('RebalanceStableBorrowRate should fail because the pool is paused, even if there is no stable borrow', async () => {
|
||||
const { pool, dai, users, configurator } = testEnv;
|
||||
const user = users[1];
|
||||
// Pause pool
|
||||
|
|
|
@ -6,6 +6,7 @@ import { DRE, waitForTx } from '../../helpers/misc-utils';
|
|||
import { BigNumber } from 'ethers';
|
||||
import { getStableDebtToken, getVariableDebtToken } from '../../helpers/contracts-getters';
|
||||
import { deploySelfdestructTransferMock } from '../../helpers/contracts-deployments';
|
||||
import { ProtocolErrors } from '../../helpers/types';
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
|
@ -101,7 +102,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
expect(afterFullATokensBalance).to.be.eq(0, 'User aWETH balance should be zero');
|
||||
});
|
||||
|
||||
it('Borrow stable WETH and Full Repay with ETH', async () => {
|
||||
it('Borrowing stable WETH should fail since stable borrowing is disabled', async () => {
|
||||
const { users, wethGateway, aDai, weth, dai, pool, helpersContract } = testEnv;
|
||||
const borrowSize = parseEther('1');
|
||||
const repaySize = borrowSize.add(borrowSize.mul(5).div(100));
|
||||
|
@ -130,27 +131,28 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
expect(aTokensBalance).to.be.gte(daiSize);
|
||||
|
||||
// Borrow WETH with WETH as collateral
|
||||
await waitForTx(
|
||||
await pool.connect(user.signer).borrow(weth.address, borrowSize, '1', '0', user.address)
|
||||
);
|
||||
|
||||
await expect(pool.connect(user.signer).borrow(weth.address, borrowSize, '1', '0', user.address))
|
||||
.to.be.revertedWith(ProtocolErrors.VL_STABLE_BORROWING_NOT_ENABLED);
|
||||
|
||||
const debtBalance = await stableDebtToken.balanceOf(user.address);
|
||||
|
||||
expect(debtBalance).to.be.gt(zero);
|
||||
// const debtBalance = await stableDebtToken.balanceOf(user.address);
|
||||
|
||||
// Full Repay WETH with native ETH
|
||||
await waitForTx(
|
||||
await wethGateway
|
||||
.connect(user.signer)
|
||||
.repayETH(MAX_UINT_AMOUNT, '1', user.address, { value: repaySize })
|
||||
);
|
||||
// expect(debtBalance).to.be.gt(zero);
|
||||
|
||||
const debtBalanceAfterRepay = await stableDebtToken.balanceOf(user.address);
|
||||
expect(debtBalanceAfterRepay).to.be.eq(zero);
|
||||
// // Full Repay WETH with native ETH
|
||||
// await waitForTx(
|
||||
// await wethGateway
|
||||
// .connect(user.signer)
|
||||
// .repayETH(MAX_UINT_AMOUNT, '1', user.address, { value: repaySize })
|
||||
// );
|
||||
|
||||
// Withdraw DAI
|
||||
await aDai.connect(user.signer).approve(pool.address, MAX_UINT_AMOUNT);
|
||||
await pool.connect(user.signer).withdraw(dai.address, MAX_UINT_AMOUNT, user.address);
|
||||
// const debtBalanceAfterRepay = await stableDebtToken.balanceOf(user.address);
|
||||
// expect(debtBalanceAfterRepay).to.be.eq(zero);
|
||||
|
||||
// // Withdraw DAI
|
||||
// await aDai.connect(user.signer).approve(pool.address, MAX_UINT_AMOUNT);
|
||||
// await pool.connect(user.signer).withdraw(dai.address, MAX_UINT_AMOUNT, user.address);
|
||||
});
|
||||
|
||||
it('Borrow variable WETH and Full Repay with ETH', async () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user