diff --git a/contracts/staking/contracts/src/core/MixinFees.sol b/contracts/staking/contracts/src/core/MixinFees.sol index 0a9ad9fd47..79382bcd0b 100644 --- a/contracts/staking/contracts/src/core/MixinFees.sol +++ b/contracts/staking/contracts/src/core/MixinFees.sol @@ -19,6 +19,7 @@ pragma solidity ^0.5.5; import "../libs/LibSafeMath.sol"; +import "../libs/LibFeeMath.sol"; import "../interfaces/IVault.sol"; import "../immutable/MixinStorage.sol"; import "../immutable/MixinConstants.sol"; @@ -29,7 +30,6 @@ import "./MixinPools.sol"; import "./MixinExchange.sol"; import "./MixinRewardVault.sol"; import "../interfaces/IStructs.sol"; -import "../libs/LibMath.sol"; contract MixinFees is @@ -127,7 +127,7 @@ contract MixinFees is ._div(100) ); - uint256 reward = LibMath._cobbDouglasSuperSimplified( + uint256 reward = LibFeeMath._cobbDouglasSuperSimplified( totalRewards, activePoolIds[i].feesCollected, totalFees, diff --git a/contracts/staking/contracts/src/libs/LibMath.sol b/contracts/staking/contracts/src/libs/LibFeeMath.sol similarity index 99% rename from contracts/staking/contracts/src/libs/LibMath.sol rename to contracts/staking/contracts/src/libs/LibFeeMath.sol index b46f671b78..af2b936650 100644 --- a/contracts/staking/contracts/src/libs/LibMath.sol +++ b/contracts/staking/contracts/src/libs/LibFeeMath.sol @@ -22,7 +22,7 @@ pragma solidity ^0.5.5; -library LibMath { +library LibFeeMath { function _nthRoot(uint256 base, uint256 n) internal pure returns (uint256 root) { assembly { diff --git a/contracts/staking/contracts/test/LibMathTest.sol b/contracts/staking/contracts/test/LibFeeMathTest.sol similarity index 87% rename from contracts/staking/contracts/test/LibMathTest.sol rename to contracts/staking/contracts/test/LibFeeMathTest.sol index 0ba4c1b123..c58e297d50 100644 --- a/contracts/staking/contracts/test/LibMathTest.sol +++ b/contracts/staking/contracts/test/LibFeeMathTest.sol @@ -20,13 +20,13 @@ pragma solidity ^0.5.5; -import "../src/libs/LibMath.sol"; +import "../src/libs/LibFeeMath.sol"; -contract LibMathTest { +contract LibFeeMathTest { function nthRoot(uint256 base, uint256 n) public pure returns (uint256 root) { - return LibMath._nthRoot(base, n); + return LibFeeMath._nthRoot(base, n); } function nthRootFixedPoint( @@ -37,7 +37,7 @@ contract LibMathTest { pure returns (uint256 root) { - return LibMath._nthRootFixedPoint(base, n); + return LibFeeMath._nthRootFixedPoint(base, n); } function cobbDouglas( @@ -53,7 +53,7 @@ contract LibMathTest { pure returns (uint256) { - return LibMath._cobbDouglas( + return LibFeeMath._cobbDouglas( totalRewards, ownerFees, totalFees, @@ -76,7 +76,7 @@ contract LibMathTest { pure returns (uint256) { - return LibMath._cobbDouglasSimplified( + return LibFeeMath._cobbDouglasSimplified( totalRewards, ownerFees, totalFees, @@ -98,7 +98,7 @@ contract LibMathTest { // pure returns (uint256) { - return LibMath._cobbDouglasSimplifiedInverse( + return LibFeeMath._cobbDouglasSimplifiedInverse( totalRewards, ownerFees, totalFees, diff --git a/contracts/staking/package.json b/contracts/staking/package.json index 94e182bc6e..5c5fe55eb4 100644 --- a/contracts/staking/package.json +++ b/contracts/staking/package.json @@ -36,7 +36,7 @@ "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(LibMathTest|LibZrxToken|MixinStake|RewardVault|Staking|StakingProxy|ZrxVault).json", + "abis": "./generated-artifacts/@(LibFeeMathTest|LibZrxToken|MixinStake|RewardVault|Staking|StakingProxy|ZrxVault).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/staking/src/artifacts.ts b/contracts/staking/src/artifacts.ts index 6ef1696202..aa8b006354 100644 --- a/contracts/staking/src/artifacts.ts +++ b/contracts/staking/src/artifacts.ts @@ -5,7 +5,7 @@ */ import { ContractArtifact } from 'ethereum-types'; -import * as LibMathTest from '../generated-artifacts/LibMathTest.json'; +import * as LibFeeMathTest from '../generated-artifacts/LibFeeMathTest.json'; import * as LibZrxToken from '../generated-artifacts/LibZrxToken.json'; import * as MixinStake from '../generated-artifacts/MixinStake.json'; import * as RewardVault from '../generated-artifacts/RewardVault.json'; @@ -19,5 +19,5 @@ export const artifacts = { LibZrxToken: LibZrxToken as ContractArtifact, RewardVault: RewardVault as ContractArtifact, ZrxVault: ZrxVault as ContractArtifact, - LibMathTest: LibMathTest as ContractArtifact, + LibFeeMathTest: LibFeeMathTest as ContractArtifact, }; diff --git a/contracts/staking/src/wrappers.ts b/contracts/staking/src/wrappers.ts index 0780022af5..2dcfc9b05d 100644 --- a/contracts/staking/src/wrappers.ts +++ b/contracts/staking/src/wrappers.ts @@ -3,7 +3,7 @@ * Warning: This file is auto-generated by contracts-gen. Don't edit manually. * ----------------------------------------------------------------------------- */ -export * from '../generated-wrappers/lib_math_test'; +export * from '../generated-wrappers/lib_fee_math_test'; export * from '../generated-wrappers/lib_zrx_token'; export * from '../generated-wrappers/mixin_stake'; export * from '../generated-wrappers/reward_vault'; diff --git a/contracts/staking/test/utils/staking_wrapper.ts b/contracts/staking/test/utils/staking_wrapper.ts index 95fe955d4c..6c4b115631 100644 --- a/contracts/staking/test/utils/staking_wrapper.ts +++ b/contracts/staking/test/utils/staking_wrapper.ts @@ -9,7 +9,7 @@ import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contra import { ERC20ProxyContract } from '@0x/contracts-asset-proxy'; import * as _ from 'lodash'; -import { artifacts, StakingContract, StakingProxyContract, ZrxVaultContract, RewardVaultContract, LibMathTestContract } from '../../src'; +import { artifacts, StakingContract, StakingProxyContract, ZrxVaultContract, RewardVaultContract, LibFeeMathTestContract } from '../../src'; import { ApprovalFactory } from './ApprovalFactory'; import { SignedStakingPoolApproval } from './types'; import { constants } from './constants'; @@ -28,7 +28,7 @@ export class StakingWrapper { private _stakingProxyContractIfExists?: StakingProxyContract; private _zrxVaultContractIfExists?: ZrxVaultContract; private _rewardVaultContractIfExists?: RewardVaultContract; - private _libMathTestContractIfExists?: LibMathTestContract; + private _LibFeeMathTestContractIfExists?: LibFeeMathTestContract; constructor(provider: Provider, ownerAddres: string, erc20ProxyContract: ERC20ProxyContract, zrxTokenContract: DummyERC20TokenContract, accounts: string[]) { this._web3Wrapper = new Web3Wrapper(provider); @@ -56,9 +56,9 @@ export class StakingWrapper { this._validateDeployedOrThrow(); return this._rewardVaultContractIfExists as RewardVaultContract; } - public getLibMathTestContract(): LibMathTestContract { + public getLibFeeMathTestContract(): LibFeeMathTestContract { this._validateDeployedOrThrow(); - return this._libMathTestContractIfExists as LibMathTestContract; + return this._LibFeeMathTestContractIfExists as LibFeeMathTestContract; } public async deployAndConfigureContracts(): Promise { // deploy zrx vault @@ -117,8 +117,8 @@ export class StakingWrapper { await this._web3Wrapper.sendTransactionAsync(setRewardVaultTxData) ); // deploy libmath test - this._libMathTestContractIfExists = await LibMathTestContract.deployFrom0xArtifactAsync( - artifacts.LibMathTest, + this._LibFeeMathTestContractIfExists = await LibFeeMathTestContract.deployFrom0xArtifactAsync( + artifacts.LibFeeMathTest, this._provider, txDefaults, ); @@ -521,12 +521,12 @@ export class StakingWrapper { } ///// MATH ///// public async nthRoot(value: BigNumber, n: BigNumber): Promise { - //const txReceipt = await this.getLibMathTestContract().nthRoot.await(value, n); - const output = await this.getLibMathTestContract().nthRoot.callAsync(value, n); + //const txReceipt = await this.getLibFeeMathTestContract().nthRoot.await(value, n); + const output = await this.getLibFeeMathTestContract().nthRoot.callAsync(value, n); return output; } public async nthRootFixedPoint(value: BigNumber, n: BigNumber): Promise { - const output = await this.getLibMathTestContract().nthRootFixedPoint.callAsync(value, n); + const output = await this.getLibFeeMathTestContract().nthRootFixedPoint.callAsync(value, n); return output; } public async cobbDouglasAsync( @@ -538,7 +538,7 @@ export class StakingWrapper { alphaNumerator: BigNumber, alphaDenominator: BigNumber ) { - const output = await this.getLibMathTestContract().cobbDouglas.callAsync( + const output = await this.getLibFeeMathTestContract().cobbDouglas.callAsync( totalRewards, ownerFees, totalFees, @@ -557,7 +557,7 @@ export class StakingWrapper { totalStake: BigNumber, alphaDenominator: BigNumber ) { - const txReceipt = await this.getLibMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync( + const txReceipt = await this.getLibFeeMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync( totalRewards, ownerFees, totalFees, @@ -566,7 +566,7 @@ export class StakingWrapper { alphaDenominator ); console.log(`Gas Used: ${txReceipt.gasUsed}`); - const output = await this.getLibMathTestContract().cobbDouglasSimplified.callAsync( + const output = await this.getLibFeeMathTestContract().cobbDouglasSimplified.callAsync( totalRewards, ownerFees, totalFees, @@ -584,7 +584,7 @@ export class StakingWrapper { totalStake: BigNumber, alphaDenominator: BigNumber ) { - const txReceipt = await this.getLibMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync( + const txReceipt = await this.getLibFeeMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync( totalRewards, ownerFees, totalFees, @@ -593,7 +593,7 @@ export class StakingWrapper { alphaDenominator ); - const output = await this.getLibMathTestContract().cobbDouglasSimplifiedInverse.callAsync( + const output = await this.getLibFeeMathTestContract().cobbDouglasSimplifiedInverse.callAsync( totalRewards, ownerFees, totalFees, diff --git a/contracts/staking/tsconfig.json b/contracts/staking/tsconfig.json index bb3e27653d..613c2e4bcc 100644 --- a/contracts/staking/tsconfig.json +++ b/contracts/staking/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "files": [ - "generated-artifacts/LibMathTest.json", + "generated-artifacts/LibFeeMathTest.json", "generated-artifacts/LibZrxToken.json", "generated-artifacts/MixinStake.json", "generated-artifacts/RewardVault.json",