forked from unitprotocol/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unitprotocol#26 from unitprotocol/auction-force-tr…
…ansfer Introduce ForceTransferAssetStore
- Loading branch information
Showing
4 changed files
with
85 additions
and
47 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,44 @@ | ||
// SPDX-License-Identifier: bsl-1.1 | ||
|
||
/* | ||
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]). | ||
*/ | ||
pragma solidity 0.7.6; | ||
|
||
import "../VaultParameters.sol"; | ||
import "../interfaces/IForceTransferAssetStore.sol"; | ||
|
||
|
||
/** | ||
* @title ForceTransferAssetStore | ||
**/ | ||
contract ForceTransferAssetStore is Auth, IForceTransferAssetStore { | ||
|
||
/* | ||
Mapping of assets that require a transfer of at least 1 unit of token | ||
to update internal logic related to staking rewards in case of full liquidation | ||
*/ | ||
mapping(address => bool) public override shouldForceTransfer; | ||
|
||
event ForceTransferAssetAdded(address indexed asset); | ||
|
||
constructor(address _vaultParameters, address[] memory initialAssets) Auth(_vaultParameters) { | ||
for (uint i = 0; i < initialAssets.length; i++) { | ||
require(!shouldForceTransfer[initialAssets[i]], "Unit Protocol: Already exists"); | ||
shouldForceTransfer[initialAssets[i]] = true; | ||
emit ForceTransferAssetAdded(initialAssets[i]); | ||
} | ||
} | ||
|
||
/** | ||
* @notice Only manager is able to call this function | ||
* @dev Mark asset as `shouldForceTransfer` | ||
* @param asset The address of the asset | ||
**/ | ||
function add(address asset) external override onlyManager { | ||
require(!shouldForceTransfer[asset], "Unit Protocol: Already exists"); | ||
require(asset != address(0), "Unit Protocol: ZERO_ADDRESS"); | ||
shouldForceTransfer[asset] = true; | ||
emit ForceTransferAssetAdded(asset); | ||
} | ||
} |
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,4 @@ | ||
interface IForceTransferAssetStore { | ||
function shouldForceTransfer ( address ) external view returns ( bool ); | ||
function add ( address asset ) 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