Omniscia Platypus Finance Audit

Pool Code Style Findings

Pool Code Style Findings

POO-01C: Asset Removal Optimization

TypeSeverityLocation
Gas OptimizationInformationalPool.sol:L443-L451

Description:

The removal of an asset from the system can be optimized.

Example:

contracts/pool/Pool.sol
430/**
431 * @notice Removes asset from asset struct
432 * @dev Can only be called by owner
433 * @param key The address of token to remove
434 */
435function removeAsset(address key) external onlyOwner {
436 if (!_assets.inserted[key]) {
437 return;
438 }
439
440 delete _assets.inserted[key];
441 delete _assets.values[key];
442
443 uint256 index = _assets.indexOf[key];
444 uint256 lastIndex = _assets.keys.length - 1;
445 address lastKey = _assets.keys[lastIndex];
446
447 _assets.indexOf[lastKey] = index;
448 delete _assets.indexOf[key];
449
450 _assets.keys[index] = lastKey;
451 _assets.keys.pop();
452}

Recommendation:

We advise it to be done so by validating whether the index to be removed is equivalent to the lastIndex and in such a case the pop instruction should be performed without the value assignment to storage, saving one SSTORE operation.

Alleviation:

The Platypus team considered this exhibit but opted not to apply a remediation for it.

POO-02C: Function Name Typographic Error

TypeSeverityLocation
Code StyleInformationalPool.sol:L478

Description:

The getEquilibruimCoverageRatio function contains a typographic error.

Example:

contracts/pool/Pool.sol
478function getEquilibruimCoverageRatio() private view returns (uint256) {

Recommendation:

We advise it to be corrected to properly illustrate what it is meant to calculate.

Alleviation:

The typo was corrected in the code.

POO-03C: Mathematical Legibility Enhancement

TypeSeverityLocation
Code StyleInformationalPool.sol:L146, L148, L149, L150, L152

Description:

The Solidity language supports fractional numbers to be represented with an e-based power suffix as long as the resulting value is an integer.

Example:

contracts/pool/Pool.sol
146_slippageParamK = 2 * 10**13; // 0.00002 * ETH_UNIT
147_slippageParamN = 7; // 7
148_c1 = 376927610599998308; // ((k**(1/(n+1))) / (n**((n)/(n+1)))) + (k*n)**(1/(n+1))
149_xThreshold = 329811659274998519; // (k*n)**(1/(n+1))
150_haircutRate = 4 * 10**14; // 0.0004 = 0.04% for intra-aggregate account swap
151_retentionRatio = ETH_UNIT; // 1
152_maxPriceDeviation = 2 * 10**16; // 2% = 0.02 in ETH_UNIT.

Recommendation:

We advise the linked values to be represented as such to better illustrate what they are meant to depict (i.e. 2 * 10**13 would be represented as 0.00002e18).

Alleviation:

The literal assignments have been optimised in readability according to our recommendation.

POO-04C: Memory Usage Optimization

TypeSeverityLocation
Gas OptimizationInformationalPool.sol:L270, L272, L298, L300, L308, L310, L318, L320, L328, L330, L339, L341, L350, L352, L361, L363, L372, L374

Description:

The linked functions read a contract value, adjust it and then emit an event for the adjustment.

Example:

contracts/pool/Pool.sol
268function setDev(address dev) external onlyOwner {
269 require(dev != address(0), 'ZERO');
270 address oldDev = _dev;
271 _dev = dev;
272 emit DevUpdated(oldDev, dev);
273}

Recommendation:

We advise the event to be emitted prior to the adjustment rendering the declaration of an in-memory variable redundant.

Alleviation:

The event emission statements have been optimised accordingly.