Skip to content

SOR - Make scale18 consistently "live" for v2 poolTokens #1723

@brunoguerios

Description

@brunoguerios

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

Metadata

Metadata

Assignees

Labels

choremaintenance related

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions