scale18 amounts for tokens with rates should always consider the rate - similar to live balances from Balancer v3 - but SOR code (i.e. PathWithAmount) uses TokenAmount, which does not take rate into account.
In order to compensate for that, inner pool math manually apply rates before/after swap calculation.
This is error prone because sometimes scale18 is "live" (i.e. considers rate) and sometimes it isn't.
The suggestion is to refactor tokens with rates to use PoolTokenWithRate and properly apply rates to scale18 amounts.
GyroE pool already follows that logic, so it can be used as reference.
Known pools that should be refactored:
ComposableStable
Gyro2
MetaStable
Note: NOT urgent - since functionality is correct, this is more of a refactor to improve maintainability
scale18amounts for tokens with rates should always consider the rate - similar tolive balancesfrom Balancer v3 - but SOR code (i.e.PathWithAmount) usesTokenAmount, which does not takerateinto account.In order to compensate for that, inner pool math manually apply rates before/after swap calculation.
This is error prone because sometimes scale18 is "live" (i.e. considers rate) and sometimes it isn't.
The suggestion is to refactor tokens with rates to use
PoolTokenWithRateand properly apply rates to scale18 amounts.GyroEpool already follows that logic, so it can be used as reference.Known pools that should be refactored:
ComposableStableGyro2MetaStableNote: NOT urgent - since functionality is correct, this is more of a refactor to improve maintainability