Skip to content

Commit

Permalink
Merge pull request #274 from curveresearch/pool-state
Browse files Browse the repository at this point in the history
Mutation bugs in `metrics.state_log.pool_state`
  • Loading branch information
allt0ld authored Oct 11, 2023
2 parents f6b49bf + bfb93ae commit 6b44066
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog.d/20231011_132850_philiplu97_pool_state.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changed
-------

- Used copy() in metrics.state_log.pool_state when referencing certain pool objects to avoid mutation bugs.
12 changes: 6 additions & 6 deletions curvesim/metrics/state_log/pool_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def get_cryptoswap_pool_state(pool):
"""Returns pool state for stableswap non-meta pools."""
return {
"D": pool.D,
"balances": pool.balances,
"balances": pool.balances.copy(),
"tokens": pool.tokens,
"price_scale": pool.price_scale,
"_price_oracle": pool._price_oracle, # pylint: disable=protected-access
"price_scale": pool.price_scale.copy(),
"_price_oracle": pool._price_oracle.copy(), # pylint: disable=protected-access
"xcp_profit": pool.xcp_profit,
"xcp_profit_a": pool.xcp_profit_a,
"last_prices": pool.last_prices,
"last_prices": pool.last_prices.copy(),
"last_prices_timestamp": pool.last_prices_timestamp,
"not_adjusted": pool.not_adjusted,
}
Expand All @@ -40,9 +40,9 @@ def get_cryptoswap_pool_state(pool):
def get_stableswap_pool_state(pool):
"""Returns pool state for stableswap non-meta pools."""
return {
"balances": pool.balances,
"balances": pool.balances.copy(),
"tokens": pool.tokens,
"admin_balances": pool.admin_balances,
"admin_balances": pool.admin_balances.copy(),
}


Expand Down

0 comments on commit 6b44066

Please sign in to comment.