2020-06-08 12:03:40 +00:00
{
"title" : "LendingPool: Borrow/repay (stable rate)" ,
"description" : "Test cases for the borrow function, stable mode." ,
"stories" : [
{
2020-08-13 14:15:02 +00:00
"description" : "User 0 deposits 1000 DAI, user 1 deposits 1 WETH as collateral and borrows 100 DAI at stable rate" ,
2020-06-08 12:03:40 +00:00
"actions" : [
{
"name" : "mint" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
2020-08-13 14:15:02 +00:00
{
"name" : "mint" ,
"args" : {
"reserve" : "WETH" ,
"amount" : "1" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "WETH" ,
"user" : "1"
} ,
"expected" : "success"
} ,
2020-06-08 12:03:40 +00:00
{
"name" : "deposit" ,
"args" : {
2020-08-13 11:06:23 +00:00
"reserve" : "WETH" ,
2020-06-08 12:03:40 +00:00
"amount" : "1" ,
2020-08-17 11:48:23 +00:00
"user" : "1"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "100" ,
"borrowRateMode" : "stable" ,
"user" : "1" ,
"timeTravel" : "365"
} ,
"expected" : "success"
}
]
} ,
{
"description" : "User 1 tries to borrow the rest of the DAI liquidity (revert expected)" ,
"actions" : [
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "900" ,
"borrowRateMode" : "stable" ,
"user" : "1"
} ,
"expected" : "revert" ,
"revertMessage" : "There is not enough collateral to cover a new borrow"
}
]
} ,
{
2020-08-20 15:09:23 +00:00
"description" : "User 1 repays the half of the DAI borrow after one year" ,
"actions" : [
{
"name" : "mint" ,
"description" : "Mint 10 DAI to cover the interest" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "10" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "repay" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "50" ,
"user" : "1" ,
"onBehalfOf" : "1" ,
"borrowRateMode" : "stable"
} ,
"expected" : "success"
}
]
} ,
{
"description" : "User 1 repays the rest of the DAI borrow after one year" ,
2020-06-08 12:03:40 +00:00
"actions" : [
{
"name" : "mint" ,
"description" : "Mint 15 DAI to cover the interest" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "15" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "repay" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "1" ,
2020-07-03 21:20:02 +00:00
"onBehalfOf" : "1" ,
"borrowRateMode" : "stable"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
}
]
} ,
{
2020-08-19 10:56:39 +00:00
"description" : "User 0 withdraws the deposited DAI plus interest" ,
2020-06-08 12:03:40 +00:00
"actions" : [
{
2020-08-19 10:56:39 +00:00
"name" : "withdraw" ,
2020-06-08 12:03:40 +00:00
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "0"
} ,
"expected" : "success"
}
]
} ,
{
"description" : "User 1 deposits 1000 DAI, user 2 tries to borrow 1000 DAI at a stable rate without any collateral (revert expected)" ,
"actions" : [
{
"name" : "mint" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"borrowRateMode" : "stable" ,
"user" : "2"
} ,
"expected" : "revert" ,
"revertMessage" : "The collateral balance is 0"
}
]
} ,
{
2020-08-19 10:56:39 +00:00
"description" : "User 0 deposits 1000 DAI, user 1,2,3,4 deposit 1 WETH each and borrow 100 DAI at stable rate. Everything is repaid, user 0 withdraws" ,
2020-06-08 12:03:40 +00:00
"actions" : [
{
"name" : "mint" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
2020-08-13 14:15:02 +00:00
{
"name" : "mint" ,
"args" : {
"reserve" : "WETH" ,
"amount" : "1" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "WETH" ,
"user" : "1"
} ,
"expected" : "success"
} ,
2020-06-08 12:03:40 +00:00
{
"name" : "deposit" ,
"args" : {
2020-08-13 11:06:23 +00:00
"reserve" : "WETH" ,
2020-06-08 12:03:40 +00:00
"amount" : "1" ,
2020-08-13 14:15:02 +00:00
"user" : "1"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "100" ,
"borrowRateMode" : "stable" ,
"user" : "1" ,
"timeTravel" : "365"
} ,
"expected" : "success"
} ,
2020-08-13 14:15:02 +00:00
{
"name" : "mint" ,
"args" : {
"reserve" : "WETH" ,
"amount" : "1" ,
"user" : "2"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "WETH" ,
"user" : "2"
} ,
"expected" : "success"
} ,
2020-06-08 12:03:40 +00:00
{
"name" : "deposit" ,
"args" : {
2020-08-13 11:06:23 +00:00
"reserve" : "WETH" ,
2020-06-08 12:03:40 +00:00
"amount" : "1" ,
2020-08-13 14:15:02 +00:00
"user" : "2"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "100" ,
"borrowRateMode" : "stable" ,
"user" : "2" ,
"timeTravel" : "365"
} ,
"expected" : "success"
} ,
2020-08-13 14:15:02 +00:00
{
"name" : "mint" ,
"args" : {
"reserve" : "WETH" ,
"amount" : "1" ,
"user" : "3"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "WETH" ,
"user" : "3"
} ,
"expected" : "success"
} ,
2020-06-08 12:03:40 +00:00
{
"name" : "deposit" ,
"args" : {
2020-08-13 11:06:23 +00:00
"reserve" : "WETH" ,
2020-06-08 12:03:40 +00:00
"amount" : "1" ,
2020-08-13 14:15:02 +00:00
"user" : "3"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "100" ,
"borrowRateMode" : "stable" ,
"user" : "3" ,
"timeTravel" : "365"
} ,
"expected" : "success"
} ,
2020-08-13 14:15:02 +00:00
{
"name" : "mint" ,
"args" : {
"reserve" : "WETH" ,
"amount" : "1" ,
"user" : "4"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "WETH" ,
"user" : "4"
} ,
"expected" : "success"
} ,
2020-06-08 12:03:40 +00:00
{
"name" : "deposit" ,
"args" : {
2020-08-13 11:06:23 +00:00
"reserve" : "WETH" ,
2020-06-08 12:03:40 +00:00
"amount" : "1" ,
2020-08-13 14:15:02 +00:00
"user" : "4"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "100" ,
"borrowRateMode" : "stable" ,
"user" : "4" ,
"timeTravel" : "365"
} ,
"expected" : "success"
} ,
{
"name" : "mint" ,
"description" : "Mint 15 DAI to cover the interest" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "15" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "repay" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "1" ,
2020-07-03 21:20:02 +00:00
"onBehalfOf" : "1" ,
"borrowRateMode" : "stable"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "mint" ,
2020-07-03 21:20:02 +00:00
"description" : "Mint 20 DAI to cover the interest" ,
2020-06-08 12:03:40 +00:00
"args" : {
"reserve" : "DAI" ,
2020-07-03 21:20:02 +00:00
"amount" : "20" ,
2020-06-08 12:03:40 +00:00
"user" : "2"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "2"
} ,
"expected" : "success"
} ,
{
"name" : "repay" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "2" ,
2020-07-03 21:20:02 +00:00
"onBehalfOf" : "2" ,
"borrowRateMode" : "stable"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "mint" ,
"description" : "Mint 30 DAI to cover the interest" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "30" ,
"user" : "3"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "3"
} ,
"expected" : "success"
} ,
{
"name" : "repay" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "3" ,
2020-07-03 21:20:02 +00:00
"onBehalfOf" : "3" ,
"borrowRateMode" : "stable"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "mint" ,
"description" : "Mint 30 DAI to cover the interest" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "30" ,
"user" : "4"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "4"
} ,
"expected" : "success"
} ,
{
"name" : "repay" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "4" ,
2020-07-03 21:20:02 +00:00
"onBehalfOf" : "4" ,
"borrowRateMode" : "stable"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
2020-08-19 10:56:39 +00:00
"name" : "withdraw" ,
2020-06-08 12:03:40 +00:00
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "0"
} ,
"expected" : "success"
}
]
} ,
{
2020-08-19 10:56:39 +00:00
"description" : "User 0 deposits 1000 DAI, user 1 deposits 2 WETH and borrow 100 DAI at stable rate first, then 100 DAI at variable rate, repays everything. User 0 withdraws" ,
2020-06-08 12:03:40 +00:00
"actions" : [
{
"name" : "mint" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
2020-08-13 14:15:02 +00:00
{
"name" : "mint" ,
"args" : {
"reserve" : "WETH" ,
"amount" : "2" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "WETH" ,
"user" : "1"
} ,
"expected" : "success"
} ,
2020-06-08 12:03:40 +00:00
{
"name" : "deposit" ,
"args" : {
2020-08-13 11:06:23 +00:00
"reserve" : "WETH" ,
2020-06-08 12:03:40 +00:00
"amount" : "2" ,
2020-08-13 14:15:02 +00:00
"user" : "1"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "100" ,
"borrowRateMode" : "stable" ,
"user" : "1" ,
"timeTravel" : "365"
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "100" ,
"borrowRateMode" : "variable" ,
"user" : "1" ,
"timeTravel" : "365"
} ,
"expected" : "success"
} ,
{
"name" : "mint" ,
"description" : "Mint 50 DAI to cover the interest" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "50" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
"reserve" : "DAI" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "repay" ,
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "1" ,
2020-07-03 21:20:02 +00:00
"onBehalfOf" : "1" ,
"borrowRateMode" : "stable"
2020-06-08 12:03:40 +00:00
} ,
"expected" : "success"
} ,
{
2020-08-19 10:56:39 +00:00
"name" : "withdraw" ,
2020-06-08 12:03:40 +00:00
"args" : {
"reserve" : "DAI" ,
"amount" : "-1" ,
"user" : "0"
} ,
"expected" : "success"
}
]
}
]
2020-07-13 08:54:08 +00:00
}