2021-02-07 03:10:29 +00:00
{
"title" : "LendingPool: Usage as collateral" ,
"description" : "Test cases for the setUserUseReserveAsCollateral() function." ,
"stories" : [
{
2021-02-19 20:50:13 +00:00
"description" : "User 0 Deposits 1000 DAI, disables DAI as collateral" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "mint" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "DAI" ,
2021-02-07 03:10:29 +00:00
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "DAI" ,
2021-02-07 03:10:29 +00:00
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "DAI" ,
2021-02-07 03:10:29 +00:00
"amount" : "1000" ,
"user" : "0"
} ,
"expected" : "success"
} ,
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "DAI" ,
2021-02-07 03:10:29 +00:00
"user" : "0" ,
"useAsCollateral" : "false"
} ,
"expected" : "success"
}
]
} ,
{
2021-02-19 20:50:13 +00:00
"description" : "User 1 Deposits 2 WETH, disables WETH as collateral, borrows 400 DAI (revert expected)" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "mint" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"amount" : "2" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"amount" : "2" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1" ,
"useAsCollateral" : "false"
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "DAI" ,
2021-02-07 03:10:29 +00:00
"amount" : "400" ,
"borrowRateMode" : "variable" ,
"user" : "1"
} ,
"expected" : "revert" ,
"revertMessage" : "The collateral balance is 0"
}
]
} ,
{
2021-02-19 20:50:13 +00:00
"description" : "User 1 enables WETH as collateral, borrows 400 DAI" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1" ,
"useAsCollateral" : "true"
} ,
"expected" : "success"
} ,
{
"name" : "borrow" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "DAI" ,
2021-02-07 03:10:29 +00:00
"amount" : "400" ,
"borrowRateMode" : "variable" ,
"user" : "1"
} ,
"expected" : "success"
}
]
} ,
{
2021-02-08 16:05:10 +00:00
"description" : "User 1 disables WETH as collateral (revert expected)" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1" ,
"useAsCollateral" : "false"
} ,
"expected" : "revert" ,
"revertMessage" : "User deposit is already being used as collateral"
}
]
} ,
{
2021-02-19 20:50:13 +00:00
"description" : "User 1 Deposits 10 UNILINKWETH, disables WETH as collateral. Should revert as 10 UNILINKWETH are not enough to cover the debt (revert expected)" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "mint" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "UNILINKWETH" ,
2021-02-07 03:10:29 +00:00
"amount" : "10" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "approve" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "UNILINKWETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "UNILINKWETH" ,
2021-02-07 03:10:29 +00:00
"amount" : "10" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1" ,
"useAsCollateral" : "false"
} ,
"expected" : "revert"
}
]
} ,
{
2021-02-19 20:50:13 +00:00
"description" : "User 1 Deposits 640 more UNILINKWETH (enough to cover the DAI debt), disables WETH as collateral" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "mint" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "UNILINKWETH" ,
2021-02-07 03:10:29 +00:00
"amount" : "640" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "deposit" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "UNILINKWETH" ,
2021-02-07 03:10:29 +00:00
"amount" : "640" ,
"user" : "1"
} ,
"expected" : "success"
} ,
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1" ,
"useAsCollateral" : "false"
} ,
"expected" : "success"
}
]
} ,
{
2021-02-19 20:50:13 +00:00
"description" : "User 1 disables UNILINKWETH as collateral (revert expected)" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-19 20:50:13 +00:00
"reserve" : "UNILINKWETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1" ,
"useAsCollateral" : "false"
} ,
"expected" : "revert"
}
]
} ,
{
2021-02-08 16:05:10 +00:00
"description" : "User 1 reenables WETH as collateral" ,
2021-02-07 03:10:29 +00:00
"actions" : [
{
"name" : "setUseAsCollateral" ,
"args" : {
2021-02-08 16:05:10 +00:00
"reserve" : "WETH" ,
2021-02-07 03:10:29 +00:00
"user" : "1" ,
"useAsCollateral" : "true"
} ,
"expected" : "success"
}
]
}
]
}