-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interfaces for erc20 and lendingPool
- Loading branch information
1 parent
05eeafd
commit d46c474
Showing
6 changed files
with
167 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.16; | ||
|
||
import './IStaderConfig.sol'; | ||
|
||
interface IIncentiveController { | ||
|
||
// events | ||
event UpdatedStaderConfig(address staderConfig); | ||
|
||
// functions | ||
function claim(address account) external; | ||
|
||
function onDeposit(address account) external; | ||
|
||
function rewardPerToken() external view returns (uint256); | ||
|
||
function earned(address account) external view returns (uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.16; | ||
|
||
interface ILendingPoolToken { | ||
function mint(address account, uint256 amount) external; | ||
|
||
function burn(address account, uint256 amount) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.16; | ||
|
||
import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol'; | ||
import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol'; | ||
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol'; | ||
|
||
import '../interfaces/IStaderConfig.sol'; | ||
import '../library/UtilLib.sol'; | ||
|
||
contract SDX is Initializable, AccessControlUpgradeable, ERC20Upgradeable, PausableUpgradeable{ | ||
event UpdatedStaderConfig(address indexed _staderConfig); | ||
|
||
IStaderConfig public staderConfig; | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize(address _admin, address _staderConfig) external initializer { | ||
UtilLib.checkNonZeroAddress(_admin); | ||
UtilLib.checkNonZeroAddress(_staderConfig); | ||
|
||
__ERC20_init('Interest bearing SD token', 'SDx'); | ||
__Pausable_init(); | ||
__AccessControl_init(); | ||
|
||
staderConfig = IStaderConfig(_staderConfig); | ||
_grantRole(DEFAULT_ADMIN_ROLE, _admin); | ||
|
||
emit UpdatedStaderConfig(_staderConfig); | ||
} | ||
|
||
/** | ||
* @notice Mints SDx when called by an authorized caller | ||
* @param to the account to mint to | ||
* @param amount the amount of SDx to mint | ||
*/ | ||
function mint(address to, uint256 amount) external whenNotPaused { | ||
UtilLib.onlyStaderContract(msg.sender, staderConfig, staderConfig.LENDING_POOL_CONTRACT()); | ||
|
||
_mint(to, amount); | ||
} | ||
|
||
/** | ||
* @notice Burns SDx when called by an authorized caller | ||
* @param account the account to burn from | ||
* @param amount the amount of SDx to burn | ||
*/ | ||
function burnFrom(address account, uint256 amount) external whenNotPaused { | ||
UtilLib.onlyStaderContract(msg.sender, staderConfig, staderConfig.LENDING_POOL_CONTRACT()); | ||
|
||
_burn(account, amount); | ||
} | ||
|
||
/** | ||
* @dev Triggers stopped state. | ||
* Contract must not be paused. | ||
*/ | ||
function pause() external { | ||
UtilLib.onlyManagerRole(msg.sender, staderConfig); | ||
|
||
_pause(); | ||
} | ||
|
||
/** | ||
* @dev Returns to normal state. | ||
* Contract must be paused | ||
*/ | ||
function unpause() external { | ||
UtilLib.onlyManagerRole(msg.sender, staderConfig); | ||
|
||
_unpause(); | ||
} | ||
|
||
function _beforeTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 amount | ||
) internal override whenNotPaused { | ||
super._beforeTokenTransfer(from, to, amount); | ||
} | ||
|
||
function updateStaderConfig(address _staderConfig) external onlyRole(DEFAULT_ADMIN_ROLE) { | ||
UtilLib.checkNonZeroAddress(_staderConfig); | ||
staderConfig = IStaderConfig(_staderConfig); | ||
emit UpdatedStaderConfig(_staderConfig); | ||
} | ||
} |