# Execution Logic

Tychi Wallet leverages a suite of backend-driven algorithms to streamline Web3 operations while maintaining  decentralization, efficiency, and user privacy. These algorithms power critical infrastructure such as gas fee abstraction, cross-chain bridging, and secure recovery.

### Multi-Chain Bridging Protocol

Tychi Wallet supports token mobility across 50+ blockchains using a deterministic bridging system combining:

* **Relay Node Validation**: Confirms lock events on source chains before executing mint/release.
* **Merkle Proof Verification**: Proves transaction inclusion within source chain blocks.
* **Signature Authentication**: Uses cryptographic signing to authorize bridge actions.
* **Liquidity Routing**: Maintains on-demand liquidity through integrated liquidity sources.
* **Smart Contract Enforcement**: Manages token minting, burning, and lock mechanics.

### Formulaic Trigger:

```plaintext
T_B = T_A - F
F = T_A * r
```

Where:

* `T_A`: Tokens locked
* `T_B`: Tokens released
* `F`: Fee deducted as `T_A * r`, where `r` is fee rate

Components of Multi-Chain Bridging

| Component                 | Purpose                                                                 |
| ------------------------- | ----------------------------------------------------------------------- |
| Optimized Relay Nodes     | Enhance transaction speed and reliability                               |
| Blockchain Bridges        | Facilitate secure asset movement between chains                         |
| Merkle Proofs             | Verify transaction integrity during cross-chain execution               |
| Cryptographic Signatures  | Ensure authenticity and tamper-proof communication                      |
| Automated Liquidity Pools | Maintain sufficient liquidity across chains                             |
| Smart Contracts           | Handle locking, minting, and token verification processes automatically |

### Gas Fee Optimization – AI Powered

Tychi Wallet features an AI-based system that continuously **monitors network congestion trends** to suggest the **optimal time** to transact—when gas fees are lower and network usage is minimal.

> ✅ Privacy Focused: This logic uses **historical and public data**, never tracking the user’s transaction history.

### Gas Fee Abstraction Flow Diagram

***

<figure><img src="/files/QQmDmFA2ahIv6W0aakab" alt=""><figcaption></figcaption></figure>

### Fee Abstraction Engine

Tychi allows users to pay gas fees using **TYI** or **BNB**—removing the burden of managing native tokens.

#### Conversion Workflow

1. **Input**: User pays with TYI or BNB
2. **Chain Detection**: System identifies the origin blockchain
3. **Gas Estimation**: Calculates required native token fee
4. **Price Aggregation**: Fetches rates from Chainlink, CoinGecko, CoinMarketCap
5. **Slippage Check**: Applies tolerance formulas to validate risk
6. **Conversion**: Executes off-chain via internal or third-party liquidity sources
7. **Finalization**: Submits transaction using converted native token

> 🔁 This creates a **frictionless, chain-agnostic** gas payment system.

### Slippage Calculation

```plaintext
effectivePrice = priceFeedAvg * (1 ± ε)
```

Where:

* `priceFeedAvg` is the median of prices from Chainlink, CoinMarketCap, and CoinGecko
* `ε` = predefined slippage threshold (1-2%), adjusted by volatility metrics

The abstraction system only proceeds when:

```plaintext
priceChainlink - priceOther| < ε * priceFeedAvg
```

This ensures consistent pricing without user overpayment.

### Social Recovery Algorithm

Tychi’s recovery module utilizes **Shamir’s Secret Sharing**. A user's private key is split across `n` guardians. A threshold `t` (e.g. 3 of 5) must approve to reconstruct the key.

#### Recovery Flow:

1. User initiates recovery
2. Guardians confirm identity and submit encrypted shares
3. Backend reconstructs key securely
4. Key is returned to user in encrypted format

#### Model Basis:

```plaintext
Key = SSS(k, t, n)
```

Where:

* `SSS` = Shamir’s Secret Sharing
* `k` = private key
* `t` = threshold required
* `n` = total guardians

All shares are encrypted and transported over secure channels.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tychi.gitbook.io/tychi-whitepaper/core-principles/execution-logic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
