Skip to content

Commit

Permalink
Report for issue #129 updated by simon135
Browse files Browse the repository at this point in the history
  • Loading branch information
code423n4 committed Nov 25, 2022
1 parent 6cb50f6 commit 0069863
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions data/simon135-Q.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##### make these checks into a single modifier to make the code more readable:
```
```js
if (_pxGmx == address(0)) revert ZeroAddress();
if (_pxGlp == address(0)) revert ZeroAddress();
if (_pirexFees == address(0)) revert ZeroAddress();
Expand All @@ -12,13 +12,13 @@
if (_stakedGlp == address(0)) revert ZeroAddress();
```
instead, make it into a modifier
```
```js
modifer nonzero(adddress t) {
if(t== address(0)) revert ZeroAddress();
}
```
##### rename the `assets` var to `amount` for readability
```
```js
function _computeAssetAmounts(Fees f, uint256 assets)
```
make into `uint256 amount`
Expand All @@ -28,9 +28,37 @@ it's very confusing because the `postFeeAmount` is the real fee amount and `fee
instead:
`feeAmount`= the fee
`postFeeAmount` the `amount-fee`
#### add parameters to `beforeDeposit` to stop huge slippage loss and to make it more useable
```
##### add parameters to `beforeDeposit` to stop huge slippage loss and to make it more useable
```js
if (totalAssets() != 0) beforeDeposit(address(0), 0, 0);

```
https://github.com/code-423n4/2022-11-redactedcartel/blob/684627b7889e34ba7799e50074d138361f0f532b/src/vaults/AutoPxGmx.sol#L383
https://github.com/code-423n4/2022-11-redactedcartel/blob/684627b7889e34ba7799e50074d138361f0f532b/src/vaults/AutoPxGmx.sol#L383

##### if `distrbutorbalance= 0` then rewards won't be processed even though there are rewards that need to get processed

```js

uint256 blockReward = pendingRewards > distributorBalance
? distributorBalance
: pendingRewards;
uint256 precision = r.PRECISION();
uint256 cumulativeRewardPerToken = r.cumulativeRewardPerToken() +
((blockReward * precision) / r.totalSupply());
```
so if `pendingRewards > distributorBalance` The amount is `distributorBalance` instead of the actual pending amounts
ex:

`pendingRewards= 1ether`
`distributorBalance=0`
The rewards will be `0` and no rewards will be distributed because of the ternary operator wrong use
instead, make the calculation into

```js
blockReward=pendingRewards;
uint256 cumulativeRewardPerToken = r.cumulativeRewardPerToken() +
((blockReward * precision) / r.totalSupply());

```


0 comments on commit 0069863

Please sign in to comment.