@@ -110,7 +110,7 @@ N_ALL_COINS: constant(int128) = N_COINS + BASE_N_COINS - 1
110
110
BASE_PRECISION_MUL: constant (uint256 [BASE_N_COINS]) = ___BASE_PRECISION_MUL___
111
111
BASE_RATES: constant (uint256 [BASE_N_COINS]) = ___BASE_RATES___
112
112
113
- # An asset shich may have a transfer fee (USDT)
113
+ # An asset which may have a transfer fee (USDT)
114
114
FEE_ASSET: constant (address ) = 0xdAC17F958D2ee523a2206206994597C13D831ec7
115
115
116
116
MAX_ADMIN_FEE: constant (uint256 ) = 10 * 10 ** 9
@@ -311,7 +311,8 @@ def get_D(xp: uint256[N_COINS], amp: uint256) -> uint256:
311
311
@view
312
312
@internal
313
313
def get_D_mem (vp_rate: uint256 , _balances: uint256 [N_COINS], amp: uint256 ) -> uint256 :
314
- return self .get_D (self ._xp_mem (vp_rate, _balances), amp)
314
+ xp: uint256 [N_COINS] = self ._xp_mem (vp_rate, _balances)
315
+ return self .get_D (xp, amp)
315
316
316
317
317
318
@view
@@ -322,7 +323,10 @@ def get_virtual_price() -> uint256:
322
323
@dev Useful for calculating profits
323
324
@return LP token virtual price normalized to 1e18
324
325
"""
325
- D: uint256 = self .get_D (self ._xp (self ._vp_rate_ro ()), self ._A ())
326
+ amp: uint256 = self ._A ()
327
+ vp_rate: uint256 = self ._vp_rate_ro ()
328
+ xp: uint256 [N_COINS] = self ._xp (vp_rate)
329
+ D: uint256 = self .get_D (xp, amp)
326
330
# D is in the units similar to DAI (e.g. converted to precision 1e18)
327
331
# When balanced, D = n * x_u - total virtual value of the portfolio
328
332
token_supply: uint256 = self .token.totalSupply ()
@@ -905,7 +909,8 @@ def calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> uint256:
905
909
@param i Index value of the coin to withdraw
906
910
@return Amount of coin received
907
911
"""
908
- return self ._calc_withdraw_one_coin (_token_amount, i, self ._vp_rate_ro ())[0 ]
912
+ vp_rate: uint256 = self ._vp_rate_ro ()
913
+ return self ._calc_withdraw_one_coin (_token_amount, i, vp_rate)[0 ]
909
914
910
915
911
916
@external
@@ -920,9 +925,10 @@ def remove_liquidity_one_coin(_token_amount: uint256, i: int128, _min_amount: ui
920
925
"""
921
926
assert not self .is_killed # dev: is killed
922
927
928
+ vp_rate: uint256 = self ._vp_rate ()
923
929
dy: uint256 = 0
924
930
dy_fee: uint256 = 0
925
- dy, dy_fee = self ._calc_withdraw_one_coin (_token_amount, i, self . _vp_rate () )
931
+ dy, dy_fee = self ._calc_withdraw_one_coin (_token_amount, i, vp_rate )
926
932
assert dy >= _min_amount, "Not enough coins removed "
927
933
928
934
self .balances[i] -= (dy + dy_fee * self .admin_fee / FEE_DENOMINATOR)
0 commit comments