-
Notifications
You must be signed in to change notification settings - Fork 4
/
TinyBondsFactory.sol
56 lines (44 loc) · 1.94 KB
/
TinyBondsFactory.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// SPDX-License-Identifier: WTFPL
pragma solidity >=0.8.0;
import {SafeMulticallable} from "solbase/utils/SafeMulticallable.sol";
import {LibClone} from "solbase/utils/LibClone.sol";
import {TinyBonds} from "./TinyBonds.sol";
/// @notice Creates clones of TinyBonds with immutable args.
/// @author 0xClandestine
contract TinyBondsFactory is SafeMulticallable {
/// -----------------------------------------------------------------------
/// Dependencies
/// -----------------------------------------------------------------------
using LibClone for address;
/// -----------------------------------------------------------------------
/// Events
/// -----------------------------------------------------------------------
event MarketCreated(address market);
/// -----------------------------------------------------------------------
/// Immutables
/// -----------------------------------------------------------------------
address public immutable implementation;
constructor() {
implementation = address(new TinyBonds());
}
/// -----------------------------------------------------------------------
/// Factory Logic
/// -----------------------------------------------------------------------
/// @dev Use a multicall if you'd like to create multiple markets in a single call.
function create(bytes32 salt, address outputToken, address inputToken, uint256 term)
external
returns (address market)
{
market = implementation.cloneDeterministic(abi.encode(outputToken, inputToken, term), salt);
emit MarketCreated(market);
}
function predictDeterministicAddress(bytes32 salt, address outputToken, address inputToken, uint256 term)
external
view
returns (address)
{
return implementation.predictDeterministicAddress(
abi.encode(outputToken, inputToken, term), salt, address(this)
);
}
}