mintInventoryImpact function

BigInt mintInventoryImpact(
  1. FeePolicy policy,
  2. MintBookTerms book,
  3. BigInt quantity
)

strike_exposure::mint_range_inventory_impact — the charge a mint of quantity over a range pays: the exact rise in the book potential. Zero at the shipped rate of zero.

Implementation

BigInt mintInventoryImpact(
    FeePolicy policy, MintBookTerms book, BigInt quantity) {
  _assertFeePolicy(policy);
  _assertBook(book);
  _assertUint(quantity, 'quantity', maximum: U64_MAX - book.totalPayout);
  if (policy.inventoryImpactMaxRate == BigInt.zero || quantity == BigInt.zero) {
    return BigInt.zero;
  }
  final before = _payoutLiability(policy, book.maxPayout, book.totalPayout);
  final after = _payoutLiability(
    policy,
    _max(book.maxPayout, book.rangeMaxPayout + quantity),
    book.totalPayout + quantity,
  );
  return inventoryImpactPotential(policy, after) -
      inventoryImpactPotential(policy, before);
}