Giter VIP home page Giter VIP logo

probity's People

Contributors

divyamaheshw avatar mrosendin avatar shine2lay avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

linqto-team

probity's Issues

Liquidate method

Liquidations can occur for an Aurei issuer or an Aurei borrower. There is a difference between the two positions.

  • Liquidation of an Aurei issuer's position will return 95% of their collateral to them. The remaining collateral is awarded to the liquidator for maintaining system health and the protocol takes a small fee.

  • Liquidation of an Aurei borrower's position will award all the collateral to the liquidator (minus a small protocol fee). The borrower maintains possession of their borrowed Aurei.

  • Remove Liquidator.sol and ILiquidator.sol contracts

  • Add liquidate() method to Treasury.sol and Teller.sol with address as argument

  • Add Liquidation event with parameters for position details and liquidator address

  • Implement liquidate -- see below

Supplier Liquidation Steps:

  • Check if the vault's ratio is below the minimum required amount. Throw error VAULT: Liquidation threshold not exceeded
  • If the caller has enough Aurei, call aurei.transferFrom(), send to the treasury, and burn it. The contract MUST be given an allowance to spend the caller's Aurei (85% of the bad debt) to repay the Aurei loan beforehand.
  • Send the collateral amount to the caller (minus protocol fee) using vault.withdraw()
  • Clear the vault's capital in Treasury
  • Clear the vault's staked collateral balance

Borrower Liquidation Steps:

  • Check if the vault's ratio is below the minimum required amount. Throw error VAULT: Liquidation threshold not exceeded
  • Send the collateral amount to the caller (minus protocol fee) using vault.withdraw()
  • Clear the vault's debt in Teller
  • Clear the vault's loan collateral balance

Blog post on liquidations

ERC2612 Implementation Error on Coston Deployment

aurei % npm run deploy:coston

> @trustline/[email protected] deploy:coston
> npx hardhat --network coston run ./scripts/deploy.ts

Creating Typechain artifacts in directory typechain for target ethers-v5
Successfully generated Typechain artifacts!
ProviderError: invalid opcode: CHAINID
    at HttpProvider.request (/Users/matthewrosendin/Desktop/aurei/node_modules/hardhat/src/internal/core/providers/http.ts:46:19)
    at LocalAccountsProvider.request (/Users/matthewrosendin/Desktop/aurei/node_modules/hardhat/src/internal/core/providers/accounts.ts:131:34)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at EthersProviderWrapper.send (/Users/matthewrosendin/Desktop/aurei/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
npm ERR! code 1
npm ERR! path /Users/matthewrosendin/Desktop/aurei
npm ERR! command failed
npm ERR! command sh -c hardhat "--network" "coston" "run" "./scripts/deploy.ts"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/matthewrosendin/.npm/_logs/2021-04-09T20_00_42_738Z-debug.log
npm ERR! code 1
npm ERR! path /Users/matthewrosendin/Desktop/aurei
npm ERR! command failed
npm ERR! command sh -c npx hardhat --network coston run ./scripts/deploy.ts

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/matthewrosendin/.npm/_logs/2021-04-09T20_00_42_765Z-debug.log

Oracle price to interest rate feedback loop

We might also have to adjust the interest rate algorithm for probity.

How I envision it working is by getting PHI/SGB and AUR/FLR price feeds from the FTSO and adjusting the interest rate up when the price is > $1 and lowering the rate when the price is < $1, based on a time step mechanism similar to the auction system.

We can fine tune this idea and make the interest rate model upgradable or modifiable through governance.

What are your thoughts on this proposal @shine2lay ?

Use solc ^0.7.4

Solidity compiler v0.8 does not allow arithmetic between uint and int which means that you can't update a uint by passing an int function param. This makes the logic much more verbose than it needs to be.

Freeze + Escape Hatch

Add the ability to freeze all operation in case of emergency (should there be a global state contract that all contract in system checks?)

Create sequential index for vaults

We need to track a sequential, numeric index for each vault and keep tabs on the last index, so we can deterministically loop and read all vaults when monitoring and managing open CDPs.

Assess liquidation penalties/fees

  • Apply penalty fee on equity position liquidation
  • Apply protocol fee on debt + equity position liquidations
  • Liquidated debt position's collateral goes to auction

How are liquidators incentivized?

Remove public variable getters

Solidity automatically creates getter functions for public variables.

Remove public variable getters in Vault. This will have no impact on clients.

Doing the same for Treasury and Teller will have an impact, so that will be a separate issue.

Standardize code styling

We should make the code as uniform as possible in order help with readability and reduce bugs.

After the code style discussion (thru comments) is finalized, we'll add that in to the README.md

Fix duplicate event definition warning

It apparently does not like duplicate definitions so we should create unique definitions for events from now on.

TypeChain Logs

Compilation finished successfully
Creating Typechain artifacts in directory typechain for target ethers-v5
Successfully generated Typechain artifacts!
Duplicate definition of LogVarUpdate (LogVarUpdate(bytes32,bytes32,bytes32,uint256,uint256), LogVarUpdate(bytes32,bytes32,uint256,uint256), LogVarUpdate(bytes32,bytes32,bytes32,address,address))
Duplicate definition of LogVarUpdate (LogVarUpdate(bytes32,bytes32,bytes32,uint256,uint256), LogVarUpdate(bytes32,bytes32,uint256,uint256), LogVarUpdate(bytes32,bytes32,bytes32,address,address))
Duplicate definition of LogVarUpdate (LogVarUpdate(bytes32,bytes32,bytes32,uint256,uint256), LogVarUpdate(bytes32,bytes32,uint256,uint256), LogVarUpdate(bytes32,bytes32,bytes32,address,address))

JavaScript Console Logs

These are coming from ethers.

Screen Shot 2021-09-26 at 2 10 12 PM

Unable to repay loan

Currently unable to complete loan repayment.

For repayment, we don't need to check that treasury balance is higher than debtAmount here:
https://github.com/trustline-inc/probity/blob/main/contracts/probity/VaultEngine.sol#L222

hey shine, I'm trying to repay debt on the vault but I'm getting execution reverted: Treasury doesn't have enough supply to loan this amount and I'm not sure why
3:17

        // Modify debt
        var result = await vault.modifyDebt(
          web3.utils.keccak256("FLR"),
          TREASURY_ADDRESS,
          WAD.mul(collateralAmount).mul(-1),
          WAD.mul(aureiAmount).mul(-1)
        );
        var data = await result.wait();
        ctx.updateTransactions(data);

        // Withdraw collateral
        result = await nativeCollateral.withdraw(WAD.mul(collateralAmount));
        data = await result.wait();

Matthew Rosendin 3:23 PM
the treasury address was the same between the modifySupply and modifyDebt calls
3:24
I'm gonna investigate a bit.
New

Shine Lee 3:26 PM
what's aur value of treasury address?

Matthew Rosendin 3:28 PM
100086000000000000000000000000000000000000000000000
3:29
or 100086.0 which looks about right to me
3:31
in AUR[treasuryAddress] >= uint256(debtAmount), the lefthand side is rad and the righthand side is being passed into the method call as wad.
3:32
^ that might be a separate issue about comparison between two different units
3:32
I am not sure why this condition is failing

Shine Lee 3:33 PM
why do you have .mul(-1) for your amounts?

Matthew Rosendin 3:34 PM
to indicate that I want to reduce the debt and collateral by that amount

Shine Lee 3:34 PM
hmm.. okay
3:35
in repayment, maybe we don't need to check that treasury balance is higher than debtAMount
3:36
becuase it doesn't matter what the treasury balance is

Matthew Rosendin 3:36 PM
yeah, I just thought that too. I can mark it as an issue in github and we can revisit

Can't get event type from log

Since events are emitted with Log or LogVarUpdate I'm unable to get the name of the event type. It should be the first event arg but I'm unable to decode it.

Vault collateral access grants

Allow a secondary externally-owned account (EOA) to use collateral of a non-owned vault. Granter specifies a maximum limit of collateral accessible to the grantee.

Document `Invalid value for block.coinbase` fix

Deployment of contracts in a local dev environment may produce the error displayed below.

The solution is to go to Metamask and:

  • (1) Reset your account
  • (2) send a transaction to any address for any amount.

Then re-deploy.

matthewrosendin@Matthews-MacBook-Pro probity % FLARE_DIR=/Users/matthewrosendin/Desktop/flare npm run deploy:local

> @trustline-inc/[email protected] deploy:local
> npx hardhat --network local run ./scripts/deploy.ts

Compiling 6 files with 0.8.4
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> contracts/Dependencies/HighAPR.sol


Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> contracts/Dependencies/LowAPR.sol


Compilation finished successfully
Creating Typechain artifacts in directory typechain for target ethers-v5
Successfully generated Typechain artifacts!
ProviderError: err: Invalid value for block.coinbase (supplied gas 50010499)
    at HttpProvider.request (/Users/matthewrosendin/Desktop/probity/node_modules/hardhat/src/internal/core/providers/http.ts:49:19)
    at LocalAccountsProvider.request (/Users/matthewrosendin/Desktop/probity/node_modules/hardhat/src/internal/core/providers/accounts.ts:168:34)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at EthersProviderWrapper.send (/Users/matthewrosendin/Desktop/probity/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

Recovering collateral from Probity

One thing that's not clear to me is how a supply-side user reclaims their collateral after making a deposit or how a demand-side user can repay debt to recover collateral. I'm not seeing this in the tests.

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.