Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.1 Collected Branch #231

Merged
merged 7 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
audit fixes
  • Loading branch information
Paul Vienhage committed Jan 26, 2022
commit 7bbacc8bb3d9ae0cb1c777c5e1b2c0062a3ecbd9
21 changes: 11 additions & 10 deletions contracts/ConvergentCurvePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ contract ConvergentCurvePool is IMinimalSwapInfoPool, BalancerPoolToken {

// The fees recorded during swaps, this is the total fees collected by LPs on all trades.
// These will be 18 point not token decimal encoded
uint128 public feesUnderlying;
uint128 public feesBond;
uint120 public feesUnderlying;
uint120 public feesBond;
// A bool to indicate if the contract is paused, stored with 'fees bond'
bool public paused;
// The fees which have been allocated to pay governance, a percent of LP fees on trades
// Since we don't have access to transfer they must be stored so governance can collect them later
uint128 public governanceFeesUnderlying;
uint128 public governanceFeesBond;
// A bool to indicate if the contract is paused, stored with 'fees bond'
bool public paused;
// A mapping of who can pause
mapping(address => bool) public pausers;
aleph-v marked this conversation as resolved.
Show resolved Hide resolved
// Stored records of governance tokens
Expand Down Expand Up @@ -349,11 +349,12 @@ contract ConvergentCurvePool is IMinimalSwapInfoPool, BalancerPoolToken {
// Governance withdraws the fees which have been paid to them
amountsOut[baseIndex] = uint256(governanceFeesUnderlying);
amountsOut[bondIndex] = uint256(governanceFeesBond);
aleph-v marked this conversation as resolved.
Show resolved Hide resolved
// We now have to zero the governance fees
governanceFeesUnderlying = 0;
governanceFeesBond = 0;
} else {
// Calculate the user's proportion of the reserves
amountsOut = _burnLP(lpOut, currentBalances, sender);
// Balancer fees collected are zero
dueProtocolFeeAmounts = new uint256[](2);
}

// We need to convert the balancer outputs to token decimals instead of 18
Expand Down Expand Up @@ -473,7 +474,7 @@ contract ConvergentCurvePool is IMinimalSwapInfoPool, BalancerPoolToken {
amountOut.sub(amountIn)
);
// we record that fee collected from the underlying
feesUnderlying += uint128(impliedYieldFee);
feesUnderlying += uint120(impliedYieldFee);
// and return the adjusted input quote
return amountIn.add(impliedYieldFee);
} else {
Expand Down Expand Up @@ -502,7 +503,7 @@ contract ConvergentCurvePool is IMinimalSwapInfoPool, BalancerPoolToken {
amountIn.sub(amountOut)
);
// we record the collected underlying fee
feesUnderlying += uint128(impliedYieldFee);
feesUnderlying += uint120(impliedYieldFee);
// and then return the updated output quote
return amountOut.sub(impliedYieldFee);
}
Expand Down Expand Up @@ -673,8 +674,8 @@ contract ConvergentCurvePool is IMinimalSwapInfoPool, BalancerPoolToken {
.sub(dueProtocolFees[bondIndex])
.sub(governanceFeesBond);
// Since all fees have been accounted for we reset the LP fees collected to zero
feesUnderlying = uint128(0);
feesBond = uint128(0);
feesUnderlying = uint120(0);
feesBond = uint120(0);
}

/// @dev Turns a token which is either 'bond' or 'underlying' into 18 point decimal
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/TestConvergentCurvePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ contract TestConvergentCurvePool is ConvergentCurvePool {
}

// Allows tests to specify fees without making trades
function setFees(uint128 amountUnderlying, uint120 amountBond) public {
function setFees(uint120 amountUnderlying, uint120 amountBond) public {
feesUnderlying = amountUnderlying;
feesBond = amountBond;
}
Expand Down