Renamed LibMath to LibFeeMath

This commit is contained in:
Greg Hysen 2019-06-25 15:07:55 -07:00
parent 4d2ba9f1e6
commit b36003896f
8 changed files with 29 additions and 29 deletions

View File

@ -19,6 +19,7 @@
pragma solidity ^0.5.5; pragma solidity ^0.5.5;
import "../libs/LibSafeMath.sol"; import "../libs/LibSafeMath.sol";
import "../libs/LibFeeMath.sol";
import "../interfaces/IVault.sol"; import "../interfaces/IVault.sol";
import "../immutable/MixinStorage.sol"; import "../immutable/MixinStorage.sol";
import "../immutable/MixinConstants.sol"; import "../immutable/MixinConstants.sol";
@ -29,7 +30,6 @@ import "./MixinPools.sol";
import "./MixinExchange.sol"; import "./MixinExchange.sol";
import "./MixinRewardVault.sol"; import "./MixinRewardVault.sol";
import "../interfaces/IStructs.sol"; import "../interfaces/IStructs.sol";
import "../libs/LibMath.sol";
contract MixinFees is contract MixinFees is
@ -127,7 +127,7 @@ contract MixinFees is
._div(100) ._div(100)
); );
uint256 reward = LibMath._cobbDouglasSuperSimplified( uint256 reward = LibFeeMath._cobbDouglasSuperSimplified(
totalRewards, totalRewards,
activePoolIds[i].feesCollected, activePoolIds[i].feesCollected,
totalFees, totalFees,

View File

@ -22,7 +22,7 @@ pragma solidity ^0.5.5;
library LibMath { library LibFeeMath {
function _nthRoot(uint256 base, uint256 n) internal pure returns (uint256 root) { function _nthRoot(uint256 base, uint256 n) internal pure returns (uint256 root) {
assembly { assembly {

View File

@ -20,13 +20,13 @@
pragma solidity ^0.5.5; 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) { function nthRoot(uint256 base, uint256 n) public pure returns (uint256 root) {
return LibMath._nthRoot(base, n); return LibFeeMath._nthRoot(base, n);
} }
function nthRootFixedPoint( function nthRootFixedPoint(
@ -37,7 +37,7 @@ contract LibMathTest {
pure pure
returns (uint256 root) returns (uint256 root)
{ {
return LibMath._nthRootFixedPoint(base, n); return LibFeeMath._nthRootFixedPoint(base, n);
} }
function cobbDouglas( function cobbDouglas(
@ -53,7 +53,7 @@ contract LibMathTest {
pure pure
returns (uint256) returns (uint256)
{ {
return LibMath._cobbDouglas( return LibFeeMath._cobbDouglas(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,
@ -76,7 +76,7 @@ contract LibMathTest {
pure pure
returns (uint256) returns (uint256)
{ {
return LibMath._cobbDouglasSimplified( return LibFeeMath._cobbDouglasSimplified(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,
@ -98,7 +98,7 @@ contract LibMathTest {
// pure // pure
returns (uint256) returns (uint256)
{ {
return LibMath._cobbDouglasSimplifiedInverse( return LibFeeMath._cobbDouglasSimplifiedInverse(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,

View File

@ -36,7 +36,7 @@
"compile:truffle": "truffle compile" "compile:truffle": "truffle compile"
}, },
"config": { "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." "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
}, },
"repository": { "repository": {

View File

@ -5,7 +5,7 @@
*/ */
import { ContractArtifact } from 'ethereum-types'; 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 LibZrxToken from '../generated-artifacts/LibZrxToken.json';
import * as MixinStake from '../generated-artifacts/MixinStake.json'; import * as MixinStake from '../generated-artifacts/MixinStake.json';
import * as RewardVault from '../generated-artifacts/RewardVault.json'; import * as RewardVault from '../generated-artifacts/RewardVault.json';
@ -19,5 +19,5 @@ export const artifacts = {
LibZrxToken: LibZrxToken as ContractArtifact, LibZrxToken: LibZrxToken as ContractArtifact,
RewardVault: RewardVault as ContractArtifact, RewardVault: RewardVault as ContractArtifact,
ZrxVault: ZrxVault as ContractArtifact, ZrxVault: ZrxVault as ContractArtifact,
LibMathTest: LibMathTest as ContractArtifact, LibFeeMathTest: LibFeeMathTest as ContractArtifact,
}; };

View File

@ -3,7 +3,7 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually. * 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/lib_zrx_token';
export * from '../generated-wrappers/mixin_stake'; export * from '../generated-wrappers/mixin_stake';
export * from '../generated-wrappers/reward_vault'; export * from '../generated-wrappers/reward_vault';

View File

@ -9,7 +9,7 @@ import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contra
import { ERC20ProxyContract } from '@0x/contracts-asset-proxy'; import { ERC20ProxyContract } from '@0x/contracts-asset-proxy';
import * as _ from 'lodash'; 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 { ApprovalFactory } from './ApprovalFactory';
import { SignedStakingPoolApproval } from './types'; import { SignedStakingPoolApproval } from './types';
import { constants } from './constants'; import { constants } from './constants';
@ -28,7 +28,7 @@ export class StakingWrapper {
private _stakingProxyContractIfExists?: StakingProxyContract; private _stakingProxyContractIfExists?: StakingProxyContract;
private _zrxVaultContractIfExists?: ZrxVaultContract; private _zrxVaultContractIfExists?: ZrxVaultContract;
private _rewardVaultContractIfExists?: RewardVaultContract; private _rewardVaultContractIfExists?: RewardVaultContract;
private _libMathTestContractIfExists?: LibMathTestContract; private _LibFeeMathTestContractIfExists?: LibFeeMathTestContract;
constructor(provider: Provider, ownerAddres: string, erc20ProxyContract: ERC20ProxyContract, zrxTokenContract: DummyERC20TokenContract, accounts: string[]) { constructor(provider: Provider, ownerAddres: string, erc20ProxyContract: ERC20ProxyContract, zrxTokenContract: DummyERC20TokenContract, accounts: string[]) {
this._web3Wrapper = new Web3Wrapper(provider); this._web3Wrapper = new Web3Wrapper(provider);
@ -56,9 +56,9 @@ export class StakingWrapper {
this._validateDeployedOrThrow(); this._validateDeployedOrThrow();
return this._rewardVaultContractIfExists as RewardVaultContract; return this._rewardVaultContractIfExists as RewardVaultContract;
} }
public getLibMathTestContract(): LibMathTestContract { public getLibFeeMathTestContract(): LibFeeMathTestContract {
this._validateDeployedOrThrow(); this._validateDeployedOrThrow();
return this._libMathTestContractIfExists as LibMathTestContract; return this._LibFeeMathTestContractIfExists as LibFeeMathTestContract;
} }
public async deployAndConfigureContracts(): Promise<void> { public async deployAndConfigureContracts(): Promise<void> {
// deploy zrx vault // deploy zrx vault
@ -117,8 +117,8 @@ export class StakingWrapper {
await this._web3Wrapper.sendTransactionAsync(setRewardVaultTxData) await this._web3Wrapper.sendTransactionAsync(setRewardVaultTxData)
); );
// deploy libmath test // deploy libmath test
this._libMathTestContractIfExists = await LibMathTestContract.deployFrom0xArtifactAsync( this._LibFeeMathTestContractIfExists = await LibFeeMathTestContract.deployFrom0xArtifactAsync(
artifacts.LibMathTest, artifacts.LibFeeMathTest,
this._provider, this._provider,
txDefaults, txDefaults,
); );
@ -521,12 +521,12 @@ export class StakingWrapper {
} }
///// MATH ///// ///// MATH /////
public async nthRoot(value: BigNumber, n: BigNumber): Promise<BigNumber> { public async nthRoot(value: BigNumber, n: BigNumber): Promise<BigNumber> {
//const txReceipt = await this.getLibMathTestContract().nthRoot.await(value, n); //const txReceipt = await this.getLibFeeMathTestContract().nthRoot.await(value, n);
const output = await this.getLibMathTestContract().nthRoot.callAsync(value, n); const output = await this.getLibFeeMathTestContract().nthRoot.callAsync(value, n);
return output; return output;
} }
public async nthRootFixedPoint(value: BigNumber, n: BigNumber): Promise<BigNumber> { public async nthRootFixedPoint(value: BigNumber, n: BigNumber): Promise<BigNumber> {
const output = await this.getLibMathTestContract().nthRootFixedPoint.callAsync(value, n); const output = await this.getLibFeeMathTestContract().nthRootFixedPoint.callAsync(value, n);
return output; return output;
} }
public async cobbDouglasAsync( public async cobbDouglasAsync(
@ -538,7 +538,7 @@ export class StakingWrapper {
alphaNumerator: BigNumber, alphaNumerator: BigNumber,
alphaDenominator: BigNumber alphaDenominator: BigNumber
) { ) {
const output = await this.getLibMathTestContract().cobbDouglas.callAsync( const output = await this.getLibFeeMathTestContract().cobbDouglas.callAsync(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,
@ -557,7 +557,7 @@ export class StakingWrapper {
totalStake: BigNumber, totalStake: BigNumber,
alphaDenominator: BigNumber alphaDenominator: BigNumber
) { ) {
const txReceipt = await this.getLibMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync( const txReceipt = await this.getLibFeeMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,
@ -566,7 +566,7 @@ export class StakingWrapper {
alphaDenominator alphaDenominator
); );
console.log(`Gas Used: ${txReceipt.gasUsed}`); console.log(`Gas Used: ${txReceipt.gasUsed}`);
const output = await this.getLibMathTestContract().cobbDouglasSimplified.callAsync( const output = await this.getLibFeeMathTestContract().cobbDouglasSimplified.callAsync(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,
@ -584,7 +584,7 @@ export class StakingWrapper {
totalStake: BigNumber, totalStake: BigNumber,
alphaDenominator: BigNumber alphaDenominator: BigNumber
) { ) {
const txReceipt = await this.getLibMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync( const txReceipt = await this.getLibFeeMathTestContract().cobbDouglasSimplifiedInverse.awaitTransactionSuccessAsync(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,
@ -593,7 +593,7 @@ export class StakingWrapper {
alphaDenominator alphaDenominator
); );
const output = await this.getLibMathTestContract().cobbDouglasSimplifiedInverse.callAsync( const output = await this.getLibFeeMathTestContract().cobbDouglasSimplifiedInverse.callAsync(
totalRewards, totalRewards,
ownerFees, ownerFees,
totalFees, totalFees,

View File

@ -3,7 +3,7 @@
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [ "files": [
"generated-artifacts/LibMathTest.json", "generated-artifacts/LibFeeMathTest.json",
"generated-artifacts/LibZrxToken.json", "generated-artifacts/LibZrxToken.json",
"generated-artifacts/MixinStake.json", "generated-artifacts/MixinStake.json",
"generated-artifacts/RewardVault.json", "generated-artifacts/RewardVault.json",