0.0.1 • Published 8 months ago

@verified-network/protocol v0.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

Protocol

This package contains the Typescript SDK for easier interaction with the Verified product smart contracts. The foundation of the protocol is the Solidity implementation of ACTUS Contract Types (https://www.actusfrf.org/algorithmic-standard) which is part of the package.

Documentation

https://docs.verified.network/

Usage

Install via yarn or npm

yarn add @verified-network/protocol

Importing contracts

import "@verified-network/protocol/contracts/....sol";

Using the Typescript SDK

import { AP } from '@verified-network/protocol';
// tested with web3@1.2.4 - other versions may cause typing issues
const ap = await AP.init(web3, ADDRESS_BOOK);

Development

Requirements and Setup

See README in root directory.

Testing

yarn test

Deploy to local ganache chain

npx hardhat deploy --network localhost

Deploy to EVM chains

npx hardhat deploy --network <chain-name>

Listing addresses of a deployment

cd deployments/<deployment>
find ./*.json | while read f ; do echo -n "$f: " ; cat "$f" | jq -r '.receipt.contractAddress' ; done

Smart Contracts

ACTUS Core

Contains banking-grade financial logic such as ACTUS day-count & end-of-month conventions, ACTUS datatypes and floating point arithmetic used throughout all ACTUS engines.

ACTUS Engines

Contains ACTUS state machine engines for each ACTUS Contract Type. An Engine implements the state transition & payoff functions and the schedule generation logic for an ACTUS Contract Type. Engines are stateless smart contracts, thus can be used on-chain as well as off-chain (e.g. by using the EVM as a TEE).

Core

Contains the protocol which is build on top of ACTUS Core and the ACTUS Engines.

Basic workflow

  1. Define an ACTUS term sheet depending on the financial contract you want to model and set up the ownership structure
  2. Use the appropriate Asset Actor contract (e.g. the PAMActor) to initialize and register the new asset on chain
  3. Make sure that the Asset Actor has the required token allowances and progress the asset vie the progress() function.

Contract Types

  • ANN (Annuity)
  • CEC (Contract Enhancement Collateral)
  • CEG (Contract Enhancement Guarantee)
  • CERTF (Certificate)
  • COLLA (Simplified Principal At Maturity with Collateral)
  • PAM (Principal At Maturity)
  • STK (Stock)

Implemented Conventions

  • Contract-Role-Sign-Convention (for PAM)

Annuity-Payment-Conventions

  • Simplified Analytical Annuity Calculation

Business-Day-Count-Conventions

  • SCF (Shift/Calculate following)
  • SCMF (Shift/Calculate modified following)
  • CSF (Calculate/Shift following)
  • CSMF (Calculate/Shift modified following)
  • SCP (Shift/Calculate preceding)
  • SCMP (Shift/Calculate modified preceding)
  • CSP (Calculate/Shift preceding)
  • CSMP (Calculate/Shift modified preceding)

End-Of-Month-Conventions

  • Same Day Shift
  • End-Of-Month Shift

Year-Fraction-Conventions (Day-Count-Methods)

  • A/AISDA (Actual Actual ISDA)
  • A/360 (Actual Three Sixty)
  • A/365 (Actual Three Sixty Five)
  • 30E/360ISDA (Thirty E Three Sixty ISDA)
  • 30E/360 (Thirty E Three Sixty)
  • 28E336 (Twenty Eight E Three Thirty Six)
  • ONE (One Intraday)
  • OBYT (OneBy Twelve Intraday)
  • HRSAA (Hours Actual Actual Intraday)
  • MINAA (Minutes Actual Actual Intraday)
  • SECAA (Seconds Actual Actual Intraday)

Data types

All ACTUS related types depended on actus-dictionary. With the exception of Array types, ACTUS types are one to one mapped in Solidity.

ACTUS Dictionary data typeCorresponding Solidity data type
Timestamp (ISO8601 Datetime)uint256 (Unix Timestamp in sec.)
Realint256 (10 ** 18, fixed point)
Integerint256 (10 ** 18, fixed point)
Varcharbytes32 or bytes (depending on length)
Enumenum
Period (ISO8601 Duration)struct (IP where I: uint256, P: enum, isSet: boolean)
Cycle (ISO8601 Duration Ls={0,1})struct (IPS where I: uint256, P: enum, S: enum, isSet: boolean)
ContractReferencestruct (object: bytes32, object2: bytes32, _type: enum, role: enum)
0.0.1

8 months ago