curve-pool-registry icon indicating copy to clipboard operation
curve-pool-registry copied to clipboard

Meta Calculator: implementation of bulk get_dy and get_dx

Open samwerner opened this issue 4 years ago • 0 comments

Feature

This PR adds full functionality for the meta pool calculator.

The following was implemented:

  • Fix small bugs in bulk get_dy (only in meta calc; these weren't tested before)
  • Add tests for bulk get_dy for meta calculator
  • Add bulk get_dx in meta calculator
  • Add tests for bulk get_dx for meta calculator

Tests

The added tests for the meta calculator can be found in: tests/local/unitary/Swaps/test_calculator_meta.py

For both, get_dy() and get_dx() of the meta calculator, tests were added for:

  • Base pool token - Base pool token swaps
  • Base pool token - Meta pool token swaps
  • Meta pool token - Meta LP token swaps
  • Meta pool token - Base pool token swaps
  • Unsupported pool sizes (raise)

Note: There are two tests disabled. In get_dx(), there is some calculation error regarding the base pool fees, which results in small differences between the expected and actual outputs. This issue can be reproduced by uncommenting the pytest decorators @pytest.mark.skip().

If the base pool fee is set to 0, via swap._set_fee(0) in the two tests, the expected and actual results in the tests are fine, apart from small floating-point differences.

The base fee computation bug is within the logic for when dx is the meta pool token and dy a base pool token (block starting at line 411 in CurveCalcMeta.vy) and for when dx is a base pool token and dy the meta pool token (block starting at line 392 in CurveCalcMeta.vy).

samwerner avatar Jan 12 '21 15:01 samwerner