Skip to content

Commit

Permalink
feat: bonded dispute module release (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
gas1cent authored Nov 13, 2024
1 parent 822962a commit feb5ea7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 33 deletions.
17 changes: 2 additions & 15 deletions solidity/contracts/modules/dispute/BondedDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,13 @@ contract BondedDisputeModule is Module, IBondedDisputeModule {
IOracle.DisputeStatus _status = ORACLE.disputeStatus(_disputeId);

if (_status == IOracle.DisputeStatus.NoResolution) {
// No resolution, we release both bonds
// No resolution, we release the disputer's bond
_params.accountingExtension.release({
_bonder: _dispute.disputer,
_requestId: _dispute.requestId,
_token: _params.bondToken,
_amount: _params.bondSize
});

_params.accountingExtension.release({
_bonder: _dispute.proposer,
_requestId: _dispute.requestId,
_token: _params.bondToken,
_amount: _params.bondSize
});
} else if (_status == IOracle.DisputeStatus.Won) {
// Disputer won, we pay the disputer and release their bond
_params.accountingExtension.pay({
Expand All @@ -83,20 +76,14 @@ contract BondedDisputeModule is Module, IBondedDisputeModule {
_amount: _params.bondSize
});
} else if (_status == IOracle.DisputeStatus.Lost) {
// Disputer lost, we pay the proposer and release their bond
// Disputer lost, we pay the proposer
_params.accountingExtension.pay({
_requestId: _dispute.requestId,
_payer: _dispute.disputer,
_receiver: _dispute.proposer,
_token: _params.bondToken,
_amount: _params.bondSize
});
_params.accountingExtension.release({
_bonder: _dispute.proposer,
_requestId: _dispute.requestId,
_token: _params.bondToken,
_amount: _params.bondSize
});
}

emit DisputeStatusChanged({_disputeId: _disputeId, _dispute: _dispute, _status: _status});
Expand Down
8 changes: 4 additions & 4 deletions solidity/test/integration/Arbitration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ contract Integration_Arbitration is IntegrationBase {
// Check: is the dispute updated as lost?
assertEq(uint256(_disputeStatus), uint256(IOracle.DisputeStatus.Lost));

// Check: does the disputer receive the disputer's bond?
// Check: does the proposer receive the disputer's bond?
uint256 _proposerBalance = _accountingExtension.balanceOf(proposer, usdc);
assertEq(_proposerBalance, _expectedBondSize * 2);
assertEq(_proposerBalance, _expectedBondSize);

// Check: does the disputer get its bond slashed?
uint256 _disputerBondedAmount = _accountingExtension.bondedAmountOf(disputer, usdc, _getId(mockRequest));
Expand Down Expand Up @@ -139,9 +139,9 @@ contract Integration_Arbitration is IntegrationBase {
// Check: is the dispute updated as lost?
assertEq(uint256(_disputeStatus), uint256(IOracle.DisputeStatus.Lost));

// Check: does the disputer receive the disputer's bond?
// Check: does the proposer receive the disputer's bond?
uint256 _proposerBalance = _accountingExtension.balanceOf(proposer, usdc);
assertEq(_proposerBalance, _expectedBondSize * 2);
assertEq(_proposerBalance, _expectedBondSize);

// Check: does the disputer get its bond slashed?
uint256 _disputerBondedAmount = _accountingExtension.bondedAmountOf(disputer, usdc, _getId(mockRequest));
Expand Down
14 changes: 0 additions & 14 deletions solidity/test/unit/modules/dispute/BondedDisputeModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ contract BondedDisputeModule_Unit_OnDisputeStatusChange is BaseTest {
abi.encode()
);

// Mock and expect the call to release, to the disputer
_mockAndExpect(
address(accountingExtension),
abi.encodeCall(accountingExtension.release, (mockResponse.proposer, _requestId, _token, _bondSize)),
abi.encode()
);

vm.prank(address(oracle));
bondedDisputeModule.onDisputeStatusChange(_getId(mockDispute), mockRequest, mockResponse, mockDispute);
}
Expand Down Expand Up @@ -176,13 +169,6 @@ contract BondedDisputeModule_Unit_OnDisputeStatusChange is BaseTest {
abi.encode(IOracle.DisputeStatus.NoResolution)
);

// Mock and expect the call to release, for the proposer
_mockAndExpect(
address(accountingExtension),
abi.encodeCall(accountingExtension.release, (mockResponse.proposer, _requestId, _token, _bondSize)),
abi.encode()
);

// Mock and expect the call to release, for the disputer
_mockAndExpect(
address(accountingExtension),
Expand Down

0 comments on commit feb5ea7

Please sign in to comment.