# buyout mechanics

The Harberger buyout is the action that gives the system its bite. Any tile that is currently owned by someone else can be taken by paying their declared price + 10% fee.

## When to buy out

There are three rational reasons:

1. **You want a specific tile** (a specific repo) and someone else has it.
2. **The current owner is under-priced.** Their declared price is below what you think the tile is worth. You take it cheap, then raise your own price.
3. **You want to earn the buyout fee distribution.** When the buyout executes, 10% of the fee splits to all holders — but you're a holder too (or about to be), so you capture a slice.

## Calculating the cost

```
buyoutCost = effectivePrice × 1.1
```

`effectivePrice` is what you see in the tile modal. It accounts for price decay (20% per 2 weeks since the last `setPrice` or buyout), so on long-held tiles it can be significantly lower than the originally declared price.

You must send **at least** `buyoutCost`. Any excess becomes your new deposit (no waste).

## What happens during the buyout

In a single transaction, the contract:

1. **Collects any pending tax** from the previous owner.
2. **Checks the tile is still valid** (not just foreclosed in the same tx).
3. **Calculates the cost**: `effectivePrice + 10% fee`.
4. **Validates `msg.value ≥ cost`**.
5. **Settles pending fees** for both you and the previous owner.
6. **Transfers** `effectivePrice + previous owner's deposit` to the previous owner.
7. **Splits the 10% buyout fee**: 90% to the Treasury balance, 10% to the holders pool.
8. **Records you as new owner** with declared price = `effectivePrice` (you can raise it later via `setPrice`).
9. **Stores any excess ETH you sent** as your new deposit.

All in one tx. The previous owner has no chance to refuse or counter-bid. That's the point.

## Limits on buying out

* **Max 5 tiles per wallet.** You can't buy out if you already own 5 tiles.
* **You can't buy out your own tile.** The contract reverts if `tile.owner == msg.sender`.
* **The tile must still be owned.** If it gets foreclosed in the same block (e.g. due to your `pokeTax` first), the buyout reverts.

## After the buyout

The frontend re-fetches state and the tile modal updates:

* Status: still OWNED, but now by you.
* Owner address: your wallet.
* Declared price: starts at the effective price (you can raise it).
* Deposit: any excess ETH from your buyout tx.
* Owner actions unlocked: Claim Fees, Add Deposit, Set Price, Abandon Tile.
* Buyout button hidden (you don't buy out yourself).

The event `TileBuyout(tileId, newOwner, prevOwner, price)` is emitted and shows up in the timeline section of the modal.

## Strategic notes

### Front-running

Base has private mempools and 2-second blocks. Sophisticated buyout strategies (snipe undervalued tiles the moment they appear) are possible but not heavily targeted today — the spread you can capture is small compared to gas + opportunity cost.

### Pricing wars

If you and someone else both want the same tile, you'll trade it back and forth, each time paying a 10% premium. The Treasury and the holders pool earn from every cycle. The contract is structurally biased to favor "patient pricing" over rapid trading.

### Honest pricing

The dominant strategy is to set your declared price close to what you'd genuinely accept to part with the tile. Too high → tax bleeds you. Too low → someone takes it.

## A worked example

Alice owns tile #100 with declared price 0.05 ETH, deposit 0.01 ETH.\
Bob wants the tile.

```
effectivePrice = 0.05 ETH (recent, no decay)
buyoutCost     = 0.05 × 1.1 = 0.055 ETH
```

Bob sends 0.06 ETH:

| Recipient                       | Amount                                             |
| ------------------------------- | -------------------------------------------------- |
| Alice (prev owner)              | 0.05 (price) + 0.01 (her deposit) = **0.06 ETH**   |
| Treasury (90% of 0.005 fee)     | **0.0045 ETH**                                     |
| Holders pool (10% of 0.005 fee) | **0.0005 ETH** distributed across all tile holders |
| Bob's new deposit (excess)      | 0.06 - 0.055 = **0.005 ETH**                       |

Bob is now owner with declared price 0.05 ETH (unchanged) and deposit 0.005 ETH. Alice walks away with 0.06 ETH. Total inflow to contract: 0.06 ETH. Total outflow from contract: 0.06 + 0.0045 + 0.0005 split-to-holders = matches.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitverse.gitbook.io/gitverse-docs/buyout-mechanics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
