Giter Site home page Giter Site logo

mstable / mstable-contracts Goto Github PK

View Code? Open in Web Editor NEW
310.0 18.0 83.0 27.14 MB

📃 Smart Contracts that make up the core of the mStable protocol

License: GNU Affero General Public License v3.0

JavaScript 0.06% TypeScript 69.10% Solidity 30.78% Shell 0.06%
ethereum stablecoins smart-contracts solidity defi

mstable-contracts's People

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

mstable-contracts's Issues

SAVE Connector for depositing collateral on Creams Iron Bank

Is your feature request related to a problem? Please describe.
The mAssets in mStable SAVE contracts (SavingsContract.sol) are deposited to produce imAssets. This collateral can be recycled to produce additional yield by adding an IConnector to the contract. Currently there is no active IConnector on mUSD SAVE.

Currently there exists a market on Cream Finance's Iron Bank (https://creamdotfinance.medium.com/introducing-the-iron-bank-bab9417c9a) that could act as a lending market for mUSD. In addition, there is an active proposal for mUSD to be listed on Aave as a market.

Describe the solution you'd like

The solution:

  • A contract implementing IConnector interface for mUSD that deposits the collateral to Creams Iron Bank (https://v1.yearn.finance/lending) and tracks the interest generated
  • Test cases for this contract

Additional context
There are a number of properties that must be fulfilled here. See the IConnector interface for more details, or the _poke function in SavingsContract.sol, or take a look at some of the example connectors in z_mocks/savings.

TS error: Cannot find namespace 'Truffle'

I'm getting the following error when deploying the contracts with yarn migrate to a local network with ganache:

yarn run v1.22.4
$ truffle migrate --network development --reset

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Starting migrations...
======================
> Network name:    'development'
> Network id:      5777
> Block gas limit: 6721975 (0x6691b7)


1_main.js
=========

/home/gus/Projects/mstable/mStable-contracts/node_modules/ts-node/dist/index.js:175
            throw error;
            ^

TSError: ⨯ Unable to compile TypeScript:
migrations/src/1_initial_migration.ts:9:20 - error TS2503: Cannot find namespace 'Truffle'.

9         artifacts: Truffle.Artifacts;
                     ~~~~~~~
migrations/src/1_initial_migration.ts:2:22 - error TS6053: File '/home/gus/Projects/mstable/mStable-contracts/types/generated/index.d.ts' not found.

2 /// <reference path="../../types/generated/index.d.ts" />
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
migrations/src/1_initial_migration.ts:3:22 - error TS6053: File '/home/gus/Projects/mstable/mStable-contracts/types/generated/types.d.ts' not found.

3 /// <reference path="../../types/generated/types.d.ts" />
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    at createTSError (/home/gus/Projects/mstable/mStable-contracts/node_modules/ts-node/src/index.ts:245:12)
    at reportTSError (/home/gus/Projects/mstable/mStable-contracts/node_modules/ts-node/src/index.ts:249:19)
    at getOutput (/home/gus/Projects/mstable/mStable-contracts/node_modules/ts-node/src/index.ts:357:34)
    at Object.compile (/home/gus/Projects/mstable/mStable-contracts/node_modules/ts-node/src/index.ts:415:32)
    at Module.m._compile (/home/gus/Projects/mstable/mStable-contracts/node_modules/ts-node/src/index.ts:493:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Object.require.extensions.<computed> [as .ts] (/home/gus/Projects/mstable/mStable-contracts/node_modules/ts-node/src/index.ts:496:12)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at require (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/require/require.js:54:1)
    at /home/gus/Projects/mstable/mStable-contracts/migrations/1_main.js:4:26
    at Script.runInContext (vm.js:131:20)
    at Script.runInNewContext (vm.js:137:17)
    at Object.file (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/require/require.js:92:1)
    at Migration._load (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/migrate/migration.js:43:1)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Migration.run (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/migrate/migration.js:167:1)
    at Object.runMigrations (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:148:1)
    at Object.runFrom (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:253:1)
    at /home/gus/Projects/mstable/mStable-contracts/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:218:1
Truffle v5.1.22 (core: 5.1.22)
Node v12.18.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I'm executing the instructions presented on Readme, and wasn't able to find any truffle or typescript issues regarding it not finding the namespace. Also, the types generated in the initial migration are not found, am I missing something?

Thanks in advance

Clean up the solidity compilation warnings shown at compile time

Is your feature request related to a problem? Please describe.
Run yarn compile and you will see a LOT of yellow warning text show up. Some of these are very very minor, some can potentially come into a larger issue.

Describe the solution you'd like
Resolve all of these warnings by modifying the solidity code, or add rules to the compiler to dismiss them, such that we have no warnings left when compilation happens.

Additional context
There is no real reason to receive warnings for the contracts in z_mocks since they are unused - these can simply be turned off.

Port IncentivisedVotingLockup contracts from `master` to `master-v2`

Is your feature request related to a problem? Please describe.
Recently this repo was ported from solc 0.5.16 to 0.8.x, and truffle/web3.js to hardhat/ethers.js.

There are a number of contracts that have not yet been migrated, and will be used in future product releases.

Describe the solution you'd like
This issue proposes that the IncentivisedVotingLockup.sol is ported from master to master-v2. This includes:

  • porting of the solidity file and all dependencies
  • refactoring to bring code in line with solc 0.8 (e.g. removal of SafeMath)
  • porting of relevant test cases to new repo (TestSavingsManager.spec.ts)

Factory contract to support permissionless fPool creation

Is your feature request related to a problem? Please describe.
Users wish to deploy their own feeder pools permissionlessly

Describe the solution you'd like
Factory contract with configurable parameters to deploy feeder pools, and test cases to support this

Port Liquidator contracts from `master` to `master-v2`

Is your feature request related to a problem? Please describe.
Recently this repo was ported from solc 0.5.16 to 0.8.x, and truffle/web3.js to hardhat/ethers.js.

There are a number of contracts that have not yet been migrated, and will be used in future product releases.

Describe the solution you'd like
This issue proposes that the Liquidator.sol is ported from master to master-v2. This includes:

  • porting of the solidity file and all dependencies
  • refactoring to bring code in line with solc 0.8 (e.g. removal of SafeMath)
  • porting of relevant test cases to new repo (TestSavingsManager.spec.ts)

Deploy on rinkeby

I guess this issue is more for the backlog, but it would be nice to have an instance running on the rinkeby test network.

Make a generic mAsset deployment script to facilitate mETH deployment

Is your feature request related to a problem? Please describe.
mStable plan to introduce a number of mAssets and feeder pools this year. Both of these deploy scripts are specific and should be made generic to support n deployments.

Describe the solution you'd like
Fork the existing deployMBTC hardhat task and make a generic deployment script for mAssets

Extra context
At a simple level, most of the "mBTC specific" things in the current deploy script are superficial. Only the mainnet deploy and re-deployment scripts have specific info in them - they may benefit from additional arguments to use for the pools deployment.

Port SavingsManager contracts from `master` to `master-v2`

Is your feature request related to a problem? Please describe.
Recently this repo was ported from solc 0.5.16 to 0.8.x, and truffle/web3.js to hardhat/ethers.js.

There are a number of contracts that have not yet been migrated, and will be used in future product releases.

Describe the solution you'd like
This issue proposes that the SavingsManager.sol is ported from master to master-v2. This includes:

  • porting of the solidity file and all dependencies
  • refactoring to bring code in line with solc 0.8 (e.g. removal of SafeMath)
  • porting of relevant test cases to new repo (TestSavingsManager.spec.ts)

KeeperDAO Coordination facility for mStable AMM (0 Fees Swap for KeeperDAO keepers)

Is your feature request related to a problem? Please describe.
Allow KeeperDAO keepers to arbitrage the AMM (mAsset). In order to give KeeperDAO an edge and to allow them to reach arbitrage price first, set fees to 0 for KeeperDAO keepers. Only whitelisted keepers can call the special function to bypass the fee.

Describe the solution you'd like

  • Requires upgrading contracts
  • adjust swap, redeem, mint, or add one function to figure out the path callable only for Keeper to set swapFee = 0 and pass it to the Logic (Library Contract).
  • Add function to set a keeper
  • Add modifier/or check in the function to check for keeper
    MassetLogic library to allow accept the swapFee from the calling function

Relevant contracts:
mStable-contracts/Masset.sol at master · mstable/mStable-contracts · GitHub mStable-contracts/MassetLogic.sol at master · mstable/mStable-contracts · GitHub

Additional context
More info: https://forum.mstable.org/t/rfc-explore-a-keeperdao-coordination-facility-for-mstable-amm/798/9

Pass Criteria

  • Working contracts
  • Unit tests
  • Fork tests including the upgrade of contracts (Ethereum mainnet) and function testing.

Clean up the typescript errors and linting

Is your feature request related to a problem? Please describe.
There are a number of typescript errors dotted around the codebase, for example in test-utils/math.ts (or most of the test-utils folder)

Describe the solution you'd like
Clean out the test and test-utils folders, as well as any root level files, that have:

  • typescript linting errors
  • unused dependencies
  • etc

Unliquidator

MIP 26 vote was passed. We should stop liquidating COMP and stkAave rewards. A contract to claim and send the rewards to the Treasury is specified in https://mips.mstable.org/MIPS/mip-26.html

  • To add test coverage to Unliquidator Smart Contract
  • Deploy the Unliquidator to mainnet
  • Protocol DAO propose new Liquidator module in the Nexus to new Unliquidator contract
  • After a week Protocol DAO accepts new Liquidator module
  • Each integration contract approves the new Unliquidator contract
    • Aave mUSD used by USDT, sUSD and DAI
    • Compound mUSD used by USDC
    • Aave mBTC used by WBTC
    • Aave BUSD Feeder Pool
    • Aave RAI Feeder Pool
  • Execute first claim for each integration contract

Port Nexus contracts from `master` to `master-v2`

Is your feature request related to a problem? Please describe.
Recently this repo was ported from solc 0.5.16 to 0.8.x, and truffle/web3.js to hardhat/ethers.js.

There are a number of contracts that have not yet been migrated, and will be used in future product releases.

Describe the solution you'd like
This issue proposes that the Nexus.sol is ported from master to master-v2. This includes:

  • porting of the solidity file and all dependencies
  • refactoring to bring code in line with solc 0.8 (e.g. removal of SafeMath)
  • porting of relevant test cases to new repo (TestSavingsManager.spec.ts)

Add a StakingRewards contract that wraps existing

Is your feature request related to a problem? Please describe.
It would be good to be able to have double incentives on mStable. Consider the scenario in which Protocol X is incentivising liquidity of a given token Y (through a contract like StakingRewards.sol), and mStable also wish to incentivise this token Y. It would be good to wrap X's rewards contract with a contract Z, to offer both tokens in one.

Describe the solution you'd like
A contract written that forks from the existing StakingRewards.sol, and facilitates the ability to wrap another rewards contract. Each time a user deposits or withdraws (i.e. in updateReward) all tokens that were accrued in the underlying contract would be collected and then factored into the reward distribution.

For example, if 100 tokens were received from X, you would need to then distribute this amount between the participants in Z between now and the time of the previous collection. This would introduce a second layer of accounting in the contract.

Port StakingRewards contracts from `master` to `master-v2`

Is your feature request related to a problem? Please describe.
Recently this repo was ported from solc 0.5.16 to 0.8.x, and truffle/web3.js to hardhat/ethers.js.

There are a number of contracts that have not yet been migrated, and will be used in future product releases.

Describe the solution you'd like
This issue proposes that the StakingRewards.sol is ported from master to master-v2. This includes:

  • porting of the solidity file and all dependencies
  • refactoring to bring code in line with solc 0.8 (e.g. removal of SafeMath)
  • porting of relevant test cases to new repo (TestSavingsManager.spec.ts)

Port RewardsDistributor contracts from `master` to `master-v2`

Is your feature request related to a problem? Please describe.
Recently this repo was ported from solc 0.5.16 to 0.8.x, and truffle/web3.js to hardhat/ethers.js.

There are a number of contracts that have not yet been migrated, and will be used in future product releases.

Describe the solution you'd like
This issue proposes that the RewardsDistributor.sol is ported from master to master-v2. This includes:

  • porting of the solidity file and all dependencies
  • refactoring to bring code in line with solc 0.8 (e.g. removal of SafeMath)
  • porting of relevant test cases to new repo (TestSavingsManager.spec.ts)

How can we help?

How can we help?

I suggest adding issues to the repo for devs that could be interested to help on the project and tag the one that are good for beginners with good first issue

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.