Forums  > General  > Contract for Difference on Ethereum  
Page 1 of 1
Display using:  


Total Posts: 72
Joined: Jul 2007
Posted: 2019-04-07 22:52
I am considering starting a pet project creating a financial derivate as smart contract on the ethereum blockchain. My idea is to create something like a contract for difference where both the buyer and sell lock an amount in the contract. The payout would be limited to what is locked up and thus there would be no forced liquidation. The contract lives until one of the parties decides to end by paying a liquidation fee into the contract. The contract then asks a third party "oracle" for the price of the underlying and pays out the two parties.

I am thinking that there has got to be something similar to this out there? (But I can't really find any? Closest thing seems to be MakerDAO.)


Total Posts: 375
Joined: Mar 2005
Posted: 2019-04-08 09:24
As ever with (smart contracts) blockchain the real-world bites:
1. What is your underlying? Unless it's something native to Ethereum you have the trust issue of reliance on an external (off-chain) source. Thus necessary smart contract logic if the external source connection is lost/source disappears; overlay this with civil law issues. E.g. I trade with IG Index on FTSE 100 my CFD still pays out X based on FTSE 100 irrespective if IG's market data feed dies...
2. Regulatory & legislation issues (e.g. UK CFDs are legitimate but regulated, is this true elsewhere)? How do you restrict geographic access/professional investor status?
3. Ever since TheDAO I have strongly believed in the need for a respected 3rd party to review/audit smart contract code as a form of quality control.
4. What value are you bringing with this endeavour?

"Yeh, after that blow out I bid the bonds at 76 and you hit man...You're 77/81 now? Cool man...What? Do I care at 80? No mate... I'm 73 bid now...I'm sure you didn't just load up just for me...".


Total Posts: 72
Joined: Jul 2007
Posted: 2019-04-08 11:52

To start with the value (or underlying) would be the price of ethereum in USD.

It would rely on existing "oracles" in the ethereum blockchain to provide the price when the contract is closed. The are a couple of these out there. One is; another is the medianizer in MakerDAO.

My plan is to decouple the CFD completely from the price source; so when the buyer and seller to enter a contract of a certain size, they also decide on a price source.


It would be effectively unregulated.


Agreed. Luckilly the pitfalls of the ethereum platform are a bit better understood today.


Total Posts: 23
Joined: May 2016
Posted: 2019-04-08 18:38
Look into Augur


Total Posts: 9
Joined: Apr 2019
Posted: 2019-04-11 21:37
Many big companies including AtFx, Plus500, and already offer Ethereum CFDs. Are CFDs on cryptocurrency unregulated?


Total Posts: 375
Joined: Mar 2005
Posted: 2019-04-11 23:23
Hey, iKryptoTrader you seem to be a crypto expert from your username and comments in the Careers section. Can you explain to us CFDs on Ethereum? We seem to have ballsed it up as we are stuck in the old world not the new crypto world. That's what being over 35 does to youWink.

"Yeh, after that blow out I bid the bonds at 76 and you hit man...You're 77/81 now? Cool man...What? Do I care at 80? No mate... I'm 73 bid now...I'm sure you didn't just load up just for me...".


Total Posts: 9
Joined: Apr 2019
Posted: 2019-04-12 04:43
It works just like regular CFDs; they're futures contracts paid in cash rather than delivery of the physical good (in this case, Ether). At Plus500, you are able to get 15x leverage versus if you were just to by Ether straight out. There is a maintenance margin of 3 1/3 %, so if Ether were to go down and if margin requirements were to be tightened simultaneously, you could possibly owe money. Personally, I'm skeptical of such arrangements. With a 100k account, you can get portfolio margin at IB, which means 1 million in buying power.


Total Posts: 1177
Joined: Feb 2007
Posted: 2019-04-12 17:07
I think OP wants to write a smart contract to do this rather than buy a CFD on an exchange. I agree with tradeking that Augur probably offers this with minimal extra tooling. It's been a while since I looked at it though.

"Learning, n. The kind of ignorance distinguishing the studious."


Total Posts: 72
Joined: Jul 2007
Posted: 2019-04-16 03:42
Just to clarify; I am not talking about a traditional CFD which (often) is a OTC contract between a bank and a retail trader with a margin account. But instead a modified contract for difference designed to work well as a smart contract inside a distributed cryptocurrency (specifically ethereum).

The contract would differ by the following:

1. The parties (buyer and seller) would lock the full contract amount in the smart contract (thus no margin account).
2. The payout function saying how much seller would pay buyer (or vice versa) at contract close would be constrained by the contract value.
3. The contract runs until one of the parties decides to close it by paying a fee into the contract.

In particular I had the following payout function in mind which combines logarithmic return with a smoothing function that is close to linear for smaller values:

atan(leverage * ln(priceEnd / priceStart)) * contractValue

The contract would be decoupled from the price source; so in principle the two parties entering the contract could decide on a third party price source which had nothing to do with the project.


My original idea was that you (as a user) would go to a trading bot which was not a smart contract and that bot would offer CFDs at a certain spread (but setting the start price slightly off). Much in the same way as a bank is counterpart for CFD retail traders.

However I have kinda given up on that idea for a number of reasons: It is not really distributed and thus could get me in legal troubles should the project ever take off. There would be quite a bit of capital tied up in it. And maybe it is a bit messy to create.

So now my idea now is that there is no price spread; the CFD smart contract will read the price from the price source when both parties have funded. There is an automated counterpart (a smart contract) which will take the other side of any trade constrained only by its funds.

Instead of the system operating directly on the native currency (ethereum) it would operate on a token issued by another smart contract. This smart contract would both buy and sell tokens.


Now that I have done a bit of research I can see that there are some other projects out there doing something somewhat similar. Augur being the biggest. But if you look into the details of what they are doing they are quite a bit different from the above. Augur eg. is a distributed exchange (amongst other things).


Total Posts: 9
Joined: Apr 2019
Posted: 2019-04-16 04:21
First of all, cryptocurrency is unregulated. So, whatever contract you had would not be legally binding in a court of law.

1. The only way this could work imo is if you require both the buyer and the seller to have the full amount locked up with you until you can distribute the winnings.

2. The winner needs to be able to win at least 5x their money to get people interested.

3. There needs to be provisions in place with a trusted lawyer (ideally a friend) in case you die (see:


Total Posts: 72
Joined: Jul 2007
Posted: 2019-04-16 10:35
1. Correct. Both parties need to lock up the full amount in the contract (called contract value below).

2. There is an explicit parameter called leverage in the payout function. You can "roll" your contract meaning when you have earned say +75% you close it and then reopen the contract with the earnings. Suppose you are long something that goes from 100 to 200 using a contract with leverage 5; you can roll as follows:

Invest 100, prices rises to 120, earnings: 100 * atan(ln(120 / 100) * 5) = 74
Reinvest 174, prices rises to 140, earnings: 174 * atan(ln(140 / 120) * 5) = 114
Reinvest 288, prices rises to 160, earnings: 288 * atan(ln(160 / 140) * 5) = 169
Reinvest 458, prices rises to 180, earnings: 458 * atan(ln(180 / 160) * 5) = 244
Reinvest 701, prices rises to 200, earnings: 701 * atan(ln(200 / 180) * 5) = 340
Final value: 1041

(Ignoring fees associated with opening or closing the contract.)

3. In principle the design should be able to run indefinitely just accumulating funds within the smart contracts.


Total Posts: 5
Joined: Jul 2014
Posted: 2019-04-29 18:41
Been waiting for something like this. Index futures contracts that are traded decentralized on a blockchain.

It is doable as the DAI USD stable coin have proven.

Preferably smart contract have a expire cycle that tracks the CME ES/SP cycle and that settles in DAI at the S&P 500 price up on expiration.

Just like with MakerDAO use oracles that provide S&P 500 close value from multiple credible sources and use an average of the prices as the contract settlement price (Bloomberg, Routers, etc?)

The performance of the Ethereum blockchain is not that high at the moment. But should be good enough for holding periods above a few minutes.
Previous Thread :: Next Thread 
Page 1 of 1