Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/core/STBL_Core.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/metatx/ERC2771ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "../interfaces/ISTBL_Register.sol";
import "../interfaces/ISTBL_USST.sol";
import "../interfaces/ISTBL_YLD.sol";
import "../interfaces/ISTBL_Core.sol";
import "../lib/STBL_AssetDefinitionLib.sol";
import "../lib/STBL_Decoder.sol";
import "../lib/STBL_Errors.sol";
/**
* @title STBL Protocol Core Contract
* @author STBL Protocol Team
* @notice Core contract managing the issuance and redemption of USST and YLD tokens
* @dev Implements iSTBL_Core interface and handles the core functionality of the STBL Protocol.
* This contract uses the UUPS proxy pattern for upgradability and supports meta-transactions
* through ERC2771Context.
*/
contract STBL_Core is
Initializable,
iSTBL_Core,
AccessControlUpgradeable,
ERC2771ContextUpgradeable,
UUPSUpgradeable
{
using STBL_AssetDefinitionLib for AssetDefinition;
using STBL_Decoder for bytes;
/** @notice Role identifier for upgrade functionality */
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
/** @notice Version number of the contract implementation */
uint256 private _version;
/**
* @notice Reference to the STBL Registry contract
* @dev Stores asset definitions and configuration data
*/
iSTBL_Register private registry;
/**
* @notice Reference to the USST token contract
* @dev Represents the fungible stablecoin token component of the protocol
*/
iSTBL_USST private USST;
/**
* @notice Reference to the YLD token contract
* @dev Represents the non-fungible yield-bearing token component of the protocol
*/
iSTBL_YLD private YLD;
/**
* @notice Address of the trusted forwarder for meta-transactions
* @dev Used to verify and process transactions where the sender is not the original transaction origin.
* Set to address(0) to disable meta-transaction support.
*/
address private trustedForwarderAddress;
/**
* @notice Modifier to check if caller is a valid issuer for an asset
* @param _assetID The asset ID to check issuer permissions for
* @dev Reverts if caller is not authorized issuer or asset is not active
* @custom:error STBL_UnauthorizedIssuer Thrown when caller is not authorized as an issuer
* @custom:error STBL_AssetDisabled Thrown when the asset is not active
*/
modifier isValidIssuer(uint256 _assetID) {
AssetDefinition memory AssetData = registry.fetchAssetData(_assetID);
if (!AssetData.isIssuer(msg.sender)) revert STBL_UnauthorizedIssuer();
if (!AssetData.isActive()) revert STBL_AssetDisabled(_assetID);
_;
}
/**
* @dev Storage gap for future upgrades
* @notice Reserved storage space to allow for layout changes in future versions.
* This gap ensures that new storage variables can be added without affecting
* the storage layout of existing variables.
*/
uint256[64] private __gap;
/**
* @dev Constructor that disables initializers to prevent implementation contract initialization
* @notice This constructor is marked as unsafe for upgrades but is required for proper proxy pattern implementation.
* The implementation contract itself should never be initialized, only proxy contracts should be.
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor() ERC2771ContextUpgradeable(address(0)) {
_disableInitializers();
}
/**
* @notice Initializes the STBL Core contract
* @dev Sets up access control roles, connects to registry and token contracts, and configures trusted forwarder.
* Can only be called once during deployment. This replaces the constructor for upgradeable contracts.
* @param _registry Address of the STBL Registry contract
*/
function initialize(address _registry) public initializer {
__AccessControl_init();
__UUPSUpgradeable_init();
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
_grantRole(UPGRADER_ROLE, _msgSender());
_setRoleAdmin(UPGRADER_ROLE, DEFAULT_ADMIN_ROLE);
registry = iSTBL_Register(_registry);
USST = iSTBL_USST(registry.fetchUSSTToken());
YLD = iSTBL_YLD(registry.fetchYLDToken());
trustedForwarderAddress = address(0);
}
/**
* @notice Authorizes upgrades to the contract implementation
* @dev Only callable by addresses with UPGRADER_ROLE. Increments version number on each upgrade.
* @param newImplementation Address of the new implementation contract (parameter currently unused)
*/
function _authorizeUpgrade(
address newImplementation
) internal override onlyRole(UPGRADER_ROLE) {
_version = _version + 1;
emit ContractUpgraded(newImplementation);
}
/**
* @notice Returns the current implementation version
* @dev Useful for tracking upgrade versions and ensuring correct implementation is deployed
* @return Current version number of the implementation
*/
function version() external view returns (uint256) {
return _version;
}
/**
* @notice Updates the trusted forwarder address for meta-transactions
* @dev Only callable by addresses with DEFAULT_ADMIN_ROLE. Setting to address(0) disables meta-transactions.
* @param _newForwarder Address of the new trusted forwarder
* @custom:event TrustedForwarderUpdated Emitted when the forwarder is updated
*/
function updateTrustedForwarder(
address _newForwarder
) external onlyRole(DEFAULT_ADMIN_ROLE) {
address previousForwarder = trustedForwarderAddress;
trustedForwarderAddress = _newForwarder;
emit TrustedForwarderUpdated(previousForwarder, _newForwarder);
}
/**
* @notice Issues USST and YLD tokens for a given asset
* @dev Only callable by the asset issuer. Checks deposit limits before minting.
* Mints fungible USST tokens representing the stable value and a non-fungible YLD token
* containing the asset metadata and yield information.
* @param _to Address to receive the tokens
* @param _metadata Metadata associated with the YLD NFT, including asset ID and stable value
* @return nftID The ID of the minted YLD token (NFT)
* @custom:event putEvent Emitted when tokens are issued
* @custom:error STBL_MaxLimitReached Thrown when deposit limit for asset has been reached
* @custom:error STBL_UnauthorizedIssuer Thrown when caller is not authorized as an issuer
* @custom:error STBL_AssetDisabled Thrown when the asset is not active
*/
function put(
address _to,
YLD_Metadata memory _metadata
) external isValidIssuer(_metadata.assetID) returns (uint256) {
if (
registry.isDepositLimitReached(
_metadata.assetID,
_metadata.stableValueNet
)
) {
revert STBL_MaxLimitReached();
}
registry.incrementAssetDeposits(
_metadata.assetID,
_metadata.stableValueNet
);
USST.mint(_to, _metadata.stableValueNet);
uint256 nftID = YLD.mint(_to, _metadata);
emit putEvent(_metadata.assetID, _to, _metadata, nftID);
return nftID;
}
/**
* @notice Redeems USST and YLD tokens for a given asset
* @dev Only callable by the asset issuer. Burns both the fungible USST tokens and the
* non-fungible YLD token, then decrements the asset deposit tracking.
* @param _assetID The ID of the asset being redeemed
* @param _from Address from which tokens are being redeemed
* @param _tokenID The ID of the YLD token (NFT) being redeemed
* @param _value The amount of USST tokens to burn during redemption
* @custom:event exitEvent Emitted when tokens are redeemed
* @custom:error STBL_UnauthorizedIssuer Thrown when caller is not authorized as an issuer
* @custom:error STBL_AssetDisabled Thrown when the asset is not active
*/
function exit(
uint256 _assetID,
address _from,
uint256 _tokenID,
uint256 _value
) external isValidIssuer(_assetID) {
USST.burn(_from, _value);
YLD.burn(_from, _tokenID);
registry.decrementAssetDeposits(_assetID, _value);
emit exitEvent(_assetID, _from, _value, _tokenID);
}
/**
* @notice Retrieves the USST token contract address
* @dev Returns the address of the fungible stablecoin token contract
* @return The address of the USST token contract
*/
function fetchUSPToken() external view returns (address) {
return address(USST);
}
/**
* @notice Retrieves the YLD token contract address
* @dev Returns the address of the non-fungible yield token contract
* @return The address of the YLD token contract
*/
function fetchUSIToken() external view returns (address) {
return address(YLD);
}
/**
* @notice Retrieves the registry contract address
* @dev Returns the address of the STBL Registry contract that manages asset definitions
* @return The address of the registry contract
*/
function fetchRegistry() external view returns (address) {
return address(registry);
}
/**
* @notice Returns the address of the trusted forwarder for meta-transactions
* @dev Implementation of the virtual function from ERC2771Context.
* Returns address(0) if meta-transactions are disabled.
* @return Address of the trusted forwarder
*/
function trustedForwarder() public view virtual override returns (address) {
return trustedForwarderAddress;
}
/**
* @notice Override to resolve inheritance conflict between ERC2771Context and Context
* @dev Returns the actual sender of the transaction, accounting for meta-transactions.
* If the transaction was sent through a trusted forwarder, extracts the real sender
* from the calldata suffix.
* @return The actual sender address
*/
function _msgSender()
internal
view
override(ContextUpgradeable, ERC2771ContextUpgradeable)
returns (address)
{
return ERC2771ContextUpgradeable._msgSender();
}
/**
* @notice Override to resolve inheritance conflict between ERC2771Context and Context
* @dev Returns the actual calldata of the transaction, accounting for meta-transactions.
* If the transaction was sent through a trusted forwarder, removes the sender address
* from the end of the calldata.
* @return The actual transaction calldata
*/
function _msgData()
internal
view
override(ContextUpgradeable, ERC2771ContextUpgradeable)
returns (bytes calldata)
{
return ERC2771ContextUpgradeable._msgData();
}
/**
* @notice Override to resolve inheritance conflict for ERC2771Context
* @dev Returns the length of the context suffix for meta-transaction support.
* The suffix contains the real sender address when using trusted forwarders.
* @return The length of the context suffix in bytes
*/
function _contextSuffixLength()
internal
view
override(ContextUpgradeable, ERC2771ContextUpgradeable)
returns (uint256)
{
return ERC2771ContextUpgradeable._contextSuffixLength();
}
}
"
},
"node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
"
},
"node_modules/@openzeppelin/contracts-upgradeable/metatx/ERC2771ContextUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (metatx/ERC2771Context.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Context variant with ERC-2771 support.
*
* WARNING: Avoid using this pattern in contracts that rely in a specific calldata length as they'll
* be affected by any forwarder whose `msg.data` is suffixed with the `from` address according to the ERC-2771
* specification adding the address size in bytes (20) to the calldata size. An example of an unexpected
* behavior could be an unintended fallback (or another function) invocation while trying to invoke the `receive`
* function only accessible if `msg.data.length == 0`.
*
* WARNING: The usage of `delegatecall` in this contract is dangerous and may result in context corruption.
* Any forwarded request to this contract triggering a `delegatecall` to itself will result in an invalid {_msgSender}
* recovery.
*/
abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable _trustedForwarder;
/**
* @dev Initializes the contract with a trusted forwarder, which will be able to
* invoke functions on this contract on behalf of other accounts.
*
* NOTE: The trusted forwarder can be replaced by overriding {trustedForwarder}.
*/
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address trustedForwarder_) {
_trustedForwarder = trustedForwarder_;
}
/**
* @dev Returns the address of the trusted forwarder.
*/
function trustedForwarder() public view virtual returns (address) {
return _trustedForwarder;
}
/**
* @dev Indicates whether any particular address is the trusted forwarder.
*/
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return forwarder == trustedForwarder();
}
/**
* @dev Override for `msg.sender`. Defaults to the original `msg.sender` whenever
* a call is not performed by the trusted forwarder or the calldata length is less than
* 20 bytes (an address length).
*/
function _msgSender() internal view virtual override returns (address) {
uint256 calldataLength = msg.data.length;
uint256 contextSuffixLength = _contextSuffixLength();
if (calldataLength >= contextSuffixLength && isTrustedForwarder(msg.sender)) {
unchecked {
return address(bytes20(msg.data[calldataLength - contextSuffixLength:]));
}
} else {
return super._msgSender();
}
}
/**
* @dev Override for `msg.data`. Defaults to the original `msg.data` whenever
* a call is not performed by the trusted forwarder or the calldata length is less than
* 20 bytes (an address length).
*/
function _msgData() internal view virtual override returns (bytes calldata) {
uint256 calldataLength = msg.data.length;
uint256 contextSuffixLength = _contextSuffixLength();
if (calldataLength >= contextSuffixLength && isTrustedForwarder(msg.sender)) {
unchecked {
return msg.data[:calldataLength - contextSuffixLength];
}
} else {
return super._msgData();
}
}
/**
* @dev ERC-2771 specifies the context as being a single address (20 bytes).
*/
function _contextSuffixLength() internal view virtual override returns (uint256) {
return 20;
}
}
"
},
"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}
"
},
"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
"
},
"contracts/interfaces/ISTBL_Register.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "../lib/STBL_Structs.sol";
/** @title STBL Register Interface
* @notice Interface for managing asset registrations and configurations in the STBL protocol
* @dev Inherits from OpenZeppelin's IAccessControl for role-based access control
*/
interface iSTBL_Register is IAccessControl {
/** @notice Emitted when the Core contract address is updated
* @param _Core The new Core contract address
*/
event CoreUpdateEvent(address _Core);
/** @notice Emitted when the treasury address is updated
* @param _treasury The new treasury address
*/
event TreasuryUpdateEvent(address _treasury);
/** @notice Emitted when a new asset is added to the registry
* @param _id The ID of the added asset
* @param _Assetdata The asset definition data
*/
event AddAssetEvent(uint256 indexed _id, AssetDefinition _Assetdata);
/** @notice Emitted when an asset is setup with contract addresses and configuration
* @param _id The ID of the setup asset
* @param _Assetdata The complete asset definition containing all configuration parameters including
* contract addresses, fee structures, limits, and durations
*/
event SetupAssetEvent(uint256 indexed _id, AssetDefinition _Assetdata);
/** @notice Emitted when an asset's cut percentage is updated
* @param _id The ID of the asset
* @param _cut The new cut percentage value
*/
event CutUpdateEvent(uint256 indexed _id, uint256 _cut);
/** @notice Emitted when an asset's limit is updated
* @param _id The ID of the asset
* @param _limit The new limit value
*/
event LimitUpdateEvent(uint256 indexed _id, uint256 _limit);
/** @notice Emitted when an asset's fees are updated
* @param _id The ID of the asset
* @param _depositFee The new deposit fee value in basis points
* @param _withdrawFee The new withdrawal fee value in basis points
* @param _insuranceFee The new insurance fee value in basis points
* @param _yieldFees The new yield fee value in basis points
*/
event FeeUpdateEvent(
uint256 indexed _id,
uint256 _depositFee,
uint256 _withdrawFee,
uint256 _insuranceFee,
uint256 _yieldFees
);
/** @notice Emitted when an asset's duration parameters are updated
* @param _id The ID of the asset
* @param _duration The new main duration value in seconds
* @param _yieldDuration The new yield duration value in seconds
*/
event durationUpdateEvent(
uint256 indexed _id,
uint256 _duration,
uint256 _yieldDuration
);
/** @notice Emitted when an additional buffer for an asset is updated
* @param _id The ID of the asset
* @param _data Additional buffer data stored as bytes
*/
event AdditionalBufferUpdateEvent(uint256 indexed _id, bytes _data);
/** @notice Emitted when an asset's oracle address is updated
* @param _id The ID of the asset
* @param _oracle The new oracle address for price feeds
*/
event OracleUpdateEvent(uint256 indexed _id, address _oracle);
/** @notice Emitted when an asset's state is updated
* @param _id The ID of the asset
* @param _state The new state of the asset (enum AssetStatus)
*/
event AssetStateUpdateEvent(uint256 indexed _id, AssetStatus _state);
/** @notice Event emitted when asset deposits are incremented
* @param assetId The ID of the asset
* @param amount The amount incremented
*/
event AssetDepositIncrementEvent(uint256 indexed assetId, uint256 amount);
/** @notice Event emitted when asset deposits are decremented
* @param assetId The ID of the asset
* @param amount The amount decremented
*/
event AssetDepositDecrementEvent(uint256 indexed assetId, uint256 amount);
/** @notice Event emitted when a trusted forwarder is updated
* @param previousForwarder The address of the previous trusted forwarder
* @param newForwarder The address of the new trusted forwarder
* @dev Indicates a change in the trusted forwarder for meta-transactions
*/
event TrustedForwarderUpdated(
address indexed previousForwarder,
address indexed newForwarder
);
/**
* @notice Emitted when the contract implementation is upgraded
* @dev Triggered during an upgrade of the contract to a new implementation
* @param newImplementation Address of the new implementation contract
*/
event ContractUpgraded(address newImplementation);
/** @notice Sets the Core contract address
* @dev Only callable by admin role
* @param _Core The new Core contract address
*/
function setCore(address _Core) external;
/** @notice Sets the treasury address
* @dev Only callable by admin role
* @param _treasury The new treasury address
*/
function setTreasury(address _treasury) external;
/** @notice Adds a new asset to the registry
* @dev Only callable by admin role
* @param _name The name of the asset
* @param _desc Description of the asset
* @param _type Asset type identifier
* @param _aggType Aggregation type flag
* @return The asset ID of the newly added asset
*/
function addAsset(
string memory _name,
string memory _desc,
uint8 _type,
bool _aggType
) external returns (uint256);
/** @notice Sets up an asset with contract addresses and configuration parameters
* @dev Only callable by admin role and allows setting all key parameters for an asset
* @param _id The unique identifier of the asset to configure
* @param _contractAddr The primary token contract address for the asset
* @param _issuanceAddr Address responsible for issuing the asset tokens
* @param _distAddr Address of the reward distribution contract
* @param _vaultAddr Address of the asset's vault contract
* @param _oracle Address of the price oracle for the asset
* @param _cut Percentage cut applied to the asset's transactions
* @param _limit Maximum value/cap for the asset
* @param _depositFee Fee charged for depositing the asset (in basis points)
* @param _withdrawFee Fee charged for withdrawing the asset (in basis points)
* @param _yieldFee Fee applied to yield generation (in basis points)
* @param _insuranceFee Insurance fee applied (in basis points)
* @param _duration Main duration parameter for protocol operations (in seconds)
* @param _yieldDuration Duration specifically for yield calculations (in seconds)
* @param _additionalBytes Additional configuration data stored as bytes
* @custom:error Pi_SetupAlreadyDone if the asset has already been set up
* @custom:error Pi_InvalidAssetSetup if the asset ID is invalid
* @custom:error Pi_InvalidFeePercentage if any fee exceeds 100% (10000 basis points)
* @custom:event SetupAssetEvent emitted when the asset is successfully set up
*/
function setupAsset(
uint256 _id,
address _contractAddr,
address _issuanceAddr,
address _distAddr,
address _vaultAddr,
address _oracle,
uint256 _cut,
uint256 _limit,
uint256 _depositFee,
uint256 _withdrawFee,
uint256 _yieldFee,
uint256 _insuranceFee,
uint256 _duration,
uint256 _yieldDuration,
bytes memory _additionalBytes
) external;
/** @notice Sets the cut percentage for an asset
* @dev Only callable by admin role
* @param _id The ID of the asset
* @param _cut The new cut percentage
*/
function setCut(uint256 _id, uint256 _cut) external;
/** @notice Sets the limit for an asset
* @dev Only callable by admin role
* @param _id The ID of the asset
* @param _limit The new limit value
*/
function setLimit(uint256 _id, uint256 _limit) external;
/** @notice Sets the fee structure for an asset
* @dev Only callable by admin role, all fees are in basis points (10000 = 100%)
* @param _id The ID of the asset
* @param _depositFee The new deposit fee percentage in basis points
* @param _withdrawFee The new withdrawal fee percentage in basis points
* @param _yieldFee The new yield fee percentage in basis points
* @param _insuranceFee The new insurance fee percentage in basis points
* @custom:error Pi_InvalidFeePercentage if any fee exceeds 100% (10000 basis points)
*/
function setFees(
uint256 _id,
uint256 _depositFee,
uint256 _withdrawFee,
uint256 _yieldFee,
uint256 _insuranceFee
) external;
/** @notice Sets the duration parameters for a specific asset
* @dev Only callable by admin role
* @param _id The ID of the asset to update durations for
* @param _duration The main duration parameter for the asset's operations, measured in seconds
* @param _yieldduration The duration parameter specifically for yield calculations, measured in seconds
*/
function setDurations(
uint256 _id,
uint256 _duration,
uint256 _yieldduration
) external;
/** @notice Sets additional buffer data for an asset
* @dev Only callable by admin role
* @param _id The ID of the asset
* @param _data Additional buffer data to store as bytes
*/
function setAdditionalBuffer(uint256 _id, bytes memory _data) external;
/** @notice Sets the oracle address for an asset
* @dev Only callable by admin role
* @param _id The ID of the asset
* @param _oracle The new oracle address
*/
function setOracle(uint256 _id, address _oracle) external;
/** @notice Disables an asset in the registry
* @dev Only callable by admin role
* @param _id Asset ID to disable
*/
function disableAsset(uint256 _id) external;
/** @notice Enables a previously disabled asset
* @dev Only callable by admin role
* @param _id Asset ID to enable
*/
function enableAsset(uint256 _id) external;
/** @notice Increments the total deposits for a specific asset
* @dev Only callable by admin or authorized contracts
* @param _id The ID of the asset to increment deposits for
* @param _amount The amount to increment deposits by
*/
function incrementAssetDeposits(uint256 _id, uint256 _amount) external;
/** @notice Decrements the total deposits for a specific asset
* @dev Only callable by Core contract
* @param _id The ID of the asset to decrement deposits for
* @param _amount The amount to decrement deposits by
*/
function decrementAssetDeposits(uint256 _id, uint256 _amount) external;
/** @notice Updates the trusted forwarder address for meta-transactions
* @dev Only callable by admin role, updates the address used for ERC2771 meta-transactions
* @param _newForwarder The new trusted forwarder address to be used
* @custom:event Emits TrustedForwarderUpdated with previous and new forwarder addresses
*/
function updateTrustedForwarder(address _newForwarder) external;
/** @notice Retrieves the complete data for a specific asset
* @param _id Asset ID to query
* @return The AssetDefinition struct containing all asset data
*/
function fetchAssetData(
uint256 _id
) external view returns (AssetDefinition memory);
/** @notice Retrieves specific element of asset data based on flag
* @dev Flag values: 0=name, 1=description, 2=contractType, 3=isAggregated, 4=isDisabled,
* 5=isSetup, 6=cut, 7=limit, 8=token, 9=issuer, 10=rewardDistributor, 11=vault
* @param _id The ID of the asset to fetch from
* @param _flag The flag indicating which element to fetch
* @return The requested element value encoded as bytes
*/
function fetchAssetElement(
uint256 _id,
uint8 _flag
) external view returns (bytes memory);
/** @notice Fetches the USST-Pegged token contract address used in the system
* @dev This represents the main stablecoin contract address
* @return The contract address of the USD-Pegged token
*/
function fetchUSSTToken() external view returns (address);
/** @notice Fetches the USD-Interest token contract address used in the system
* @dev This represents the interest-bearing stablecoin contract address
* @return The contract address of the USD-Interest token
*/
function fetchYLDToken() external view returns (address);
/** @notice Retrieves the Core contract address
* @return The address of the Core contract
*/
function fetchCore() external view returns (address);
/** @notice Retrieves the treasury address
* @return The address of the treasury contract
*/
function fetchTreasury() external view returns (address);
/** @notice Retrieves the current counter value
* @dev The counter tracks the total number of assets added to the registry
* @return The current counter value
*/
function fetchCounter() external view returns (uint256);
/** @notice Retrieves the total deposit amount for a specific asset
* @param _assetID The ID of the asset to query
* @return The total amount deposited for the specified asset
*/
function fetchDeposits(uint256 _assetID) external view returns (uint256);
/** @notice Checks if adding a deposit amount would exceed the asset's deposit limit
* @param _assetID The ID of the asset to check deposit limit for
* @param _amount The amount proposed to be deposited
* @return True if the deposit limit would be exceeded, false otherwise
*/
function isDepositLimitReached(
uint256 _assetID,
uint256 _amount
) external view returns (bool);
/** @notice Returns the address of the trusted forwarder for meta-transactions
* @dev Used by ERC2771Context to validate meta-transaction relayers
* @return The address of the current trusted forwarder
*/
function trustedForwarder() external view returns (address);
}
"
},
"contracts/interfaces/ISTBL_USST.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
/**
* @title STBL USST Token Interface
* @notice Interface for the STBL USST stablecoin token
* @dev Extends ERC20 and AccessControl functionality
*/
interface iSTBL_USST is IERC20, IERC20Permit, IAccessControl {
/** @notice Event emitted when an address is blacklisted */
event Blacklisted(address indexed account);
/** @notice Event emitted when an address is unblacklisted */
event Unblacklisted(address indexed account);
/** @notice Event emitted when tokens are minted via protocol */
event MintEvent(address indexed to, uint256 amount);
/** @notice Event emitted when tokens are burned via protocol */
event BurnEvent(address indexed from, uint256 amount);
/** @notice Event emitted when tokens are minted via bridge */
event BridgeMint(address indexed to, uint256 amount, bytes _data);
/** @notice Event emitted when tokens are burned via bridge */
event BridgeBurn(address indexed from, uint256 amount, bytes _data);
/** @notice Event emitted when a trusted forwarder is updated
* @param previousForwarder The address of the previous trusted forwarder
* @param newForwarder The address of the new trusted forwarder
* @dev Indicates a change in the trusted forwarder for meta-transactions
*/
event TrustedForwarderUpdated(
address indexed previousForwarder,
address indexed newForwarder
);
/**
* @notice Emitted when the contract implementation is upgraded
* @dev Triggered during an upgrade of the contract to a new implementation
* @param newImplementation Address of the new implementation contract
*/
event ContractUpgraded(address newImplementation);
/** @notice Checks if an address is blacklisted
* @param _account Address to check
* @return Whether the address is blacklisted
*/
function isBlacklisted(address _account) external view returns (bool);
/** @notice Adds an address to the blacklist
* @param _account Address to be blacklisted
* @dev Only callable by addresses with BLACKLISTER_ROLE
*/
function enableBlacklist(address _account) external;
/** @notice Removes an address from the blacklist
* @param _account Address to be unblacklisted
* @dev Only callable by addresses with BLACKLISTER_ROLE
*/
function disableBlacklist(address _account) external;
/**
* @notice Mints new tokens to a specified address
* @param _to Address to receive the minted tokens
* @param _amt Amount of tokens to mint
*/
function mint(address _to, uint256 _amt) external;
/**
* @notice Burns tokens from a specified address
* @param _from Address from which to burn tokens
* @param _amt Amount of tokens to burn
*/
function burn(address _from, uint256 _amt) external;
/**
* @notice Mints new tokens for bridge operations
* @dev Only callable by addresses with BRIDGE_ROLE when the contract is not paused.
* Used for cross-chain bridge operations. Emits a BridgeMint event with additional data.
* @param _to The address that will receive the minted tokens
* @param _amt The amount of tokens to mint
* @param _data Additional data related to the bridge operation (e.g., source chain info)
* @custom:event Emits BridgeMint event
*/
function bridgeMint(address _to, uint256 _amt, bytes memory _data) external;
/**
* @notice Burns tokens for bridge operations
* @dev Only callable by addresses with BRIDGE_ROLE when the contract is not paused.
* Used for cross-chain bridge operations. Emits a BridgeBurn event with additional data.
* @param _from The address from which tokens will be burned
* @param _amt The amount of tokens to burn
* @param _data Additional data related to the bridge operation (e.g., destination chain info)
* @custom:event Emits BridgeBurn event
*/
function bridgeBurn(
address _from,
uint256 _amt,
bytes memory _data
) external;
/**
* @notice Pauses all token transfers
*/
function pause() external;
/**
* @notice Unpauses token transfers
*/
function unpause() external;
}
"
},
"contracts/interfaces/ISTBL_YLD.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../lib/STBL_Structs.sol";
/**
* @title iSTBL_YLD Interface
* @notice Interface for the STBL YLD contract that manages yield-generating NFT tokens with lifecycle controls
* @dev Extends IAccessControl and IERC721 to provide role-based permissions and standard NFT functionality
* @author STBL Protocol Team
*/
interface iSTBL_YLD is IAccessControl, IERC721 {
/**
* @notice Emitted when the trusted forwarder address is updated
* @param previousForwarder Address of the previous trusted forwarder
* @param newForwarder Address of the new trusted forwarder
* @dev Used for meta-transaction support and gasless transactions
*/
event TrustedForwarderUpdated(
address indexed previousForwarder,
address indexed newForwarder
);
/**
* @notice Emitted when an NFT is disabled
* @param _id Token ID of the disabled NFT
* @dev Disabled NFTs cannot be transferred or used until re-enabled
*/
event NFTDisabled(uint256 indexed _id);
/**
* @notice Emitted when a disabled NFT is re-enabled
* @param _id Token ID of the enabled NFT
* @dev Re-enabled NFTs restore full functionality including transfers
*/
event NFTEnabled(uint256 indexed _id);
/**
* @notice Emitted when a new NFT is minted
* @param _addr Recipient address of the minted NFT
* @param _id Token ID of the newly minted NFT
* @param _nftMetadata Complete metadata structure for the NFT
* @dev Contains all relevant data for the newly created yield-bearing token
*/
event MintEvent(
address indexed _addr,
uint256 indexed _id,
YLD_Metadata _nftMetadata
);
/**
* @notice Emitted when an NFT is permanently burned
* @param _from Address that previously owned the burned NFT
* @param _id Token ID of the burned NFT
* @dev Burning permanently removes the token from circulation
*/
event BurnEvent(address indexed _from, uint256 indexed _id);
/**
* @notice Emitted when the contract implementation is upgraded
* @dev Triggered during an upgrade of the contract to a new implementation
* @param newImplementation Address of the new implementation contract
*/
event ContractUpgraded(address newImplementation);
/**
* @notice Updates the base URI for token metadata
* @dev Changes the base URI used for constructing token metadata URLs
* @dev Only callable by addresses with DEFAULT_ADMIN_ROLE
* @param _uri The new base URI to set for token metadata
*/
function setBaseURI(string memory _uri) external;
/**
* @notice Pauses all contract functionality
* @dev Only callable by PAUSER_ROLE. Prevents transfers, minting, and burning
* @custom:security Emergency function to halt all operations
*/
function pause() external;
/**
* @notice Resumes all contract functionality
* @dev Only callable by PAUSER_ROLE. Restores normal operations after pause
* @custom:security Should only be called after emergency conditions are resolved
*/
function unpause() external;
/**
* @notice Retrieves complete metadata for a specific NFT
* @param _tokenID Token ID to query metadata for
* @return YLD_Metadata struct containing all token data
* @dev Reverts with NonexistentToken if tokenID does not exist
* @custom:view-function Pure read operation with no state changes
*/
function getNFTData(
uint256 _tokenID
) external view returns (YLD_Metadata memory);
/**
* @notice Creates a new NFT with specified metadata
* @param _to Recipient address for the new NFT
* @param _metadata Complete metadata structure for the NFT
* @return Token ID of the newly minted NFT
* @dev Only callable by MINTER_ROLE. Increments total supply
* @custom:security Validates recipient address and metadata integrity
*/
function mint(
address _to,
YLD_Metadata memory _metadata
) external returns (uint256);
/**
* @notice Permanently destroys an existing NFT
* @param _from Current owner address of the NFT
* @param _id Token ID to burn
* @dev Only callable by BURNER_ROLE. Decrements total supply
* @custom:security V
Submitted on: 2025-09-26 12:35:14
Comments
Log in to comment.
No comments yet.