Skip to content
Open
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
10 changes: 10 additions & 0 deletions contracts/mocks/common/PoolEtherRejecterMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import "../generic/PoolGeneric.sol";

contract PoolEtherRejecterMock is PoolGeneric {

uint internal mcrValue = 1 ether;

function getPoolValueInEth() public override virtual view returns (uint) {
return address(this).balance;
}

function getMCR() public override virtual view returns (uint) {
return mcrValue;
}

receive() external payable override {
revert("I secretly hate ether");
}
Expand Down
13 changes: 13 additions & 0 deletions contracts/mocks/common/PoolMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contract PoolMock is PoolGeneric {

Asset[] public assets;
mapping (uint => uint) internal prices;
uint internal mcrValue;

uint public constant MCR_RATIO_DECIMALS = 4;
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
Expand Down Expand Up @@ -118,4 +119,16 @@ contract PoolMock is PoolGeneric {
return prices[0];
}

function getMCR() public override virtual view returns (uint) {
return mcrValue;
}

function setMCR(uint _mcrValue) public {
mcrValue = _mcrValue;
}

function updateMCRInternal(bool /* forceUpdate */) external override {
// noop - required for Ramm.swap
}

}
6 changes: 3 additions & 3 deletions contracts/mocks/common/ReentrancyExploiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.18;

contract ReentrancyExploiter {

// re-entrancy attack params
address public target;
uint public value;
Expand Down Expand Up @@ -34,9 +34,9 @@ contract ReentrancyExploiter {
(bool ok, bytes memory returndata) = _target.call{value: _value}(_data);

if (!ok) {
// pass revert reason
// pass revert reason and bubble it up if present
if (returndata.length > 0) {
assembly {
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
Expand Down
28 changes: 0 additions & 28 deletions contracts/mocks/modules/Assessment/ASMockMemberRoles.sol

This file was deleted.

22 changes: 0 additions & 22 deletions contracts/mocks/modules/Ramm/RAMockMemberRoles.sol

This file was deleted.

4 changes: 2 additions & 2 deletions hardhat-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ const config = {
},

mocha: {
bail: false,
bail: process.env.BAIL === 'true',
exit: true,
jobs: Number(process.env.MOCHA_JOBS) || undefined,
parallel: true,
slow: 5000,
timeout: 0,
timeout: Number(process.env.TIMEOUT || 30000),
},

networks: require('./networks'),
Expand Down
2 changes: 0 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ const constants = require('./constants');
const helpers = require('./helpers');
const multicall = require('./multicall');
const protocol = require('./protocol');
const pool = require('./pool');
const signing = require('./signing');

const nexus = {
awsKms,
constants,
helpers,
multicall,
pool,
protocol,
signing,
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"dev": "nodemon --ext js,sol -x hardhat test test/unit test/integration test/layout --show-stack-traces",
"dev-integration": "nodemon --ext js,sol -x hardhat test test/integration --show-stack-traces",
"dev-unit": "nodemon --ext js,sol -x hardhat test test/unit --show-stack-traces",
"coverage": "NODE_OPTIONS='--max-old-space-size=8192' hardhat coverage --testfiles 'test/{unit,integration}/**/*.js'",
"coverage": "MOCHA_JOBS=1 NODE_OPTIONS='--max-old-space-size=8192' hardhat coverage --testfiles 'test/{unit,integration}/**/*.js'",
"test": "hardhat test test/unit test/integration test/layout",
"test-integration": "hardhat test test/integration",
"test-unit": "hardhat test test/unit",
Expand Down
3 changes: 1 addition & 2 deletions test/integration/Pool/mcr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ const { expect } = require('chai');
const { loadFixture, time } = require('@nomicfoundation/hardhat-network-helpers');

const setup = require('../setup');
const { createCover, daysToSeconds } = require('../utils');
const { createCover, daysToSeconds, setMCR, calculateCurrentMCR } = require('../utils');

const { parseEther, parseUnits } = ethers;
const { PoolAsset, PauseTypes } = nexus.constants;
const { setMCR, calculateCurrentMCR } = nexus.pool;
const { BigIntMath } = nexus.helpers;

const ONE_NXM = parseEther('1');
Expand Down
2 changes: 2 additions & 0 deletions test/integration/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const helpers = require('./helpers');
const cover = require('./cover');
const ramm = require('./ramm');
const pool = require('../../utils/pool');

module.exports = {
...helpers,
...cover,
...ramm,
...pool,
};
3 changes: 1 addition & 2 deletions test/unit/Pool/calculateCurrentMCR.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const { expect } = require('chai');
const { nexus } = require('hardhat');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');

const setup = require('./setup');
const { calculateCurrentMCR } = nexus.pool;
const { calculateCurrentMCR } = require('../utils');

const stored = 12348870328212262601890n;
const desired = 10922706197119349905840n;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Pool/getMCRRatio.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { ethers } = require('hardhat');
const { expect } = require('chai');
const { nexus, ethers } = require('hardhat');
const { loadFixture, setBalance } = require('@nomicfoundation/hardhat-network-helpers');

const setup = require('./setup');
const { setNextBlockTime } = require('../../utils/evm');
const { calculateCurrentMCR } = nexus.pool;
const { calculateCurrentMCR } = require('../utils');
const { parseEther } = ethers;

const stored = 12348870328212262601890n;
Expand Down
5 changes: 2 additions & 3 deletions test/unit/Pool/updateMCR.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { expect } = require('chai');
const { nexus, ethers } = require('hardhat');
const { ethers } = require('hardhat');
const { loadFixture, impersonateAccount, setBalance } = require('@nomicfoundation/hardhat-network-helpers');

const setup = require('./setup');
const { setNextBlockTime } = require('../../utils/evm');
const { setMCR, calculateCurrentMCR } = nexus.pool;
const { setNextBlockTime, calculateCurrentMCR, setMCR } = require('../utils');

const stored = 12348870328212262601890n;
const desired = 10922706197119349905840n;
Expand Down
20 changes: 20 additions & 0 deletions test/unit/Ramm/getBookValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { ethers } = require('hardhat');
const { expect } = require('chai');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');

const { setup } = require('./setup');

const { parseEther } = ethers;

describe('getBookValue', function () {
it('should return the correct book value', async function () {
const fixture = await loadFixture(setup);
const { ramm, pool, tokenController } = fixture.contracts;

const bookValue = await ramm.getBookValue();
const capital = await pool.getPoolValueInEth();
const supply = await tokenController.totalSupply();

expect(bookValue).to.be.equal((parseEther('1') * capital) / supply);
});
});
Loading