trustline-inc / probity Goto Github PK
View Code? Open in Web Editor NEWA transparent asset-based lending protocol implemented for the EVM.
Home Page: https://docs.trustline.co
License: Other
A transparent asset-based lending protocol implemented for the EVM.
Home Page: https://docs.trustline.co
License: Other
Line 285 in 11da921
We need to be able to delegate VP to a price provider in order to earn rewards from ftso system while the collateral sits in the system.
Refer to the tests I wrote in the previous v1 version
Throw error CUST: Non-existent vault
Enable emergency system shutdown through governance
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:
VAULT: Liquidation threshold not exceeded
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.vault.withdraw()
Treasury
Borrower Liquidation Steps:
VAULT: Liquidation threshold not exceeded
vault.withdraw()
Teller
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
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 ?
From what we discussed, it is related to the size of APR_TO_MPR
Set up a Prettier pre-commit hook in package.json
to auto-format code changes on git push
If the user wants to use FLR as collateral, we should convert it to WFLR.
I created a new initialize
script to set up Probity in local dev. I followed the structure of other scripts, but it throws the error sending a transaction requires a signer
. I need your help @shine2lay to get this resolved.
https://github.com/trustline-inc/probity/blob/main/scripts/initialize.ts
Expected Behavior
Running npm run initialize
will initialize a collateral type after contracts have been deployed locally.
Calling openVault
from an address with a vault should revert the transaction
Acceptance Criteria
probity/contracts/probity/Treasury.sol
Line 81 in 9f1ecec
Make a GitHub action to generate the artifacts: https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts
The artifacts can be a local copy of the deployed version.
https://github.com/marketplace/actions/npm-publish
The published package can be installed via npm and the contracts deployed locally without having to compile them.
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.
Add the ability to freeze all operation in case of emergency (should there be a global state contract that all contract in system checks?)
Teller
borrow
repay
Treasury
stake
redeem
withdraw
Aurei contract should be strictly <
instead of <=
https://github.com/trustline-inc/aurei/blob/main/contracts/Treasury.sol#L271
It should be fixed temporarily in the UI to not display these 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.
Right now any external caller can mint and burn Aurei. Need to add modifiers to only allow the Treasury or Comptroller to call.
Remove the ability to open a vault with an amount of debt and equity. Vaults should only be open-able with a collateral deposit, at least for now.
What is the purpose of this param? I am not sure why there would be multiple treasury contracts.
function modifySupply(
bytes32 collId,
address treasuryAddress,
int256 collAmount,
int256 supplyAmount
) external {}
How are liquidators incentivized?
We should allow user to pick whether AUR or TCN to withdraw from 'interest'
Error should hold this format contractName/FunctionName/error message
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.
Should the Collateral
struct in VaultEngine
have a var for the liquidation ratio?
Ensure collateral can continue to earn rewards and delegate votes
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
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.
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.
NewShine 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 failingShine 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 amountShine 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 isMatthew Rosendin 3:36 PM
yeah, I just thought that too. I can mark it as an issue in github and we can revisit
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.
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.
We currently have
9 decimal places for prices,
18 decimal places for collateral
27 decimal places for Accumulators
45 decimal places for Aurei
Deployment of contracts in a local dev environment may produce the error displayed below.
The solution is to go to Metamask and:
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)
Right now all of them are set for MIT
, we need to access and change it.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.