Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@ You can enable the "hot deploy" mode when doing fork testing development. The mo
To enable Hot Deploys set the HOT_DEPLOY variable in the contracts/.env file. Enable various modes using comma separated flags to direct which contracts need source updated (in the node runtime):

- strategy -> strategy contract associated to fixture
- vaultCore -> vaultCore or oethVaultCore depending on the nature of the fixture
- vaultAdmin -> vaultAdmin or oethVaultAdmin depending on the nature of the fixture
- vault -> OUSDVault or OETHVault depending on the nature of the fixture
- harvester -> harvester or oethHarvester (not yet supported)

example: HOT_DEPLOY=strategy,vaultCore,vaultAdmin,harvester
example: HOT_DEPLOY=strategy,vault,harvester

#### Supporting new fixtures / contracts

Expand Down
4 changes: 0 additions & 4 deletions contracts/contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ interface IVault {

function governor() external view returns (address);

function ADMIN_IMPLEMENTATION() external view returns (address);

// VaultAdmin.sol
function setVaultBuffer(uint256 _vaultBuffer) external;

Expand Down Expand Up @@ -167,8 +165,6 @@ interface IVault {

function initialize(address) external;

function setAdminImpl(address) external;

function addWithdrawalQueueLiquidity() external;

function requestWithdrawal(uint256 _amount)
Expand Down
6 changes: 3 additions & 3 deletions contracts/contracts/mocks/MockOETHVault.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { OETHVaultCore } from "../vault/OETHVaultCore.sol";
import { OETHVault } from "../vault/OETHVault.sol";
import { StableMath } from "../utils/StableMath.sol";
import "../utils/Helpers.sol";

contract MockOETHVault is OETHVaultCore {
contract MockOETHVault is OETHVault {
using StableMath for uint256;

constructor(address _weth) OETHVaultCore(_weth) {
constructor(address _weth) OETHVault(_weth) {
_setGovernor(msg.sender);
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/contracts/mocks/MockOETHVaultAdmin.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { OETHVaultAdmin } from "../vault/OETHVaultAdmin.sol";
import { OETHVault } from "../vault/OETHVault.sol";

contract MockOETHVaultAdmin is OETHVaultAdmin {
constructor(address _weth) OETHVaultAdmin(_weth) {}
contract MockOETHVault is OETHVault {
constructor(address _weth) OETHVault(_weth) {}

// fetches the WETH amount in outstanding withdrawals
function outstandingWithdrawalsAmount()
Expand Down
10 changes: 3 additions & 7 deletions contracts/contracts/mocks/MockVault.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { VaultCore } from "../vault/VaultCore.sol";
import { VaultAdmin } from "../vault/VaultAdmin.sol";
import { StableMath } from "../utils/StableMath.sol";
import "../utils/Helpers.sol";

contract MockVault is VaultCore {
contract MockVault is VaultAdmin {
using StableMath for uint256;

uint256 storedTotalValue;

constructor(address _asset) VaultCore(_asset) {}
constructor(address _asset) VaultAdmin(_asset) {}

function setTotalValue(uint256 _value) public {
storedTotalValue = _value;
Expand Down Expand Up @@ -39,8 +39,4 @@ contract MockVault is VaultCore {
return 0;
}
}

function setMaxSupplyDiff(uint256 _maxSupplyDiff) external onlyGovernor {
maxSupplyDiff = _maxSupplyDiff;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { VaultAdmin } from "./VaultAdmin.sol";
* @title OETH Base VaultAdmin Contract
* @author Origin Protocol Inc
*/
contract OETHBaseVaultAdmin is VaultAdmin {
contract OETHBaseVault is VaultAdmin {
constructor(address _weth) VaultAdmin(_weth) {}
}
12 changes: 0 additions & 12 deletions contracts/contracts/vault/OETHBaseVaultCore.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { VaultCore } from "./VaultCore.sol";
import { VaultAdmin } from "./VaultAdmin.sol";

/**
* @title OETH Plume VaultCore Contract
* @title OETH Plume VaultAdmin Contract
* @author Origin Protocol Inc
*/
contract OETHPlumeVaultCore is VaultCore {
constructor(address _weth) VaultCore(_weth) {}
contract OETHPlumeVault is VaultAdmin {
constructor(address _weth) VaultAdmin(_weth) {}

// @inheritdoc VaultCore
// @inheritdoc VaultAdmin
function _mint(
address,
uint256 _amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { VaultAdmin } from "./VaultAdmin.sol";
* @title OETH VaultAdmin Contract
* @author Origin Protocol Inc
*/
contract OETHVaultAdmin is VaultAdmin {
contract OETHVault is VaultAdmin {
constructor(address _weth) VaultAdmin(_weth) {}
}
12 changes: 0 additions & 12 deletions contracts/contracts/vault/OETHVaultCore.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { VaultAdmin } from "./VaultAdmin.sol";
* @title Origin Sonic VaultAdmin contract on Sonic
* @author Origin Protocol Inc
*/
contract OSonicVaultAdmin is VaultAdmin {
contract OSVault is VaultAdmin {
constructor(address _wS) VaultAdmin(_wS) {}
}
12 changes: 12 additions & 0 deletions contracts/contracts/vault/OSonicVault.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { VaultAdmin } from "./VaultAdmin.sol";

/**
* @title Origin Sonic VaultAdmin contract on Sonic
* @author Origin Protocol Inc
*/
contract OSonicVault is VaultAdmin {
constructor(address _wS) VaultAdmin(_wS) {}
}
13 changes: 0 additions & 13 deletions contracts/contracts/vault/OSonicVaultCore.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { VaultAdmin } from "./VaultAdmin.sol";
* @title OUSD VaultAdmin Contract
* @author Origin Protocol Inc
*/
contract OUSDVaultAdmin is VaultAdmin {
contract OUSDVault is VaultAdmin {
constructor(address _usdc) VaultAdmin(_usdc) {}
}
12 changes: 0 additions & 12 deletions contracts/contracts/vault/OUSDVaultCore.sol

This file was deleted.

54 changes: 4 additions & 50 deletions contracts/contracts/vault/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,14 @@

## Hierarchy

![Vault Core Hierarchy](../../docs/VaultHierarchy.svg)
![Vault Hierarchy](../../docs/VaultHierarchy.svg)

## OUSD Vault
## Vault

## Vault Core Squashed
## Vault Squashed

![Vault Core Squashed](../../docs/VaultCoreSquashed.svg)
![Vault Squashed](../../docs/VaultSquashed.svg)

### Storage

![Vault Storage](../../docs/VaultStorage.svg)

## Vault Admin Squashed

![Vault Admin Squashed](../../docs/VaultAdminSquashed.svg)

## OETH Vault

## Vault Core Squashed

![OETH Vault Core Squashed](../../docs/OETHVaultCoreSquashed.svg)

## Vault Admin Squashed

![OETH Vault Admin Squashed](../../docs/OETHVaultAdminSquashed.svg)

### Storage

![OETH Vault Storage](../../docs/OETHVaultStorage.svg)

## Base OETH Vault

## Vault Core Squashed

![OETH Vault Core Squashed](../../docs/OETHBaseVaultCoreSquashed.svg)

## Vault Admin Squashed

![OETH Vault Admin Squashed](../../docs/OETHBaseVaultAdminSquashed.svg)

### Storage

![OETH Vault Storage](../../docs/OETHBaseVaultStorage.svg)

## Origin Sonic (OS) Vault

## Vault Core Squashed

![Sonic Vault Core Squashed](../../docs/OSonicVaultCoreSquashed.svg)

## Vault Admin Squashed

![Sonic Vault Admin Squashed](../../docs/OSonicVaultAdminSquashed.svg)

### Storage

![Sonic Vault Storage](../../docs/OSonicVaultStorage.svg)
27 changes: 3 additions & 24 deletions contracts/contracts/vault/VaultAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { IVault } from "../interfaces/IVault.sol";
import { StableMath } from "../utils/StableMath.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";

import "./VaultStorage.sol";
import "./VaultCore.sol";

abstract contract VaultAdmin is VaultStorage {
abstract contract VaultAdmin is VaultCore {
using SafeERC20 for IERC20;
using StableMath for uint256;
using SafeCast for uint256;
Expand All @@ -31,7 +31,7 @@ abstract contract VaultAdmin is VaultStorage {
_;
}

constructor(address _asset) VaultStorage(_asset) {}
constructor(address _asset) VaultCore(_asset) {}

/***************************************
Configuration
Expand Down Expand Up @@ -415,27 +415,6 @@ abstract contract VaultAdmin is VaultStorage {
IERC20(_asset).safeTransfer(governor(), _amount);
}

/**
* @dev Calculate how much asset (eg. WETH or USDC) in the vault is not reserved for the withdrawal queue.
* That is, it is available to be redeemed or deposited into a strategy.
*/
function _assetAvailable() internal view returns (uint256 assetAvailable) {
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;

// The amount of asset that is still to be claimed in the withdrawal queue
uint256 outstandingWithdrawals = queue.queued - queue.claimed;

// The amount of sitting in asset in the vault
uint256 assetBalance = IERC20(asset).balanceOf(address(this));

// If there is not enough asset in the vault to cover the outstanding withdrawals
if (assetBalance <= outstandingWithdrawals) {
return 0;
}

return assetBalance - outstandingWithdrawals;
}

/***************************************
Strategies Admin
****************************************/
Expand Down
47 changes: 0 additions & 47 deletions contracts/contracts/vault/VaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -736,53 +736,6 @@ abstract contract VaultCore is VaultInitializer {
return asset == _asset;
}

function ADMIN_IMPLEMENTATION() external view returns (address adminImpl) {
bytes32 slot = adminImplPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
adminImpl := sload(slot)
}
}

/**
* @dev Falldown to the admin implementation
* @notice This is a catch all for all functions not declared in core
*/
// solhint-disable-next-line no-complex-fallback
fallback() external {
bytes32 slot = adminImplPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())

// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(
gas(),
sload(slot),
0,
calldatasize(),
0,
0
)

// Copy the returned data.
returndatacopy(0, 0, returndatasize())

switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}

function _min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
Expand Down
Loading
Loading