GreenBondV2
Inherits: ERC4626
Author: @sandybradley
ERC4626 Vault on Arbitrum, wth USDT as asset and Aave as passive income lockup. Active income is earned through project payouts, financed by deployed assets. Time weighted asset lockup period of 3-6 months applies to enable the above.
State Variables
ASSET
USDT on arbitrum
ERC20 internal constant ASSET = ERC20(0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9);
AAVE_ASSET
aUSDT on arbitrum
ERC20 public constant AAVE_ASSET = ERC20(0x6ab707Aca953eDAeFBc4fD23bA73294241490620);
POOL
Aave pool on arbitrum (proxy)
IL2Pool public constant POOL = IL2Pool(0x794a61358D6845594F94dc1DB02A252b5b4814aD);
ENCODER
Aave encoder on arbitrum
IL2Encoder public constant ENCODER = IL2Encoder(0x9abADECD08572e0eA5aF4d47A9C7984a5AA503dC);
LOCKUP
Deposit lockup time, default 3 months
uint64 public LOCKUP = 3 * 30 days;
DEPLOYED_ASSETS
Transient tokens deployed to project (~ 6 months lock-up)
uint256 public DEPLOYED_ASSETS;
TOTAL_DEPLOYED_ASSETS
Total assets deployed to projects
uint256 public TOTAL_DEPLOYED_ASSETS;
TOTAL_REPAID_ASSETS
Total assets paid by projects
uint256 public TOTAL_REPAID_ASSETS;
GOV
Governance addresses
mapping(address => bool) public GOV;
depositTimestamps
Time weighted average lockup time per address
mapping(address => uint256) public depositTimestamps;
projectCount
uint256 public projectCount;
projects
mapping(uint256 => Project) public projects;
rewards
mapping(address => uint256) internal rewards;
lastClaimTimestamps
mapping(address => uint256) internal lastClaimTimestamps;
Functions
constructor
constructor() ERC4626(ASSET, "GreenBondV2", "gBOND2");
_govCheck
function _govCheck() internal view;
changeLockup
function changeLockup(uint64 newLockup) external;
addGov
function addGov(address newGov) external;
removeGov
function removeGov(address oldGov) external;
recoverToken
function recoverToken(address token, address receiver, uint256 tokenAmount) external;
registerProject
function registerProject(address projectAdmin, string calldata projectName) external returns (uint256);
linkProjectAgreement
function linkProjectAgreement(uint256 projectId, string calldata masterAgreement) external;
completeProject
function completeProject(uint256 projectId) external;
payProject
function payProject(uint256 assets, uint256 projectId) external;
receiveIncome
function receiveIncome(uint256 assets, uint256 projectId) external;
totalAssets
function totalAssets() public view virtual override returns (uint256);
deposit
function deposit(uint256 assets, address receiver) public virtual override returns (uint256 shares);
mint
function mint(uint256 shares, address receiver) public virtual override returns (uint256 assets);
withdraw
function withdraw(uint256 assets, address receiver, address owner) public virtual override returns (uint256 shares);
redeem
function redeem(uint256 shares, address receiver, address owner) public virtual override returns (uint256 assets);
transfer
function transfer(address to, uint256 amount) public virtual override returns (bool success);
transferFrom
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool success);
beforeWithdraw
function beforeWithdraw(uint256 assets, uint256) internal virtual override;
afterDeposit
function afterDeposit(uint256 assets, uint256) internal virtual override;
_updateDepositTimestamp
function _updateDepositTimestamp(address account, uint256 shares) internal;
_updateTransferTimestamp
function _updateTransferTimestamp(address account, uint256 shares) internal;
Events
GovernorAdded
event GovernorAdded(address newGov);
GovernorRemoved
event GovernorRemoved(address oldGov);
PaidProject
event PaidProject(address admin, uint256 amount, uint256 projectId);
ReceivedIncome
event ReceivedIncome(address indexed sender, uint256 assets, uint256 projectId);
ProjectRegistered
event ProjectRegistered(uint256 indexed project);
Errors
InsufficientAsset
error InsufficientAsset();
InsufficientLiquidity
error InsufficientLiquidity();
InsufficientBalance
error InsufficientBalance();
InsufficientAllowance
error InsufficientAllowance();
UnknownToken
error UnknownToken();
ZeroShares
error ZeroShares();
ZeroAmount
error ZeroAmount();
ZeroAddress
error ZeroAddress();
Overflow
error Overflow();
IdenticalAddresses
error IdenticalAddresses();
InsufficientLockupTime
error InsufficientLockupTime();
Unauthorized
error Unauthorized();
NotProject
error NotProject();
Structs
Project
struct Project {
bool isActive;
bool isCompleted;
address admin;
uint128 totalAssetsSupplied;
uint128 totalAssetsRepaid;
string projectName;
string masterAgreement;
}