-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into perf/opo-605-private-erc20-resolution-module
- Loading branch information
Showing
31 changed files
with
2,822 additions
and
3,319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 94 additions & 103 deletions
197
solidity/contracts/modules/dispute/BondedDisputeModule.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,106 @@ | ||
// // SPDX-License-Identifier: MIT | ||
// pragma solidity ^0.8.19; | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
// // solhint-disable-next-line no-unused-import | ||
// import {Module, IModule} from '@defi-wonderland/prophet-core-contracts/solidity/contracts/Module.sol'; | ||
// import {IOracle} from '@defi-wonderland/prophet-core-contracts/solidity/interfaces/IOracle.sol'; | ||
// solhint-disable-next-line no-unused-import | ||
import {Module, IModule} from '@defi-wonderland/prophet-core-contracts/solidity/contracts/Module.sol'; | ||
import {IOracle} from '@defi-wonderland/prophet-core-contracts/solidity/interfaces/IOracle.sol'; | ||
|
||
// import {IBondedDisputeModule} from '../../../interfaces/modules/dispute/IBondedDisputeModule.sol'; | ||
import {IBondedDisputeModule} from '../../../interfaces/modules/dispute/IBondedDisputeModule.sol'; | ||
|
||
// contract BondedDisputeModule is Module, IBondedDisputeModule { | ||
// constructor(IOracle _oracle) Module(_oracle) {} | ||
contract BondedDisputeModule is Module, IBondedDisputeModule { | ||
constructor(IOracle _oracle) Module(_oracle) {} | ||
|
||
// /// @inheritdoc IModule | ||
// function moduleName() external pure returns (string memory _moduleName) { | ||
// return 'BondedDisputeModule'; | ||
// } | ||
/// @inheritdoc IModule | ||
function moduleName() external pure returns (string memory _moduleName) { | ||
return 'BondedDisputeModule'; | ||
} | ||
|
||
// /// @inheritdoc IBondedDisputeModule | ||
// function decodeRequestData(bytes32 _requestId) public view returns (RequestParameters memory _params) { | ||
// _params = abi.decode(requestData[_requestId], (RequestParameters)); | ||
// } | ||
/// @inheritdoc IBondedDisputeModule | ||
function decodeRequestData(bytes calldata _data) public view returns (RequestParameters memory _params) { | ||
_params = abi.decode(_data, (RequestParameters)); | ||
} | ||
|
||
// /// @inheritdoc IBondedDisputeModule | ||
// function disputeEscalated(bytes32 _disputeId) external onlyOracle {} | ||
/// @inheritdoc IBondedDisputeModule | ||
function disputeResponse( | ||
IOracle.Request calldata _request, | ||
IOracle.Response calldata _response, | ||
IOracle.Dispute calldata _dispute | ||
) external onlyOracle { | ||
RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); | ||
|
||
// /// @inheritdoc IBondedDisputeModule | ||
// function disputeResponse( | ||
// bytes32 _requestId, | ||
// bytes32 _responseId, | ||
// address _disputer, | ||
// address _proposer | ||
// ) external onlyOracle returns (IOracle.Dispute memory _dispute) { | ||
// _dispute = IOracle.Dispute({ | ||
// disputer: _disputer, | ||
// responseId: _responseId, | ||
// proposer: _proposer, | ||
// requestId: _requestId, | ||
// status: IOracle.DisputeStatus.Active, | ||
// createdAt: block.timestamp | ||
// }); | ||
_params.accountingExtension.bond({ | ||
_bonder: _dispute.disputer, | ||
_requestId: _dispute.requestId, | ||
_token: _params.bondToken, | ||
_amount: _params.bondSize | ||
}); | ||
|
||
// RequestParameters memory _params = decodeRequestData(_requestId); | ||
// _params.accountingExtension.bond({ | ||
// _bonder: _disputer, | ||
// _requestId: _requestId, | ||
// _token: _params.bondToken, | ||
// _amount: _params.bondSize | ||
// }); | ||
emit ResponseDisputed({ | ||
_requestId: _dispute.requestId, | ||
_responseId: _dispute.responseId, | ||
_disputeId: _getId(_dispute), | ||
_dispute: _dispute, | ||
_blockNumber: block.number | ||
}); | ||
} | ||
|
||
// emit ResponseDisputed(_requestId, _responseId, _disputer, _proposer); | ||
// } | ||
/// @inheritdoc IBondedDisputeModule | ||
function onDisputeStatusChange( | ||
bytes32 _disputeId, | ||
IOracle.Request calldata _request, | ||
IOracle.Response calldata _response, | ||
IOracle.Dispute calldata _dispute | ||
) external onlyOracle { | ||
RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); | ||
IOracle.DisputeStatus _status = ORACLE.disputeStatus(_disputeId); | ||
|
||
// /// @inheritdoc IBondedDisputeModule | ||
// function onDisputeStatusChange(bytes32, /* _disputeId */ IOracle.Dispute memory _dispute) external onlyOracle { | ||
// RequestParameters memory _params = decodeRequestData(_dispute.requestId); | ||
// IOracle.DisputeStatus _status = _dispute.status; | ||
// address _proposer = _dispute.proposer; | ||
// address _disputer = _dispute.disputer; | ||
if (_status == IOracle.DisputeStatus.NoResolution) { | ||
// No resolution, we release both bonds | ||
_params.accountingExtension.release({ | ||
_bonder: _dispute.disputer, | ||
_requestId: _dispute.requestId, | ||
_token: _params.bondToken, | ||
_amount: _params.bondSize | ||
}); | ||
|
||
// if (_status == IOracle.DisputeStatus.NoResolution) { | ||
// // No resolution, we release both bonds | ||
// _params.accountingExtension.release({ | ||
// _bonder: _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({ | ||
_requestId: _dispute.requestId, | ||
_payer: _dispute.proposer, | ||
_receiver: _dispute.disputer, | ||
_token: _params.bondToken, | ||
_amount: _params.bondSize | ||
}); | ||
_params.accountingExtension.release({ | ||
_bonder: _dispute.disputer, | ||
_requestId: _dispute.requestId, | ||
_token: _params.bondToken, | ||
_amount: _params.bondSize | ||
}); | ||
} else if (_status == IOracle.DisputeStatus.Lost) { | ||
// Disputer lost, we pay the proposer and release their bond | ||
_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 | ||
}); | ||
} | ||
|
||
// _params.accountingExtension.release({ | ||
// _bonder: _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({ | ||
// _requestId: _dispute.requestId, | ||
// _payer: _proposer, | ||
// _receiver: _disputer, | ||
// _token: _params.bondToken, | ||
// _amount: _params.bondSize | ||
// }); | ||
// _params.accountingExtension.release({ | ||
// _bonder: _disputer, | ||
// _requestId: _dispute.requestId, | ||
// _token: _params.bondToken, | ||
// _amount: _params.bondSize | ||
// }); | ||
// } else if (_status == IOracle.DisputeStatus.Lost) { | ||
// // Disputer lost, we pay the proposer and release their bond | ||
// _params.accountingExtension.pay({ | ||
// _requestId: _dispute.requestId, | ||
// _payer: _disputer, | ||
// _receiver: _proposer, | ||
// _token: _params.bondToken, | ||
// _amount: _params.bondSize | ||
// }); | ||
// _params.accountingExtension.release({ | ||
// _bonder: _proposer, | ||
// _requestId: _dispute.requestId, | ||
// _token: _params.bondToken, | ||
// _amount: _params.bondSize | ||
// }); | ||
// } | ||
|
||
// emit DisputeStatusChanged({ | ||
// _requestId: _dispute.requestId, | ||
// _responseId: _dispute.responseId, | ||
// _disputer: _disputer, | ||
// _proposer: _proposer, | ||
// _status: _status | ||
// }); | ||
// } | ||
// } | ||
emit DisputeStatusChanged({_disputeId: _disputeId, _dispute: _dispute, _status: _status}); | ||
} | ||
} |
Oops, something went wrong.