/** * Copyright 2017–2019, LaborX PTY * Licensed under the AGPL Version 3 license. */ pragma solidity ^0.4.25; interface EscrowBaseInterface { function hasCurrencySupport(bytes32 _symbol) public view returns (bool); function getFeeInfo( bytes32 _tradeRecordId, address _seller, address _buyer ) external view returns (uint16, uint16, uint); function getSellerFeeInfo(address _seller) external view returns (uint16, uint); function getBuyerFeeInfo(address _buyer) external view returns (uint16, uint); function setFeeManager(address _feeManager) external returns (uint); /// @notice Gets balance locked on escrow. /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @return currency symbol /// @return currence balance on escrow function getBalanceOf( bytes32 _tradeRecordId, address _seller, address _buyer ) external view returns (bytes32, uint); /// @notice Creates an escrow record for provided symbol "`_symbol`" /// @dev Escrow is reusable so the same tradeRecordId could be reused after an escrow /// with the same identifier is resolved. /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _symbol symbol of payment currency /// @param _value amount to initially deposit to escrow; could be 0 /// @param _transferImmediatelyToBuyerAmount amount to transfer immediately to a buyer /// @param _feeStatus fee condition (1st bit - seller, 2nd - buyer) /// @return result code of an operation function createEscrow( bytes32 _tradeRecordId, address _seller, address _buyer, bytes32 _symbol, uint _value, uint _transferImmediatelyToBuyerAmount, uint8 _feeStatus ) external payable returns (uint); /// @notice Deposits to an escrow provided amount `_value` /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _value amount to deposit /// @param _transferImmediatelyToBuyerAmount amount to transfer immediately to a buyer /// @param _feeStatus fee condition (1st bit - seller, 2nd - buyer) /// @return result code of an operation function deposit( bytes32 _tradeRecordId, address _seller, address _buyer, uint _value, uint _transferImmediatelyToBuyerAmount, // transfers _transferImmediatelyToBuyerAmount directly to _buyer. uint8 _feeStatus ) external payable returns (uint); /// @notice Transfers `_value` from escrow to buyer `_buyer` /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @dev Seller shoud sign hash of (message, escrow address, msg.sig, _value, _expireAtBlock, _salt) data /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _value amount to withdraw from escrow /// @param _expireAtBlock expiry block after which transaction will be invalid /// @param _salt random bytes to identify signed data /// @param _sellerSignature signature produced by seller /// @param _feeStatus fee condition (1st bit - seller, 2nd - buyer) /// @return result code of an operation function releaseBuyerPayment( bytes32 _tradeRecordId, address _seller, address _buyer, uint _value, uint _expireAtBlock, uint _salt, bytes _sellerSignature, uint8 _feeStatus ) external returns (uint); /// @notice Transfers `_value` from escrow to seller `_seller` /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @dev Buyer shoud sign hash of (message, escrow address, msg.sig, _value, _expireAtBlock, _salt) data /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _value amount to withdraw from escrow /// @param _expireAtBlock expiry block after which transaction will be invalid /// @param _salt random bytes to identify signed data /// @param _buyerSignature signature produced by buyer /// @return result code of an operation function sendSellerPayback( bytes32 _tradeRecordId, address _seller, address _buyer, uint _value, uint _expireAtBlock, uint _salt, bytes _buyerSignature ) external returns (uint); /// @notice Transfers `_value` from escrow to seller `_seller` and buyer `_buyer` /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @dev Seller and buyer shoud sign hash of (message, escrow address, msg.sig, _sellerValue, _buyerValue, _expireAtBlock, _salt) data /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _sellerValue amount to withdraw from escrow to the seller /// @param _buyerValue amount to withdraw from escrow to the buyer /// @param _expireAtBlock expiry block after which transaction will be invalid /// @param _salt random bytes to identify signed data /// @param _signatures concatenated signatures produced by seller and buyer /// @param _feeStatus fee condition (1st bit - seller, 2nd - buyer) /// @return result code of an operation function releaseNegotiatedPayment( bytes32 _tradeRecordId, address _seller, address _buyer, uint _sellerValue, uint _buyerValue, uint _expireAtBlock, uint _salt, bytes _signatures, uint8 _feeStatus ) external returns (uint); /// @notice Starts a dispute process between seller `_seller` and buyer `_buyer`. /// Could start only if an arbiter was specified. /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @dev Seller and buyer shoud sign hash of (message, escrow address, msg.sig, _expireAtBlock, _salt) data /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _expireAtBlock expiry block after which transaction will be invalid /// @param _salt random bytes to identify signed data /// @param _signature signature of an initiator /// @return result code of an operation function initiateDispute( bytes32 _tradeRecordId, address _seller, address _buyer, uint _expireAtBlock, uint _salt, bytes _signature ) external returns (uint); /// @notice Cancels an initiated dispute process /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @dev Seller and buyer shoud sign hash of (message, escrow address, msg.sig, _expireAtBlock, _salt) data /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _expireAtBlock expiry block after which transaction will be invalid /// @param _salt random bytes to identify signed data /// @param _signature signature of an initiator /// @return result code of an operation function cancelDispute( bytes32 _tradeRecordId, address _seller, address _buyer, uint _expireAtBlock, uint _salt, bytes _signature ) external returns (uint); /// @notice Transfers disputed value from escrow to the seller `_seller` and the buyer `_buyer` according /// to provided buyer value `_buyerValue`. The value of escrow - _buyerValue will be transferred to the seller. /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @dev Arbiter should sign hash of (message, escrow address, msg.sig, _buyerValue, _expireAtBlock) data /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _buyerValue value that will be transferred to the buyer /// @param _expireAtBlock expiry block after which transaction will be invalid /// @param _arbiterSignature signature of an arbiter /// @return result code of an operation function releaseDisputedPayment( bytes32 _tradeRecordId, address _seller, address _buyer, uint _buyerValue, uint _expireAtBlock, bytes _arbiterSignature ) external returns (uint); /// @notice Deletes escrow record when it is no more needed. /// Escrow should be empty to be deleted. /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment function deleteEscrow( bytes32 _tradeRecordId, address _seller, address _buyer ) external returns (uint); function getArbiter(bytes32 _tradeRecordId, address _seller, address _buyer) external view returns (address); /// @notice Sets a new arbiter `_arbiter`. His address should be approved by both parties. /// @dev Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer) /// @dev Seller and buyer shoud sign hash of (message, escrow address, msg.sig, _arbiter, _expireAtBlock, _salt) data /// @param _tradeRecordId identifier of escrow record /// @param _seller who will mainly deposit to escrow /// @param _buyer who will eventually is going to receive payment /// @param _expireAtBlock expiry block after which transaction will be invalid /// @param _salt random bytes to identify signed data /// @param _bothSignatures signatures of seller and buyer function setArbiter( bytes32 _tradeRecordId, address _seller, address _buyer, address _arbiter, uint _expireAtBlock, uint _salt, bytes _bothSignatures ) external returns (uint); /// @notice Performs transfer of a currency `_symbol` /// from a `msg.sender` to service fee recepient /// @param _symbol target currency symbol /// @param _from holder address of the `_symbol` /// @param _amount amount to retransfer /// @return result code of an operation function retranslateToFeeRecipient(bytes32 _symbol, address _from, uint _amount) external payable returns (uint); }