Skip to main content

Bond AtlETH

Overview of AtlETH Bonding

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 on.

TL;DR
  • Bonding AtlETH: Use bond to lock AtlETH as collateral in the Atlas system for participating 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 ETH to AtlETH; withdraw converts AtlETH back to ETH. 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 the solver account; withdraw converts AtlETH back to ETH.

Bonding/Unbonding Guide

The bond and unbond functions in the Atlas smart contract are core mechanisms for managing AtlETH tokens within the Atlas protocol. Bonded tokens are required as collateral to participate in MEV backrun auctions and other Atlas activities.

Bonding AtlETH

The bond function locks a specified amount of AtlETH tokens, creating a "bonded" status. These tokens are non-transferable until unbonded. This bonded AtlETH serves as a form of collateral within the Atlas system.

To initiate bonding, users specify the amount of AtlETH they wish to lock. Atlas then designates those tokens as bonded, making them available for Atlas-specific functions.

Unbonding AtlETH

The unbond function initiates the process to release AtlETH from its bonded state. There is a waiting period before the tokens are fully "free" for transfer or withdrawal. During this period, tokens remain within the system and can still be used for Atlas functions if necessary.

Depositing and Withdrawing AtlETH

  • deposit AtlETH: Converts ETH to AtlETH by sending ETH to the Atlas contract, minting equivalent AtlETH tokens.
  • withdraw AtlETH: Converts AtlETH back into ETH. Only unbonded tokens are eligible for withdrawal.

Depositing and Bonding AtlETH in a single call

  • depositAndBond AtlETH: Converts ETH to AtlETH by sending ETH to the Atlas contract, minting equivalent AtlETH tokens, and bonding them.

Viewing Bonded and Unbonding AtlETH Balances

  • balanceOfBonded: Shows the total AtlETH currently bonded for a specified account.
  • balanceOfUnbonding: Displays the amount of AtlETH in the unbonding state for a specified account.

Example Functions

Deposit ETH

/**
* 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);
const receipt = await tx.wait();
console.log('Deposit transaction confirmed in block', receipt.blockNumber);
} catch (error) {
console.error('Error sending deposit:', error);
}
}

Bond AtlETH

Note: You need to deposit ETH before bonding AtlETH.

/**
* 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());
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);
}
}

Deposit and Bond

/**
* 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

/**
* 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

/**
* 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);
}
}

These functions provide essential operations for managing AtlETH within the Atlas protocol, from depositing and bonding to unbonding and redeeming tokens.