Skip to content

Commit

Permalink
update some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Nov 18, 2024
1 parent cf949f5 commit 2044e94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions examples/tokens/ERC20.vy
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(_name: String[32], _symbol: String[32], _decimals: uint8, _supply:
self.balanceOf[msg.sender] = init_supply
self.totalSupply = init_supply
self.minter = msg.sender
log IERC20.Transfer(empty(address), msg.sender, init_supply)
log IERC20.Transfer(sender=empty(address), receiver=msg.sender, value=init_supply)



Expand All @@ -54,7 +54,7 @@ def transfer(_to : address, _value : uint256) -> bool:
# so the following subtraction would revert on insufficient balance
self.balanceOf[msg.sender] -= _value
self.balanceOf[_to] += _value
log IERC20.Transfer(msg.sender, _to, _value)
log IERC20.Transfer(sender=msg.sender, receiver=_to, value=_value)
return True


Expand All @@ -73,7 +73,7 @@ def transferFrom(_from : address, _to : address, _value : uint256) -> bool:
# NOTE: vyper does not allow underflows
# so the following subtraction would revert on insufficient allowance
self.allowance[_from][msg.sender] -= _value
log IERC20.Transfer(_from, _to, _value)
log IERC20.Transfer(sender=_from, receiver=_to, value=_value)
return True


Expand All @@ -89,7 +89,7 @@ def approve(_spender : address, _value : uint256) -> bool:
@param _value The amount of tokens to be spent.
"""
self.allowance[msg.sender][_spender] = _value
log IERC20.Approval(msg.sender, _spender, _value)
log IERC20.Approval(owner=msg.sender, spender=_spender, value=_value)
return True


Expand All @@ -106,7 +106,7 @@ def mint(_to: address, _value: uint256):
assert _to != empty(address)
self.totalSupply += _value
self.balanceOf[_to] += _value
log IERC20.Transfer(empty(address), _to, _value)
log IERC20.Transfer(sender=empty(address), receiver=_to, value=_value)


@internal
Expand All @@ -120,7 +120,7 @@ def _burn(_to: address, _value: uint256):
assert _to != empty(address)
self.totalSupply -= _value
self.balanceOf[_to] -= _value
log IERC20.Transfer(_to, empty(address), _value)
log IERC20.Transfer(sender=_to, receiver=empty(address), value=_value)


@external
Expand Down
14 changes: 7 additions & 7 deletions examples/tokens/ERC4626.vy
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def decimals() -> uint8:
def transfer(receiver: address, amount: uint256) -> bool:
self.balanceOf[msg.sender] -= amount
self.balanceOf[receiver] += amount
log IERC20.Transfer(msg.sender, receiver, amount)
log IERC20.Transfer(sender=msg.sender, receiver=receiver, value=amount)
return True


@external
def approve(spender: address, amount: uint256) -> bool:
self.allowance[msg.sender][spender] = amount
log IERC20.Approval(msg.sender, spender, amount)
log IERC20.Approval(owner=msg.sender, spender=spender, value=amount)
return True


Expand All @@ -72,7 +72,7 @@ def transferFrom(sender: address, receiver: address, amount: uint256) -> bool:
self.allowance[sender][msg.sender] -= amount
self.balanceOf[sender] -= amount
self.balanceOf[receiver] += amount
log IERC20.Transfer(sender, receiver, amount)
log IERC20.Transfer(sender=sender, receiver=receiver, value=amount)
return True


Expand Down Expand Up @@ -137,7 +137,7 @@ def deposit(assets: uint256, receiver: address=msg.sender) -> uint256:

self.totalSupply += shares
self.balanceOf[receiver] += shares
log IERC4626.Deposit(msg.sender, receiver, assets, shares)
log IERC4626.Deposit(sender=msg.sender, owner=receiver, assets=assets, shares=shares)
return shares


Expand Down Expand Up @@ -170,7 +170,7 @@ def mint(shares: uint256, receiver: address=msg.sender) -> uint256:

self.totalSupply += shares
self.balanceOf[receiver] += shares
log IERC4626.Deposit(msg.sender, receiver, assets, shares)
log IERC4626.Deposit(sender=msg.sender, owner=receiver, assets=assets, shares=shares)
return assets


Expand Down Expand Up @@ -207,7 +207,7 @@ def withdraw(assets: uint256, receiver: address=msg.sender, owner: address=msg.s
self.balanceOf[owner] -= shares

extcall self.asset.transfer(receiver, assets)
log IERC4626.Withdraw(msg.sender, receiver, owner, assets, shares)
log IERC4626.Withdraw(sender=msg.sender, receiver=receiver, owner=owner, assets=assets, shares=shares)
return shares


Expand All @@ -233,7 +233,7 @@ def redeem(shares: uint256, receiver: address=msg.sender, owner: address=msg.sen
self.balanceOf[owner] -= shares

extcall self.asset.transfer(receiver, assets)
log IERC4626.Withdraw(msg.sender, receiver, owner, assets, shares)
log IERC4626.Withdraw(sender=msg.sender, receiver=receiver, owner=owner, assets=assets, shares=shares)
return assets


Expand Down
10 changes: 5 additions & 5 deletions examples/tokens/ERC721.vy
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _transferFrom(_from: address, _to: address, _tokenId: uint256, _sender: addr
# Add NFT
self._addTokenTo(_to, _tokenId)
# Log the transfer
log IERC721.Transfer(_from, _to, _tokenId)
log IERC721.Transfer(sender=_from, receiver=_to, token_id=_tokenId)


### TRANSFER FUNCTIONS ###
Expand Down Expand Up @@ -275,7 +275,7 @@ def approve(_approved: address, _tokenId: uint256):
assert (senderIsOwner or senderIsApprovedForAll)
# Set the approval
self.idToApprovals[_tokenId] = _approved
log IERC721.Approval(owner, _approved, _tokenId)
log IERC721.Approval(owner=owner, approved=_approved, token_id=_tokenId)


@external
Expand All @@ -291,7 +291,7 @@ def setApprovalForAll(_operator: address, _approved: bool):
# Throws if `_operator` is the `msg.sender`
assert _operator != msg.sender
self.ownerToOperators[msg.sender][_operator] = _approved
log IERC721.ApprovalForAll(msg.sender, _operator, _approved)
log IERC721.ApprovalForAll(owner=msg.sender, operator=_operator, approved=_approved)


### MINT & BURN FUNCTIONS ###
Expand All @@ -313,7 +313,7 @@ def mint(_to: address, _tokenId: uint256) -> bool:
assert _to != empty(address)
# Add NFT. Throws if `_tokenId` is owned by someone
self._addTokenTo(_to, _tokenId)
log IERC721.Transfer(empty(address), _to, _tokenId)
log IERC721.Transfer(sender=empty(address), receiver=_to, token_id=_tokenId)
return True


Expand All @@ -333,7 +333,7 @@ def burn(_tokenId: uint256):
assert owner != empty(address)
self._clearApproval(owner, _tokenId)
self._removeTokenFrom(owner, _tokenId)
log IERC721.Transfer(owner, empty(address), _tokenId)
log IERC721.Transfer(sender=owner, receiver=empty(address), token_id=_tokenId)


@view
Expand Down

0 comments on commit 2044e94

Please sign in to comment.