forked from LayerZero-Labs/LayerZero-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreasuryV2.sol
68 lines (54 loc) · 1.91 KB
/
TreasuryV2.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
68
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "./interfaces/ILayerZeroTreasury.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "./interfaces/ILayerZeroUltraLightNodeV2.sol";
contract TreasuryV2 is ILayerZeroTreasury, Ownable {
using SafeMath for uint;
uint public nativeBP;
uint public zroFee;
bool public feeEnabled;
bool public zroEnabled;
ILayerZeroUltraLightNodeV2 public uln;
event NativeBP(uint bp);
event ZroFee(uint zroFee);
event FeeEnabled(bool feeEnabled);
event ZroEnabled(bool zroEnabled);
constructor(address _ulnv2) {
uln = ILayerZeroUltraLightNodeV2(_ulnv2);
}
function getFees(bool payInZro, uint relayerFee, uint oracleFee) external view override returns (uint) {
if (feeEnabled) {
if (payInZro) {
require(zroEnabled, "LayerZero: ZRO is not enabled");
return zroFee;
} else {
return relayerFee.add(oracleFee).mul(nativeBP).div(10000);
}
}
return 0;
}
function setFeeEnabled(bool _feeEnabled) external onlyOwner {
feeEnabled = _feeEnabled;
emit FeeEnabled(_feeEnabled);
}
function setZroEnabled(bool _zroEnabled) external onlyOwner {
zroEnabled = _zroEnabled;
emit ZroEnabled(_zroEnabled);
}
function setNativeBP(uint _nativeBP) external onlyOwner {
nativeBP = _nativeBP;
emit NativeBP(_nativeBP);
}
function setZroFee(uint _zroFee) external onlyOwner {
zroFee = _zroFee;
emit ZroFee(_zroFee);
}
function withdrawZROFromULN(address _to, uint _amount) external onlyOwner {
uln.withdrawZRO(_to, _amount);
}
function withdrawNativeFromULN(address payable _to, uint _amount) external onlyOwner {
uln.withdrawNative(_to, _amount);
}
}