Skip to main content

Prototype and wrappers to work with Ensuro Smart Contracts

Project description

Project generated with PyScaffold

ensuro

Prototype and wrappers to work with Ensuro Smart Contracts

This package is for working with the Ensuro Protocol (https://github.com/ensuro/ensuro) from Python.

It includes the prototype written in pure-python that can be used for simulation of Ensuro. Also includes the wrappers that together with the compiled contracts can be used to deploy or use contracts deployed on the blockchain.

Getting information from Ensuro objects

PremiumsAccount
  • .active_pure_premiums

  • .surplus: balance of pure premiums of finalized policies.

  • .won_pure_premiums: accumulated pure premiums of expired/not defaulted policies.

  • .borrowed_active_pp: pure premiums of active policies that were used for payouts. Always <= active_pure_premiums` and always = 0 if won_pure_premiums != 0.

  • .pure_premiums: it’s a property that computes the total pure premiums as self.active_pure_premiums + self.won_pure_premiums - self.borrowed_active_pp

EToken
  • .total_supply(): total amount in dollars in the pool.

  • .scr: amount that it’s locked as solvency capital of active policies

  • .scr_interest_rate: weighted average of the interest rate paid by the active policies

  • .utilization_rate: percentage of utilization of the eToken. Property calculated as scr / total_supply

  • .token_interest_rate: interest rate for the EToken, it’s calculated as scr_interest_rate * utilization_rate

  • .funds_available: available capital (total_supply - scr)

  • .funds_available_to_lock: available capital that can be used as scr, (total_supply - scr) * max_utilization_rate

  • .total_withdrawable(): amount that can be withdrawn, considering the liquidity_requirement.

  • .get_loan(): current debt of the pool with this eToken

RiskModule
  • .get_minimum_premium(payout, loss_prob, expiration): minimum premium

Copying files from Ensuro main repository

Instructions to copy files from ensuro repository:

rm src/ensuro/contracts/*.json
for x in `find ../ensuro/artifacts/contracts/ -maxdepth 2 -name "*.json" -not -name "*.dbg.json" `; do
    cp $x src/ensuro/contracts/ ;
done
for x in `find ../ensuro/artifacts/contracts/interfaces/ -maxdepth 2 -name "*.json" -not -name "*.dbg.json" `; do
    cp $x src/ensuro/contracts/ ;
done
for x in `find ../ensuro/artifacts/contracts/underwriters/ -maxdepth 2 -name "*.json" -not -name "*.dbg.json" `; do
    cp $x src/ensuro/contracts/ ;
done
for x in ERC1967Proxy.json IERC20Metadata.json IERC20.json IERC721.json ; do
    cp `find ../ensuro/artifacts/@openzeppelin/ -name $x` src/ensuro/contracts/$x ;
done
cp ../ensuro/artifacts/@ensuro/utils/contracts/TestCurrency.sol/TestCurrency.json src/ensuro/contracts/TestCurrency.json
cp ../ensuro/prototype/ensuro.py src/ensuro/prototype.py
cp ../ensuro/prototype/wrappers.py src/ensuro/wrappers.py
cp ../ensuro/prototype/utils.py src/ensuro/utils.py

Note

This project has been set up using PyScaffold 4.1.1. For details and usage information on PyScaffold see https://pyscaffold.org/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ensuro-3.0.0b1.tar.gz (125.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ensuro-3.0.0b1-py3-none-any.whl (127.7 kB view details)

Uploaded Python 3

File details

Details for the file ensuro-3.0.0b1.tar.gz.

File metadata

  • Download URL: ensuro-3.0.0b1.tar.gz
  • Upload date:
  • Size: 125.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ensuro-3.0.0b1.tar.gz
Algorithm Hash digest
SHA256 ce61920311fbf39610b314ba9b3741d6cb68e1c261c542b08cd064837a3ca39e
MD5 d53eef0c0610250d4506978d550b2305
BLAKE2b-256 f699c29aa6d0b94f6014a28a5af38e8b14e0356b9ce7ca77e434dfdd0a9e3105

See more details on using hashes here.

File details

Details for the file ensuro-3.0.0b1-py3-none-any.whl.

File metadata

  • Download URL: ensuro-3.0.0b1-py3-none-any.whl
  • Upload date:
  • Size: 127.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ensuro-3.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 41ae0a448a6e35aee146119483b1ff775a35672ae24d2e9fb007db0608dfa3d9
MD5 f9a1fa0988bed5cca48000e63b755ca5
BLAKE2b-256 adb246cbbe947a19aaeab18dab19502a690229195ecee6d699866c21916dd229

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page