RestakingDeveloper DocsLST Precompile

TangleLstPrecompile

The TangleLstPrecompile is a precompiled contract that facilitates interaction with the Tangle network’s pool management functionality. It provides a comprehensive interface for users to manage their pool operations.

The latest version of the precompile can be found here.

Address

  • Contract Address: 0x0000000000000000000000000000000000000809

This interface is designed to be used by Solidity contracts to interact with the TangleLst pallet, enabling complex pool management operations on the Tangle network.

Interface

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.8.3;
 
/// @dev The TangleLst contract's address.
address constant TANGLE_LST = 0x0000000000000000000000000000000000000809;
 
/// @dev The TangleLst contract's instance.
TangleLst constant TANGLE_LST_CONTRACT = TangleLst(TANGLE_LST);
 
/// @author The Tangle Team
/// @title Pallet TangleLst Interface
/// @title The interface through which solidity contracts will interact with the TangleLst pallet
/// @custom:address 0x0000000000000000000000000000000000000809
interface TangleLst {
    /// @dev Join a pool with a specified amount.
    /// @param amount The amount to join with.
    /// @param poolId The ID of the pool to join.
    function join(uint256 amount, uint256 poolId) external returns (uint8);
 
    /// @dev Bond extra to a pool.
    /// @param poolId The ID of the pool.
    /// @param extraType The type of extra bond (0 for FreeBalance, 1 for Rewards).
    /// @param extra The amount of extra bond.
    function bondExtra(uint256 poolId, uint8 extraType, uint256 extra) external returns (uint8);
 
    /// @dev Unbond from a pool.
    /// @param memberAccount The account of the member.
    /// @param poolId The ID of the pool.
    /// @param unbondingPoints The amount of unbonding points.
    function unbond(bytes32 memberAccount, uint256 poolId, uint256 unbondingPoints) external returns (uint8);
 
    /// @dev Withdraw unbonded funds from a pool.
    /// @param poolId The ID of the pool.
    /// @param numSlashingSpans The number of slashing spans.
    function poolWithdrawUnbonded(uint256 poolId, uint32 numSlashingSpans) external returns (uint8);
 
    /// @dev Withdraw unbonded funds for a member.
    /// @param memberAccount The account of the member.
    /// @param poolId The ID of the pool.
    /// @param numSlashingSpans The number of slashing spans.
    function withdrawUnbonded(bytes32 memberAccount, uint256 poolId, uint32 numSlashingSpans) external returns (uint8);
 
    /// @dev Create a new pool.
    /// @param amount The initial amount to create the pool with.
    /// @param root The root account of the pool.
    /// @param nominator The nominator account of the pool.
    /// @param bouncer The bouncer account of the pool.
    /// @param name The name of the pool.
    /// @param icon The icon for the pool.
    function create(uint256 amount, bytes32 root, bytes32 nominator, bytes32 bouncer, bytes calldata name, bytes calldata icon) external returns (uint8);
 
    /// @dev Create a new pool with a specific pool ID.
    /// @param amount The initial amount to create the pool with.
    /// @param root The root account of the pool.
    /// @param nominator The nominator account of the pool.
    /// @param bouncer The bouncer account of the pool.
    /// @param poolId The desired pool ID.
    /// @param name The name of the pool.
    /// @param icon The icon for the pool.
    function createWithPoolId(uint256 amount, bytes32 root, bytes32 nominator, bytes32 bouncer, uint256 poolId, bytes calldata name, bytes calldata icon) external returns (uint8);
 
    /// @dev Nominate validators for a pool.
    /// @param poolId The ID of the pool.
    /// @param validators An array of validator accounts to nominate.
    function nominate(uint256 poolId, bytes32[] calldata validators) external returns (uint8);
 
    /// @dev Set the state of a pool.
    /// @param poolId The ID of the pool.
    /// @param state The new state (0 for Open, 1 for Blocked, 2 for Destroying).
    function setState(uint256 poolId, uint8 state) external returns (uint8);
 
    /// @dev Set metadata for a pool.
    /// @param poolId The ID of the pool.
    /// @param metadata The metadata to set.
    function setMetadata(uint256 poolId, bytes calldata metadata) external returns (uint8);
 
    /// @dev Chill a pool (stop nominating validators).
    /// @param poolId The ID of the pool.
    function chill(uint256 poolId) external returns (uint8);
 
    /// @dev Set commission for a pool.
    /// @param poolId The ID of the pool.
    /// @param newCommission The new commission rate.
    function setCommission(uint256 poolId, uint32 newCommission) external returns (uint8);
 
    /// @dev Claim commission for a pool.
    /// @param poolId The ID of the pool.
    function claimCommission(uint256 poolId) external returns (uint8);
 
    /// @dev Update roles for a pool.
    /// @param poolId The ID of the pool.
    /// @param newRoot The new root account.
    /// @param newNominator The new nominator account.
    /// @param newBouncer The new bouncer account.
    function updateRoles(uint256 poolId, bytes32 newRoot, bytes32 newNominator, bytes32 newBouncer) external returns (uint8);
 
    /// @dev Adjust pool deposit.
    /// @param poolId The ID of the pool.
    function adjustPoolDeposit(uint256 poolId) external returns (uint8);
 
    /// @dev Set global configurations (only callable by root).
    /// @param minJoinBond The minimum bond required to join a pool (0 for no change).
    /// @param minCreateBond The minimum bond required to create a pool (0 for no change).
    /// @param maxPools The maximum number of pools (0 for no change).
    /// @param globalMaxCommission The global maximum commission percentage (0 for no change).
    function setConfigs(uint256 minJoinBond, uint256 minCreateBond, uint32 maxPools, uint32 globalMaxCommission) external returns (uint8);
}

Pool Roles

Each pool has three distinct roles:

  • Root: Administrator with full control over pool settings
  • Nominator: Manages validator selection and staking strategy
  • Bouncer: Controls member access and pool state

Commission System

Pools can set commission rates on rewards:

  • Commission is set as a percentage (0-100)
  • Pool operators can claim accumulated commissions
  • Global maximum commission limits are enforced by the network

Example

contract PoolOperationsExample {
    address constant precompileAddress = 0x0000000000000000000000000000000000000809;
    ITangleLstPrecompile precompile = ITangleLstPrecompile(precompileAddress);
 
    function joinPool(uint256 amount, uint256 poolId) public returns (uint8) {
        // Call the join function on the precompile contract
        uint8 statusCode = precompile.join(amount, poolId);
 
        // Handle the status code as needed
        require(statusCode == 0, "Join pool failed");
 
        return statusCode;
    }
 
    function createNewPool(
        uint256 amount,
        bytes32 root,
        bytes32 nominator,
        bytes32 bouncer,
        string memory poolName
    ) public returns (uint8) {
        // Create a new pool with custom name and icon
        uint8 statusCode = precompile.create(
            amount,
            root,
            nominator,
            bouncer,
            bytes(poolName),
            "" // Empty icon
        );
 
        require(statusCode == 0, "Pool creation failed");
        return statusCode;
    }
 
    function nominateValidators(
        uint256 poolId,
        bytes32[] memory validators
    ) public returns (uint8) {
        // Nominate validators for a pool
        uint8 statusCode = precompile.nominate(poolId, validators);
 
        require(statusCode == 0, "Nomination failed");
        return statusCode;
    }
}