# 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="https://249592560-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo5MtmDmmppRk2wSgm7kp%2Fuploads%2FAVXumhrpMf6QbSFZfFns%2Fimage.png?alt=media&#x26;token=ee04b41f-be40-4f05-b202-8a88e5dc71f2" 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.
