---
description: >-
  atlETH serves as a wrapped representation of the blockchain's native token
  within Atlas. While named "atlETH" for simplicity, it represents the native
  token of whichever blockchain Atlas is deployed
---

# Bond atlETH

## TL;DR

* **Bonding AtlETH**: Use `bond` to lock atlETH as collateral in the Atlas system for participation in MEV backrun auctions. Bonded tokens cannot be transferred or withdrawn until unbonded.
* **Unbonding AtlETH**: Use `unbond` to start releasing bonded tokens. Tokens enter a waiting period before they are fully liquid and withdrawable.
* **Depositing & Withdrawing**: `deposit` converts POL to atlETH; `withdraw` converts atlETH back to POL. Only unbonded tokens can be withdrawn.
* **Viewing Balances**: `balanceOfBonded` and `balanceOfUnbonding` let users check bonded and unbonding atlETH for any account.
* **Redeem vs Withdraw:** `redeem` transfers atlETH to solver account, `withdraw` converts atlETH back to POL

## Bonding/ Unbonding Guide

The `bond` and `unbond` functions in the Atlas smart contract are core mechanisms for managing **AtlETH token** within the Atlas protocol. By bonding AtlETH tokens,  solvers temporarily "lock" their tokens in the system, making them eligible for participating in specific Atlas MEV backrun auctions

#### Bonding atlETH

The `bond` **function** allows users to lock a specified amount of `atlETH` tokens, creating a "bonded" status. When tokens are bonded, they cannot be transferred or withdrawn until they are `unbonded`. This bonded `atlETH` serves as a form of collateral or commitment to the Atlas system, often required for solvers to participate in activities where token commitment helps ensure reliability and reduce risk.

To initiate bonding, users specify the amount of `atlETH` they wish to lock. Atlas then designates those tokens as bonded, making them immediately available for Atlas-specific functions. Bonded tokens signify that the user is actively engaged in the Atlas protocol, especially in contexts requiring financial backing.

#### Unbonding atlETH

The `unbond` **function** begins the process of removing atlETH from a bonded state, initiating a wait period before the tokens are fully "free" for transfer or withdrawal. During the unbonding period, the tokens are still in the system and can be used within Atlas functions if needed, but the unbonding process must complete before they are entirely unrestricted.

The unbonding process is essential for solvers who wish to release their tokens back into a fully liquid state. However, to avoid disruptions, Atlas may implement conditions to delay unbonding or adjust withdrawal amounts in cases where funds are needed to maintain system solvency.

### Depositing and Withdrawing AtlETH

**deposit** atlETH

The **`deposit` function** allows users to convert POL directly into atlETH by sending POL to the Atlas contract, which mints the equivalent atlETH tokens.&#x20;

**withdraw atlETH**

The **`withdraw` function** allows users to redeem atlETH back into POL. Withdrawals are only available for unbonded **atlETH**, meaning users must first **`unbond`** any tokens in a bonded state before they can withdraw. This ensures liquidity and stability in the Atlas ecosystem while allowing users to easily enter and exit with POL.

### Viewing Bonded and Unbonding atlETH Balances

The **`balanceOfBonded`** and **`balanceOfUnbonding`** functions allow users to view the status of their AtlETH tokens in the Atlas protocol.

* **`balanceOfBonded`**: Shows the total amount of atlETH currently bonded for a specified account. Bonded tokens are locked and cannot be transferred or withdrawn until unbonded, making this function essential for solvers verifying their participation in protocol activities.
* **`balanceOfUnbonding`**: Shows the amount of atlETH currently in the unbonding state for a specified account. These tokens are in the process of becoming available for withdrawal but are still subject to the unbonding period.

## Examples:

1. Deposit POL

```typescript
/**
 * Deposits ETH into the Atlas contract by calling its deposit function.
 * @param amount The amount of ETH to deposit in wei, as a BigInt.
 */
async function deposit(amount: bigint) {
  try {
    const tx = await atlEthContract.deposit({
      value: amount.toString() // send ETH along with the call
    });

    console.log('Deposit transaction hash:', tx.hash);

    // Wait for the transaction to be confirmed
    const receipt = await tx.wait();
    console.log('Deposit transaction confirmed in block', receipt.blockNumber);
  } catch (error) {
    console.error('Error sending deposit:', error);
  }
}

```

1. Bond altETH

Requires to to first deposit POL first

```typescript
/**
* Bonds a specified amount of AtlETH tokens.
* @param amount The amount of AtlETH tokens to bond, in BigInt format.
*/
async function bond(amount: bigint) {
  try {
    const tx = await atlEthContract.bond(amount.toString()); // Ethers.js expects a string or number
    console.log('Bond transaction hash:', tx.hash);
    const receipt = await tx.wait();
    console.log('Bond transaction confirmed in block', receipt.blockNumber);
  } catch (error) {
    console.error('Error bonding AtlETH:', error);
  }
}

```

**DepositAndBond**

```typescript
/**
* Deposits ETH and bonds a specified amount of AtlETH tokens.
* @param depositAmount The amount of ETH to deposit in wei, in BigInt format.
* @param amountToBond The amount of AtlETH tokens to bond, in BigInt format.
*/
async function depositAndBond(depositAmount: bigint, amountToBond: bigint) {
  try {
    const tx = await atlEthContract.depositAndBond(amountToBond.toString(), {
      value: depositAmount.toString()
    });
    console.log('Deposit and bond transaction hash:', tx.hash);
    const receipt = await tx.wait();
    console.log('Deposit and bond transaction confirmed in block', receipt.blockNumber);
  } catch (error) {
    console.error('Error depositing and bonding AtlETH:', error);
  }
}
```

**Unbond Function**

```typescript
/**
 * Starts the unbonding process for a specified amount of AtlETH tokens.
 * @param amount The amount of AtlETH tokens to unbond, in BigInt format.
 */
async function unbond(amount: bigint) {
  try {
    const tx = await atlEthContract.unbond(amount.toString());
    console.log('Unbond transaction hash:', tx.hash);
    const receipt = await tx.wait();
    console.log('Unbond transaction confirmed in block', receipt.blockNumber);
  } catch (error) {
    console.error('Error unbonding AtlETH:', error);
  }
}

```

Redeem

```typescript
/**
 * Redeems a specified amount of AtlETH tokens for withdrawal.
 * @param amount The amount of AtlETH tokens to redeem, in BigInt format.
 */
async function redeem(amount: bigint) {
  try {
    const tx = await atlEthContract.redeem(amount.toString());
    console.log('Redeem transaction hash:', tx.hash);
    const receipt = await tx.wait();
    console.log('Redeem transaction confirmed in block', receipt.blockNumber);
  } catch (error) {
    console.error('Error redeeming AtlETH:', error);
  }
}
```
