Skip to content

Commit

Permalink
Initial rename finished, compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchimedesCrypto committed May 9, 2022
1 parent 2d00038 commit 8dd66ce
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 86 deletions.
2 changes: 1 addition & 1 deletion contracts/bonds-v2/BondDepository.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract KlimaBondDepositoryV2 is IBondDepository, NoteKeeper {
/* ======== CONSTRUCTOR ======== */

constructor(
IOlympusAuthority _authority,
IKlimaAuthority _authority,
IERC20 _klima,
IwsKLIMA _wsklima,
IStaking _staking,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.7.5;

import "./interfaces/IOlympusAuthority.sol";
import "./interfaces/IKlimaAuthority.sol";

import "./types/OlympusAccessControlled.sol";
import "./types/KlimaAccessControlled.sol";

contract OlympusAuthority is IOlympusAuthority, OlympusAccessControlled {
contract KlimaAuthority is IKlimaAuthority, KlimaAccessControlled {
/* ========== STATE VARIABLES ========== */

address public override governor;
Expand All @@ -31,7 +31,7 @@ contract OlympusAuthority is IOlympusAuthority, OlympusAccessControlled {
address _guardian,
address _policy,
address _vault
) OlympusAccessControlled(IOlympusAuthority(address(this))) {
) KlimaAccessControlled(IKlimaAuthority(address(this))) {
governor = _governor;
emit GovernorPushed(address(0), governor, true);
guardian = _guardian;
Expand Down
4 changes: 2 additions & 2 deletions contracts/bonds-v2/interfaces/IAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.0;
// interfaces
import "./IERC20.sol";
import "./ITreasuryExtender.sol";
import "./IOlympusAuthority.sol";
import "./IKlimaAuthority.sol";

enum AllocatorStatus {
OFFLINE,
Expand All @@ -12,7 +12,7 @@ enum AllocatorStatus {
}

struct AllocatorInitData {
IOlympusAuthority authority;
IKlimaAuthority authority;
ITreasuryExtender extender;
IERC20[] tokens;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.7.5;

interface IOlympusAuthority {
interface IKlimaAuthority {
/* ========== EVENTS ========== */

event GovernorPushed(address indexed from, address indexed to, bool _effectiveImmediately);
Expand Down
4 changes: 2 additions & 2 deletions contracts/bonds-v2/interfaces/INoteKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ interface INoteKeeper {
function redeem(
address _user,
uint256[] memory _indexes,
bool _sendgOHM
bool _sendwsKLIMA
) external returns (uint256);

function redeemAll(address _user, bool _sendgOHM) external returns (uint256);
function redeemAll(address _user, bool _sendwsKLIMA) external returns (uint256);

function pushNote(address to, uint256 index) external;

Expand Down
8 changes: 4 additions & 4 deletions contracts/bonds-v2/types/BaseAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../interfaces/IAllocator.sol";
import "../interfaces/ITreasury.sol";

// types
import "../types/OlympusAccessControlledV2.sol";
import "../types/KlimaAccessControlledV2.sol";

// libraries
import "../libraries/SafeERC20.sol";
Expand All @@ -19,7 +19,7 @@ error BaseAllocator_OnlyExtender(address sender);
/**
* @title BaseAllocator
* @notice
* This abstract contract serves as a template for writing new Olympus Allocators.
* This abstract contract serves as a template for writing new Klima Allocators.
* Many of the functionalities regarding handling of Treasury funds by the Guardian have
* been delegated to the `TreasuryExtender` contract, and thus an explanation for them can be found
* in `TreasuryExtender.sol`.
Expand Down Expand Up @@ -69,7 +69,7 @@ error BaseAllocator_OnlyExtender(address sender);
*
* This was a short summary of the Allocator lifecycle.
*/
abstract contract BaseAllocator is OlympusAccessControlledV2, IAllocator {
abstract contract BaseAllocator is KlimaAccessControlledV2, IAllocator {
using SafeERC20 for IERC20;

// Indices which represent the ids of the deposits in the `TreasuryExtender`
Expand All @@ -87,7 +87,7 @@ abstract contract BaseAllocator is OlympusAccessControlledV2, IAllocator {
// The extender with which the Allocator communicates.
ITreasuryExtender public immutable extender;

constructor(AllocatorInitData memory data) OlympusAccessControlledV2(data.authority) {
constructor(AllocatorInitData memory data) KlimaAccessControlledV2(data.authority) {
_tokens = data.tokens;
extender = data.extender;

Expand Down
6 changes: 3 additions & 3 deletions contracts/bonds-v2/types/FrontEndRewarder.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.10;

import "../types/OlympusAccessControlled.sol";
import "../types/KlimaAccessControlled.sol";
import "../interfaces/IERC20.sol";

abstract contract FrontEndRewarder is OlympusAccessControlled {
abstract contract FrontEndRewarder is KlimaAccessControlled {
/* ========= STATE VARIABLES ========== */

uint256 public daoReward; // % reward for dao (3 decimals: 100 = 1%)
Expand All @@ -14,7 +14,7 @@ abstract contract FrontEndRewarder is OlympusAccessControlled {

IERC20 internal immutable klima; // reward token

constructor(IOlympusAuthority _authority, IERC20 _klima) OlympusAccessControlled(_authority) {
constructor(IKlimaAuthority _authority, IERC20 _klima) KlimaAccessControlled(_authority) {
klima = _klima;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.7.5;

import "../interfaces/IOlympusAuthority.sol";
import "../interfaces/IKlimaAuthority.sol";

abstract contract OlympusAccessControlled {
abstract contract KlimaAccessControlled {
/* ========== EVENTS ========== */

event AuthorityUpdated(IOlympusAuthority indexed authority);
event AuthorityUpdated(IKlimaAuthority indexed authority);

string UNAUTHORIZED = "UNAUTHORIZED"; // save gas

/* ========== STATE VARIABLES ========== */

IOlympusAuthority public authority;
IKlimaAuthority public authority;

/* ========== Constructor ========== */

constructor(IOlympusAuthority _authority) {
constructor(IKlimaAuthority _authority) {
authority = _authority;
emit AuthorityUpdated(_authority);
}
Expand Down Expand Up @@ -45,7 +45,7 @@ abstract contract OlympusAccessControlled {

/* ========== GOV ONLY ========== */

function setAuthority(IOlympusAuthority _newAuthority) external onlyGovernor {
function setAuthority(IKlimaAuthority _newAuthority) external onlyGovernor {
authority = _newAuthority;
emit AuthorityUpdated(_newAuthority);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.8.10;

import "../interfaces/IOlympusAuthority.sol";
import "../interfaces/IKlimaAuthority.sol";

error UNAUTHORIZED();
error AUTHORITY_INITIALIZED();
Expand All @@ -9,18 +9,18 @@ error AUTHORITY_INITIALIZED();
/// instead of pointing towards the logic to execute. Over many
/// functions this bloats contract size unnecessarily.
/// imho modifiers are a meme.
abstract contract OlympusAccessControlledV2 {
abstract contract KlimaAccessControlledV2 {
/* ========== EVENTS ========== */

event AuthorityUpdated(IOlympusAuthority authority);
event AuthorityUpdated(IKlimaAuthority authority);

/* ========== STATE VARIABLES ========== */

IOlympusAuthority public authority;
IKlimaAuthority public authority;

/* ========== Constructor ========== */

constructor(IOlympusAuthority _authority) {
constructor(IKlimaAuthority _authority) {
authority = _authority;
emit AuthorityUpdated(_authority);
}
Expand Down Expand Up @@ -49,13 +49,13 @@ abstract contract OlympusAccessControlledV2 {

/* ========== GOV ONLY ========== */

function initializeAuthority(IOlympusAuthority _newAuthority) internal {
if (authority != IOlympusAuthority(address(0))) revert AUTHORITY_INITIALIZED();
function initializeAuthority(IKlimaAuthority _newAuthority) internal {
if (authority != IKlimaAuthority(address(0))) revert AUTHORITY_INITIALIZED();
authority = _newAuthority;
emit AuthorityUpdated(_newAuthority);
}

function setAuthority(IOlympusAuthority _newAuthority) external {
function setAuthority(IKlimaAuthority _newAuthority) external {
_onlyGovernor();
authority = _newAuthority;
emit AuthorityUpdated(_newAuthority);
Expand Down
43 changes: 22 additions & 21 deletions contracts/bonds-v2/types/NoteKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.10;

import "../types/FrontEndRewarder.sol";

import "../interfaces/IgOHM.sol";
import "../interfaces/IStaking.sol";
import "../interfaces/ITreasury.sol";
import "../interfaces/INoteKeeper.sol";
Expand All @@ -13,20 +12,22 @@ abstract contract NoteKeeper is INoteKeeper, FrontEndRewarder {
mapping(address => Note[]) public notes; // user deposit data
mapping(address => mapping(uint256 => address)) private noteTransfers; // change note ownership

IwsKLIMA internal immutable gOHM;
IwsKLIMA internal immutable wsKLIMA;
IStaking internal immutable staking;
ITreasury internal treasury;

constructor(
IOlympusAuthority _authority,
IERC20 _ohm,
IwsKLIMA _gohm,
IKlimaAuthority _authority,
IERC20 _klima,
IwsKLIMA _wsklima,
IStaking _staking,
ITreasury _treasury
) FrontEndRewarder(_authority, _ohm) {
gOHM = _gohm;
) FrontEndRewarder(_authority, _klima) {

wsKLIMA = _wsklima;
staking = _staking;
treasury = _treasury;

}

// if treasury address changes on authority, update it
Expand All @@ -45,7 +46,7 @@ abstract contract NoteKeeper is INoteKeeper, FrontEndRewarder {
/**
* @notice adds a new Note for a user, stores the front end & DAO rewards, and mints & stakes payout & rewards
* @param _user the user that owns the Note
* @param _payout the amount of OHM due to the user
* @param _payout the amount of KLIMA due to the user
* @param _expiry the timestamp when the Note is redeemable
* @param _marketID the ID of the market deposited into
* @return index_ the index of the Note in the user's array
Expand All @@ -63,7 +64,7 @@ abstract contract NoteKeeper is INoteKeeper, FrontEndRewarder {
// the new note is pushed to the user's array
notes[_user].push(
Note({
payout: gOHM.sKLIMATowKLIMA(_payout),
payout: wsKLIMA.sKLIMATowKLIMA(_payout),
created: uint48(block.timestamp),
matured: _expiry,
redeemed: 0,
Expand All @@ -77,7 +78,7 @@ abstract contract NoteKeeper is INoteKeeper, FrontEndRewarder {
// mint and stake payout
treasury.mint(address(this), _payout + rewards);

// note that only the payout gets staked (front end rewards are in OHM)
// note that only the payout gets staked (front end rewards are in KLIMA)
staking.stake(address(this), _payout, false, true);
}

Expand All @@ -87,13 +88,13 @@ abstract contract NoteKeeper is INoteKeeper, FrontEndRewarder {
* @notice redeem notes for user
* @param _user the user to redeem for
* @param _indexes the note indexes to redeem
* @param _sendgOHM send payout as gOHM or sOHM
* @return payout_ sum of payout sent, in gOHM
* @param _sendwsKLIMA send payout as wsKLIMA or sKLIMA
* @return payout_ sum of payout sent, in wsKLIMA
*/
function redeem(
address _user,
uint256[] memory _indexes,
bool _sendgOHM
bool _sendwsKLIMA
) public override returns (uint256 payout_) {
uint48 time = uint48(block.timestamp);

Expand All @@ -106,22 +107,22 @@ abstract contract NoteKeeper is INoteKeeper, FrontEndRewarder {
}
}

if (_sendgOHM) {
gOHM.transfer(_user, payout_); // send payout as gOHM
if (_sendwsKLIMA) {
wsKLIMA.transfer(_user, payout_); // send payout as wsKLIMA
} else {
staking.unwrap(_user, payout_); // unwrap and send payout as sOHM
staking.unwrap(_user, payout_); // unwrap and send payout as sKLIMA
}
}

/**
* @notice redeem all redeemable markets for user
* @dev if possible, query indexesFor() off-chain and input in redeem() to save gas
* @param _user user to redeem all notes for
* @param _sendgOHM send payout as gOHM or sOHM
* @return sum of payout sent, in gOHM
* @param _sendwsKLIMA send payout as wsKLIMA or sKLIMA
* @return sum of payout sent, in wsKLIMA
*/
function redeemAll(address _user, bool _sendgOHM) external override returns (uint256) {
return redeem(_user, indexesFor(_user), _sendgOHM);
function redeemAll(address _user, bool _sendwsKLIMA) external override returns (uint256) {
return redeem(_user, indexesFor(_user), _sendwsKLIMA);
}

/* ========== TRANSFER ========== */
Expand Down Expand Up @@ -185,7 +186,7 @@ abstract contract NoteKeeper is INoteKeeper, FrontEndRewarder {
* @notice calculate amount available for claim for a single note
* @param _user the user that the note belongs to
* @param _index the index of the note in the user's array
* @return payout_ the payout due, in gOHM
* @return payout_ the payout due, in wsKLIMA
* @return matured_ if the payout can be redeemed
*/
function pendingFor(address _user, uint256 _index) public view override returns (uint256 payout_, bool matured_) {
Expand Down
Loading

0 comments on commit 8dd66ce

Please sign in to comment.