> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b1nary.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart Contracts

> Base contracts, Solana programs, and key execution functions.

## Production: Base mainnet

| Contract      | Address                                      |
| ------------- | -------------------------------------------- |
| BatchSettler  | `0xd281ADdB8b5574360Fd6BFC245B811ad5C582a3B` |
| Controller    | `0x2Ab6D1c41f0863Bc2324b392f1D8cF073cF42624` |
| MarginPool    | `0xa1e04873F6d112d84824C88c9D6937bE38811657` |
| OTokenFactory | `0x0701b7De84eC23a3CaDa763bCA7A9E324486F6D7` |
| Oracle        | `0x09daa0194A3AF59b46C5443aF9C20fAd98347671` |
| Whitelist     | `0xC0E6b9F214151cEDbeD3735dF77E9d8EE70ebA8A` |
| AddressBook   | `0x48FE24a69417038a2D3d46B2B6B9De03b884eD72` |
| USDC          | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
| WETH          | `0x4200000000000000000000000000000000000006` |
| cbBTC         | `0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf` |

## Production: Solana mainnet

| Program / Account              | Address                                        |
| ------------------------------ | ---------------------------------------------- |
| b1nary Batch Settler           | `GpR6id2cHu5fUGsFm7NUKkB4NzfuEDa6brPzkSrgAzvS` |
| Solana Margin Pool             | `FH3z4BYRZMFU8YzpJoFXUbrdoYksdERnWbZvDAEc3qcC` |
| CCTP V2 Token Messenger Minter | `CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe` |
| CCTP V2 Message Transmitter    | `CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC` |
| USDC Mint                      | `4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU` |
| wSOL Mint                      | `So11111111111111111111111111111111111111112`  |
| TSLAx Mint                     | `XsDoVfqeBukxuZHWhdvWHBhgEHjGNst4MLodqsJHzoB`  |

## Testnet (Base Sepolia)

| Contract          | Address                                      |
| ----------------- | -------------------------------------------- |
| BatchSettler      | `0x766bD3aF1D102f7EbcB65a7B7bC12478C2DbA918` |
| Controller        | `0xB64a532B71E711B5F45B906D9Fc09c184EC54CA0` |
| MarginPool        | `0x727ddBD04A691E73feaE26349F48144953Ef20d6` |
| OTokenFactory     | `0x1cEA6AE65c06972249831f617ea196863Fb66e6D` |
| Oracle            | `0x101cB9E8a3105EfB18A81E768238eFc041F31E15` |
| Whitelist         | `0xda732e343cfAd50Df28881B66f111779671a17E1` |
| AddressBook       | `0x9e8cd9a79d667f4154e123604bF62d35a3d9673C` |
| LUSD (mock USDC)  | `0xAB51a471493832C1D70cef8ff937A850cf37c860` |
| LETH (mock WETH)  | `0x8A6Aa2304797898d46eC1d342Fedc817D3a973B6` |
| LBTC (mock cbBTC) | `0x39fA11EbBE82699Fd9F79C566D7384064571d2b4` |

Base EVM contracts are UUPS-proxied and verified on BaseScan. Solana programs are deployed on Solana mainnet.

## Key functions

### Base: executeOrder

```solidity theme={null}
function executeOrder(
    Quote calldata quote,
    bytes calldata signature,
    uint256 amount,
    uint256 collateral
) external returns (uint256 vaultId)
```

On **BatchSettler**. Permissionless. Atomically: verifies the market maker's EIP-712 signature, locks your collateral, mints oTokens to the MM, and pays premium to you (minus 4% protocol fee).

The `Quote` struct:

```solidity theme={null}
struct Quote {
    address oToken;
    uint256 bidPrice;
    uint256 deadline;
    uint256 quoteId;
    uint256 maxAmount;
    uint256 makerNonce;
}
```

All fields come directly from the `GET /prices` response. `amount` is in oToken units (8 decimals, `1e8` = 1 ETH notional).

### Base collateral calculation

**Puts:**

```
collateral = (amount * strike_price_8dec) / 1e10
```

Result in USDC (6 decimals).

**ETH Calls:**

```
collateral = amount * 1e10
```

Result in WETH (18 decimals).

**cbBTC Calls:**

```
collateral = amount
```

Result in cbBTC (8 decimals, same as oToken).

### Solana: ExecuteOrder

Solana quotes from `GET /prices` map to the Solana b1nary Batch Settler `ExecuteOrder` instruction.

Important execution rules:

* USDC and wSOL use the SPL Token Program.
* TSLAx uses Token-2022: `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`.
* SOL covered calls wrap SOL to wSOL before execution when wSOL collateral is insufficient.
* The operator/hot wallet sponsors setup and transaction fees where supported.
* The user's Solana embedded trading wallet signs only where token ownership authority is required.

### Solana collateral calculation

**Puts:**

```
collateral = (amount * strike_price_8dec) / 1e10
```

Result in USDC (6 decimals).

**SOL calls:**
Use wSOL/SOL in 9 decimals.

**TSLAx calls:**
Use TSLAx in 8 decimals.

### CCTP V2 bridge

Circle CCTP V2 is used to consolidate USDC across Base and Solana.

* Base -> Solana: `mintRecipient` must be the user's Solana USDC token account (ATA), not the wallet owner. Backend validates or creates the ATA before reserving the bridge.
* Solana -> Base: `mintRecipient` is the Base smart trading account encoded as bytes32.
* Agents should wait for the actual minted amount before executing a destination-chain trade; CCTP fees/rounding can make the received amount lower than the burn amount.

### makerNonce

```solidity theme={null}
function makerNonce(address mm) external view returns (uint256)
```

Current nonce for a market maker. Quotes with stale nonce are rejected.

### incrementMakerNonce

```solidity theme={null}
function incrementMakerNonce() external returns (uint256)
```

Invalidates all outstanding signed quotes for the caller. Used as a circuit breaker.

### getVault

```solidity theme={null}
function getVault(
    address owner,
    uint256 vaultId
) external view returns (Vault memory)
```

On **Controller**. Returns vault details: `shortOtoken`, `collateralAsset`, `shortAmount`, `collateralAmount`.
