Skip to content

Commit

Permalink
add some natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Dec 7, 2023
1 parent 1e8dc1a commit 9bace0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion contracts/main/CurveStableSwapMetaNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ def _transfer_out(
):
"""
@notice Transfer a single token from the pool to receiver.
@dev This function is called by `remove_liquidity` and
`remove_liquidity_one_coin`, `_exchange`, `_withdraw_admin_fees` and
`remove_liquidity_imbalance` methods.
@param _coin_idx Index of the token to transfer out
@param _amount Amount of token to transfer out
@param receiver Address to send the tokens to
Expand Down Expand Up @@ -585,6 +588,7 @@ def exchange(
@param j Index value of the coin to receive
@param _dx Amount of `i` being exchanged
@param _min_dy Minimum amount of `j` to receive
@param _receiver Address that receives `j`
@return Actual amount of `j` received
"""
return self._exchange(
Expand Down Expand Up @@ -619,6 +623,7 @@ def exchange_received(
@param j Index value of the coin to receive
@param _dx Amount of `i` being exchanged
@param _min_dy Minimum amount of `j` to receive
@param _receiver Address that receives `j`
@return Actual amount of `j` received
"""
assert asset_type != 2 # dev: exchange_received not supported if pool contains rebasing tokens
Expand Down Expand Up @@ -1858,7 +1863,8 @@ def set_new_fee(_new_fee: uint256, _new_offpeg_fee_multiplier: uint256):
def set_ma_exp_time(_ma_exp_time: uint256, _D_ma_time: uint256):
"""
@notice Set the moving average window of the price oracles.
@param _ma_exp_time Moving average window. It is time_in_seconds / ln(2)
@param _ma_exp_time Moving average window for the price oracle. It is time_in_seconds / ln(2).
@param _D_ma_time Moving average window for the D oracle. It is time_in_seconds / ln(2).
"""
assert msg.sender == factory.admin() # dev: only owner
assert unsafe_mul(_ma_exp_time, _D_ma_time) > 0 # dev: 0 in input values
Expand Down
9 changes: 6 additions & 3 deletions contracts/main/CurveStableSwapNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ def _transfer_in(
@notice Contains all logic to handle ERC20 token transfers.
@param coin_idx Index of the coin to transfer in.
@param dx amount of `_coin` to transfer into the pool.
@param dy amount of `_coin` to transfer out of the pool.
@param sender address to transfer `_coin` from.
@param receiver address to transfer `_coin` to.
@param expect_optimistic_transfer True if contract expects an optimistic coin transfer
Expand Down Expand Up @@ -396,7 +395,8 @@ def _transfer_out(_coin_idx: int128, _amount: uint256, receiver: address):
"""
@notice Transfer a single token from the pool to receiver.
@dev This function is called by `remove_liquidity` and
`remove_liquidity_one`, `_exchange` and `_withdraw_admin_fees` methods.
`remove_liquidity_one_coin`, `_exchange`, `_withdraw_admin_fees` and
`remove_liquidity_imbalance` methods.
@param _coin_idx Index of the token to transfer out
@param _amount Amount of token to transfer out
@param receiver Address to send the tokens to
Expand Down Expand Up @@ -507,6 +507,7 @@ def exchange(
@param j Index value of the coin to receive
@param _dx Amount of `i` being exchanged
@param _min_dy Minimum amount of `j` to receive
@param _receiver Address that receives `j`
@return Actual amount of `j` received
"""
return self._exchange(
Expand Down Expand Up @@ -541,6 +542,7 @@ def exchange_received(
@param j Index value of the coin to receive
@param _dx Amount of `i` being exchanged
@param _min_dy Minimum amount of `j` to receive
@param _receiver Address that receives `j`
@return Actual amount of `j` received
"""
assert not 2 in asset_types # dev: exchange_received not supported if pool contains rebasing tokens
Expand Down Expand Up @@ -1868,7 +1870,8 @@ def set_new_fee(_new_fee: uint256, _new_offpeg_fee_multiplier: uint256):
def set_ma_exp_time(_ma_exp_time: uint256, _D_ma_time: uint256):
"""
@notice Set the moving average window of the price oracles.
@param _ma_exp_time Moving average window. It is time_in_seconds / ln(2)
@param _ma_exp_time Moving average window for the price oracle. It is time_in_seconds / ln(2).
@param _D_ma_time Moving average window for the D oracle. It is time_in_seconds / ln(2).
"""
assert msg.sender == factory.admin() # dev: only owner
assert unsafe_mul(_ma_exp_time, _D_ma_time) > 0 # dev: 0 in input values
Expand Down

0 comments on commit 9bace0d

Please sign in to comment.