function bite(bytes32 ilk, address urn) public returns (uint id) {
// Get the rate, spot, and dust from the ilk in the vat.
(,uint256 rate,uint256 spot,,uint256 dust) = vat.ilks(ilk);
// get the ink and art from the urn from the Vat.
(uint256 ink, uint256 art) = vat.urns(ilk, urn);
// ensure End has not happened
// require the Vault to be unsafe (see definition above).
require(spot > 0 && mul(ink, spot) < mul(art, rate), "Cat/not-unsafe");
// Loads the `ilk` data into memory as an optimization.
Ilk memory milk = ilks[ilk];
// Declares a variable that will be assigned in the following scope.
// Defines a new scope, this prevents a stack too deep error in solidity
// Calculate the available space in the box
uint256 room = sub(box, litter);
// test whether the remaining space in the litterbox is dusty
require(litter < box && room >= dust, "Cat/liquidation-limit-hit");
// Sets the amount of debt to be covered by the auction.
// (smaller of either the amount of normalized debt, maximum debt chunk size, or space in the box)
// divided by the rate, divided by the penalty fee.
dart = min(art, mul(min(milk.dunk, room), WAD) / rate / milk.chop);
// Takes the minimum of the collateral balance or the
// amount of collateral represented by the debt to be covered
uint256 dink = min(ink, mul(ink, dart) / art);
// Prevents no-collateral auctions
require(dart > 0 && dink > 0 , "Cat/null-auction");
// Protects against int overflow when converting from uint to int
require(dart <= 2**255 && dink <= 2**255, "Cat/overflow" );
// Called in this way, vat.grab will:
// - Remove the dink and the dart from the bitten Vault (urn)
// - Adds the collateral (dink) to the Cat's gem
// - Adds the debt (dart) to the Vow's debt (vat.sin[vow])
// - Increases the total unbacked dai (vice) in the system
// This may leave the CDP in a dusty state
ilk, urn, address(this), address(vow), -int256(dink), -int256(dart)
// Adds the debt to the debt-queue in Vow (Vow.Sin and Vow.sin[now])
vow.fess(mul(dart, rate));
{ // Avoid stack too deep
// This calcuation will overflow if dart*rate exceeds ~10^14,
// i.e. the maximum dunk is roughly 100 trillion DAI.
// Multiplies the accumulated rate by the normalized debt to be covered
// to get the total debt tab (debt + stability fee + liquidation penalty) for the auction.
uint256 tab = mul(mul(dart, rate), milk.chop) / WAD;
// Updates the amount of litter in the box
litter = add(litter, tab);
// Calls kick on the collateral's Flipper contract.
// tab is the total debt to be sent to auction
// gal: address(vow) sets up the Vow as the recipient of the Dai income for this auction
// bid: 0 indicates that this is the opening bid
// This moves the collateral from the Cat's gem to the Flipper's gem in the Vat
id = Kicker(milk.flip).kick({
// Emits an event about the bite to notify actors (for instance keepers) about the new auction
emit Bite(ilk, urn, dink, dart, mul(dart, rate), milk.flip, id);