This repository has been archived by the owner on Jun 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
MigrationOffsetSupply.sol
68 lines (50 loc) · 2.13 KB
/
MigrationOffsetSupply.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
pragma solidity 0.8.15;
import "modules/SPPLY/SPPLY.v1.sol";
import {CustomSupply} from "modules/SPPLY/submodules/CustomSupply.sol";
import {IgOHM} from "src/interfaces/IgOHM.sol";
/// @title MigrationOffsetSupply
/// @author 0xJem
/// @notice SPPLY submodule representing a manual adjustment for OHM in the migration contract
contract MigrationOffsetSupply is CustomSupply {
/// @notice The quantity of gOHM (in native decimals) to offset in the migration contract
uint256 public gOhmOffset;
// ========== EVENTS ========== //
event GOhmOffsetUpdated(uint256 gOhmOffset_);
// ========== CONSTRUCTOR ========== //
constructor(
Module parent_,
address source_,
uint256 gOhmOffset_
) CustomSupply(parent_, 0, 0, 0, 0, source_) {
gOhmOffset = gOhmOffset_;
emit GOhmOffsetUpdated(gOhmOffset_);
}
// ========== SUBMODULE SETUP ========== //
/// @inheritdoc Submodule
function SUBKEYCODE() public pure override returns (SubKeycode) {
return toSubKeycode("SPPLY.MIGOFFSET");
}
/// @inheritdoc Submodule
function VERSION() external pure override returns (uint8 major, uint8 minor) {
major = 1;
minor = 0;
}
/// @inheritdoc Submodule
function INIT() external override onlyParent {}
// ========== DATA FUNCTIONS ========== //
/// @inheritdoc SupplySubmodule
/// @dev Calculated as the quantity of gOHM (`gOhmOffset`) multiplied by the current index
function getProtocolOwnedTreasuryOhm() external view override returns (uint256) {
// Convert from gOHM to OHM using the current index
IgOHM gOHM = IgOHM(address(SPPLYv1(address(parent)).gohm()));
return gOHM.balanceFrom(gOhmOffset);
}
// ========== ADMIN FUNCTIONS ========== //
/// @notice Set the quantity of gOHM (in native decimals) to offset in the migration contract
///
/// @param gOhmOffset_ The new quantity of gOHM to offset
function setGOhmOffset(uint256 gOhmOffset_) external onlyParent {
gOhmOffset = gOhmOffset_;
emit GOhmOffsetUpdated(gOhmOffset_);
}
}