code wiki / (root) / nx_fin_taxopt.nx

nx_fin_taxopt.nx source

↩ module page · 48 lines · 2583 B

1// nx_fin_taxopt.nx -- R7 tax-OPTIMIZATION / entity modeling = "park gains like the big companies", LEGALLY. 2// Models the §1202 QSBS exclusion (hold >=5yr in qualified small-biz stock -> exclude up to the greater of $10M 3// or 10x basis from federal cap gains), pass-through vs C-corp double-taxation comparison, and the value of 4// DEFERRING a tax bill (compound growth on the retained tax). Pure, i64 (cents/bps/years). AI drafts + MODELS; 5// a licensed CPA/attorney signs anything filed. license_tier: ORIGINAL 6import "nx_syscalls.nx" 7const TO_MAGIC_10000: i64 = 10000 8 9const TO_QSBS_MIN_YEARS: i64 = 5 10const TO_QSBS_FLOOR_CENTS: i64 = 1000000000 // $10,000,000 §1202 floor 11 12func to_max(a: i64, b: i64) -> i64 { if a > b { return a } return b } 13func to_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } 14 15// §1202 QSBS exclusion (cents): qualifies AND held >=5yr -> exclude up to greater of $10M or 10x basis. 16func to_qsbs_exclusion(gain_cents: i64, basis_cents: i64, held_years: i64, qualifies: i64) -> i64 { 17 if qualifies != 1 { return 0 } 18 if held_years < TO_QSBS_MIN_YEARS { return 0 } 19 let cap: i64 = to_max(TO_QSBS_FLOOR_CENTS, 10*basis_cents) 20 return to_min(gain_cents, cap) 21} 22 23// federal cap-gains tax after applying an exclusion. 24func to_tax_after_qsbs(gain_cents: i64, excluded_cents: i64, rate_bps: i64) -> i64 { 25 var taxable: i64 = gain_cents - excluded_cents 26 if taxable < 0 { taxable = 0 } 27 return taxable * rate_bps / TO_MAGIC_10000 28} 29 30// pass-through (S-corp / LLC) tax = profit * individual rate. 31func to_passthrough_tax(profit_cents: i64, individual_rate_bps: i64) -> i64 { return profit_cents * individual_rate_bps / TO_MAGIC_10000 } 32 33// C-corp TOTAL tax = corporate tax + dividend tax on the paid-out remainder (the double taxation). 34func to_ccorp_total_tax(profit_cents: i64, corp_rate_bps: i64, div_rate_bps: i64, payout_bps: i64) -> i64 { 35 let corp_tax: i64 = profit_cents * corp_rate_bps / TO_MAGIC_10000 36 let after: i64 = profit_cents - corp_tax 37 let dividend: i64 = after * payout_bps / TO_MAGIC_10000 38 let div_tax: i64 = dividend * div_rate_bps / TO_MAGIC_10000 39 return corp_tax + div_tax 40} 41 42// value gained by DEFERRING a tax bill and investing it at rate_bps for `years` (compound). This is the "park it 43// and let it grow" advantage the big players use. 44func to_deferral_gain(tax_cents: i64, rate_bps: i64, years: i64) -> i64 { 45 var acc: i64 = tax_cents; var i: i64 = 0 46 while i < years { acc = acc * (TO_MAGIC_10000 + rate_bps) / TO_MAGIC_10000; i = i + 1 } 47 return acc - tax_cents 48}