Giter Club home page Giter Club logo

amphoraprotocol's Introduction

About:

Built off of Interest Protocol, Convex, Synthetix rewards and custom code, Amphora Protocol is a highly efficient lending market for sUSD that acquires Curve and Convex to enhance voting pairs, and provides new routes for users to use SNX LP tokens for greater liquidity.

This repo is a V0.1 draft, it is incomplete, unaudited and extremely broken. Please don't be dumb enough to try and implement this current code in a fork, as your users will get rekt.

Development bounties are coming soon, but anyone can contribute through opening a pull request. If you have questions, reach out to @adamscochran on Twitter.

setup

to setup the repo first run

npm run setup

then cp SAMPLE.env .env and fill up .env with some values

compile

to compile the contracts, simply run

npm run compile

test

npm run test

To Do:

  • need to be able to add _enabledLPTokens
  • and remove from them
  • check on deposit (force withdraw if mismatch)
  • Check on withdrawal
  • Adjust controller balance manager
  • update vaultSummaries() to include lptokens
  • check that oracle reads virtaul balances correctly
  • check the liquidation math reads virtual balances correctly
  • check the liquidation flow correctly moves virtual balances and deposit tokens
  • Create vesting version of Amphora
  • Set vesting Amphora as the reward
  • Implement onchain treasury
  • Create "fill the amphora" system to bootstrap network
  • Rework reward splitter
  • Create smart contracts for Amphora Locked CRV and Amphora Locked CVX

repository

*
├───test - test suites
│   └───mainnet/* - simulation of deployment and basic user interaction. npx hardhat test test/mainnet/index.ts
│   └───governance/* - simulation of governance processes. npx hardhat test test/governance/index.ts
├───contracts
│   ├───_external - external contracts copied into the repository, e.g. openzeppelin, uniswap, chainlink
│   ├── governance - governance related contracts
│   │   ├── governor - governor is a reimplmentation of Governor Bravo, aptly named Governor Charlie. It uses a custom proxy system
│   │   │   ├── GovernorDelegate.sol - Delegate for governor contract
│   │   │   ├── GovernorDelegator.sol - Delegator for governor contract
│   │   │   ├── GovernorStorage.sol - Storage structs for governor contract
│   │   │   ├── IGovernor.sol - Interface & events for governor contract
│   │   │   ├── IIpt.sol - Helper IIpt interface
│   │   │   └── Structs.sol - Structs shared by governance
│   │   └─ token
│   │       ├── IToken.sol - Interface & events for governance token
│   │       ├── TokenDelegate.sol - Delegate for governance token
│   │       ├── TokenDelegator.sol - Delegator for governance token
│   │       └── TokenStorage.sol - Storage structs for governance token
│   ├── lending - contracts related to the IP lending system
│   │   ├── IVaultController.sol - Interface & events for vault controller
│   │   ├── IVault.sol - Interface & events for vault
│   │   ├── VaultController.sol - Vault controller, master of all vaults. manages interest across all vaults
│   │   └── Vault.sol - individual vault, simply an accounting wallet
│   ├── oracle
│   │   ├── External
│   │   │   ├── ChainlinkOracleRelay.sol - an oracle which hooks to a chainlink oracle
│   │   │   └── UniswapV3OracleRelay.sol - an oracle which hooks to a uniswap v3 pool
│   │   ├── Logic
│   │   │   └── AnchoredViewRelay.sol - an oracle which consumes two oracle relays and constructs an anchored view
│   │   ├── IOracleRelay.sol - generic interface for an oracle relay which can report a price
│   │   ├── IOracleMaster.sol - Interface for the oracle master
│   │   └── OracleMaster.sol - Oracle master is effecitvely an address book of oracle relays
│   ├── rewards
│   │   ├── Booster.sol - the primary rewards engine that controls pools.
│   │   ├── ConvexStaker.sol - the smart contract that manages staking LP pairs into Convex directly.
│   │   ├── ExtraRewardsStashConvex.sol - a rewards stash template that is designed to process Convex rewards.
│   │   ├── RewardsFactory.sol - A factory for generating base reward pools for each staking pool.
│   │   ├── StashFactory.sol - A factory for generating stashes - uses ExtraRewardsStashConvex.sol as template.
│   │   ├── TokenFactory.sol - A factory that generates deposit tokens when depositing into a pool. Deposit tokens are then staked in corresponding base reward pool.
│   │   └── VirtualBalanceRewardPool.sol - A factory that creates virtual balance reward pools that attach to a base reward pool any time there is more than one token reward per pool.
│   ├── token
│   │   └── UFragments.sol - the amplforth ufragments contract
│   ├───IUSDA.sol - interface & events for USDA
│   └───USDA.sol - relabancing erc20 token
└───hardhat.config.ts - configuration for hardhat

amphoraprotocol's People

Contributors

gfxlabs avatar jbarber13 avatar elee1766 avatar openorg-gg avatar soptq avatar shr1ftyy avatar unclegrandpa925 avatar

Stargazers

SeasSaltyFunk avatar Edward Hoang avatar  avatar  avatar n0x avatar Joakim Bakke Hellum avatar

Watchers

Tommy Anderson avatar Joakim Bakke Hellum avatar  avatar  avatar

amphoraprotocol's Issues

Create Locked CRV Implementations [Paid Bounty]

Similar to Convex's cvxCRV, Amphora will support a amphCRV.

For this bounty you should fork Convex's cvxCRV system (the cvxCRV contract, the locking contract, and a voting system) and make some minor modifications:

  • Since Curve's system requires whitelisting before we can vote lock/vote, the contract will need to contain a flag and store the $CRV in the contract until we've been approved.
  • After approval it will need to lock the CRV to allow voting.

Success Criteria:

A successful bounty will include:

  • Delivery of all three elements of the CRV locking implementation
  • The ability to have users deposit CRV and receive amphCRV
  • The ability for the locker contract to hold CRV until our implementation has been approved
  • The ability for the locker contract to lock veCRV after our implementation has been approved
  • The ability to claim rewards from our locked veCRV position and forward them to a treasury contract
  • The ability for the owner to set a treasury contract
  • The ability for an owner OR a vote manager role to vote using the veCRV position
  • Unit tests (written in Hardhat) in the /tests folder. They should cover test cases for both before and after approval.
  • Solidity 0.6.12 or 0.8.4 preferred but not mandatory.
  • Should be well organized into its own folder under /contracts

Candidate Selection:

Preference will be given to Gitcoin candidates who have done similar types of work, and who outline the approach they would take in their application.

Preference is also given to candidates (on Gitcoin or not) who have worked with Amphora in the past.

Bounty Payout:

The payout for a successful implementation is $2k.

https://gitcoin.co/issue/29374

Create a Vesting Redemption Contract [Paid Bounty]

The goal of this bounty is to create a vesting system.

In the Amphora protocol, our main governance token is $AMPH, but when users receive rewards they are received in $vAMPH (Vesting Amphora) which is a standard ERC-20 mintable/burnable token with no additional special features.

Users will use a specialty vesting contract to vest and unlock the $vAMPH.

When a user creates a new vesting position, the contract will take their $AMPH and they will be able to choose between:

  • An instant unlock that pays out 0.25 $AMPH per $vAMPH
  • Up to a 4 year unlock that pays out 1.12 $AMPH per $vAMPH

A user can decide to select any amount of time within that time frame, the contract should mint the total amount of tokens and store it in the contract at the start. The should be able to claim their vested amount each day. The amounts in between those two options should be on a curve so that vesting longer is always significantly more favorable and not just a linear function.

When a user has additional $vAMPH to vest then the contract will either need to:

  • A) Figure out how to adjust the end date and tokens to claim per day, so the users new vest is properly factored in.
  • B) Or, create a new vesting streaming.

If option B (which is likely safer) then it should also:

  • Have a function to look up all streams
  • Have a function to claim from all streams at once.

If you choose to implement with multiple streams you can choose the structure you think is best, either multiple streams defined by a mapping, or an array, or even different contracts deployed via a factory.

Elements of a Successful Bounty:

  • A vesting contract that accepts token X
  • Lets a user pick a day between A and B and creates a vesting stream of claimable tokens
  • Users can easily see their total vesting tokens and tokens available to claim from each position with viewable functions
  • Users can easily see the final vesting date of each stream
  • You've written detailed test coverage (in Hardhat) that fits into /AmphoraProtocol/tests and tests each element of the vesting contract
  • The contract owner should be allowed to pause/halt the creation of new vesting streams.
  • Implementation is preferred in Solidity 0.6.12 or Solidity 0.8.9 so it aligns with other contracts in the repo.
  • If using Solidity 0.6.12 please ensure to use the appropriate safemath libraries from the repo.

Candidate Selection:

Preference will be given to Gitcoin candidates who have done similar types of work, and who outline the approach they would take in their application.

Preference is also given to candidates (on Gitcoin or not) who have worked with Amphora in the past.

Bounty Payout:

The payout for this bounty is $3k in USDC.

https://gitcoin.co/issue/29373

Creating locked amphCVX contract [Paid Bounty]

Similar to Convex's cvxCRV, Amphora will support a amphCVX

For this bounty you should create a contract that can

  • Accept CVX from a user and return minted amphCVX.
  • Lock the CVX balance as vlCVX in Convex.
  • Claim rewards from the Convex contracts for vlCVX and send them to an address called 'RewardSplitter'
  • Delegate vlCVX voting power to an address defined by contract owner.
  • Let the owner change the RewardSplitter.

Success Criteria:

A successful bounty will include:

  • Delivery of the contract with features outlined above.
  • Unit tests (written in Hardhat) in the /tests folder. They should cover test cases for both before and after approval.
  • Solidity 0.6.12 or 0.8.4 preferred but not mandatory.
  • Should be well organized into its own folder under /contracts

Candidate Selection:

Preference will be given to Gitcoin candidates who have done similar types of work, and who outline the approach they would take in their application.

Preference is also given to candidates (on Gitcoin or not) who have worked with Amphora in the past.

Bounty Payout:

The payout for a successful implementation is $2k.

https://gitcoin.co/issue/29375

Combine Booster and Vault Controller Logic

We want to combine some of the Booster and Vault Controller logic to make a cleaner integration.

The goal for user experience:

  • User goes to our site, and sees a list of assets they can deposit. These are both regular ERC20 tokens and LP tokens.
  • The user hits deposit, and the asset goes into their vault.
  • If the asset is an LP token the user sees rewards growing in their vault and can hit a 'claim' button to claim those rewards.

Current issues:

  • To start vaults only counted a users collateral balance using ERC-20 tokens in the address. We updated this to include LP tokens by adding a balance tracker, this way LP tokens can count as collateral AND be deposited into BaseRewardPools.
    -- But, this means we've got to have two different functions to support depositing ERC-20 and LP tokens, and it is messy.
  • The current Booster logic is sloppy and challenging to maintain.

Ideal:

  • Vault Controller contains a mapping of supported tokens (ERC-20 and LP tokens)

  • Each token now has a "wrapping" address, a contract which will wrap the token and apply any needed logic.

  • Each token will have a reward pool (like the kind in the booster) generated for it when it is added to the system.

  • Vault Controller contains a mapping of tokens -> a token wrapping contract

  • Vault Controller contains a struct mapping of reward pools.

  • Vault Controller has one deposit function.

  • The deposit function checks if a token is supported, if it is, it then checks if it is an LP token (such as $3CRV).

  • If it is an LP token, the token is sent to a wrapping contract. The wrapping contract deposits the $3CRV into Convex. It then deposits a $w3CRV into the users vault, and a $3CRVdepositToken into the BaseRewardPool on behalf of the vault address.

  • If it is not an LP token, it should be sent to the wrapping contract. The wrapping contract will just hold the token. It then deposits a $wX token into the users vault, and a $XdepositToken into the BaseRewardPool on behalf of the vault address.

  • The users collateral is calculated by reading the wrapped tokens + any regular ERC-20 tokens. So Oracles will need to map both.

  • When a wrapped token is liquidated, the depositToken will need to be withdrawn from the reward pool, then the token will need to be unwrapped and the underlying ERC-20 token will be sent to the liquidator.

Review and Write Tests for USDA [Paid Bounty]

The file /contracts/USDA.sol is based on "USDI" from Interest Protocol, but the contract has been changed to include a fee on transfer mechanism through its inherited contract in /contracts/token/UFragments.sol

For this bounty, you should:

  1. Review the changes to the contract.
  2. Make any suggestions on improving efficiency or code.
  3. Identity and propose a solution to issues.
  4. Write a series to cases to test the new features.

The tests should cover:

  • Standard transfers
  • Deposits and withdraws from a Curve pool
  • Deposits and withdraws from a Uniswap V2 pool
  • Exchanges with a Curve pool
  • Exchanges with a Uniswap pool
  • That all update functions have correct permissions
  • That all update functions are working

Tests should be written in Hardhat and be added into the testing set up on this repo.

Bounty Payout:

This bounty will pay out $500 in USDC

https://gitcoin.co/issue/29376

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.