-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathShareCollateralToken.sol
More file actions
42 lines (35 loc) · 1.89 KB
/
ShareCollateralToken.sol
File metadata and controls
42 lines (35 loc) · 1.89 KB
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
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
import {ShareTokenLib} from "../lib/ShareTokenLib.sol";
import {ShareCollateralTokenLib} from "../lib/ShareCollateralTokenLib.sol";
import {IShareToken, ShareToken} from "./ShareToken.sol";
import {IVersioned} from "../interfaces/IVersioned.sol";
/// @title ShareCollateralToken
/// @notice ERC20 compatible token representing collateral in Silo
/// @custom:security-contact security@silo.finance
abstract contract ShareCollateralToken is ShareToken {
/// @inheritdoc IShareToken
function mint(address _owner, address /* _spender */, uint256 _amount) external virtual override onlySilo {
_mint(_owner, _amount);
}
/// @inheritdoc IShareToken
function burn(address _owner, address _spender, uint256 _amount) external virtual override onlySilo {
if (_owner != _spender) _spendAllowance(_owner, _spender, _amount);
_burn(_owner, _amount);
}
/// @inheritdoc IVersioned
function VERSION() external pure virtual returns (string memory) { // solhint-disable-line func-name-mixedcase
return "ShareCollateralToken 4.1.3";
}
/// @dev Check if sender is solvent after the transfer
function _afterTokenTransfer(address _sender, address _recipient, uint256 _amount) internal virtual override {
IShareToken.ShareTokenStorage storage $ = ShareTokenLib.getShareTokenStorage();
// for minting or burning, Silo is responsible to check all necessary conditions
// for transfer make sure that _sender is solvent after transfer
if (ShareTokenLib.isTransfer(_sender, _recipient) && $.transferWithChecks) {
bool senderIsSolvent = ShareCollateralTokenLib.isSolventAfterCollateralTransfer(_sender);
require(senderIsSolvent, IShareToken.SenderNotSolventAfterTransfer());
}
ShareToken._afterTokenTransfer(_sender, _recipient, _amount);
}
}