# Deep Dive

## SimpleCollateralAuctionGraph1 contract

Note: *The Underlying referred within the context of this particular contract spec is actually the FUnderlying.*

This contract is exclusive to a loan market, and is created by the MarketDao at the time of market settlement initiation (ie, when a loan market expiry has been reached) only when the loan market has outstanding liability.

The purpose of the auction is to sell the underlying in order to raise the currency amount to cover the liability. The starting price includes a slippage added to the oracle price obtained for the currency-underlying pair. There will be a discount window during which the underlying will be sold at a discount. In other words, the sell price of the underlying continuously decreases until it reaches a maximum allowed discount level (eg 40% discounted from the start price). Beyond this window, the underlying will continue to be sold at the maximum allowed discount.

The auction is deemed inactive and therefore, the corresponding loan market settled, if either of the following holds:

- All the underlying has been sold
- The outstanding currency amount has been raised

### Dao-only

Function | Params | Description |
---|---|---|

start | `params` | Called only by the MarketDao. |

### Common

Function | Params | Description |
---|---|---|

current_price | - | Can be called by anyone. Returns the current selling price of the underlying per currency at any time t according to the following formula $$ P_t = \frac {P_0 \cdot D - (P_0 - P_T)(t - t_0)} D \text{ if}\ (t < T) $$ and $$ P_t = P_T \text{ if}\ (t \geq T) $$ where t _{0} : Auction start timeP _{0} : Auction start priceT : Time when discount duration ends P _{T} : Max discounted priceD : Discount duration period |

purchase | `amount` | Can be called by anyone. Sells the given amount of underlying to the caller in exchange for currency (from the caller’s account) according to the current_price of the underlying. |

purchase_for_remaining_currency | - | Can be called by anyone. Sells as much of the FUnderlying to the caller as is needed to raise the remaining currency according to the current_price of the underlying. |

purchase_remaining_underlying | - | Can be called by anyone. For the remaining FUnderlying, computes the currency amount. If the currency amount is more than the required amount to raise, then the function behaves the same as `purchase_for_remaining_currency()` |

### Escape-hatch

Function | Params | Description |
---|---|---|

escape_hatch_underlying_f | - | Can be called only by the owner, aka, MarketDao. Transfers contracts balance of the MFT FUnderlying token to the Escape Hatch Token Holder wallet. |