Skip to content

Commit c567d33

Browse files
refactor: assign private function return values to memory
1 parent 87c8cf1 commit c567d33

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

contracts/pool-templates/meta/SwapTemplateMeta.vy

+11-5
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ N_ALL_COINS: constant(int128) = N_COINS + BASE_N_COINS - 1
110110
BASE_PRECISION_MUL: constant(uint256[BASE_N_COINS]) = ___BASE_PRECISION_MUL___
111111
BASE_RATES: constant(uint256[BASE_N_COINS]) = ___BASE_RATES___
112112

113-
# An asset shich may have a transfer fee (USDT)
113+
# An asset which may have a transfer fee (USDT)
114114
FEE_ASSET: constant(address) = 0xdAC17F958D2ee523a2206206994597C13D831ec7
115115

116116
MAX_ADMIN_FEE: constant(uint256) = 10 * 10 ** 9
@@ -311,7 +311,8 @@ def get_D(xp: uint256[N_COINS], amp: uint256) -> uint256:
311311
@view
312312
@internal
313313
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)
315316

316317

317318
@view
@@ -322,7 +323,10 @@ def get_virtual_price() -> uint256:
322323
@dev Useful for calculating profits
323324
@return LP token virtual price normalized to 1e18
324325
"""
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)
326330
# D is in the units similar to DAI (e.g. converted to precision 1e18)
327331
# When balanced, D = n * x_u - total virtual value of the portfolio
328332
token_supply: uint256 = self.token.totalSupply()
@@ -905,7 +909,8 @@ def calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> uint256:
905909
@param i Index value of the coin to withdraw
906910
@return Amount of coin received
907911
"""
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]
909914

910915

911916
@external
@@ -920,9 +925,10 @@ def remove_liquidity_one_coin(_token_amount: uint256, i: int128, _min_amount: ui
920925
"""
921926
assert not self.is_killed # dev: is killed
922927

928+
vp_rate: uint256 = self._vp_rate()
923929
dy: uint256 = 0
924930
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)
926932
assert dy >= _min_amount, "Not enough coins removed"
927933

928934
self.balances[i] -= (dy + dy_fee * self.admin_fee / FEE_DENOMINATOR)

0 commit comments

Comments
 (0)