Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
[Fund] added interface
Browse files Browse the repository at this point in the history
  • Loading branch information
carlolm committed Dec 11, 2017
1 parent 474e221 commit 03aefe1
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 18 deletions.
45 changes: 45 additions & 0 deletions contracts/Fund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,51 @@ import "./zeppelin/DestructiblePausable.sol";
* in traditional funds, while maximizing transparency and mitigating fraud risk for investors.
*/

contract IFund {
uint public decimals;
uint public minInitialSubscriptionEth;
uint public minSubscriptionEth;
uint public minRedemptionShares;
uint public totalEthPendingSubscription;
uint public totalEthPendingWithdrawal;
uint public totalSharesPendingRedemption;
uint public totalSupply;

uint public adminFeeBps;
uint public mgmtFeeBps;
uint public performFeeBps;

uint public lastCalcDate;
uint public navPerShare;
uint public accumulatedMgmtFees;
uint public accumulatedAdminFees;
uint public lossCarryforward;

function getInvestor(address _addr)
returns (
uint ethTotalAllocation,
uint ethPendingSubscription,
uint sharesOwned,
uint sharesPendingRedemption,
uint ethPendingWithdrawal
) {}

function usdToEth(uint _usd)
returns (uint eth) {}

function ethToUsd(uint _eth)
returns (uint usd) {}

function ethToShares(uint _eth)
returns (uint shares) {}

function sharesToEth(uint _shares)
returns (uint ethAmount) {}

function getBalance()
returns (uint ethAmount) {}
}

contract Fund is DestructiblePausable {
using SafeMath for uint;

Expand Down
4 changes: 2 additions & 2 deletions contracts/InvestorActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract InvestorActions is DestructibleModified {

// Modules
IDataFeed public dataFeed;
Fund fund;
IFund fund;

// This modifier is applied to all external methods in this contract since only
// the primary Fund contract can use this module
Expand Down Expand Up @@ -279,7 +279,7 @@ contract InvestorActions is DestructibleModified {
onlyOwner
returns (bool success)
{
fund = Fund(_fund);
fund = IFund(_fund);
fundAddress = _fund;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/NavCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract NavCalculator is DestructibleModified {

// Modules
IDataFeed public dataFeed;
Fund fund;
IFund fund;

// This modifier is applied to all external methods in this contract since only
// the primary Fund contract can use this module
Expand Down Expand Up @@ -134,7 +134,7 @@ contract NavCalculator is DestructibleModified {
function setFund(address _address)
onlyOwner
{
fund = Fund(_address);
fund = IFund(_address);
fundAddress = _address;
}

Expand Down
7 changes: 5 additions & 2 deletions test/0_ownable.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const constructors = {
),
};

contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
contract('OwnableModified', (accounts) => {
let owned, dataFeed, navCalculator, investorActions;
const [
owner0,
Expand All @@ -65,7 +65,10 @@ contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {

const addressZero = '0x0000000000000000000000000000000000000000';

before('should prepare', () => assert.isAtLeast(accounts.length, 5));
before('should prepare', () => {
console.log(` ****** START TEST [ ${scriptName} ]*******`);
assert.isAtLeast(accounts.length, 5);
});

Object.keys(constructors).forEach((name) => {
describe(name, () => {
Expand Down
17 changes: 10 additions & 7 deletions test/1_investors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ const NavCalculator = artifacts.require('./NavCalculator.sol');

const scriptName = path.basename(__filename);

contract(`****** START TEST [ ${scriptName} ]*******`, () => {
contract('InvestorActions', () => {
let fund;
let navCalculator;
let investorActions;

before(() => Promise.all([
Fund.deployed(),
NavCalculator.deployed(),
InvestorActions.deployed()
])
.then(values => [fund, navCalculator, investorActions] = values));
before(() => {
console.log(` ****** START TEST [ ${scriptName} ] *******`);
return Promise.all([
Fund.deployed(),
NavCalculator.deployed(),
InvestorActions.deployed()
])
.then(values => [fund, navCalculator, investorActions] = values);
});

it('should set fund to the correct fund address', () => investorActions.setFund(fund.address)
.then(() => investorActions.fundAddress.call())
Expand Down
3 changes: 2 additions & 1 deletion test/2_nav_calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (typeof web3.eth.getAccountsPromise === "undefined") {
Promise.promisifyAll(web3.eth, { suffix: "Promise" });
}

contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
contract('NavCalculator', (accounts) => {
let MANAGER = accounts[0];
let EXCHANGE = accounts[1];
const GAS_AMT = 500000;
Expand Down Expand Up @@ -110,6 +110,7 @@ contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
}

before(() => {
console.log(` ****** START TEST [ ${scriptName} ] *******`);
return Promise.all([Fund.deployed(), NavCalculator.deployed(), DataFeed.deployed()])
.then(_values => {
[fund, navCalculator, dataFeed] = _values;
Expand Down
3 changes: 2 additions & 1 deletion test/3_initialize_fund.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (typeof web3.eth.getAccountsPromise === 'undefined') {
Promise.promisifyAll(web3.eth, { suffix: 'Promise' });
}

contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
contract('Initialize Fund', (accounts) => {
// helpers
const getBalancePromise = address => web3.eth.getBalancePromise(address);
const weiToNum = wei => web3.fromWei(wei, 'ether').toNumber();
Expand Down Expand Up @@ -53,6 +53,7 @@ contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
{ from: OWNER, value: 0 }
)
.then((instance) => {
console.log(` ****** START TEST [ ${scriptName} ] *******`);
dataFeed = instance;
return Promise.all([
NavCalculator.new(dataFeed.address, { from: OWNER }),
Expand Down
3 changes: 2 additions & 1 deletion test/4_fund_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ethToWei = eth => web3.toWei(eth, 'ether');
const diffInWei = (a, b) => weiToNum(a) - weiToNum(b);
const gasToWei = gas => gas * 1e11;

contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
contract('FundActions', (accounts) => {
const OWNER = accounts[0];
const MANAGER = accounts[0];
const EXCHANGE = accounts[1];
Expand Down Expand Up @@ -71,6 +71,7 @@ contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
{ from: OWNER, value: 0 }
)
.then((instance) => {
console.log(` ****** START TEST [ ${scriptName} ] *******`);
dataFeed = instance;
return Promise.all([
NavCalculator.new(dataFeed.address, { from: OWNER }),
Expand Down
5 changes: 3 additions & 2 deletions test/5_advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ethToWei = eth => web3.toWei(eth, 'ether');
const diffInWei = (a, b) => weiToNum(a) - weiToNum(b);
const gasToWei = gas => gas * 1e11;

contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
contract('Advanced', (accounts) => {

const OWNER = accounts[0];
const MANAGER = accounts[0];
Expand All @@ -46,7 +46,7 @@ contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
const USD_ETH_BASIS = 30000;
const SECONDS_IN_YEAR = 31536000;

const investors = accounts.slice(2);
const investors = accounts.slice(-2);

// contract instances
let dataFeed, fund, navCalculator, investorActions;
Expand All @@ -61,6 +61,7 @@ contract(`****** START TEST [ ${scriptName} ]*******`, (accounts) => {
{ from: OWNER, value: 0 }
)
.then(instance => {
console.log(` ****** START TEST [ ${scriptName} ] *******`);
dataFeed = instance;
return Promise.all([
NavCalculator.new(dataFeed.address, { from: OWNER }),
Expand Down

0 comments on commit 03aefe1

Please sign in to comment.