Skip to content

Commit

Permalink
fix collateral mgr
Browse files Browse the repository at this point in the history
  • Loading branch information
ethereumdegen committed Oct 11, 2024
1 parent 5f1d6b3 commit b301ac1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 6 additions & 3 deletions packages/contracts/contracts/CollateralManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradea
import "./interfaces/ICollateralManager.sol";
import { Collateral, CollateralType, ICollateralEscrowV1 } from "./interfaces/escrow/ICollateralEscrowV1.sol";
import "./interfaces/ITellerV2.sol";

import "./interfaces/IProtocolPausingManager.sol";
import "./interfaces/IHasProtocolPausingManager.sol";
contract CollateralManager is OwnableUpgradeable, ICollateralManager {
/* Storage */
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
Expand Down Expand Up @@ -78,8 +79,10 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager {
_;
}

modifier whenProtocolNotPaused() {
require( PausableUpgradeable(address(tellerV2)).paused() == false , "Protocol is paused");
modifier whenProtocolNotPaused() {
address pausingManager = IHasProtocolPausingManager( address(tellerV2) ).getProtocolPausingManager();

require( IProtocolPausingManager(address(pausingManager)).protocolPaused() == false , "Protocol is paused");
_;
}

Expand Down
6 changes: 5 additions & 1 deletion packages/contracts/tests/TellerV2/TellerV2_Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract TellerV2_Test is Testable {
WethMock wethMock;
TestERC20Token daiMock;
CollateralManager collateralManager;
ProtocolPausingManager protocolPausingManager;

uint256 marketId1;
uint256 collateralAmount = 10;
Expand Down Expand Up @@ -81,7 +82,7 @@ contract TellerV2_Test is Testable {
EscrowVault escrowVault = new EscrowVault();
escrowVault.initialize();

ProtocolPausingManager protocolPausingManager = new ProtocolPausingManager();
protocolPausingManager = new ProtocolPausingManager();
protocolPausingManager.initialize();

// Deploy LenderCommitmentForwarder
Expand Down Expand Up @@ -171,6 +172,9 @@ contract TellerV2_Test is Testable {
}

function test_collateralEscrow() public {



// Submit bid as borrower
uint256 bidId = submitCollateralBid();
// Accept bid as lender
Expand Down
12 changes: 6 additions & 6 deletions packages/contracts/tests/TellerV2/TellerV2_bids.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ contract TellerV2_bids_test is Testable {

collateralManagerMock.forceSetCommitCollateralValidation(false);

vm.expectRevert("Collateral balance could not be validated");
vm.expectRevert("C bal NV");
tellerV2.submitBid(
address(1), // lending token
1, // market ID
Expand Down Expand Up @@ -321,7 +321,7 @@ contract TellerV2_bids_test is Testable {
ActionNotAllowed.selector,
bidId,
"cancelBid",
"Only the bid owner can cancel!"
"Not bid owner"
)
);
tellerV2.cancelBid(bidId);
Expand Down Expand Up @@ -421,7 +421,7 @@ contract TellerV2_bids_test is Testable {
ActionNotAllowed.selector,
bidId,
"lenderAcceptBid",
"Bid must be pending"
"Bid not pending"
)
);

Expand Down Expand Up @@ -660,7 +660,7 @@ contract TellerV2_bids_test is Testable {
ActionNotAllowed.selector,
bidId,
"repayLoan",
"Loan must be accepted"
"Loan not accepted"
)
);

Expand Down Expand Up @@ -701,7 +701,7 @@ contract TellerV2_bids_test is Testable {
ActionNotAllowed.selector,
bidId,
"repayLoan",
"Loan must be accepted"
"Loan not accepted"
)
);

Expand Down Expand Up @@ -812,7 +812,7 @@ contract TellerV2_bids_test is Testable {
ActionNotAllowed.selector,
bidId,
"liquidateLoan",
"Loan must be accepted"
"Loan not accepted"
)
);
tellerV2.liquidateLoanFull(bidId);
Expand Down

0 comments on commit b301ac1

Please sign in to comment.