-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLedgerFactory.sol
67 lines (59 loc) · 2.04 KB
/
LedgerFactory.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
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./proxy/LedgerProxy.sol";
import "../interfaces/ILedger.sol";
contract LedgerFactory {
// LIDO address
address private immutable LIDO;
// Ledger beacon address
address private immutable LEDGER_BEACON;
/**
* @notice Constructor
* @param _lido - LIDO address
* @param _ledgerBeacon - ledger beacon address
*/
constructor(address _lido, address _ledgerBeacon) {
require(_lido != address(0), "LF: LIDO_ZERO_ADDRESS");
require(_ledgerBeacon != address(0), "LF: BEACON_ZERO_ADDRESS");
LIDO = _lido;
LEDGER_BEACON = _ledgerBeacon;
}
/**
* @notice Create new ledger proxy contract
* @param _stashAccount - stash account address on relay chain
* @param _controllerAccount - controller account on relay chain
* @param _vKSM - vKSM contract address
* @param _controller - xcmTransactor(relaychain calls relayer) contract address
* @param _minNominatorBalance - minimal allowed nominator balance
* @param _minimumBalance - minimal allowed active balance for ledger
* @param _maxUnlockingChunks - maximum amount of unlocking chunks
*/
function createLedger(
bytes32 _stashAccount,
bytes32 _controllerAccount,
address _vKSM,
address _controller,
uint128 _minNominatorBalance,
uint128 _minimumBalance,
uint256 _maxUnlockingChunks
) external returns (address) {
require(msg.sender == LIDO, "LF: ONLY_LIDO");
address ledger = address(
new LedgerProxy(
LEDGER_BEACON,
abi.encodeWithSelector(
ILedger.initialize.selector,
_stashAccount,
_controllerAccount,
_vKSM,
_controller,
_minNominatorBalance,
LIDO,
_minimumBalance,
_maxUnlockingChunks
)
)
);
return ledger;
}
}