Fixes the borrow-repay-variable scenario

This commit is contained in:
emilio 2020-08-13 16:58:06 +02:00
parent 85f6feba89
commit db17958737
2 changed files with 169 additions and 44 deletions

View File

@ -34,7 +34,7 @@
]
},
{
"description": "User 0 deposits 1000 DAI, user 1 deposits 1 ETH as collateral and borrows 100 DAI at variable rate",
"description": "User 0 deposits 1000 DAI, user 1 deposits 1 WETH as collateral and borrows 100 DAI at variable rate",
"actions": [
{
"name": "mint",
@ -62,14 +62,30 @@
},
"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",
"sendValue": "1"
"user": "1"
},
"expected": "success"
},
@ -198,8 +214,25 @@
]
},
{
"description": "User 2 deposits a small amount of ETH to account for rounding errors",
"description": "User 2 deposits a small amount of WETH to account for rounding errors",
"actions": [
{
"name": "mint",
"args": {
"reserve": "WETH",
"amount": "1",
"user": "2"
},
"expected": "success"
},
{
"name": "approve",
"args": {
"reserve": "WETH",
"user": "2"
},
"expected": "success"
},
{
"name": "deposit",
"args": {
@ -214,16 +247,32 @@
]
},
{
"description": "User 0 deposits 1 ETH, user 1 deposits 100 LINK as collateral and borrows 0.5 ETH at variable rate",
"description": "User 0 deposits 1 WETH, user 1 deposits 100 LINK as collateral and borrows 0.5 ETH at variable rate",
"actions": [
{
"name": "mint",
"args": {
"reserve": "WETH",
"amount": "1",
"user": "0"
},
"expected": "success"
},
{
"name": "approve",
"args": {
"reserve": "WETH",
"user": "0"
},
"expected": "success"
},
{
"name": "deposit",
"args": {
"reserve": "WETH",
"amount": "1",
"user": "0",
"sendValue": "1"
"user": "0"
},
"expected": "success"
},
@ -275,7 +324,6 @@
"name": "repay",
"args": {
"reserve": "WETH",
"amount": "0",
"user": "1",
"onBehalfOf": "1",
@ -287,25 +335,6 @@
}
]
},
{
"description": "User 1 tries to repay without sending any ETH value (revert expected)",
"actions": [
{
"name": "repay",
"args": {
"reserve": "WETH",
"amount": "-1",
"user": "1",
"borrowRateMode": "variable",
"onBehalfOf": "1",
"sendValue": "0"
},
"expected": "revert",
"revertMessage": "Invalid msg.value sent for the repayment"
}
]
},
{
"description": "User 2 tries to repay everything on behalf of user 1 using uint(-1) (revert expected)",
"actions": [
@ -317,8 +346,7 @@
"amount": "-1",
"user": "2",
"borrowRateMode": "variable",
"onBehalfOf": "1",
"sendValue": "-1"
"onBehalfOf": "1"
},
"expected": "revert",
"revertMessage": "To repay on behalf of an user an explicit amount to repay is needed"
@ -326,8 +354,25 @@
]
},
{
"description": "User 3 repays a small amount of ETH on behalf of user 1",
"description": "User 3 repays a small amount of WETH on behalf of user 1",
"actions": [
{
"name": "mint",
"args": {
"reserve": "WETH",
"amount": "1",
"user": "3"
},
"expected": "success"
},
{
"name": "approve",
"args": {
"reserve": "WETH",
"user": "3"
},
"expected": "success"
},
{
"name": "repay",
"args": {
@ -336,16 +381,32 @@
"amount": "0.2",
"user": "3",
"borrowRateMode": "variable",
"onBehalfOf": "1",
"sendValue": "0.2"
"onBehalfOf": "1"
},
"expected": "success"
}
]
},
{
"description": "User 1 repays the ETH borrow after one year",
"description": "User 1 repays the WETH borrow after one year",
"actions": [
{
"name": "mint",
"args": {
"reserve": "WETH",
"amount": "1",
"user": "2"
},
"expected": "success"
},
{
"name": "approve",
"args": {
"reserve": "WETH",
"user": "2"
},
"expected": "success"
},
{
"name": "repay",
"args": {
@ -354,15 +415,14 @@
"amount": "-1",
"borrowRateMode": "variable",
"user": "1",
"onBehalfOf": "1",
"sendValue": "-1"
"onBehalfOf": "1"
},
"expected": "success"
}
]
},
{
"description": "User 0 redeems the deposited ETH plus interest",
"description": "User 0 redeems the deposited WETH plus interest",
"actions": [
{
"name": "redeem",
@ -423,7 +483,7 @@
]
},
{
"description": "User 0 deposits 1000 USDC, user 1 deposits 1 ETH as collateral and borrows 100 USDC at variable rate",
"description": "User 0 deposits 1000 USDC, user 1 deposits 1 WETH as collateral and borrows 100 USDC at variable rate",
"actions": [
{
"name": "mint",
@ -451,14 +511,30 @@
},
"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",
"sendValue": "1"
"user": "1"
},
"expected": "success"
},
@ -546,7 +622,6 @@
"name": "redeem",
"args": {
"reserve": "WETH",
"amount": "-1",
"user": "1"
},
@ -599,14 +674,30 @@
{
"description": "user 3 deposits 0.1 ETH collateral to borrow 100 DAI; 0.1 ETH is not enough to borrow 100 DAI (revert expected)",
"actions": [
{
"name": "mint",
"args": {
"reserve": "WETH",
"amount": "0.1",
"user": "1"
},
"expected": "success"
},
{
"name": "approve",
"args": {
"reserve": "WETH",
"user": "1"
},
"expected": "success"
},
{
"name": "deposit",
"args": {
"reserve": "WETH",
"amount": "0.1",
"user": "3",
"sendValue": "0.1"
"user": "3"
},
"expected": "success"
},
@ -683,6 +774,23 @@
{
"description": "user 3 deposits 0.1 ETH collateral to borrow 100 USDC; 0.1 ETH is not enough to borrow 100 USDC (revert expected)",
"actions": [
{
"name": "mint",
"args": {
"reserve": "WETH",
"amount": "1",
"user": "3"
},
"expected": "success"
},
{
"name": "approve",
"args": {
"reserve": "WETH",
"user": "1"
},
"expected": "success"
},
{
"name": "deposit",
"args": {
@ -723,7 +831,7 @@
]
},
{
"description": "User 0 deposits 1000 DAI, user 6 deposits 2 ETH and borrow 100 DAI at variable rate first, then 100 DAI at stable rate, repays everything. User 0 redeems",
"description": "User 0 deposits 1000 DAI, user 6 deposits 2 WETH and borrow 100 DAI at variable rate first, then 100 DAI at stable rate, repays everything. User 0 redeems",
"actions": [
{
"name": "mint",
@ -751,6 +859,23 @@
},
"expected": "success"
},
{
"name": "mint",
"args": {
"reserve": "WETH",
"amount": "2",
"user": "6"
},
"expected": "success"
},
{
"name": "approve",
"args": {
"reserve": "WETH",
"user": "6"
},
"expected": "success"
},
{
"name": "deposit",
"args": {

View File

@ -12,7 +12,7 @@ BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN});
const scenarioFolder = './test/helpers/scenarios/';
const selectedScenarios: string[] = ['borrow-repay-stable.json'];
const selectedScenarios: string[] = ['borrow-repay-variable.json'];
fs.readdirSync(scenarioFolder).forEach((file) => {
if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return;