Skip to content

Commit

Permalink
Website: Minor fixes of names
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
cfries authored Nov 10, 2024
1 parent 19d4931 commit 4030cd3
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 71 deletions.
50 changes: 25 additions & 25 deletions ERCS/erc-6123.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ which can be processed in a completely frictionless way.

### Methods

The following methods specify a Smart Derivative Contract's trade initiation and settlement life cycle. For further information, please also look at the interface documentation ISDC.sol.
The following methods specify a Smart Derivative Contract's trade initiation, trade termination and settlement life cycle. For further information, please also look at the interface documentation ISDC.sol.

#### Trade Initiation Phase: `inceptTrade`

Expand Down Expand Up @@ -89,56 +89,56 @@ The counterparty that called `inceptTrade` has the option to cancel the trade, e
function cancelTrade(address withParty, string memory tradeData, int position, int256 paymentAmount, string memory initialSettlementData) external;
```

#### Trade Settlement Phase: `initiateSettlement`
#### Trade Termination: `requestTermination`

Allows eligible participants (such as counterparties or a delegated agent) to trigger a settlement phase.
Allows an eligible party to request a mutual termination of the trade with the correspondig `tradeId` with a termination amount she is willing to pay and provide further termination terms (e.g. an XML)

```solidity
function initiateSettlement() external;
function requestTradeTermination(string memory tradeId, int256 terminationPayment, string memory terminationTerms) external;
```

#### Trade Settlement Phase: `performSettlement`
#### Trade Termination: `confirmTradeTermination`

Valuation may be provided on-chain or off-chain via an external oracle service that calculates the settlement or coupon amounts and uses external market data.
This method serves as a callback called from an external oracle providing settlement amount and used settlement data, which also get stored.
The settlement amount will be checked according to contract terms, resulting in either a regular settlement or a termination of the trade.
Allows an eligible party to confirm a previously requested (mutual) trade termination, including termination payment value and termination terms

```solidity
function performSettlement(int256 settlementAmount, string memory settlementData) external;
function confirmTradeTermination(string memory tradeId, int256 terminationPayment, string memory terminationTerms) external;
```

#### Trade Settlement Phase: `afterTransfer`
#### Trade Termination: `cancelTradeTermination`

This method - either called back from the provided settlement token directly or from an eligible address - completes the settlement transfer.
This might result in a termination or start of the next settlement phase, depending on the provided success flag.
The transactionData is emitted as part of the corresponding event: `TradeSettled` or `TradeTerminated`
The party that initiated `requestTradeTermination` has the option to withdraw the request, e.g., in the case where the termination is not confirmed in a timely manner.

```solidity
function afterTransfer(bool success, string memory transactionData) external;
function cancelTradeTermination(string memory tradeId, int256 terminationPayment, string memory terminationTerms) external;
```

#### Trade Termination: `requestTermination`
#### Settlement Phase: `initiateSettlement`

Allows an eligible party to request a mutual termination of the trade with the correspondig `tradeId` with a termination amount she is willing to pay and provide further termination terms (e.g. an XML)
Allows eligible participants (such as counterparties or a delegated agent) to trigger a settlement phase.

```solidity
function requestTradeTermination(string memory tradeId, int256 terminationPayment, string memory terminationTerms) external;
function initiateSettlement() external;
```

#### Trade Termination: `confirmTradeTermination`
#### Settlement Phase: `performSettlement`

Allows an eligible party to confirm a previously requested (mutual) trade termination, including termination payment value and termination terms
Valuation may be provided on-chain or off-chain via an external oracle service that calculates the settlement or coupon amounts and uses external market data.
This method serves as a callback called from an external oracle providing settlement amount and used settlement data, which also get stored.
The settlement amount will be checked according to contract terms, resulting in either a regular settlement or a termination of the trade.

```solidity
function confirmTradeTermination(string memory tradeId, int256 terminationPayment, string memory terminationTerms) external;
function performSettlement(int256 settlementAmount, string memory settlementData) external;
```

#### Trade Termination: `cancelTradeTermination`
#### Settlement Phase: `afterTransfer`

The party that initiated `requestTradeTermination` has the option to withdraw the request, e.g., in the case where the termination is not confirmed in a timely manner.
This method - either called back from the provided settlement token directly or from an eligible address - completes the settlement transfer.
The transactionData is emitted as part of the corresponding event: `SettlementTransferred` or `SettlementFailed`
This might result in a termination or start of the next settlement phase, depending on the provided success flag.

```solidity
function cancelTradeTermination(string memory tradeId, int256 terminationPayment, string memory terminationTerms) external;
function afterTransfer(bool success, string memory transactionData) external;
```


Expand Down Expand Up @@ -223,12 +223,12 @@ Emitted when a settlement is requested. May trigger the settlement phase.
event SettlementRequested(address initiator, string tradeData, string lastSettlementData);
```

#### SettlementEvaluated
#### SettlementDetermined

Emitted when the settlement phase is started.

```solidity
event SettlementEvaluated(address initiator, int256 settlementAmount, string settlementData);
event SettlementDetermined(address initiator, int256 settlementAmount, string settlementData);
```

#### SettlementTransferred
Expand Down
24 changes: 11 additions & 13 deletions assets/erc-6123/contracts/ERC20Settlement.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.7.0 <0.9.0;
pragma solidity >=0.7.0;

import "./ISDC.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
Expand Down Expand Up @@ -38,36 +38,35 @@ contract ERC20Settlement is ERC20, IERC20Settlement{
_mint(to, amount);
}

function checkedTransfer(address to, uint256 value, uint256 transactionID) public onlySDC{
function transferAndCallback(address to, uint256 value, uint256 transactionID, address callbackContract) public onlySDC{
if ( balanceOf(sdcAddress) < value)
ISDC(sdcAddress).afterTransfer(false, Strings.toString(transactionID));
ISDC(callbackContract).afterTransfer(false, transactionID, Strings.toString(transactionID));
else
ISDC(sdcAddress).afterTransfer(true, Strings.toString(transactionID));
ISDC(callbackContract).afterTransfer(true, transactionID, Strings.toString(transactionID));
}

function checkedTransferFrom(address from, address to, uint256 value, uint256 transactionID) external view onlySDC {
function transferFromAndCallback(address from, address to, uint256 value, uint256 transactionID, address callbackContract) external view onlySDC {
revert("not implemented");
}

function checkedBatchTransfer(address[] memory to, uint256[] memory values, uint256 transactionID ) public onlySDC{
function transferBatchAndCallback(address[] memory to, uint256[] memory values, uint256 transactionID, address callbackContract) public onlySDC{
require (to.length == values.length, "Array Length mismatch");
uint256 requiredBalance = 0;
for(uint256 i = 0; i < values.length; i++)
requiredBalance += values[i];
if (balanceOf(msg.sender) < requiredBalance){
ISDC(sdcAddress).afterTransfer(false, Strings.toString(transactionID));
ISDC(callbackContract).afterTransfer(false, transactionID, Strings.toString(transactionID));
return;
}
else{
for(uint256 i = 0; i < to.length; i++){
_transfer(sdcAddress,to[i],values[i]);
}
ISDC(sdcAddress).afterTransfer(true, Strings.toString(transactionID));
ISDC(callbackContract).afterTransfer(true, transactionID, Strings.toString(transactionID));
}
}


function checkedBatchTransferFrom(address[] memory from, address[] memory to, uint256[] memory values, uint256 transactionID ) public onlySDC{
function transferBatchFromAndCallback(address[] memory from, address[] memory to, uint256[] memory values, uint256 transactionID, address callbackContract) public onlySDC{
require (from.length == to.length, "Array Length mismatch");
require (to.length == values.length, "Array Length mismatch");
for(uint256 i = 0; i < from.length; i++){
Expand All @@ -78,15 +77,14 @@ contract ERC20Settlement is ERC20, IERC20Settlement{
totalRequiredBalance += values[j];
}
if (balanceOf(fromAddress) < totalRequiredBalance){
ISDC(sdcAddress).afterTransfer(false, Strings.toString(transactionID));
ISDC(callbackContract).afterTransfer(false, transactionID, Strings.toString(transactionID));
return;
}

}
for(uint256 i = 0; i < to.length; i++){
_transfer(from[i],to[i],values[i]);
}
ISDC(sdcAddress).afterTransfer(true, Strings.toString(transactionID));
ISDC(callbackContract).afterTransfer(true, transactionID, Strings.toString(transactionID));
}

}
52 changes: 36 additions & 16 deletions assets/erc-6123/contracts/IERC20Settlement.sol
Original file line number Diff line number Diff line change
@@ -1,53 +1,73 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.7.0 <0.9.0;
pragma solidity >=0.7.0;



import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/*------------------------------------------- DESCRIPTION ---------------------------------------------------------------------------------------
* @title ERC6123 - Settlement Token Interface
* @dev Settlement Token Interface enhances the ERC20 Token by introducing so called checked transfer functionality which can be used to directly interact with an SDC.
* Checked transfers can be conducted for single or multiple transactions where SDC will receive a success message whether the transfer was executed successfully or not.
* @dev Settlement Token Interface enhances the ERC20 Token by introducing an asynchronous (checked) transfer functionality which can be used to directly interact with an SDC.
* Transfers can be conducted for single or multiple transactions where SDC will receive a success message whether the transfer was executed successfully or not.
* The SDC or callbackContract needs to implemnt a function afterTransfer(bool success, uint256 transactionID, string memory transactionData)
*/
interface IERC20Settlement is IERC20 {

/**
* @dev Emitted when a transfer gets requested
* @param from the address from which to transfer
* @param to the address to which to transfer
* @param value the value to transfer
* @param transactionID a transaction ID that may serve as correlation ID, will be passed to the callback.
* @param callbackContract a contract implementing afterTransfer
*/
event TransferRequested(address from, address to, uint256 value, uint256 transactionID, address callbackContract);

interface IERC20Settlement is IERC20 {
/**
* @dev Emitted when a batch transfer gets requested
* @param from the addresses from which to transfer
* @param to the addresses to which to transfer
* @param value the values to transfer
* @param transactionID a transaction ID that may serve as correlation ID, will be passed to the callback.
* @param callbackContract a contract implementing afterTransfer
*/
event TransferBatchRequested(address[] from, address[] to, uint256[] value, uint256 transactionID, address callbackContract);

/*
* @dev Performs a single transfer from msg.sender balance and checks whether this transfer can be conducted
* @param to - receiver
* @param value - transfer amount
* @param transactionID
* @param transactionID - an id that will be passed back to the callback
* @param callbackContract - a contract implementing the method afterTransfer(bool success, uint256 transactionID, string memory transactionData)
*/
function checkedTransfer(address to, uint256 value, uint256 transactionID) external;
function transferAndCallback(address to, uint256 value, uint256 transactionID, address callbackContract) external;

/*
* @dev Performs a single transfer to a single addresss and checks whether this transfer can be conducted
* @param from - payer
* @param to - receiver
* @param value - transfer amount
* @param transactionID
* @param transactionID - an id that will be passed back to the callback
* @param callbackContract - a contract implementing the method afterTransfer(bool success, uint256 transactionID, string memory transactionData)
*/
function checkedTransferFrom(address from, address to, uint256 value, uint256 transactionID) external ;

function transferFromAndCallback(address from, address to, uint256 value, uint256 transactionID, address callbackContract) external ;

/*
* @dev Performs a multiple transfers from msg.sender balance and checks whether these transfers can be conducted
* @param to - receivers
* @param values - transfer amounts
* @param transactionID
* @param transactionID - an id that will be passed back to the callback
* @param callbackContract - a contract implementing the method afterTransfer(bool success, uint256 transactionID, string memory transactionData)
*/
function checkedBatchTransfer(address[] memory to, uint256[] memory values, uint256 transactionID ) external;
function transferBatchAndCallback(address[] memory to, uint256[] memory values, uint256 transactionID, address callbackContract) external;

/*
* @dev Performs a multiple transfers between multiple addresses and checks whether these transfers can be conducted
* @param from - payers
* @param to - receivers
* @param value - transfer amounts
* @param transactionID
* @param values - transfer amounts
* @param transactionID - an id that will be passed back to the callback
* @param callbackContract - a contract implementing the method afterTransfer(bool success, uint256 transactionID, string memory transactionData)
*/
function checkedBatchTransferFrom(address[] memory from, address[] memory to, uint256[] memory values, uint256 transactionID ) external;


function transferBatchFromAndCallback(address[] memory from, address[] memory to, uint256[] memory values, uint256 transactionID, address callbackContract) external;
}
9 changes: 5 additions & 4 deletions assets/erc-6123/contracts/ISDC.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.7.0 <0.9.0;
pragma solidity >=0.7.0;

/*------------------------------------------- DESCRIPTION ---------------------------------------------------------------------------------------*/

Expand Down Expand Up @@ -124,7 +124,7 @@ interface ISDC {
* @param settlementAmount the settlement amount. If settlementAmount > 0 then receivingParty receives this amount from other party. If settlementAmount < 0 then other party receives -settlementAmount from receivingParty.
* @param settlementData. the tripple (product, previousSettlementData, settlementData) determines the settlementAmount.
*/
event SettlementEvaluated(address initiator, int256 settlementAmount, string settlementData);
event SettlementDetermined(address initiator, int256 settlementAmount, string settlementData);

/**
* @dev Emitted when settlement process has been finished
Expand Down Expand Up @@ -212,7 +212,7 @@ interface ISDC {

/**
* @notice Called to trigger according settlement on chain-balances callback for initiateSettlement() event handler
* @dev perform settlement checks, may initiate transfers and emits {SettlementEvaluated}
* @dev perform settlement checks, may initiate transfers and emits {SettlementDetermined}
* @param settlementAmount the settlement amount. If settlementAmount > 0 then receivingParty receives this amount from other party. If settlementAmount < 0 then other party receives -settlementAmount from receivingParty.
* @param settlementData. the tripple (product, previousSettlementData, settlementData) determines the settlementAmount.
*/
Expand All @@ -222,10 +222,11 @@ interface ISDC {
/**
* @notice May get called from outside to to finish a transfer (callback). The trade decides on how to proceed based on success flag
* @param success tells the protocol whether transfer was successful
* @param transactionID a transaction
* @param transactionData data associtated with the transfer, will be emitted via the events.
* @dev emit a {SettlementTransferred} or a {SettlementFailed} event. May emit a {TradeTerminated} event.
*/
function afterTransfer(bool success, string memory transactionData) external;
function afterTransfer(bool success, uint256 transactionID, string memory transactionData) external;

/// Trade termination

Expand Down
2 changes: 1 addition & 1 deletion assets/erc-6123/contracts/SDCSingleTrade.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.7.0 <0.9.0;
pragma solidity >=0.7.0;

import "./ISDC.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
Loading

0 comments on commit 4030cd3

Please sign in to comment.