# Trading bonds and shares

> Selling and buying SigmaFi bonds and shares through asks, splitting a bond into shares, share-vault auctions, lot auctions and custody wraps.

Source: https://lithosprotocol.org/docs/sigmafi/trading

**Level:** Advanced

*Assumes you know what a token and a block height are, and have read the [SigmaFi overview](https://lithosprotocol.org/docs/sigmafi/overview).*

A SigmaFi loan is a token, so it can change hands before it ends. This page covers selling and buying
bond units and shares, splitting a unit into shares, the auctions that sell a liquidated loan's
collateral, and wrapping a token that must not travel raw. Lend offers, which buy from asks
automatically, are on [Lending](https://lithosprotocol.org/docs/sigmafi/lending).

## Selling with an ask

An **ask** offers bond units or shares you hold for sale. In the panel use **Create > Sell a bond**.
Through the API call `POST /sigmafi/zc/asks/check` then `POST /sigmafi/zc/asks`.

You choose one of the following pricings:

| Pricing | Contract | The price |
|---|---|---|
| Fixed | `SaleOrder` | A total price for the units, paid pro rata on partial fills |
| Yield | `PricedAsk` | The buyer pays your repayment discounted at a yield you name, optionally moving in a straight line by the ask's expiry. A fixed floor still binds |
| Fixed, guarded | `PricedAsk` | A fixed price that stops selling while the bond's cover is under a ratio you set |

An ask also takes the following:

| Option | What it sets |
|---|---|
| `minFill` | The fewest raw units one purchase may take. Default 1 |
| Sale guard | A cover ratio and oracle age under which the ask does not sell. See [Why a sale guard](#why-a-sale-guard) |
| Expiry | From then, anyone may return the units to you. Default 5,040 blocks (about 7 days) |

You can cancel an ask at any time. Partial fills leave the rest on sale at the same terms.

> **Warning: An ask's box ERG is a closing fee**
>
> An ask box holds 0.003 ERG: the 0.001 ERG box minimum and a 0.002 ERG refund fee. When the ask sells in
> full, that ERG goes to the buyer or the batcher that fills it, not back to you. On expiry it pays the
> batcher that returns the units. An ERG ask priced at or under 0.003 ERG pays you nothing.

The client refuses to list a bond that is already under its own oracle ratio. Anyone could liquidate it
instead, which pays the holder, you, all the collateral.

### Why a sale guard

An ask on a bond close to its ratio is a free option for buyers: a buyer pays at most the repayment, then
liquidates for all the collateral. A sale guard stops the ask selling while the bond's collateral is
worth less than your ratio of the repayment at a fresh oracle. While the guard holds the ask still, you
can liquidate the bond yourself and claim the vault with your unit.

## Buying from an ask

Browse asks in the panel's **Market** view, or `GET /sigmafi/zc/markets/{market}/asks`. Buy with the
ticket, or `POST /sigmafi/zc/asks/{boxId}/buy` with the number of `units`, which defaults to all of
them.

Before you buy, the client checks the token's origin on chain:

- A bond unit must come from a genuine SigmaFi fill.
- Shares must come from a genuine share mint holding a genuine unit. Unproven shares are refused.
- Any other token is bought with a warning, because nothing proves what it is.

A yield-priced ask is quoted at the most it asks over the next 3 blocks, as a fill is. The client also
refuses to buy a claim on a bond already under its own ratio, and points you to liquidating it instead.

## Shares

A bond unit can be split into **shares**, so a loan can be sold in parts or held by many people. By
default a unit becomes 100 shares with 6 decimals, so `1.000000` share is 1% of the loan.

### Splitting a unit into shares

Use **Create > Split into shares**, or `POST /sigmafi/zc/bonds/{assetId}/fractionalize`. Your unit goes
into a mint request. A batcher then mints the shares for the mint fee:

- You receive 100 shares.
- 100 shares plus one more stay locked in a share vault, beside the bond unit.
- The share token's id is the request's box id, and the token is named `ZCS-Bond-Shares-` and the bond's
  first six characters.

You choose one of the following vaults:

| Vault | After a liquidation |
|---|---|
| Selective (default) | Collateral that splits pro rata is paid out in kind. Only items too thin to split, under 100 raw units such as an NFT, go to auction |
| Dutch | All the collateral goes to auction for the loan's currency |
| Plain | Everything is paid out in kind. Lend offers do not buy plain shares |

A Selective or Dutch vault also takes auction terms: an **opening** and a **floor** price, in percent of
the repayment, an auction **length** (default 720 blocks) and an **expiry** (default the greater of
2,160 blocks and the length). The mint fee and the pull fee default to 0.005 ERG each.

> **Note: A Dutch vault on a SigUSD loan always auctions**
>
> Every box keeps 0.001 ERG, and on a SigUSD loan that ERG is not the loan's currency. So after a
> liquidation a Dutch vault on a SigUSD loan always opens an auction, and partial claims wait for it.

### Claiming with shares

When the loan ends, anyone may **pull** the settlement into the share vault for the pull fee:
`POST /sigmafi/zc/vaults/{boxId}/pull`. Batchers do this for you. Shareholders then claim in the
following ways:

| Claim | What you get |
|---|---|
| Partial | Burn some shares and take your share of each asset: `floor(balance × shares burned / shares outstanding)`. Waits for the pull and for any open auction |
| Final | Burn every outstanding share and take everything left in the vault |
| Un-fractionalize | Before the pull, burn every share to get the bond unit back |

Rounding down means a tiny claim can round an asset to zero. The client sells and claims in lots big
enough that the loan's currency never rounds to zero, and warns when a collateral token would.

Shares are priced as a **percentage of face**: what shares cost compared with the repayment they claim.
That figure compares across loans of any size.

### Share-vault auctions

When a liquidated loan's settlement is pulled into a Selective or Dutch vault, an auction may open. No
auction opens unless some collateral item is too thin to split: under 100 raw units in a Selective vault,
and every item in a Dutch vault. Which auction opens is fixed at the pull:

| Auction | Opens when | A buyer |
|---|---|---|
| Floor auction | The vault holds less of the loan's currency than the floor target | Brings the vault's currency up to the target, which falls in a straight line from the opening to the floor over the length and then holds, and takes the whole lot |
| Excess auction | The vault already holds the floor target | Pays a price falling from the opening to zero over the length, and takes only the thin items. Everything else stays for pro rata claims |

A floor auction that reaches its expiry unsold ends, and claims take the collateral in kind. An excess
auction that reaches zero ends the same way. The guarantee to shareholders: after a liquidation the vault
holds at least the floor in the loan's currency, unless the collateral all splits pro rata or the floor
auction expires unsold.

Buy an open vault auction from the panel's **Auctions** view, or `POST /sigmafi/zc/vaults/{boxId}/buy`.

## Selling collateral in a lot auction

A **lot auction** sells a basket of tokens whole, to the first buyer, for one currency. It is how a
lender paid in kind turns collateral back into the loan's currency without staying online. Use
**Create > Sale auction**, or `POST /sigmafi/zc/lots`.

A lot has the following terms:

| Term | What it sets |
|---|---|
| Market | The currency it sells for, ERG or SigUSD |
| Items | The tokens sold. A SigUSD lot may also sell ERG, and may not hold SigUSD itself |
| Opening, floor | The price until the start, and from the end on |
| Start, end | Between them the price falls in a straight line. Start defaults to now |
| Expiry | From then, anyone may return the lot to you for the refund fee. Default the end |
| Refund fee | Default 0.002 ERG. On a SigUSD lot the buyer takes all the box's ERG, this fee included |

The price only falls, so a purchase priced now stays valid. On an ERG lot the box's own ERG comes back
to you with the payment. Lend offers never buy lots, because a lot is not a bond.

## Wrapping a token

Some tokens grant authority wherever they appear in a transaction. A LithosDex liquidity position's owner
NFT is one: any transaction that spends a box holding it can claim or resize the position. Put such a
token raw into an order, bond or ask, and a stranger running a SigmaFi step could drain the position.

A **wrap** prevents that. Use **Create > Wrap an NFT**, or `POST /sigmafi/zc/wraps`:

1. The token goes into a wrap request. A batcher mints three **receipt** units for the mint fee.
2. You receive one receipt unit, named `ZCS-Wrap-` and the token's first six characters.
3. The token and the other two units stay in a wrap vault, which nothing else can be spent beside.

Pledge, sell or auction the receipt instead of the token. Whoever holds the receipt can **unwrap**:
`POST /sigmafi/zc/wraps/{receiptId}/unwrap` burns all three units and returns the token. A wrap costs
about 0.038 ERG: two box minimums, a 0.03 ERG refresh reserve that keeps the vault ahead of storage rent
for about six years, the 0.005 ERG mint fee and the miner fee. The client refuses a LithosDex position NFT
in a lot and asks you to wrap it.

## Next steps

- [Lending](https://lithosprotocol.org/docs/sigmafi/lending): lend offers that buy from asks automatically.
- [Borrowing](https://lithosprotocol.org/docs/sigmafi/borrowing): buying back a claim on your own loan.
- [Pricing](https://lithosprotocol.org/docs/sigmafi/pricing): how yield asks and share prices are computed.
- [The Lithos client and panel](https://lithosprotocol.org/docs/extensions/sigmafi-bonds): the Market and Auctions views.
