Skip to content

Basic Contract Functions

Hart Lambur edited this page Aug 27, 2018 · 5 revisions

Abstract

The following spec outlines the core functions required for the bilateral derivative smart contract as originally specified in the TRS whitepaper.

Motivation

These core contract functions are the basis for the bilateral derivative smart contract. They are the core means by which a contract can be valued, accessed, and secured.

Specification

Core Contract Functions:

  • function remargin() external returns (bool success) Does the following:

    1. Call calcNPV() to determine the current contract value;
    2. Move funds between the margin and escrow accounts such that the escrow balance equals the current NPV;
    3. Call terminate() to determine if the contract should be terminated.
  • function calcNPV() internal returns (bool success) Recalculates the economic terms of the function.

  • function withdraw(address _destination, uint _amount) external returns (bool success) Allows either the maker or taker to withdraw funds from their respective margin accounts into their public wallet addresses.

  • function deposit(address _destination) external returns (bool success); Transfers incoming funds into the margin account of either the maker or taker.

  • function terminate() external returns (bool success) Does the following:

    1. Call calcNPV() to determine the current contract value;
    2. Move funds between the margin and escrow accounts such that the escrow balance equals the current NPV;
    3. Call terminate() to determine if the contract should be terminated.