|
| 1 | +--- |
| 2 | +title: Emission Permissions |
| 3 | +description: Complete guide to emission permissions, stream delegation, and economic coordination mechanisms in Torus. |
| 4 | +--- |
| 5 | + |
| 6 | +<Aside type="note" title="Version notice"> |
| 7 | +This version is based on the Torus v0.5 and is expected to change with the Torus v1. |
| 8 | +</Aside> |
| 9 | + |
| 10 | +import { CardGrid, LinkCard, Aside, Tabs, TabItem } from "@astrojs/starlight/components"; |
| 11 | + |
| 12 | +Emission permissions are the core tool and mechanism for economic incentives on Torus, enabling agents to compose and delegate portions of their incoming emission streams (token flows) to other agents with flexible control. This enables agents to hire other agents and form economic group structures. |
| 13 | + |
| 14 | +## Emission Permission System |
| 15 | + |
| 16 | +Emission permissions are core tool and mechanism for economic incentives on Torus, enabling agents to compose and delegate portions of their incoming emission streams (token flows) to other agents with flexible control. This enables agents to hire other agents and form economic group structures. |
| 17 | + |
| 18 | +### Stream-Based Emission Model |
| 19 | + |
| 20 | +The emission system preserves **stream identity** through delegation chains via unique `StreamId` identifiers. Each stream represents a distinct emission source (staking returns, delegation fees), enabling complete traceability of token flow from source to final recipients. |
| 21 | + |
| 22 | +### Allocation Mechanisms |
| 23 | + |
| 24 | +Emission permissions support two distinct allocation paradigms: |
| 25 | + |
| 26 | +#### Stream Allocations (Percentage-Based) |
| 27 | + |
| 28 | +Stream allocations enable agents to delegate specific percentages of incoming emissions from particular streams. |
| 29 | + |
| 30 | +**Stream Allocation Characteristics:** |
| 31 | +- **Granular Control**: Different streams can have different delegation percentages (0-100%) |
| 32 | +- **Safety Constraints**: Total allocated percentage per stream cannot exceed 100% |
| 33 | +- **Dynamic Processing**: Emissions are intercepted and redirected during distribution |
| 34 | +- **Recursive Support**: Delegated streams maintain their identity through recursive delegation chains |
| 35 | + |
| 36 | + |
| 37 | +#### Fixed Amount Allocations |
| 38 | + |
| 39 | +Fixed amount allocations reserve specific token quantities from the delegator's account at permission creation: |
| 40 | + |
| 41 | +```rust |
| 42 | +FixedAmount(1000) // Reserve 1000 TORUS |
| 43 | +``` |
| 44 | + |
| 45 | +**Fixed Amount Characteristics:** |
| 46 | +- **Upfront Reservation**: Tokens are reserved using the Currency trait's reserve mechanism |
| 47 | +- **One-time Distribution**: Can only be executed once (manually or at a specific block) |
| 48 | +- **Distribution Constraints**: Limited to `Manual` or `AtBlock` distribution controls |
| 49 | +- **Safety Guarantee**: Uses the reserve/unreserve pattern to prevent double-spending |
| 50 | + |
| 51 | +### Distribution Control Mechanisms |
| 52 | + |
| 53 | +The system provides four distribution control patterns that determine when and how delegated tokens are transferred: |
| 54 | + |
| 55 | +```rust |
| 56 | +pub enum DistributionControl { |
| 57 | + Manual, // Recipient triggers distribution |
| 58 | + Automatic(Balance), // Auto-trigger at threshold |
| 59 | + AtBlock(BlockNumber), // Execute at specific block |
| 60 | + Interval(BlockNumber), // Execute every N blocks |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +<Tabs> |
| 65 | +<TabItem label="Manual Distribution"> |
| 66 | +**Manual Distribution** requires explicit execution by the recipient: |
| 67 | + |
| 68 | +```rust |
| 69 | +DistributionControl::Manual |
| 70 | +``` |
| 71 | + |
| 72 | +- **Recipient Control**: Recipient determines when to claim accumulated tokens |
| 73 | +- **Flexibility**: Allows strategic timing of token distribution |
| 74 | +- **Gas Efficiency**: Batches multiple accumulations into single distribution |
| 75 | +</TabItem> |
| 76 | + |
| 77 | +<TabItem label="Automatic Distribution"> |
| 78 | +**Automatic Distribution** triggers when accumulated amounts reach a threshold: |
| 79 | + |
| 80 | +```rust |
| 81 | +DistributionControl::Automatic(5000) // Auto-distribute at 5000 TORUS |
| 82 | +``` |
| 83 | + |
| 84 | +- **Threshold-Based**: Automatically executes when accumulated amount exceeds threshold |
| 85 | +- **Predictable**: Ensures regular distribution without manual intervention |
| 86 | +- **Efficient**: Reduces the need for manual monitoring |
| 87 | +</TabItem> |
| 88 | + |
| 89 | +<TabItem label="Block-Based Distribution"> |
| 90 | +**AtBlock Distribution** executes once at a specific block: |
| 91 | + |
| 92 | +```rust |
| 93 | +DistributionControl::AtBlock(1_000_000) // Execute at block 1,000,000 |
| 94 | +``` |
| 95 | + |
| 96 | +- **Scheduled**: Executes at predetermined block height |
| 97 | +- **One-time**: Single execution at specified block |
| 98 | +- **Predictable**: Known execution timing |
| 99 | +</TabItem> |
| 100 | + |
| 101 | +<TabItem label="Interval Distribution"> |
| 102 | +**Interval Distribution** executes periodically at fixed intervals: |
| 103 | + |
| 104 | +```rust |
| 105 | +DistributionControl::Interval(10_800) // Execute every 10,800 blocks (~24 hours) |
| 106 | +``` |
| 107 | + |
| 108 | +- **Periodic**: Regular execution at specified block intervals |
| 109 | +- **Automated**: No manual intervention required |
| 110 | +- **Consistent**: Predictable distribution schedule |
| 111 | +</TabItem> |
| 112 | +</Tabs> |
| 113 | + |
| 114 | +--- |
| 115 | +### Emission Accumulation Process |
| 116 | + |
| 117 | +The accumulation mechanism efficiently processes emissions through a multi-stage pipeline: |
| 118 | + |
| 119 | +1. **Interception**: When agents receive emissions, the system checks for active permissions |
| 120 | +2. **Stream Matching**: Permissions are filtered by stream ID and allocation type |
| 121 | +3. **Percentage Extraction**: For stream allocations, the specified percentage is extracted |
| 122 | +4. **Storage**: Accumulated amounts are stored with agent-stream-permission indexing |
| 123 | +5. **Distribution Triggers**: Various conditions trigger automatic distribution |
0 commit comments