nx_caplab_finance.nx
buildroot/runtime/nx_caplab_finance.nx
about
nx_caplab_finance.nx -- Capitalism Lab R7: firm finances (loans/debt/interest/
bankruptcy). Cash isn't infinite: a firm can BORROW (up to a credit limit) to
fund expansion/investment, pays INTEREST on its debt each period, can REPAY,
and goes BANKRUPT when its net worth falls below what its credit can cover.
A loan adds liquidity (cash) AND liability (debt) equally -- it does NOT raise
net worth; only earnings do, and interest erodes it. Integer, deterministic.
finance record (*i64): [0]=cash [1]=debt
net_worth = cash - debt
loan(amt) : if debt+amt <= credit_limit -> cash+=amt, debt+=amt
interest(rate) : cash -= debt*rate/100
repay(amt) : pay = min(amt, debt, cash); cash-=pay, debt-=pay
bankrupt : net_worth <= -credit_limit (underwater beyond all credit)
nx_safety_envelope:
intended_use: capitalism-lab firm finances (pure, mutate the record)
sil_target: SIL1
verdict: NOT_YET_EVALUATED
genealogy_id: capitalism_lab_finance_canon
lineage_id: nx_caplab_finance_v1
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_caplab_finance_test.nx
structs
| none |
consts
| 26 | const NX_FIN_CASH: nx_int = 0 |
| 27 | const NX_FIN_DEBT: nx_int = 1 |
functions
| 29 | func nx_clab_fin_networth(fin: *i64) -> nx_int |
| 35 | func nx_clab_fin_loan(fin: *i64, amount: nx_int, credit_limit: nx_int) -> nx_int called by 1: main |
| 43 | func nx_clab_fin_interest(fin: *i64, rate_pct: nx_int) called by 1: main |
| 49 | func nx_clab_fin_repay(fin: *i64, amount: nx_int) called by 1: main |
| 59 | func nx_clab_fin_bankrupt(fin: *i64, credit_limit: nx_int) -> nx_int |