Skip to content

Citadel-DAO/citadel-protocol

Repository files navigation

CitadelDAO contracts

Forked from https://github.com/OlympusDAO/olympus-contracts

🔧 Setting up Local Development

Required:

Environment Variables:

  • INFURA_API_KEY: The Infura project key to fork with

Local Setup Steps:

  1. git clone https://github.com/Citadel-DAO/citadel-protocol.git
  2. Install dependencies: yarn
  3. Compile Solidity: yarn compile
  4. Set environment variables. See above section on required env variables.
  5. Run Deployment Script: yarn hardhat deploy

Allocator Guide

The following is a guide for interacting with the treasury as a reserve allocator.

A reserve allocator is a contract that deploys funds into external strategies, such as Aave, Curve, etc.

Treasury Address: 0x31F8Cc382c9898b273eff4e0b7626a6987C846E8

Managing: The first step is withdraw funds from the treasury via the "manage" function. "Manage" allows an approved address to withdraw excess reserves from the treasury.

Note: This contract must have the "reserve manager" permission, and that withdrawn reserves decrease the treasury's ability to mint new OHM (since backing has been removed).

Pass in the token address and the amount to manage. The token will be sent to the contract calling the function.

function manage( address _token, uint _amount ) external;

Managing treasury assets should look something like this:

treasury.manage( DAI, amountToManage );

Returning: The second step is to return funds after the strategy has been closed. We utilize the deposit function to do this. Deposit allows an approved contract to deposit reserve assets into the treasury, and mint OHM against them. In this case however, we will NOT mint any OHM. This will be explained shortly.

Note The contract must have the "reserve depositor" permission, and that deposited reserves increase the treasury's ability to mint new OHM (since backing has been added).

Pass in the address sending the funds (most likely the allocator contract), the amount to deposit, and the address of the token. The final parameter, profit, dictates how much OHM to send. send_, the amount of OHM to send, equals the value of amount minus profit.

function deposit( address _from, uint _amount, address _token, uint _profit ) external returns ( uint send_ );

To ensure no OHM is minted, we first get the value of the asset, and pass that in as profit. Pass in the token address and amount to get the treasury value.

function tokenValue( address _token, uint _amount ) public view returns ( uint value_ );

All together, returning funds should look something like this:

treasury.deposit( amountToReturn, wBTC, treasury.tokenValue( wBTC, amountToReturn ) );

About

DEPRECATED: see https://github.com/Citadel-DAO/citadel-contracts for new project location

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors