### StakedMonad Contract API Reference Source: https://docs.kintsu.xyz/the-kintsu-protocol/architecture-and-integration/3rd-party-integration-guide Provides details on key functions and parameters for interacting with the StakedMonad contract, including deposit, mint, requestUnlock, and sendBatchUnlockRequests. ```APIDOC StakedMonad Contract: ## Deposit Functions: 1. **`deposit(address receiver)`** * **Description**: Standard ERC7535/ERC4626 compliant deposit. Users deposit native MON via `msg.value` to receive sMON shares. * **Parameters**: * `receiver` (address): The address that will receive the minted sMON shares. * **Requirements**: * `msg.value` must be greater than or equal to `MINIMUM_DEPOSIT`. * **Returns**: None (emits `Deposit` event on success). * **Internal Calls**: `_updateFees()` 2. **`mint(uint96 shares, address receiver)`** * **Description**: Allows users to specify the exact number of sMON shares they want to receive. The required MON amount is calculated based on the current redemption ratio. * **Parameters**: * `shares` (uint96): The desired number of sMON shares to mint. * `receiver` (address): The address that will receive the minted sMON shares. * **Requirements**: * `msg.value` must be greater than or equal to the calculated MON amount for `shares`. * `msg.value` must be greater than or equal to `MINIMUM_DEPOSIT`. * Excess `msg.value` is refunded to the caller. * **Returns**: None (emits `Deposit` event on success). * **Internal Calls**: `_updateFees()`, `convertToAssets()` ## Redemption Functions: 1. **`requestUnlock(uint96 shares)`** * **Description**: Initiates the redemption process by transferring sMON shares from the user to the contract and queuing them for unbonding. * **Parameters**: * `shares` (uint96): The amount of sMON shares to request for unlock. * **Process**: 1. sMON shares are transferred from `msg.sender` to the StakedMonad contract. 2. The request is added to a batch based on the current batch interval (`currentBatchUnlockId`). 3. User's requests are tracked in `userUnlockRequests`. * **State Change**: * Shares are moved to escrow and become unusable. * **Returns**: None. 2. **`sendBatchUnlockRequests(uint40[] calldata batchIds)`** * **Description**: Processes completed unlock request batches, calculating their MON value and initiating the unbonding process with underlying nodes. * **Parameters**: * `batchIds` (uint40[]): An array of batch IDs to process, must be in ascending order and belong to past intervals. * **Process**: 1. Iterates through provided `batchIds`. 2. Calculates `aggregateSpotValue` and `aggregateShares` for the batches. 3. Updates `batchUnlockRequests` with `spotValue` and `submissionTime`. 4. Burns the `aggregateShares` from the contract's total supply. 5. Calls `_doUnbonding(aggregateSpotValue)` to reduce `totalPooled`. * **Requirements**: * `batchId < currentBatchUnlockId` for all provided IDs. * **Returns**: None. * **Internal Calls**: `_doUnbonding()` ## Key Constants/Variables (Implied): * `MINIMUM_DEPOSIT`: Minimum amount of MON required for deposits. * `BATCH_INTERVAL_DELAY`: Delay defining batch intervals. * `CREATION_TIME`: Timestamp of contract creation, used for batch ID calculation. * `convertToAssets(uint96 shares)`: Internal function to calculate MON value for sMON shares. * `_updateFees()`: Internal function to account for protocol fees. * `_doUnbonding(uint256 value)`: Internal function to initiate unbonding with underlying nodes. ``` -------------------------------- ### Redeem sMON Shares from StakedMonad Contract Source: https://docs.kintsu.xyz/the-kintsu-protocol/architecture-and-integration/3rd-party-integration-guide A two-step process for redeeming sMON shares for native MON. First, users request an unlock of their sMON shares. Second, batches of unlock requests are processed to initiate the unbonding and eventual return of MON. ```solidity /// @notice Initiates the redemption process by requesting an unlock of sMON shares. /// @param shares The amount of sMON shares to redeem. /// @dev Transfers sMON shares from user to contract, adds request to a batch. /// Shares are put in escrow and cannot be transferred or used for staking. function requestUnlock(uint96 shares) external { // ... transfers shares from msg.sender to contract ... // ... determines currentBatchUnlockId based on timestamp and BATCH_INTERVAL_DELAY ... // ... adds shares to batchUnlockRequests mapping for the batchId ... // ... tracks user's requests in userUnlockRequests mapping ... } ``` ```solidity /// @notice Processes completed unlock request batches. /// @param batchIds An array of batch IDs that are ready to be processed (ascending order). /// @dev Can be called by anyone, intended for automation. /// Calculates aggregate MON value for batches based on current redemption ratio. /// Updates batchUnlockRequests with spotValue and submissionTime. /// Burns aggregated sMON shares from total supply. /// Calls _doUnbonding to initiate unbonding with underlying nodes. function sendBatchUnlockRequests(uint40[] calldata batchIds) external { // ... iterates through batchIds ... // ... calculates aggregateSpotValue and aggregateShares ... // ... updates batchUnlockRequests ... // ... burns aggregateShares ... // ... calls _doUnbonding(aggregateSpotValue) ... } ``` -------------------------------- ### Deposit MON into StakedMonad Contract Source: https://docs.kintsu.xyz/the-kintsu-protocol/architecture-and-integration/3rd-party-integration-guide Allows users to deposit native MON tokens into the StakedMonad contract to receive sMON shares. Two functions are available: `deposit` (ERC7535/ERC4626 compliant) and `mint` (allows specifying desired sMON shares). Both require a minimum deposit amount and handle fee updates internally. ```solidity /// @notice Standard deposit function adhering to ERC7535/ERC4626. /// @param receiver The address that will receive the newly minted sMON shares. /// @dev The amount of MON to deposit is specified via msg.value. /// The 'assets' parameter is for standard compliance and not used for deposit amount. /// Requires msg.value >= MINIMUM_DEPOSIT. function deposit(address receiver) external payable { // ... implementation details ... } /// @notice Allows users to specify the number of sMON shares they wish to receive. /// @param shares The desired number of sMON shares to mint. /// @param receiver The address that will receive the newly minted sMON shares. /// @dev The required MON amount (msg.value) is calculated based on 'shares' and current redemption ratio. /// User must send at least the calculated amount; excess MON is refunded. /// Requires msg.value >= MINIMUM_DEPOSIT. function mint(uint96 shares, address receiver) external payable { // ... implementation requires internal _updateFees() call ... // ... calculates required MON based on convertToAssets(shares) ... // ... mints sMON shares to receiver ... // ... emits Deposit event ... } ``` -------------------------------- ### Cancel Unlock Request Source: https://docs.kintsu.xyz/the-kintsu-protocol/architecture-and-integration/3rd-party-integration-guide Enables users to cancel an unlock request, but only within the same batch interval in which it was initiated. The function removes the request's shares from the batch, deletes the request from the user's array, and transfers the sMON shares back to the user. It requires the unlockIndex to identify the request and verifies it belongs to the current batch interval. ```APIDOC cancelUnlockRequest(uint256 unlockIndex) - Description: Cancels a pending unlock request within its original batch interval. - Parameters: - unlockIndex: uint256 - The index of the unlock request to cancel. - Logic: 1. Verifies the request exists and the current batch ID matches the request's batch ID. 2. Removes the shares associated with the cancelled request from the batchUnlockRequests. 3. Deletes the unlock request from the user's userUnlockRequests array. 4. Transfers the sMON shares back to the user. - Related Functions/Concepts: - getBatchUnlockIdAtTime(): Used to find the active batch ID. - batch interval: The time window during which a batch is processed and requests can be cancelled. - Error Conditions/Considerations: - Requests can only be cancelled within the same batch interval they were sent. - The active batch can be found via getBatchUnlockIdAtTime. ``` -------------------------------- ### Redeem Unlocked MON Source: https://docs.kintsu.xyz/the-kintsu-protocol/architecture-and-integration/3rd-party-integration-guide Allows users to claim their unlocked MON tokens after the specified COOLDOWN_PERIOD has passed since the batch submission time. The function calculates the redeemable amount based on user shares and batch spot value, handles potential withdrawals from nodes if contract balance is insufficient, and transfers the assets to the specified receiver. The user's unlock request is removed upon successful redemption. ```APIDOC redeem(uint256 unlockIndex, address payable receiver) - Description: Claims unlocked MON tokens after the cooldown period has elapsed. - Parameters: - unlockIndex: uint256 - The index of the user's specific unlock request in their userUnlockRequests array. - receiver: address payable - The address where the redeemed MON tokens will be sent. - Logic: 1. Verifies the unlockIndex is valid. 2. Checks if the associated batch has been submitted and the COOLDOWN_PERIOD has passed (block.timestamp > batch.submissionTime + COOLDOWN_PERIOD). 3. Calculates the MON amount to redeem based on user shares and the batch's spotValue. 4. If contract balance is insufficient, calls _doWithdrawUnbonded() to attempt to claim unbonded MON from nodes. 5. Deletes the user's unlock request. 6. Transfers the calculated MON assets to the receiver address. - Related Functions/Concepts: - _doWithdrawUnbonded(): Called internally to fetch unbonded MON from nodes. - COOLDOWN_PERIOD: The time delay after batch submission before redemption is possible. - submissionTime: Timestamp when the batch was submitted. - spotValue: The recorded value of MON for the batch when it was sent for unbonding. - Error Conditions/Considerations: - Redemption is not instant; requires a cooldown period. - Success depends on underlying staking nodes successfully unbonding and returning MON. ``` -------------------------------- ### StakedMonad Contract Interface - Solidity Source: https://docs.kintsu.xyz/the-kintsu-protocol/architecture-and-integration/contract-interface-and-functions This Solidity interface defines the core functions of the StakedMonad contract. It includes methods for converting assets to shares and vice versa, managing deposits and withdrawals, and handling batch unlock requests. The interface also exposes functions for previewing operations and querying total shares. ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.26; interface IStakedMonad { struct UnlockRequest { uint96 shares; uint40 batchId; } struct UnlockRequestBatch { uint96 shares; uint96 spotValue; uint40 submissionTime; } /// @notice Converts MON into LST shares at the current block timestamp /// @dev `totalShares()` accounts for both minted and mintable shares function convertToShares(uint96 assets) external view returns (uint96 shares); /// @notice Converts LST shares into MON at the current block timestamp /// @dev `totalShares()` accounts for both minted and mintable shares function convertToAssets(uint96 shares) external view returns (uint96 assets); function getBatchUnlockIdAtTime(uint256 timestamp) external view returns (uint40 batchId); /// @notice Deposit MON into the protocol and receive LST shares to represent your position /// @notice MON must be greater than minimum stake /// @dev Deposit amount must be specified by `msg.value` /// @dev First param `assets` satisfies ERC7535/ERC4626 /// @param receiver - Recipient of the minted shares /// @return shares - Quantity of shares minted function deposit(uint96, address receiver) external payable returns (uint96 shares); function previewDeposit(uint96 assets) external view returns (uint96 shares); /// @notice Mint LST shares to represent your position of MON deposited into the protocol /// @notice MON must be greater than minimum stake /// @dev Deposit amount must be specified by `msg.value` /// @param shares - Number of shares desired /// @param receiver - Recipient of the minted shares /// @return assets - MON deposited function mint(uint96 shares, address receiver) external payable returns (uint96 assets); function previewMint(uint96 shares) external view returns (uint96 assets); /// @notice Step 1 of 2 in process of withdrawing staked MON /// @notice Transfers LST specified in `shares` argument to the vault contract /// @notice Unlock is batched into current batch request function requestUnlock(uint96 shares) external; /// @notice Allow user to cancel their unlock request /// @notice Most users will have 1 concurrent unlock request (`unlockIndex` == 0) but advanced users may have more /// @notice Must be done in the same batch interval in which the request was originally sent /// @dev Order of unlock requests is not guaranteed between cancellations function cancelUnlockRequest(uint256 unlockIndex) external; /// @notice Step 2 of 2 in process of withdrawing staked MON /// @notice Returns original deposit amount plus interest to depositor address /// @notice Transfers MON to caller /// @notice Associated batch unlock request must have been completed /// @dev Deletes the caller's unlock request function redeem(uint256 unlockIndex, address payable receiver) external returns (uint96 assets); /// @notice Compound earned rewards for all validators /// @dev Can be called by anyone function compound() external; /// @notice Trigger unlock requests of previous batched requests /// @notice Distributes unlock requests to nominators according to current stake imbalances /// @notice Calculates a batch spot values for LST in the batches /// @notice Burns associated LST /// @dev Batch IDs must be specified in ascending order (for gas efficient duplicate check) /// @dev Cannot be called for a batch that has not concluded /// @dev Cannot be called for a batch that has already been redeemed function sendBatchUnlockRequests(uint40[] calldata batchIds) external; /// @notice Attempts to claim unbonded MON from all nodes function withdrawUnbonded() external; /// @notice Shares that could exist at the current block timestamp /// @notice Includes both minted and mintable shares function totalShares() external view returns (uint96); /// @notice Shares that could be minted by the protocol at the current block timestamp function mintableProtocolShares() external view returns (uint96 shares); function getAllUserUnlockRequests(address user) external view returns (UnlockRequest[] memory); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.