Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

fees.gno

0.50 Kb · 12 lines
 1package escrow_v3
 2
 3// basisPointsFee computes floor(amount*bps/10000) without overflowing the
 4// intermediate product. For nonnegative amount and bps <= 10000, the quotient
 5// product and final sum are <= amount; the remainder product is < 100000000.
 6// Callers retain their existing configured rates, recipients and rounding.
 7func basisPointsFee(amount, bps int64) int64 {
 8	if amount < 0 || bps < 0 || bps > 10000 {
 9		panic("invalid fee inputs")
10	}
11	return (amount/10000)*bps + ((amount%10000)*bps)/10000
12}