Closed chanhosuh closed 1 year ago
Proposed: insert the second code block into SimCurveCryptoPool.prepare_for_run()
Note: this will change the SimCurveCryptoPool end-to-end test results
def prepare_for_run(self, prices):
xcp = self._get_xcp(self.D)
n = self.n
if n == 2:
root = _sqrt_int
elif n == 3:
root = _cbrt
# Get/set initial prices
initial_prices = prices.iloc[0, 0 : n - 1].tolist()
initial_prices = [int(10**18 / p) for p in initial_prices]
self.last_prices = initial_prices
self.price_scale = initial_prices
self._price_oracle = initial_prices
# Set virtual price & xcp profit to 1
self.tokens = xcp
self.xcp_profit = 10**18
self.xcp_profit_a = 10**18
# Upbdate balances, preserving xcp
initial_prices_root = [root(p) for p in initial_prices]
new_D = prod(initial_prices_root) * xcp * n // 10 ** (18 * (n - 1))
balances = self._convert_D_to_balances(new_D)
self.balances = balances
# Recompute and store D & virtual_price
xp = self._xp() # pylint: disable=protected-access
computed_D = newton_D(self.A, self.gamma, xp)
self.D = computed_D
virtual_price = self.get_virtual_price()
self.virtual_price = virtual_price
Set virtual price, xcp profit (regular and admin), to 10**18 in
prepare_for_run
.