Giter Site home page Giter Site logo

centrifuge / tinlake Goto Github PK

View Code? Open in Web Editor NEW
102.0 19.0 23.0 2.05 MB

Smart contracts for Tinlake, the on-chain securitization protocol for real-world assets

License: GNU Affero General Public License v3.0

Solidity 99.10% Shell 0.90%
rwa ethereum solidity

tinlake's Introduction

Tinlake Contracts

Open source implementation of Tinlake in Solidity. This repository contains the core contracts of Tinlake.

Tinlake is a set of smart contracts that allows companies and individuals to use tokenized non-fungible real-world assets as collateral to obtain liquidity.

For learning more about how Tinlake works, you can visit the Tinlake documentation.

Getting started

Tinlake uses foundry for development. Please install the foundry client. Then, run the following command to install the dependencies:

forge update

Testing

The tests for Tinlake are written in Solidity

Run all tests

forge test

Run specific tests

A regular expression can be used to only run specific tests.

forge test -m <REGEX>
forge test -m testName
forge test -m ':ContractName\.'

Deployment

To deploy Tinlake, you need to set up a .env file with the deployment parameters. A sample file can be found in .env.example.

To confirm that the .env file is set up correctly, run:

./bin/env-check.sh

Once you've double checked all the environment variables, the deployment can be started:

forge script script/deploy.s.sol:DeployScript --rpc-url $RPC_URL  --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv

When the deployment is complete, you can print the list of deployed contracts:

ROOT_CONTRACT=0x0 forge script script/print_contracts.s.sol:PrintContractsScript --rpc-url $RPC_URL -vvvv

And you can also run the set of RPC tests against the newly deployed pool:

ROOT_CONTRACT=0x0 MAKER_RPC_TESTS=false forge script script/run-rpc-tests.s.sol:RunRPCTests --rpc-url $RPC_URL

Community

Join our public Discord: Centrifuge Discord.

tinlake's People

Contributors

astox avatar charleenfei avatar hieronx avatar ilinzweilin avatar lucasvo avatar xmxanuel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinlake's Issues

Lightswitch

add tests for lightswitch and extend functionality if needed

potential feature: flagging a loan as ongoing

This might be useful to prevent certain interaction patterns from the admin side if a loan is ongoing, currently we only limit these interactions from the borrower side by using the NFT owner check.

consistent use and extensions of file pattern

every file method should have a bytes32 what.

Every contract which has a dependency on another contract should have file methods to change the dependency.

Example for reception.sol

    // --- Data ---
    DeskLike desk;
    ShelfLike shelf;
    PileLike pile;

 function file(bytes32 what, address addr) public auth {
        if (what == "pile") pile = PileLike(addr);
        else if (what == "shelf") shelf = ShelfLike(addr);
        else if (what == "desk") desk = DeskLike(addr);
        else revert();
    }

I think we should use the file pattern only for external configuration. If one core contract calls another core contract we should use other method names.

mcd auction (flipper contract)

each new ERC20 for MCD has a individual gemJoin and flipper contract (auction).

Currently, we are using the default flipper contract.

We need to define the requirements for our auction contract. (Additional Whitelist etc)

add simple lender contract

A simple lender contract should be added for use cases without a CVT token.

The simple lender contract should provide the pile with new currency tokens if a new nft gets locked.

Add handling for defaulted loans

https://centrifuge.hackmd.io/CwncH44eTRyCJOKaZpc6bQ

##### AC

  • As a pool operator I want to remove defaulted loans from my tinlake pool
  • As a whitelisted collector I want to be able to buy out underlying assets from the default loans by repaying the outstanding debt
  • As an admin I want to whitelist collectors
  • As the owner of a defaulted loan I should not be able to repay the loan anymore & should see that my loan got collected in the UI

when is a loan considered defaulted?

  • if the loan price is not matching the loan threshold it is considered defaulted
  • assumption: for now pool admins/operators can modify loan prices

##### TC

Spotter

  • detects collectable loans
  • current implementation: same threshold for all loans
    optional: could manage individual loans (interface wouldn't change)

Tag

  • know the default price for a collectable loans
  • current implementation: default price for the loan == loan debt
    optional : could manage the auction prices

Pile

  • remove defaulted loan
  • adjust the loss value

Shelf

  • allow to move collateral asset to the collector

Tranche Manager

  • monitor loss changes of the pool

Collector

  • ask spotter if a loan is collectable
  • if collectable: asks tag for the default price
  • remove defaulted loan from the pile
  • move ownership of collateral asset from shelf to self
  • functions:
    repayLoan()
    freeNFT()

Keeper
not implemented
would manage the access to the collector (whitelist or auction)

investigate: failed borrow on kovan with previous principal/appraisal=0

Setup:

three loans whitelisted loans with appraisal=0 and prinicipal=0 before the whitelisting with non zero values.

appraisal=0 and principal=0 is an edge case and results in a loan repaid state.

Investigate if the edge case caused a broken contract state for the following transactions.

next whitelisting with non zero values failed in the borrow transaction afterwards

See:
https://kovan.etherscan.io/tx/0xc5cac4169620ff8835c23f24820904e8f587f76aa3a4033e8d06f68670ceff61

investigate: balance call in reception.borrow assumes lender.provide

after the appraisal of an NFT changes dynamically it could be the case that the desk.balance call in reception.borrow is trying to reduce it instead of providing more liquidity

Currently, it would fail because the pile doesn't have the needed currency.
In case the pile would own currency a reduce would be triggered.

The borrow transaction would fail because the pile would not receive extra liquidity.

add whitelist undo functionality

It should be possible to modify the defined principal and interest after the whitelisting happened by the admin.

Only the admin should be allowed to change the principal and the interest rate/

If the loan is already borrowed it should be not possible.

add collector contract

The collector contract should allow seizing of collateral that is overdue at a specified price

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.