diff --git a/components/EvmToSubstrateConverter.tsx b/components/EvmToSubstrateConverter.tsx index ea1c1cd..7264c7c 100644 --- a/components/EvmToSubstrateConverter.tsx +++ b/components/EvmToSubstrateConverter.tsx @@ -37,7 +37,7 @@ const AddressConverter = () => { try { const convertedAddress = evmToTangle(evmAddress); setTangleAddress(convertedAddress); - } catch (error) { + } catch { setTangleAddress("Invalid EVM address."); } }; diff --git a/components/Tabs.tsx b/components/Tabs.tsx index 0dcaacb..9aa245f 100644 --- a/components/Tabs.tsx +++ b/components/Tabs.tsx @@ -13,7 +13,7 @@ export const Tabs: FC<{ const { data, mutate } = useSWR(storageKey, (key) => { try { return JSON.parse(localStorage.getItem(key) ?? ""); - } catch (e) { + } catch { return null; } }); diff --git a/pages/developers/precompiles/features/multi-asset-delegation.mdx b/pages/developers/precompiles/features/multi-asset-delegation.mdx index e170b7a..f239f09 100644 --- a/pages/developers/precompiles/features/multi-asset-delegation.mdx +++ b/pages/developers/precompiles/features/multi-asset-delegation.mdx @@ -59,9 +59,9 @@ Below are example usages for some core methods on the multi-asset delegation int 1. Expand the `deposit(uint256 assetId, address tokenAddress, uint256 amount, uint8 lockMultiplier)` section. 2. Set `assetId` to `0` for ERC20 tokens, or provide another valid ID for other assets. -3. Provide the ERC20 contract address in `tokenAddress` if `assetId` is `0`. If using a native asset ID, this may be ignored depending on your setup. +3. Provide the ERC20 contract address in `tokenAddress` if `assetId` is `0`. For native assets, set this to the zero address. 4. Enter the `amount` you wish to deposit (in your asset's smallest unit, e.g., Wei for WETH). -5. Specify a `lockMultiplier` value if required by your delegation logic (`0` for no lock). +5. Specify a `lockMultiplier` value for lock duration rewards (`0` for no lock, higher values for increased rewards). 6. Click "transact" and confirm the MetaMask popup. ### 2. Schedule a Withdrawal @@ -69,7 +69,7 @@ Below are example usages for some core methods on the multi-asset delegation int 1. Expand `scheduleWithdraw(uint256 assetId, address tokenAddress, uint256 amount)`. 2. Fill in `assetId` (`0` for ERC20), `tokenAddress` (if `assetId` is `0`), and `amount`. 3. Click "transact" and approve the MetaMask transaction. -4. The withdrawal is now scheduled; you can later execute or cancel it. +4. The withdrawal enters an unbonding period; you can execute it after the period ends or cancel it anytime. ### 3. Execute a Scheduled Withdrawal @@ -87,8 +87,9 @@ Below are example usages for some core methods on the multi-asset delegation int ### 5. Delegate to an Operator 1. Expand `delegate(bytes32 operator, uint256 assetId, address tokenAddress, uint256 amount, uint64[] memory blueprintSelection)`. -2. Enter the operator (as a bytes32 account id), the asset ID, token address if assetId is `0` (ERC20), the amount to delegate, and any required blueprint parameters. -3. Click "transact" to nominate that account as your operator with a specified stake. +2. Enter the operator (as a bytes32 account ID), the asset ID, token address if assetId is `0` (ERC20), the amount to delegate. +3. Provide `blueprintSelection` as an array of blueprint IDs the operator should participate in. +4. Click "transact" to delegate your assets to the operator. ### 6. Schedule Unstake for Delegators @@ -112,8 +113,8 @@ Below are example usages for some core methods on the multi-asset delegation int ### 9. Check Overall Balance 1. Expand `balanceOf(address who, uint256 assetId, address tokenAddress)`. -2. Enter the address you want to inspect, assetId (0 for ERC20), and `tokenAddress` if needed. -3. Click "call" to see the total amount of assets held (deposited + delegated). +2. Enter the address you want to inspect, assetId (`0` for ERC20), and `tokenAddress` if needed. +3. Click "call" to see the total amount of assets held (deposited but not yet delegated). ### 10. Check Delegated Balance @@ -123,6 +124,22 @@ Below are example usages for some core methods on the multi-asset delegation int --- +## Asset Types + +- **Asset ID 0**: ERC20 tokens (requires token address) +- **Asset ID 1+**: Native or custom assets configured in the runtime + +## Lock Multipliers + +The `lockMultiplier` parameter in the deposit function allows users to lock their assets for longer periods in exchange for increased rewards: + +- `0`: No lock (standard delegation) +- Higher values: Longer lock periods with proportionally higher reward multipliers + +## Blueprint Selection + +When delegating, the `blueprintSelection` parameter specifies which service blueprints the operator should run on your behalf. This enables targeted delegation to specific services or applications. + ## More Information For a complete list of methods and their parameters, refer to the Solidity interface above. This interface exposes all the critical multi-asset delegation functionality provided by Tangle's runtime, enabling you to manage deposits, schedule and execute withdrawals, delegate tokens, and unstake as needed—all through an Ethereum-compatible workflow. Make sure to handle asset IDs, token addresses, and amounts accurately to avoid transaction failures. diff --git a/pages/developers/precompiles/overview.mdx b/pages/developers/precompiles/overview.mdx index 063e8ac..5eb1db0 100644 --- a/pages/developers/precompiles/overview.mdx +++ b/pages/developers/precompiles/overview.mdx @@ -84,6 +84,7 @@ The precompiled contracts are categorized by address and based on the origin net | Schnorr-Ristretto255 | Verifies Schnorr signatures using the Ristretto255 curve. | `0x000000000000000000000000000000000000081f` | | Schnorr-Taproot | Verifies Schnorr signatures using the Taproot Scheme. | `0x0000000000000000000000000000000000000820` | | Bls12-381 | Performs operations on the BLS12-381 curve. | `0x0000000000000000000000000000000000000821` | -| MultiAsset Delegation | Provides functions for managing multi-asset delegation pallet. | `0x0000000000000000000000000000000000000822` | -| Services Pallet | Provides functions for managing services pallet. | `0x0000000000000000000000000000000000000823` | -| Liqued Staking | Provides functions for managing liquid staking pallet. | `0x0000000000000000000000000000000000000824` | +| Tangle LST | Provides functions for managing liquid staking pools. | `0x0000000000000000000000000000000000000809` | +| MultiAsset Delegation | Provides functions for managing multi-asset delegation. | `0x0000000000000000000000000000000000000822` | +| Credits | Provides functions for managing cloud credits system. | `0x0000000000000000000000000000000000000825` | +| Services | Provides functions for managing service blueprints and instances. | `0x0000000000000000000000000000000000000900` | diff --git a/pages/restake/_meta.ts b/pages/restake/_meta.ts index 3cafdb5..1799650 100644 --- a/pages/restake/_meta.ts +++ b/pages/restake/_meta.ts @@ -15,6 +15,7 @@ const meta: Meta = { }, "restake-introduction": "Tangle Restaking", incentives: "Incentives", + credits: "Tangle Credits", how_to_restake: "How to Restake on Tangle", restake_developers: "Developer Docs", "-- liquid staking": { diff --git a/pages/restake/credits/_meta.ts b/pages/restake/credits/_meta.ts new file mode 100644 index 0000000..09c936d --- /dev/null +++ b/pages/restake/credits/_meta.ts @@ -0,0 +1,9 @@ +import { Meta } from "nextra"; + +const meta: Meta = { + index: "Overview", + claiming: "How to Claim Credits", + precompile: "Credits Precompile", +}; + +export default meta; diff --git a/pages/restake/credits/claiming.mdx b/pages/restake/credits/claiming.mdx new file mode 100644 index 0000000..4485516 --- /dev/null +++ b/pages/restake/credits/claiming.mdx @@ -0,0 +1,82 @@ +--- +title: How to Claim Credits +description: Step-by-step guide to claiming your earned credits from the Cloud Credits pallet +--- + +# How to Claim Credits + +This guide walks you through the process of claiming your earned credits from TNT staking through the Cloud Credits pallet. + +## Prerequisites + +- **Active TNT Stake**: You must have TNT staked through Tangle's multi-asset delegation system +- **Minimum Stake**: Your stake must meet the lowest tier threshold to earn credits +- **Off-chain Account**: An identifier linking your claim to off-chain credit management + +## Claiming via Polkadot.js Apps + +### Step 1: Connect to Tangle Network + +1. Go to [Polkadot.js Apps](https://polkadot.js.org/apps) +2. Connect to the Tangle Network endpoint +3. Import or connect your account with TNT stake + +### Step 2: Navigate to Extrinsics + +1. Go to **Developer** → **Extrinsics** +2. Select your account from the dropdown +3. Choose `cloudCredits` from the pallet list +4. Select `claimCredits` from the call dropdown + +### Step 3: Fill Parameters + +**Amount to Claim (`amount_to_claim`):** + +- Enter the number of credits you want to claim +- Must not exceed your accrued amount within the claim window +- Use the RPC query (see below) to check your maximum claimable amount + +**Off-chain Account ID (`offchain_account_id`):** + +- Your identifier for linking to off-chain credit systems +- Maximum length is configurable (check pallet constants) +- Keep this consistent across claims + +![PolkadotJS Claim](/images/claim.png) + +### Step 4: Submit Transaction + +1. Click **Submit Transaction** +2. Enter your password if prompted +3. Confirm the transaction +4. Monitor the transaction status in the **Network** → **Explorer** + +## Alternative: Asset-Specific Claims + +For claiming credits from specific asset stakes: + +1. Choose `claimCreditsWithAsset` instead of `claimCredits` +2. Add the **Asset ID** parameter for the specific asset +3. The same amount and off-chain account ID rules apply + +![PolkadotJS Claim](/images/claim-assets.png) + +## Events and Monitoring + +### CreditsClaimed Event + +When you successfully claim: + +``` +CreditsClaimed { + who: Your_Account_ID, + amount_claimed: Claimed_Amount, + offchain_account_id: Your_Offchain_ID +} +``` + +## Related Documentation + +- [Credits Overview](/restake/credits) - Understanding the Cloud Credits pallet +- [Credits Precompile](/restake/credits/precompile) - Technical documentation for developers +- [How to Restake](/restake/how_to_restake) - Guide to staking TNT tokens diff --git a/pages/restake/credits/index.mdx b/pages/restake/credits/index.mdx new file mode 100644 index 0000000..18e6aa2 --- /dev/null +++ b/pages/restake/credits/index.mdx @@ -0,0 +1,39 @@ +--- +title: Credits +description: Earn free usage credits for AI tools by staking TNT tokens on Tangle. +--- + +# Credits + +## What Are Credits? + +Credits are a way for re-stakers on Tangle to earn credits on [ai.tangle.tools](https://ai.tangle.tools). When you stake TNT tokens, you automatically earn credits that can be used for AI services like text generation, image creation, and other AI tools. + +## How to Earn Credits + +Stake TNT/LstTNT tokens on Tangle and you'll automatically start earning credits. The more TNT you stake, the more credits you earn over time. You don't need to do anything special - just stake your tokens and credits accumulate automatically. + +## How to Use Your Credits + +1. Stake TNT tokens on Tangle +2. Visit [ai.tangle.tools](https://ai.tangle.tools) +3. Claim your accumulated credits + +### Earning Mechanism + +Credits accumulate based on your staked TNT amount. Higher stake amounts earn credits at a higher rate. + +### Credit Expiry + +Credits have an expiry period to encourage regular usage rather than hoarding. On Tangle Mainnet, you can accumulate credits for up to one week from your last claim. After one week, your accumulated credits reset to zero and you start earning fresh credits again. + +This system encourages users to actively claim and use their credits rather than letting them pile up indefinitely. + +### Claiming Process + +To claim credits, you submit a transaction with your GitHub account as the off-chain ID. The system calculates how many credits you've earned based on your stake, verifies this amount, and emits an event that credits the specified amount to your GitHub account on ai.tangle.tools. + +## Next Steps + +- **[How to Claim Credits](/restake/credits/claiming)** - Learn how to claim your earned credits +- **[Credits Precompile](/restake/credits/precompile)** - Technical documentation for developers working with the credits system diff --git a/pages/restake/credits/precompile.mdx b/pages/restake/credits/precompile.mdx new file mode 100644 index 0000000..97fe0cf --- /dev/null +++ b/pages/restake/credits/precompile.mdx @@ -0,0 +1,99 @@ +--- +title: Credits Precompile +description: Solidity interface for interacting with the Tangle Credits system +--- + +# Credits Precompile + +The Credits precompile provides an Ethereum-compatible interface for interacting with the Tangle Credits system. This allows smart contracts and dApps to manage credits programmatically. + +## Contract Address + +- **Mainnet & Testnet**: `0x0000000000000000000000000000000000000825` + +## Interface + +```solidity +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity >=0.8.3; + +/// @dev The Credits contract's address. +address constant CREDITS = 0x0000000000000000000000000000000000000825; + +/// @dev The Credits contract's instance. +Credits constant CREDITS_CONTRACT = Credits(CREDITS); + +/// @author The Tangle Team +/// @title Credits Pallet Interface +/// @notice Interface for interacting with the Tangle Credits system +/// @custom:address 0x0000000000000000000000000000000000000825 +interface Credits { + /// @dev Burn TNT tokens to generate credits + /// @param amount The amount of TNT to burn + /// @return Success status (0 for success) + function burn(uint256 amount) external returns (uint8); + + /// @dev Claim accumulated credits + /// @param amount The amount of credits to claim + /// @param offchainAccountId The off-chain account identifier + /// @return Success status (0 for success) + function claimCredits( + uint256 amount, + bytes calldata offchainAccountId + ) external returns (uint8); + + /// @dev Get the current credit emission rate for a staked amount + /// @param stakedAmount The amount of TNT staked + /// @return The credits earned per block + function getCurrentRate(uint256 stakedAmount) external view returns (uint256); + + /// @dev Calculate accrued credits for an account + /// @param account The account to check + /// @return The amount of claimable credits + function calculateAccruedCredits(address account) external view returns (uint256); + + /// @dev Get the current stake tier configuration + /// @return thresholds Array of stake thresholds + /// @return rates Array of emission rates per block + function getStakeTiers() external view returns ( + uint256[] memory thresholds, + uint256[] memory rates + ); + + /// @dev Get stake tier for a specific asset + /// @param assetId The asset identifier + /// @return thresholds Array of stake thresholds + /// @return rates Array of emission rates per block + function getAssetStakeTiers(uint256 assetId) external view returns ( + uint256[] memory thresholds, + uint256[] memory rates + ); + + /// @dev Events + event CreditsGrantedFromBurn(address indexed account, uint256 burned, uint256 credits); + event CreditsClaimed(address indexed account, uint256 amount, bytes offchainAccountId); +} +``` + +### Claiming Credits + +```solidity +contract CreditClaimer { + Credits constant credits = Credits(0x0000000000000000000000000000000000000825); + + function claimMyCredits(uint256 amount, string memory accountId) external { + // Convert string to bytes for off-chain account ID + bytes memory offchainId = bytes(accountId); + + // Claim the credits + uint8 result = credits.claimCredits(amount, offchainId); + require(result == 0, "Claim failed"); + } +} +``` + +## Related Documentation + +- [Credits Overview](/restake/credits/overview) +- [Claiming Credits](/restake/credits/claiming) +- [Multi-Asset Delegation](/developers/precompiles/features/multi-asset-delegation) diff --git a/pages/restake/incentives/how_rewards_work.mdx b/pages/restake/incentives/how_rewards_work.mdx index d51c443..e892213 100644 --- a/pages/restake/incentives/how_rewards_work.mdx +++ b/pages/restake/incentives/how_rewards_work.mdx @@ -14,6 +14,8 @@ Restaking rewards in the Tangle Network are designed to incentivize both operato 3. **Reward Vaults:** Asset Vaults to which restaked tokens are assigned for reward distribution. 4. **Delegators:** Users who delegate their tokens to operators, sharing in the rewards generated by the operators' activities. 5. **Operators:** Validators who restake their tokens and provide services, earning rewards through their participation in the restaking protocol. +6. **Lock Duration Multipliers:** Enhanced rewards for longer lock periods (1.1x to 1.6x multipliers). +7. **Service-Specific Rewards:** Rewards tied to specific service blueprints and instances. ## Whitelisting Blueprints for Rewards diff --git a/pages/restake/lst_developers/lst_precompile.mdx b/pages/restake/lst_developers/lst_precompile.mdx index 6f95fa5..9b5942d 100644 --- a/pages/restake/lst_developers/lst_precompile.mdx +++ b/pages/restake/lst_developers/lst_precompile.mdx @@ -60,7 +60,9 @@ interface TangleLst { /// @param root The root account of the pool. /// @param nominator The nominator account of the pool. /// @param bouncer The bouncer account of the pool. - function create(uint256 amount, bytes32 root, bytes32 nominator, bytes32 bouncer) external returns (uint8); + /// @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. @@ -68,7 +70,9 @@ interface TangleLst { /// @param nominator The nominator account of the pool. /// @param bouncer The bouncer account of the pool. /// @param poolId The desired pool ID. - function createWithPoolId(uint256 amount, bytes32 root, bytes32 nominator, bytes32 bouncer, uint256 poolId) external returns (uint8); + /// @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. @@ -85,6 +89,30 @@ interface TangleLst { /// @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). @@ -94,21 +122,69 @@ interface TangleLst { } ``` +#### 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 ```solidity -contract JoinPoolExample { +contract PoolOperationsExample { address constant precompileAddress = 0x0000000000000000000000000000000000000809; ITangleLstPrecompile precompile = ITangleLstPrecompile(precompileAddress); - function joinPool(uint256 amount, uint256 poolId) public returns (uint256) { + function joinPool(uint256 amount, uint256 poolId) public returns (uint8) { // Call the join function on the precompile contract - uint256 statusCode = precompile.join(amount, poolId); + 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; + } } ``` diff --git a/public/images/claim-assets.png b/public/images/claim-assets.png new file mode 100644 index 0000000..47c8082 Binary files /dev/null and b/public/images/claim-assets.png differ diff --git a/public/images/claim.png b/public/images/claim.png new file mode 100644 index 0000000..535aff1 Binary files /dev/null and b/public/images/claim.png differ