Skip to content

Commit

Permalink
feat: amount and shares as input
Browse files Browse the repository at this point in the history
  • Loading branch information
makcandrov committed Aug 10, 2023
1 parent 4304dd0 commit bb4797a
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions test/blue_tests.tree
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@
├── it should set lastUpdate[market.id] to block.timestamp
└── it should emit CreateMarket(market.id, market)
.
└── supply(Market calldata market, uint256 amount, address onBehalf, bytes calldata data) external
└── supply(Market memory market, uint256 amount, uint256 shares, address onBehalf, bytes calldata data) external
├── when market is not created
│ └── revert with MARKET_NOT_CREATED
└── when market is created
├── when the amount to supply is zero
│ └─revert with ZERO_AMOUNT
└── when the amount to supply is not zero
├── when both amount and shares are null or both amount and shares are not null
│ └─ revert with INCONSISTENT_INPUT
└── when one of amount or shares is null and one of amount or shares is not null
├── when onBehalf is the zero address
│ └── revert with ZERO_ADDRESS
└── when onBehalf is not the zero address
├── it should accrue the interests
├── it should set shares to amount.toSharesDown(totalSupply[market.id], totalSupplyShares[market.id])
├── when amount is not zero
│ └── it should set shares to amount.toSharesUp(totalSupply[market.id], totalSupplyShares[market.id])
├── when amount is zero
│ └── it should set amount to shares.toAssetsDown(totalSupply[id], totalSupplyShares[id])
├── it should add shares to supplyShares[market.id][onBehalf]
├── it should add shares to totalSupplyShares[market.id]
├── it should add amount to totalSupply[market.id]
Expand All @@ -77,44 +80,50 @@
│ └── it should call sender's onBlueSupply callback
└── it should transfer amount of the borrowable asset from the sender to Blue
.
└── withdraw(Market memory market, uint256 shares, address onBehalf, address receiver) external
└── withdraw(Market memory market, uint256 amount, uint256 shares, address onBehalf, address receiver) external
├── when market is not created
│ └── revert with MARKET_NOT_CREATED
└── when market is created
├── when the shares to withdraw are zero
│ └─revert with ZERO_SHARES
└── when the shares to withdraw are not zero
├── when both amount and shares are null or both amount and shares are not null
│ └─ revert with INCONSISTENT_INPUT
└── when one of amount or shares is null and one of amount or shares is not null
├── when receiver is the zero address
│ └── revert with ZERO_ADDRESS
└── when receiver is not the zero address
├── when not sender and not approved
│ └── revert with UNAUTHORIZED
└── when sender or approved
├── it should accrue the interests
├── when amount is not zero
│ └── it should set shares to amount.toSharesUp(totalSupply[market.id], totalSupplyShares[market.id])
├── when amount is zero
│ └── it should set amount to shares.toAssetsDown(totalSupply[id], totalSupplyShares[id])
├── it should remove shares from supplyShares[market.id][onBehalf]
├── it should remove shares from totalSupplyShares[market.id]
├── it should set amount to shares.toAssetsDown(totalSupply[market.id], totalSupplyShares[market.id])
├── it should remove amount from totalSupply[market.id]
├── it should emit Withdraw(market.id, msg.sender, onBehalf, receiver, amount, shares)
├── it should transfer amount of the borrowable asset to the receiver
└── when totalBorrow[market.id] > totalSupply[market.id]
└── revert with INSUFFICIENT_LIQUIDITY
.
└── borrow(Market memory market, uint256 amount, address onBehalf, address receiver) external
└── borrow(Market memory market, uint256 amount, uint256 shares, address onBehalf, address receiver) external
├── when market is not created
│ └── revert with MARKET_NOT_CREATED
└── when market is created
├── when the amount to borrow is zero
│ └─revert with ZERO_AMOUNT
└── when the amount to borrow is not zero
├── when both amount and shares are null or both amount and shares are not null
│ └─ revert with INCONSISTENT_INPUT
└── when one of amount or shares is null and one of amount or shares is not null
├── when receiver is the zero address
│ └── revert with ZERO_ADDRESS
└── when receiver is not the zero address
├── when not sender and not approved
│ └── revert with UNAUTHORIZED
└── when sender or approved
├── it should accrue the interests
├── it should set shares to amount.toSharesUp(totalBorrow[market.id], totalBorrowShares[market.id])
├── when amount is not zero
│ └── it should set shares to amount.toSharesUp(totalSupply[market.id], totalSupplyShares[market.id])
├── when amount is zero
│ └── it should set amount to shares.toAssetsDown(totalSupply[id], totalSupplyShares[id])
├── it should add shares to borrowShares[market.id][onBehalf]
├── it should add shares to totalBorrowShares[market.id]
├── it should add amount to totalBorrow[market.id]
Expand All @@ -126,20 +135,23 @@
└── when totalBorrow[market.id] > totalSupply[market.id]
└── revert with INSUFFICIENT_LIQUIDITY
.
└── repay(Market memory market, uint256 shares, address onBehalf, bytes calldata data) external
└── repay(Market memory market, uint256 amount, uint256 shares, address onBehalf, bytes calldata data) external
├── when market is not created
│ └── revert with MARKET_NOT_CREATED
└── when market is created
├── when the shares to repay are zero
│ └─revert with ZERO_SHARES
└── when the shares to repay are not zero
├── when both amount and shares are null or both amount and shares are not null
│ └─ revert with INCONSISTENT_INPUT
└── when one of amount or shares is null and one of amount or shares is not null
├── when onBehalf is the zero address
│ └── revert with ZERO_ADDRESS
└── when onBehalf is not the zero address
├── it should accrue the interests
├── when amount is not zero
│ └── it should set shares to amount.toSharesUp(totalSupply[market.id], totalSupplyShares[market.id])
├── when amount is zero
│ └── it should set amount to shares.toAssetsDown(totalSupply[id], totalSupplyShares[id])
├── it should remove shares from borrowShares[market.id][onBehalf]
├── it should remove shares from totalBorrowShares[market.id]
├── it should set amount to shares.toAssetsUp(totalBorrow[market.id], totalBorrowShares[market.id])
├── it should remove amount from totalBorrow[market.id]
├── it should emit Repay(market.id, msg.sender, onBehalf, amount, shares)
├── if data.length > 0
Expand Down

0 comments on commit bb4797a

Please sign in to comment.