ERC-6123 · Draft · ERC · 2022-12-13
ERC-6123: Smart Derivative Contract
A draft interface for Smart Derivative Contracts: on-chain state machines that run the whole life cycle of an OTC derivative or bond, from trade agreement through oracle-driven periodic settlement to termination.
What problem does it solve?
Over-the-counter (OTC) derivatives such as interest rate swaps are bilateral contracts that exchange cash flows for years. Their market value changes daily, so each side is exposed to the other defaulting (counterparty credit risk). Post-trade processing (confirmations, valuations, margin calls, settlements) is slow, manual and different at every institution.
ERC-6123 describes a Smart Derivative Contract (SDC): a deterministic protocol where every step of the trade life cycle is a defined state transition. Settlement is done frequently in tokens, and pre-agreed margin buffers are locked so payment is guaranteed up to a limit. If a party fails to meet its obligations, the contract terminates automatically and a termination fee is paid by the defaulting party. The authors report proof-of-concept runs with legally binding digital interest rate swaps in 2021 and 2022.
How it works
The spec splits the API into interfaces:
ISDCTrade – agreeing and ending a trade
inceptTrade(withParty, tradeData, position, paymentAmount, initialSettlementData): one party proposes a trade and gets atradeId.confirmTrade(...): the counterparty submits the same terms (with opposite signs) and the contract matches them.cancelTradelets the incepting party withdraw an unconfirmed trade.requestTradeTermination/confirmTradeTermination/cancelTradeTermination: mutual early termination with an agreed payment.
ISDCSettlement – the settlement loop
initiateSettlement()emitsSettlementRequestedwith the trade data and last settlement data.- An external valuation oracle computes the amount owed and calls
performSettlement(settlementAmount, settlementData). - The amount is checked against the contract terms and transferred, or the trade terminates if it can't be.
afterSettlement()prepares the next cycle (for example re-checking pre-funding).
IAsyncTransfer / IAsyncTransferCallback support settlement through an external payment system: the token (or an eligible address) calls back afterTransfer(success, transactionID, transactionData).
Events (TradeIncepted, TradeConfirmed, SettlementDetermined, SettlementTransferred, SettlementFailed, TradeTerminated…) make every state change observable. Settlement can use any ERC-20 token.
Sample code
The trade-agreement handshake and an oracle settlement, using signatures from the spec:
interface ISDCTrade {
event TradeIncepted(address initiator, string tradeId, string tradeData);
event TradeConfirmed(address confirmer, string tradeId);
function inceptTrade(address withParty, string memory tradeData, int256 position,
int256 paymentAmount, string memory initialSettlementData)
external returns (string memory);
function confirmTrade(address withParty, string memory tradeData, int256 position,
int256 paymentAmount, string memory initialSettlementData) external;
}
interface ISDCSettlement {
event SettlementRequested(address initiator, string tradeData, string lastSettlementData);
function initiateSettlement() external;
function performSettlement(int256 settlementAmount, string memory settlementData) external;
function afterSettlement() external;
}
// Party A proposes a swap: receive fixed (+1), no upfront payment
await sdc.connect(partyA).inceptTrade(partyB.address, tradeXml, 1, 0, "init");
// Party B confirms with mirrored position and payment
await sdc.connect(partyB).confirmTrade(partyA.address, tradeXml, -1, 0, "init");
// Later, each cycle: trigger, then the valuation oracle reports the amount
await sdc.initiateSettlement();
await sdc.connect(oracle).performSettlement(-12_500n * 10n ** 18n, marketDataJson);
Things to know
- Status: Draft. The interface has changed over time and may still change.
- Valuation is off-chain: the contract trusts a pre-agreed oracle and valuation model. The quality of the whole system depends on that oracle.
- Trade terms are passed as strings (the spec suggests XML for trade data). Contracts store and match them but do not interpret their financial meaning.
- Margin buffers only guarantee payment up to the locked amount. A market move bigger than the buffer within one cycle ends in termination, not full payment.
- Regulatory, legal and accounting treatment of such contracts is outside the standard and needs separate review.