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

Commit

Permalink
Remove fees
Browse files Browse the repository at this point in the history
  • Loading branch information
asoong committed Jan 3, 2019
1 parent 06b2cd3 commit 359c259
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1,212 deletions.
70 changes: 30 additions & 40 deletions contracts/core/tokens/RSetToken.sol
Expand Up @@ -93,10 +93,6 @@ contract RSetToken is
RHelperLibrary.State public rebalanceState;
uint256 public lastRebalanceTimestamp;

// Fee setting, values in basis points
uint256 public entranceFee;
uint256 public rebalanceFee;

// State governing rebalance cycle
uint256 public proposalPeriod;
uint256 public rebalanceInterval;
Expand Down Expand Up @@ -142,8 +138,6 @@ contract RSetToken is
* @param _manager Manager of the Rebalancing Set
* @param _proposalPeriod Amount of time for users to inspect a rebalance proposal
* @param _rebalanceInterval Minimum amount of time between rebalances
* @param _entranceFee Entrance fee as a percentage of initialSet when minting the Rebalancing Set
* @param _rebalanceFee Rebalance fee as a percentage of the next allocation components when settling
* @param _name The name of the new RSetToken
* @param _symbol The symbol of the new RSetToken
*/
Expand All @@ -155,8 +149,6 @@ contract RSetToken is
address _manager,
uint256 _proposalPeriod,
uint256 _rebalanceInterval,
uint256 _entranceFee,
uint256 _rebalanceFee,
string _name,
string _symbol
)
Expand Down Expand Up @@ -197,8 +189,6 @@ contract RSetToken is

// Rebalancing Set Token state
manager = _manager;
entranceFee = _entranceFee;
rebalanceFee = _rebalanceFee;
currentAllocation = RSetToken.ComponentAllocation({
components: _components,
units: _units,
Expand Down Expand Up @@ -413,36 +403,36 @@ contract RSetToken is
"RSetToken.mint: Cannot mint during Rebalance"
);

uint256 issuerTotal = 0;
uint256 managerFee = 0;
uint256 protocolFee = 0;

if (entranceFee > 0) {
// Calculate total fees and remaining issuer total
uint256 totalFees = RHelperLibrary.calculateTotalFees(
_quantity,
entranceFee
);
issuerTotal = _quantity.sub(totalFees);

(managerFee, protocolFee) = RHelperLibrary.calculateFeeSplit(
totalFees,
coreInstance
);

_mint(manager, managerFee);
} else {
issuerTotal = _quantity;
}

// Update token balance of the manager
_mint(_issuer, issuerTotal);

if (protocolFee > 0) {
// Get protocol address and add fees to protocol and issuer
address protocolAddress = coreInstance.protocolAddress();
_mint(protocolAddress, protocolFee);
}
// uint256 issuerTotal = 0;
// uint256 managerFee = 0;
// uint256 protocolFee = 0;

// if (entranceFee > 0) {
// // Calculate total fees and remaining issuer total
// uint256 totalFees = RHelperLibrary.calculateTotalFees(
// _quantity,
// entranceFee
// );
// issuerTotal = _quantity.sub(totalFees);

// (managerFee, protocolFee) = RHelperLibrary.calculateFeeSplit(
// totalFees,
// coreInstance
// );

// _mint(manager, managerFee);
// } else {
// issuerTotal = _quantity;
// }

// // Update token balance of the manager
_mint(_issuer, _quantity);

// if (protocolFee > 0) {
// // Get protocol address and add fees to protocol and issuer
// address protocolAddress = coreInstance.protocolAddress();
// _mint(protocolAddress, protocolFee);
// }
}

/*
Expand Down
15 changes: 2 additions & 13 deletions contracts/core/tokens/RSetTokenFactory.sol
Expand Up @@ -54,8 +54,6 @@ contract RSetTokenFactory {
address manager;
uint256 rebalanceInterval;
uint256 proposalPeriod;
uint256 entranceFee;
uint256 rebalanceFee;
string name;
string symbol;
}
Expand Down Expand Up @@ -94,8 +92,6 @@ contract RSetTokenFactory {
* | manager | 32 |
* | proposalPeriod | 64 |
* | rebalanceInterval | 96 |
* | entranceFee | 128 |
* | rebalanceFee | 160 |
*
* @param _components The address of component tokens
* @param _units The units of each component token
Expand Down Expand Up @@ -142,10 +138,8 @@ contract RSetTokenFactory {
parameters.manager,
parameters.proposalPeriod,
parameters.rebalanceInterval,
parameters.entranceFee,
parameters.rebalanceFee,
parameters.name,
parameters.symbol
_name.bytes32ToString(),
_symbol.bytes32ToString()
);
}

Expand All @@ -166,13 +160,8 @@ contract RSetTokenFactory {
mstore(parameters, mload(add(_callData, 32))) // manager
mstore(add(parameters, 32), mload(add(_callData, 64))) // proposalPeriod
mstore(add(parameters, 64), mload(add(_callData, 96))) // rebalanceInterval
mstore(add(parameters, 96), mload(add(_callData, 128))) // entranceFee
mstore(add(parameters, 128), mload(add(_callData, 160))) // rebalanceFee
}

parameters.name = _name.bytes32ToString();
parameters.symbol = _symbol.bytes32ToString();

return parameters;
}
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -91,7 +91,7 @@
"lint-staged": "^7.2.0",
"module-alias": "^2.1.0",
"openzeppelin-solidity": "^2.0.0",
"set-protocol-utils": "^1.0.0-beta.19",
"set-protocol-utils": "^1.0.0-beta.21",
"solium": "^1.1.7",
"tiny-promisify": "^1.0.0",
"truffle-hdwallet-provider": "^1.0.0-web3one.0",
Expand Down
36 changes: 0 additions & 36 deletions test/contracts/core/tokens/rsetToken.spec.ts
Expand Up @@ -129,8 +129,6 @@ contract('RebalancingSetToken', accounts => {
let subjectManager: Address;
let subjectProposalPeriod: BigNumber;
let subjectRebalanceInterval: BigNumber;
let subjectEntranceFee: BigNumber;
let subjectRebalanceFee: BigNumber;
const subjectName: string = 'Rebalancing Set';
const subjectSymbol: string = 'RBSET';

Expand All @@ -146,8 +144,6 @@ contract('RebalancingSetToken', accounts => {
subjectManager = managerAccount;
subjectProposalPeriod = ONE_DAY_IN_SECONDS;
subjectRebalanceInterval = ONE_DAY_IN_SECONDS;
subjectEntranceFee = new BigNumber(10000);
subjectRebalanceFee = new BigNumber(25000);
});

async function subject(): Promise<RSetTokenContract> {
Expand All @@ -159,8 +155,6 @@ contract('RebalancingSetToken', accounts => {
subjectManager,
subjectProposalPeriod,
subjectRebalanceInterval,
subjectEntranceFee,
subjectRebalanceFee,
subjectName,
subjectSymbol,
);
Expand Down Expand Up @@ -243,20 +237,6 @@ contract('RebalancingSetToken', accounts => {
expect(rebalancingInterval).to.be.bignumber.equal(subjectRebalanceInterval);
});

it ('creates a set with the correct entrance fee', async () => {
rebalancingSetToken = await subject();

const entranceFee = await rebalancingSetToken.entranceFee.callAsync();
expect(entranceFee).to.be.bignumber.equal(subjectEntranceFee);
});

it ('creates a set with the correct rebalance fee', async () => {
rebalancingSetToken = await subject();

const rebalanceFee = await rebalancingSetToken.rebalanceFee.callAsync();
expect(rebalanceFee).to.be.bignumber.equal(subjectRebalanceFee);
});

it('sets the rebalancingSetToken state to Default', async () => {
rebalancingSetToken = await subject();

Expand Down Expand Up @@ -309,8 +289,6 @@ contract('RebalancingSetToken', accounts => {
const manager = managerAccount;
const proposalPeriod = ONE_DAY_IN_SECONDS;
const rebalanceInterval = ONE_DAY_IN_SECONDS;
const entranceFee = ZERO;
const rebalanceFee = ZERO;

rebalancingSetToken = await rebalancingWrapper.deployRSetTokenAsync(
rebalancingFactory.address,
Expand All @@ -320,8 +298,6 @@ contract('RebalancingSetToken', accounts => {
manager,
proposalPeriod,
rebalanceInterval,
entranceFee,
rebalanceFee,
);

subjectCaller = managerAccount;
Expand Down Expand Up @@ -354,8 +330,6 @@ contract('RebalancingSetToken', accounts => {
const manager = managerAccount;
const proposalPeriod = ONE_DAY_IN_SECONDS;
const rebalanceInterval = ONE_DAY_IN_SECONDS;
const entranceFee = ZERO;
const rebalanceFee = ZERO;

rebalancingSetToken = await rebalancingWrapper.deployRSetTokenAsync(
rebalancingFactory.address,
Expand All @@ -365,8 +339,6 @@ contract('RebalancingSetToken', accounts => {
manager,
proposalPeriod,
rebalanceInterval,
entranceFee,
rebalanceFee,
);

subjectCaller = managerAccount;
Expand Down Expand Up @@ -399,8 +371,6 @@ contract('RebalancingSetToken', accounts => {
const manager = managerAccount;
const proposalPeriod = ONE_DAY_IN_SECONDS;
const rebalanceInterval = ONE_DAY_IN_SECONDS;
const entranceFee = ZERO;
const rebalanceFee = ZERO;

rebalancingSetToken = await rebalancingWrapper.deployRSetTokenAsync(
rebalancingFactory.address,
Expand All @@ -410,8 +380,6 @@ contract('RebalancingSetToken', accounts => {
manager,
proposalPeriod,
rebalanceInterval,
entranceFee,
rebalanceFee,
);

subjectCaller = managerAccount;
Expand Down Expand Up @@ -954,8 +922,6 @@ contract('RebalancingSetToken', accounts => {
const manager = managerAccount;
const proposalPeriod = ONE_DAY_IN_SECONDS;
const rebalanceInterval = ONE_DAY_IN_SECONDS;
const entranceFee = ZERO;
const rebalanceFee = ZERO;

rebalancingSetToken = await rebalancingWrapper.deployRSetTokenAsync(
rebalancingFactory.address,
Expand All @@ -965,8 +931,6 @@ contract('RebalancingSetToken', accounts => {
manager,
proposalPeriod,
rebalanceInterval,
entranceFee,
rebalanceFee,
);

subjectCaller = managerAccount;
Expand Down
10 changes: 1 addition & 9 deletions utils/wrappers/rWrapper.ts
Expand Up @@ -65,8 +65,6 @@ export class RWrapper {
tokenManager: Address,
proposalPeriod: BigNumber,
rebalanceCoolOffPeriod: BigNumber,
entranceFee: BigNumber,
rebalanceFee: BigNumber,
name: string = 'Rebalancing Set',
symbol: string = 'RBSET',
from: Address = this._tokenOwnerAddress
Expand All @@ -79,8 +77,6 @@ export class RWrapper {
tokenManager,
proposalPeriod,
rebalanceCoolOffPeriod,
entranceFee,
rebalanceFee,
name,
symbol,
{ from, gas: DEFAULT_GAS },
Expand Down Expand Up @@ -234,18 +230,14 @@ export class RWrapper {
manager: Address,
initialAllocation: RebalanceComponents,
proposalPeriod: BigNumber,
entranceFee: BigNumber = ZERO,
rebalanceFee: BigNumber = ZERO,
initialUnitShares: BigNumber = DEFAULT_UNIT_SHARES,
): Promise<RSetTokenContract> {
// Generate defualt rSetToken params
const rebalanceInterval = ONE_DAY_IN_SECONDS;
const callData = SetUtils.generateRebalancingSetTokenCallData(
const callData = SetUtils.generateRSetTokenCallData(
manager,
proposalPeriod,
rebalanceInterval,
entranceFee,
rebalanceFee
);

// Create rSetToken
Expand Down

0 comments on commit 359c259

Please sign in to comment.