Abstract
Blockchain-based smart contracts are considered a promising technology for handling financial agreements securely. In order to realize this vision, we need a formal language to unambiguously describe contract clauses. We introduce Findel – a purely declarative financial domain-specific language (DSL) well suited for implementation in blockchain networks. We implement an Ethereum smart contract that acts as a marketplace for Findel contracts and measure the cost of its operation. We analyze challenges in modeling financial agreements in decentralized networks and outline directions for future work (See the author’s post-print at https://orbilu.uni.lu/handle/10993/30975 and the related source code at https://github.com/cryptolu/findel).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
- 2.
We may refer to Findel contracts simply as contracts, when the distinction between them and Ethereum smart contracts is clear from the context.
- 3.
INF is a symbol representing infinite time, i.e., \(t_0 < INF\) for every \(t_0\). \(\delta \) is an implementation dependent constant intended for handling imperfect precision of time signal in distributed networks.
- 4.
In case of Or, execute exactly one of the sub-nodes, according to the owner-submitted value indicating the choice; delete the other one. It is the only primitive that requires an additional user-supplied argument for execution.
- 5.
Beware of front-runners: Bob can monitor the network and try to join a contract as soon as he sees Alice’s attempt to do so. Depending on the network latency and miner’s behavior, either transaction can be confirmed.
- 6.
BTCRelay is a prominent example: users submit Bitcoin block headers to a smart contract, which implies their authenticity from the validity of easily verifiable proof-of-work. After a header is stored on the Ethereum blockchain, users check with a Merkle proof that the Bitcoin block contains a given transaction.
- 7.
For simplicity, we only consider 256-bit integers as observable values. Boolean values can be trivially simulated via integers.
- 8.
By definition, an expired contract is equivalent to \(\mathrm {Zero}\).
- 9.
An expired contract should also be deleted even if its owner is offline forever. Our current implementation does not handle the latter case, though it may be considered an attack vector due to increasing storage usage. A possible approach is for a marketplace to offer rewards for keeping track of expired contracts and triggering their deletion.
- 10.
Compare to [JES00]: “If you acquire (c1 or c2) you must immediately acquire either c1 or c2 (but not both)”. We can not force a user to make this decision.
- 11.
In this particular case, an equivalent contract \(\mathrm {Give}(\mathrm {Or}(\mathrm {One}(USD),\mathrm {One}(EUR)))\) solves the issue. In more complex cases this is not necessarily the case.
- 12.
A likely rationale: rounding issues break consensus.
- 13.
Solidity version: 0.4.4+commit.4633f3de.Emscripten.clang.
- 14.
Szabo makes a case against state variables in general, stating that “they should be avoided unless utterly necessary”.
- 15.
In traditional finance, a future is a standardized contract while a forward is not. This distinction is not relevant for our model.
References
Atzei, N., Bartoletti, M., Cimoli, T.: A survey of attacks on ethereum smart contracts. IACR Cryptol. ePrint Arch. 2016, 1007 (2016)
Statistical release. OTC derivatives statistics at end-june 2016 (2016). https://www.bis.org/publ/otc_hy1611.pdf
Browser-solidity online compiler (2016). https://ethereum.github.io/browser-solidity/
A next-generation smart contract and decentralized application platform (2014). https://github.com/ethereum/wiki/wiki/White-Paper
Clack, C.D., Bakshi, V.A., Braine, L.: Smart contract templates: foundations, design landscape and research directions. CoRR, abs/1608.00771 (2016)
Yakoubov, S., Fromknecht, C., Velicanu, D.: A decentralized public key infrastructure with identity retention. Cryptology ePrint Archive, Report 2014/803 (2014). http://eprint.iacr.org/2014/803
Chaudhary, S.: Adventures in financial and software engineering (2015). https://falconair.github.io/2015/01/30/composingcontracts.html
Cox, J.C., Ross, S.A., Rubinstein, M.: Option pricing: a simplified approach. J. Finan. Econ. 7(3), 229–263 (1979)
del Castillo, M.: JP Morgan, credit suisse among 8 in latest bank blockchain test (2016). http://www.coindesk.com/jp-morgan-credit-suisse-among-8-in-latest-bank-blockchain-test/
Ethstats (2017). https://ethstats.net/
Functional programming for ethereum (2017). https://github.com/fp-ethereum/fp-ethereum
Frankau, S., Spinellis, D., Nassuphis, N., Burgard, C.: Commercial uses: going functional on exotic trades. J. Func. Program. 19(01), 27–45 (2009)
Gaillourdet, J.-M.: A software language approach to derivative contracts in finance (2011). http://ceur-ws.org/vol-750/yrs06.pdf
Gibbons, J.: Functional programming for domain-specific languages. In: Zsók, V., Horváth, Z., Csató, L. (eds.) CEFP 2013. LNCS, vol. 8606, pp. 1–28. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-15940-9_1
Greenspan, G.: Why many smart contract use cases are simply impossible (2016). http://www.coindesk.com/three-smart-contract-misconceptions/
Hvitved, T.: A survey of formal languages for contracts. In: Fourth Workshop on Formal Languages and Analysis of Contract-Oriented Software (FLACOS 2010), pp. 29–32. Citeseer (2010)
Icos, token sales, crowdsales (2017). https://www.smithandcrown.com/icos/
Peyton Jones, S.L., Eber, J.-M.: How to write a financial contract, The Fun of Programming (2003)
Peyton Jones, S.L., Eber, J.-M., Seward, J.: Composing contracts: an adventure in financial engineering, functional pearl. In: ICFP, pp. 280–292. ACM (2000)
Khovratovich, D.: debt.sol (2016). https://gist.github.com/khovratovich/45f68082b556b45eb64e8e1c3eb82892
Lewison, K., Corella, F.: Backing rich credentials with a blockchain PKI (2016). https://pomcor.com/techreports/BlockchainPKI.pdf
Ocaml at lexifi (2000). https://www.lexifi.com/blogs/ocaml
Mortensen, S.: Universal contracts (2016). https://github.com/corda/corda/tree/master/experimental/src
Oraclize (2016). http://www.oraclize.it/
Reality keys (2016). https://www.realitykeys.com/
Revere, R.R.: What is the difference between transaction cost and execution cost in browser solidity? (2016). https://ethereum.stackexchange.com/q/5812/5113
Schiller, T.: Financial domain-specific language listing (2013). http://www.dslfin.org/resources.html
Schuldenzucker, S.: Decomposing contracts (2014). http://www.ifi.uzh.ch/ce/people/schuldenzucker/decomposingcontracts.pdf
Schuldenzucker, S.: An axiomatic framework for no-arbitrage relationships in financial derivatives markets (2016). http://www.ifi.uzh.ch/ce/publications/LPT.pdf
Gün Sirer, E.: Thoughts on the dao hack (2016). http://hackingdistributed.com/2016/06/17/thoughts-on-the-dao-hack/
Seijas, P.L., Thompson, S., McAdams, D.: Scripting smart contracts for distributed ledger technology. Cryptology ePrint Archive, Report 2016/1156 (2016). http://eprint.iacr.org/2016/1156
Szabo, N.: Formalizing and securing relationships on public networks (1997). http://journals.uic.edu/ojs/index.php/fm/article/view/548
Szabo, N.: A formal language for analyzing contracts (2002). http://nakamotoinstitute.org/contract-language/
Tlsnotary (2016). https://tlsnotary.org/
Ethereum improvement proposal: Token standard (2016). https://github.com/ethereum/EIPs/issues/20
van Straaten, A.: Composing contracts (2007). https://web.archive.org/web/20130814194431/http://contracts.scheming.org
Walton, C.: Scala contracts project (2012). https://github.com/channingwalton/scala-contracts/wiki
Wood, G.: Ethereum: a secure decentralised generalised transaction ledger (2014). http://gavwood.com/paper.pdf
Gross domestic product 2015 (2016). http://databank.worldbank.org/data/download/GDP.pdf
Worldcoinindex (2017). https://www.worldcoinindex.com/coin/ethereum
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
A Examples
A Examples
-
A fixed-rate currency exchange: the owner sells €10 for $11.
$$\begin{aligned} \mathrm {And}(\mathrm {Give}(\mathrm {Scale}(10, \mathrm {One}(EUR))),\mathrm {Scale}(11,\mathrm {One}(USD)) \end{aligned}$$ -
A market-rate currency exchange: the owner sells €10 at market rate as reported by the gateway at addr.
$$\begin{aligned} \mathrm {Scale}(10, \mathrm {And}(\mathrm {Give}(\mathrm {One}(EUR)), ScaleObs(addr,\mathrm {One}(USD)))) \end{aligned}$$ -
A zero-coupon bond: the owner receives $100 at \(t_0\).
$$\begin{aligned} \mathrm {Timebound}(t_0-\delta , t_0+\delta , \mathrm {Scale}(100, \mathrm {One}(USD))) \end{aligned}$$ -
A bond with coupons: the owner receives $1000 (face value) in three years (maturity date) and two coupon payments of $50 at regular intervals before the maturity date.
$$\begin{aligned} \mathrm {And}(\mathrm {At}(\text {now + 3 years},c_{face}),\mathrm {And}(\mathrm {At}(\text {now + 1 years}, c_{cpn}),\mathrm {At}(\text {now + 1 years},c_{cpn}))) \end{aligned}$$where
$$\begin{aligned} c_{face} = \mathrm {Scale}(1000,\mathrm {One}(USD)), \quad c_{cpn} = \mathrm {Scale}(50,\mathrm {One}(USD)) \end{aligned}$$ -
A future (a forward Footnote 15): parties agree to execute the underlying contract \(c\) at \(t_0\).
$$\begin{aligned} \mathrm {Timebound}(t_0-\delta , t_0+\delta , c) \end{aligned}$$ -
An option: the owner can choose at (European option) or before (American option) time \(t_0\) whether to execute the underlying contract \(c\).
$$\begin{aligned} \mathrm {Timebound}(t_0-\delta , t_0+\delta , \mathrm {Or}(c, \mathrm {Zero})) \end{aligned}$$$$\begin{aligned} \mathrm {Timebound}(now, t_0+\delta , \mathrm {Or}(c, \mathrm {Zero})) \end{aligned}$$ -
A binary option: the owner receives $10 if a predefined event took place at \(t_0\) and nothing otherwise.
$$\begin{aligned} \mathrm {If}(addr, \mathrm {Scale}(10, \mathrm {One}(USD)), \mathrm {Zero}) \end{aligned}$$
Rights and permissions
Copyright information
© 2017 International Financial Cryptography Association
About this paper
Cite this paper
Biryukov, A., Khovratovich, D., Tikhomirov, S. (2017). Findel: Secure Derivative Contracts for Ethereum. In: Brenner, M., et al. Financial Cryptography and Data Security. FC 2017. Lecture Notes in Computer Science(), vol 10323. Springer, Cham. https://doi.org/10.1007/978-3-319-70278-0_28
Download citation
DOI: https://doi.org/10.1007/978-3-319-70278-0_28
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-70277-3
Online ISBN: 978-3-319-70278-0
eBook Packages: Computer ScienceComputer Science (R0)