Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Feb 23, 2024
1 parent 04e5da6 commit df9320c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions examples/factory/Exchange.vy
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#pragma version >0.3.10

from ethereum.ercs import ERC20
from ethereum.ercs import IERC20


interface Factory:
def register(): nonpayable


token: public(ERC20)
token: public(IERC20)
factory: Factory


@deploy
def __init__(_token: ERC20, _factory: Factory):
def __init__(_token: IERC20, _factory: Factory):
self.token = _token
self.factory = _factory

Expand Down
8 changes: 4 additions & 4 deletions examples/factory/Factory.vy
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma version >0.3.10

from ethereum.ercs import ERC20
from ethereum.ercs import IERC20

interface Exchange:
def token() -> ERC20: view
def token() -> IERC20: view
def receive(_from: address, _amt: uint256): nonpayable
def transfer(_to: address, _amt: uint256): nonpayable


exchange_codehash: public(bytes32)
# Maps token addresses to exchange addresses
exchanges: public(HashMap[ERC20, Exchange])
exchanges: public(HashMap[IERC20, Exchange])


@deploy
Expand Down Expand Up @@ -39,7 +39,7 @@ def register():


@external
def trade(_token1: ERC20, _token2: ERC20, _amt: uint256):
def trade(_token1: IERC20, _token2: IERC20, _amt: uint256):
# Perform a straight exchange of token1 to token 2 (1:1 price)
# NOTE: Any practical implementation would need to solve the price oracle problem
self.exchanges[_token1].receive(msg.sender, _amt)
Expand Down
6 changes: 3 additions & 3 deletions examples/market_maker/on_chain_market_maker.vy
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma version >0.3.10

from ethereum.ercs import ERC20
from ethereum.ercs import IERC20


totalEthQty: public(uint256)
totalTokenQty: public(uint256)
# Constant set in `initiate` that's used to calculate
# the amount of ether/tokens that are exchanged
invariant: public(uint256)
token_address: ERC20
token_address: IERC20
owner: public(address)

# Sets the on chain market maker with its owner, initial token quantity,
Expand All @@ -17,7 +17,7 @@ owner: public(address)
@payable
def initiate(token_addr: address, token_quantity: uint256):
assert self.invariant == 0
self.token_address = ERC20(token_addr)
self.token_address = IERC20(token_addr)
self.token_address.transferFrom(msg.sender, self, token_quantity)
self.owner = msg.sender
self.totalEthQty = msg.value
Expand Down
2 changes: 1 addition & 1 deletion examples/tokens/ERC4626.vy
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ event Withdraw:


@deploy
def __init__(asset: ERC20):
def __init__(asset: IERC20):
self.asset = asset


Expand Down

0 comments on commit df9320c

Please sign in to comment.