primitivefinance / portfolio

Portfolio is an automated market making protocol for implementing custom strategies at the lowest cost possible.

Home Page:https://www.primitive.xyz/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pool fees can be set to be greater than 100%

TomAFrench opened this issue · comments

Here we treat _state.fee as if it were bounded above by 10000.

iteration.feeAmount =
((iteration.remainder > maxInput ? maxInput : iteration.remainder) * _state.fee) / 10_000;

When creating a pool however, you can set its fee/priority fee to an arbitrary uint16 , i.e. fee <= 65535.

function _createPool(
uint24 pairId,
address controller,
uint16 priorityFee,
uint16 fee,
uint16 volatility,
uint16 duration,
uint16 jit,
uint128 maxPrice,
uint128 price
) internal returns (uint64 poolId) {

You can trace this up to the external function multiprocess with no input validation on it. It's then possible to create pools with fees in excess of 100% which will then revert on any swap.

Ah, I see we do this after the fact here.