# Magicspend++

## Overview

Normally, if a user wants to transact on a new chain, they need to:

1. Bridge tokens across chains
2. Manage gas on each chain
3. Wait for settlement before taking action

This creates friction, slows down activity, and reduces usability across chains.

**Magicspend++** lets users spend their token balances across multiple chains in one seamless transaction without bridging delays or worrying about gas fees:

* No bridging needed – funds are instantly available on the target chain
* No gas headaches – gas fees are sponsored
* Fast transactions – executed at the speed of the destination chain

## How it works

**Magicspend++** removes this friction with a borrow-and-settle model:

1. Resource Lock
   * Locks part of the user’s tokens on source chains.
   * Those funds can’t be spent elsewhere until settlement.
   * Enforced differently depending on wallet type:
     * **Turnkey Signers:** [Turnkey policies](https://docs.turnkey.com/concepts/policies/overview) prevent wallets from spending locked tokens.
     * **Privy Authorized Keys and Policies**:  [Privy policies](https://docs.privy.io/controls/policies/overview) prevent wallets from spending locked tokens.
     * **Smart contract wallets (e.g. Safe)**: Co-signer must approve spending of locked tokens.
2. Enclave Vault
   * Instantly lends tokens on the target chain so the user can transact right away.
   * The loan is repaid later using the locked funds across chains.

### Example

Let's say the user wants to buy 10 GMX tokens on Arbitrum but only has funds on Optimism and Base.

<figure><img src="https://2429876521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGaftPmsUdt8hxUf6uzhp%2Fuploads%2FrvGwniA2YUkhotCcQy4x%2FMagicspend%2B%2B(1).jpg?alt=media&#x26;token=a207cc8c-b1d8-4a9d-a574-e74d37ddd8af" alt=""><figcaption></figcaption></figure>

**Magicspend++ flow:**

1. Borrow USDC on Arbitrum vault
2. Instantly swap on Arbitrum DEX
3. Settlement takes place later and deducts from Base and Optimism

<figure><img src="https://2429876521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGaftPmsUdt8hxUf6uzhp%2Fuploads%2FOgUZxKQbkXOY8Q0L7Ugc%2FMagicspend%2B%2B(2).jpg?alt=media&#x26;token=5e5499e1-1cc5-4229-ba61-7ad1e98cc662" alt=""><figcaption></figcaption></figure>

### Wallet Support

Enclave supports Magicspend++ with the following wallet types:

1. Turnkey EOA Wallets
2. Privy EOA Wallets
3. Smart Contract Wallets (ERC4337, ERC7579 Smart Accounts)

### Batched Transactions and Gas Abstraction

Enclave leverages ERC4337 paymasters to abstract gas for users. ERC4337 /7579 accounts are also able to execute batched transactions which allows the end user to borrow from Enclave's vault and execute the desired action (ex. swap on Uniswap) in a single atomic on-chain transaction.

**EOA Support**

In order to support Turnkey EOAs, Enclave leverages EIP7702 to convert the EOA into a smart contract wallet, allowing it to inherit the properties of a smart contract wallet which supports gas sponsorship and transaction batching.

### Quote Types

#### Amount In

User specifies **exactly how much to spend** (inclusive of fees).&#x20;

For example: User wants to spend exactly $10 to buy a memecoin.

Enclave gives **$9.90 on target chain, settles $10 across balances** on other chains.

#### Amount Out

User specifies **how much they need on the target chain**

For example: User needs $10 on Base to lend on Morpho

Enclave gives **$10 on target chain**, **settles $10.10 across balances** on other chains.

{% hint style="info" %}
**Note on fees:** The quote includes fees for both the borrow cost as well as sponsoring the gas fees to be paid on the target chain for execution of the user's desired action, and the gas fees to be paid on the settlement chains for settlement transactions.
{% endhint %}
