forked from martriay/scAMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Registry.sol
29 lines (21 loc) · 862 Bytes
/
Registry.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./Exchange.sol";
contract Registry {
mapping(address => address) public tokenToExchange;
event NewExchange(address indexed token, address indexed exchange);
function createExchange(address _tokenAddress) public returns (address) {
require(_tokenAddress != address(0), "invalid token address");
require(
tokenToExchange[_tokenAddress] == address(0),
"exchange already exists"
);
Exchange exchange = new Exchange(_tokenAddress);
tokenToExchange[_tokenAddress] = address(exchange);
emit NewExchange(_tokenAddress, address(exchange));
return address(exchange);
}
function getExchange(address _tokenAddress) public view returns (address) {
return tokenToExchange[_tokenAddress];
}
}