Formulas & derived params
📝 Draft. This chapter has not been reviewed yet — content may be incomplete or change.
Problem. Compute amounts, indices, and parameter values from other values instead of hard-coding them.
🚧 This recipe is a stub. Outline of what it will cover:
- Where formulas appear: output/input
amount_sat, a param'scompute, and hooksetvalues. (Not witnesses — a witness takes a literal value, not an expression.)- Operators (
+ - * /, comparisons,&& || !) and references (instance.X,params.X,input_id.amount_sat,input_id.asset,input_id.present).- Functions:
pow(base, exp), andconcat(...)forOP_RETURNdataonly.- The special
feevalue used in change and re-lock formulas.- Computed params (
"compute": "..."): interest =PRINCIPAL_AMOUNT * PRINCIPAL_INTEREST_RATE / 10000, and params derived from issuance outpoints.
In the meantime the formula language reference
has the operators, the references, and the $ prefix rule.