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/Assets/LT1/STBL_LT1_YieldDistributor.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/metatx/ERC2771ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../../interfaces/ISTBL_Register.sol";
import "../../interfaces/ISTBL_Core.sol";
import "../../interfaces/ISTBL_YLD.sol";
import "../../lib/STBL_AssetDefinitionLib.sol";
import "../../lib/STBL_Structs.sol";
import "../../lib/STBL_Errors.sol";
import "./interfaces/ISTBL_LT1_AssetVault.sol";
import "./interfaces/ISTBL_LT1_AssetIssuer.sol";
import "./interfaces/ISTBL_LT1_AssetYieldDistributor.sol";
import "./lib/STBL_LT1_Asset_Errors.sol";
/**
* @title STBL LT1 Yield Distributor
* @author STBL Protocol Team
* @notice Manages reward distribution for USDY assets in the STBL Protocol
* @dev This contract handles the distribution of yield rewards to USDY token holders.
* It implements a reward index system for efficient reward calculation and distribution.
* The contract integrates with the STBL registry system and supports meta-transactions.
*/
contract STBL_LT1_YieldDistributor is
Initializable,
iSTBL_LT1_AssetYieldDistributor,
ERC2771ContextUpgradeable,
UUPSUpgradeable
{
using STBL_AssetDefinitionLib for AssetDefinition;
using SafeERC20 for IERC20;
/** @notice Role identifier for contract upgrade authorization */
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
/** @notice Current implementation version number for tracking upgrades */
uint256 private _version;
/** @notice Registry contract interface reference */
iSTBL_Register public registry;
/** @notice Unique identifier for the USDY asset */
uint256 public assetID;
/** @notice Timestamp of the previous reward distribution */
uint256 public previousDistribution;
/** @notice Mapping of token IDs to their staking information */
mapping(uint256 => stakingStruct) public stakingData;
/** @notice Total supply of staked tokens */
uint256 public totalSupply;
/** @notice Multiplier used for precision in reward calculations (18 decimals) */
uint256 private constant MULTIPLIER = 1e18;
/** @notice Global reward index for reward calculation */
uint256 private rewardIndex;
/**
* @dev Storage gap reserved for future state variables in upgradeable contracts
* @notice This gap ensures storage layout compatibility when adding new state variables in future versions
*/
uint256[64] private __gap;
/**
* @notice Ensures caller is the authorized issuer contract
* @dev Reverts if the caller is not the issuer for this asset
*/
modifier isIssuer() {
AssetDefinition memory AssetData = registry.fetchAssetData(assetID);
if (!AssetData.isIssuer(msg.sender))
revert STBL_Asset_InvalidIssuer(assetID);
_;
}
/**
* @notice Contract constructor that initializes the ERC2771Context with a null trusted forwarder
* @dev The trusted forwarder will be configured during the initialize() call via the registry
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor() ERC2771ContextUpgradeable(address(0)) {}
/**
* @notice Initializes the issuer contract with asset configuration and access controls
* @dev Sets up UUPS upgradeability, access control roles, and links to the protocol registry
* @dev This function can only be called once during proxy deployment
* @param _id The unique asset identifier this issuer will manage
* @param _registry Address of the STBL protocol registry contract
* @custom:security Only the deployer receives initial admin and upgrader roles
*/
function initialize(uint256 _id, address _registry) public initializer {
__UUPSUpgradeable_init();
registry = iSTBL_Register(_registry);
assetID = _id;
previousDistribution = block.timestamp;
}
/**
* @notice Authorizes contract upgrades to new implementation addresses
* @dev Implements UUPS upgrade authorization pattern with role-based access control
* @dev Automatically increments version number on successful upgrades
* @param newImplementation Address of the new contract implementation to upgrade to
* @custom:security Requires UPGRADER_ROLE which is managed by the protocol registry
*/
function _authorizeUpgrade(address newImplementation) internal override {
if (!registry.hasRole(UPGRADER_ROLE, _msgSender()))
revert STBL_UnauthorizedCaller();
_version = _version + 1;
emit ContractUpgraded(newImplementation);
}
/**
* @notice Returns the current contract implementation version
* @dev Useful for tracking which version of the contract is currently deployed
* @return The version number, incremented with each upgrade
*/
function version() external view returns (uint256) {
return _version;
}
/**
* @notice Distributes yield rewards to all stakers
* @param reward Amount of reward tokens to distribute
* @dev Updates the global reward index and transfers tokens from vault to this contract.
* Only callable by the authorized vault contract after yield duration has passed.
* @custom:error STBL_AssetAlreadyDisabled Thrown if the asset is disabled
* @custom:error STBL_Asset_YieldDurationNotReached Thrown if the yield duration hasn't been reached
* @custom:error STBL_Asset_InvalidVault Thrown if the caller is not the authorized vault
* @custom:event RewardDistributed Emitted when rewards are successfully distributed
*/
function distributeReward(uint256 reward) external {
AssetDefinition memory AssetData = registry.fetchAssetData(assetID);
if (!AssetData.isActive()) revert STBL_AssetDisabled(assetID);
if (previousDistribution + AssetData.yieldDuration >= block.timestamp)
revert STBL_Asset_YieldDurationNotReached(
assetID,
previousDistribution
);
if (!AssetData.isVault(msg.sender))
revert STBL_Asset_InvalidVault(assetID);
IERC20(AssetData.token).safeTransferFrom(
msg.sender,
address(this),
reward
);
rewardIndex += (reward * MULTIPLIER) / totalSupply;
previousDistribution = block.timestamp;
emit RewardDistributed(reward);
}
/**
* @notice Calculates pending rewards for a specific token ID
* @param id Token ID to calculate rewards for
* @return Amount of pending rewards earned since last update
* @dev Internal function that uses the reward index difference to calculate pending rewards
*/
function _calculateRewards(uint256 id) private view returns (uint256) {
uint256 shares = stakingData[id].balance;
return
(shares * (rewardIndex - stakingData[id].rewardIndex)) / MULTIPLIER;
}
/**
* @notice Returns the total rewards earned for a specific token ID
* @param id Token ID to query
* @return Total rewards earned (both claimed and pending)
* @dev Combines already earned rewards with pending rewards
*/
function calculateRewardsEarned(
uint256 id
) external view returns (uint256) {
return stakingData[id].earned + _calculateRewards(id);
}
/**
* @notice Updates the reward state for a specific token ID
* @param id Token ID to update
* @dev Internal function that calculates and stores pending rewards, updates reward index
*/
function _updateRewards(uint256 id) private {
stakingData[id].earned += _calculateRewards(id);
stakingData[id].rewardIndex = rewardIndex;
}
/**
* @notice Enables staking for a token ID
* @param id Token ID to enable staking for
* @param value Amount of tokens to stake
* @dev Updates rewards before changing balance, increases total supply.
* Only callable by the authorized issuer contract.
* @custom:event StakingEnabled Emitted when staking is enabled for a token ID
*/
function enableStaking(uint256 id, uint256 value) external isIssuer {
_updateRewards(id);
stakingData[id].balance += value;
totalSupply += value;
emit StakingEnabled(id, value);
}
/**
* @notice Disables staking for a token ID
* @param id Token ID to disable staking for
* @param value Amount of tokens to unstake
* @dev Updates rewards before changing balance, decreases total supply.
* Only callable by the authorized issuer contract.
* @custom:event StakingDisabled Emitted when staking is disabled for a token ID
*/
function disableStaking(uint256 id, uint256 value) external isIssuer {
_updateRewards(id);
stakingData[id].balance -= value;
totalSupply -= value;
emit StakingDisabled(id, value);
}
/**
* @notice Claims accumulated rewards for a specific token ID
* @param id Token ID to claim rewards for
* @return Amount of rewards claimed and transferred
* @dev Transfers all accumulated rewards to the token owner, resets earned balance.
* Validates that both the asset and the specific token are not disabled.
* @custom:error STBL_AssetAlreadyDisabled Thrown if the asset is disabled
* @custom:error STBL_YLDDisabled Thrown if the specific token is disabled
* @custom:event RewardClaimed Emitted when rewards are claimed for a token ID
*/
function claim(uint256 id) external returns (uint256) {
AssetDefinition memory AssetData = registry.fetchAssetData(assetID);
if (!AssetData.isActive()) revert STBL_AssetDisabled(assetID);
iSTBL_YLD YToken = iSTBL_YLD(registry.fetchYLDToken());
YLD_Metadata memory MetaData = iSTBL_YLD(registry.fetchYLDToken())
.getNFTData(id);
if (MetaData.isDisabled && AssetData.issuer != msg.sender)
revert STBL_YLDDisabled(id);
_updateRewards(id);
uint256 reward = stakingData[id].earned;
if (reward > 0) {
stakingData[id].earned = 0;
IERC20(AssetData.token).safeTransfer(YToken.ownerOf(id), reward);
emit RewardClaimed(id, reward);
}
return reward;
}
/**
* @notice Returns the address of the trusted forwarder for meta-transactions
* @return The address of the current trusted forwarder from the registry
* @dev Used by ERC2771Context to validate meta-transaction relayers.
* Delegates to the registry for centralized forwarder management.
*/
function trustedForwarder() public view virtual override returns (address) {
return registry.trustedForwarder();
}
/**
* @notice Retrieves the asset ID managed by this vault instance
* @dev Returns the unique identifier for the asset type this vault handles
* @return The asset ID associated with this vault
*/
function fetchAssetID() external view returns (uint256) {
return assetID;
}
/**
* @notice Retrieves the protocol registry contract address
* @dev Returns the registry contract that provides system configuration and access control
* @return The address of the protocol registry contract
*/
function fetchRegistry() external view returns (address) {
return address(registry);
}
/**
* @notice Resolves message sender in the context of potential meta-transactions
* @dev Overrides both Context and ERC2771Context to handle inheritance conflicts
* @dev Returns the actual transaction originator when using meta-transactions via trusted forwarder
* @return The address of the actual message sender, accounting for meta-transaction forwarding
*/
function _msgSender()
internal
view
override(ERC2771ContextUpgradeable)
returns (address)
{
return ERC2771ContextUpgradeable._msgSender();
}
/**
* @notice Resolves message data in the context of potential meta-transactions
* @dev Overrides both Context and ERC2771Context to handle inheritance conflicts
* @dev Returns the actual transaction calldata when using meta-transactions via trusted forwarder
* @return The actual transaction calldata, accounting for meta-transaction forwarding
*/
function _msgData()
internal
view
override(ERC2771ContextUpgradeable)
returns (bytes calldata)
{
return ERC2771ContextUpgradeable._msgData();
}
/**
* @notice Returns the context suffix length for ERC2771 meta-transaction support
* @dev Overrides both Context and ERC2771Context to handle inheritance conflicts
* @dev Used internally by ERC2771Context to properly decode meta-transaction data
* @return The length of the context suffix appended to meta-transaction calldata
*/
function _contextSuffixLength()
internal
view
override(ERC2771ContextUpgradeable)
returns (uint256)
{
return ERC2771ContextUpgradeable._contextSuffixLength();
}
}
"
},
"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);
}
}
}
"
},
"node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
"
},
"node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
"
},
"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_Core.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../lib/STBL_Structs.sol";
/**
* @title STBL Core Interface
* @notice Interface for core functionality of the STBL Protocol
* @dev Defines the main entry and exit points for assets in the protocol
*/
interface iSTBL_Core {
/**
* @notice Emitted when an asset is deposited into the protocol
* @param _id The asset identifier
* @param _to Address receiving the minted token
* @param _metadata Metadata associated with the YLD token
* @param _tokenID ID of the minted token
*/
event putEvent(
uint256 indexed _id,
address indexed _to,
YLD_Metadata _metadata,
uint256 _tokenID
);
/**
* @notice Emitted when an asset is withdrawn from the protocol
* @param _id The asset identifier
* @param _to Address receiving the withdrawn assets
* @param _value The value of the withdrawn assets
* @param _tokenID ID of the burned token
*/
event exitEvent(
uint256 indexed _id,
address indexed _to,
uint256 _value,
uint256 _tokenID
);
/**
* @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 Method to update trusted forwarder
* @param _newForwarder Address of the new trusted forwarder
* @dev Only callable by admin
*/
function updateTrustedForwarder(address _newForwarder) external;
/**
* @notice Issues X and Y tokens for a given asset
* @dev Only callable by the asset issuer
* @param _to Address to receive the tokens
* @param _metadata Metadata associated with the YLD Token
* @return nftID The ID of the minted Y token (NFT)
*/
function put(
address _to,
YLD_Metadata memory _metadata
) external returns (uint256);
/**
* @notice Withdraws assets from the protocol
* @param _assetID The identifier of the asset being withdrawn
* @param _from Address that owns the token being burned
* @param _tokenID ID of the token to burn
* @param _value The amount of X tokens to burn during redemption
*/
function exit(
uint256 _assetID,
address _from,
uint25
Submitted on: 2025-09-28 15:15:20
Comments
Log in to comment.
No comments yet.