import { INTERNAL_ERROR_MESSAGE, Result, Ok, Err } from "@"; type Result$0 = Result; export type Fpv = { /** * ***Brief*** * Unwraps the wrapped value of type `T1`. * * ***Requirement*** * Does not `panic`. * * ***Example*** * ```ts * let unsafe: Unsafe = Unsafe(500n); * unsafe.unwrap(); * ``` */ unwrap(): bigint; decimals(): T1; representation(): bigint; eq(x: bigint): boolean; eq(x: Fpv): boolean; eq(x: Fpv.Compatible): boolean; lt(x: bigint): boolean; lt(x: Fpv): boolean; lt(x: Fpv.Compatible): boolean; gt(x: bigint): boolean; gt(x: Fpv): boolean; gt(x: Fpv.Compatible): boolean; lteq(x: bigint): boolean; lteq(x: Fpv): boolean; lteq(x: Fpv.Compatible): boolean; gteq(x: bigint): boolean; gteq(x: Fpv): boolean; gteq(x: Fpv.Compatible): boolean; add(x: bigint): Fpv; add(x: Fpv): Fpv; add(x: Fpv.Compatible): Fpv; sub(x: bigint): Fpv; sub(x: Fpv): Fpv; sub(x: Fpv.Compatible): Fpv; mul(x: bigint): Fpv; mul(x: Fpv): Fpv; mul(x: Fpv.Compatible): Fpv; div(x: bigint): Fpv.Result>; div(x: Fpv): Fpv.Result>; div(x: Fpv.Compatible): Fpv.Result>; pow(x: bigint): Fpv.Result>; pow(x: Fpv): Fpv.Result>; pow(x: Fpv.Compatible): Fpv.Result>; sqrt(): Fpv.Result>; convert(decimals: T2): Fpv.Result>; percentageOf(x: bigint): Fpv.Result>; percentageOf(x: Fpv): Fpv.Result>; percentageOf(x: Fpv.Compatible): Fpv.Result>; percentageGain(newValue: bigint): Fpv.Result>; percentageGain(newValue: Fpv): Fpv.Result>; percentageGain(newValue: Fpv.Compatible): Fpv.Result>; percentageLoss(newValue: bigint): Fpv.Result>; percentageLoss(newValue: Fpv): Fpv.Result>; percentageLoss(newValue: Fpv.Compatible): Fpv.Result>; percentageChange(newValue: bigint): Fpv.Result>; percentageChange(newValue: Fpv): Fpv.Result>; percentageChange(newValue: Fpv.Compatible): Fpv.Result>; sliceOf(percentage: bigint): Fpv.Result>; sliceOf(percentage: Fpv): Fpv.Result>; sliceOf(percentage: Fpv.Compatible): Fpv.Result>; addPercentage(percentage: bigint): Fpv.Result>; addPercentage(percentage: Fpv): Fpv.Result>; addPercentage(percentage: Fpv.Compatible): Fpv.Result>; subPercentage(percentage: bigint): Fpv.Result>; subPercentage(percentage: Fpv): Fpv.Result>; subPercentage(percentage: Fpv.Compatible): Fpv.Result>; toNumber(): number; }; /** * ***Warning*** * Does not support negative `decimals`. */ export function Fpv(_v: Fpv.Compatible, _decimals: T1): Fpv.Result> { /***/ { if (decimals() < 0n) return Err("FPV.ERR_NEGATIVE_DECIMALS"); return Ok({ unwrap, decimals, representation, eq, lt, gt, lteq, gteq, add, sub, mul, div, pow, sqrt, convert, percentageOf, percentageGain, percentageLoss, percentageChange, sliceOf, addPercentage, subPercentage, toNumber }); } function unwrap(): bigint { return Fpv.Calculator.unwrap(_v); } function decimals(): T1 { return _decimals; } function representation(): bigint { return 10n ** decimals(); } function eq(x: bigint): boolean; function eq(x: Fpv): boolean; function eq(x: Fpv.Compatible): boolean { return Fpv.Calculator.eq(_v, x); } function lt(x: bigint): boolean; function lt(x: Fpv): boolean; function lt(x: Fpv.Compatible): boolean { return Fpv.Calculator.lt(_v, x); } function gt(x: bigint): boolean; function gt(x: Fpv): boolean; function gt(x: Fpv.Compatible): boolean { return Fpv.Calculator.gt(_v, x); } function lteq(x: bigint): boolean; function lteq(x: Fpv): boolean; function lteq(x: Fpv.Compatible): boolean { return Fpv.Calculator.lteq(_v, x); } function gteq(x: bigint): boolean; function gteq(x: Fpv): boolean; function gteq(x: Fpv.Compatible): boolean { return Fpv.Calculator.gteq(_v, x); } function add(x: bigint): Fpv; function add(x: Fpv): Fpv; function add(x: Fpv.Compatible): Fpv { return Fpv.Calculator .add(_v, x, decimals()) .expect(INTERNAL_ERROR_MESSAGE); } function sub(x: bigint): Fpv; function sub(x: Fpv): Fpv; function sub(x: Fpv.Compatible): Fpv { return Fpv.Calculator .sub(_v, x, decimals()) .expect(INTERNAL_ERROR_MESSAGE); } function mul(x: bigint): Fpv; function mul(x: Fpv): Fpv; function mul(x: Fpv.Compatible): Fpv { return Fpv.Calculator .mul(_v, x, decimals()) .expect(INTERNAL_ERROR_MESSAGE); } function div(x: bigint): Fpv.Result>; function div(x: Fpv): Fpv.Result>; function div(x: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.div(_v, x, decimals()); } function pow(x: bigint): Fpv.Result>; function pow(x: Fpv): Fpv.Result>; function pow(x: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.pow(_v, x, decimals()); } function sqrt(): Fpv.Result> { return Fpv.Calculator.sqrt(_v, decimals()); } function convert(decimals$0: T2): Fpv.Result> { return Fpv.Calculator.convert(_v, decimals(), decimals$0); } function percentageOf(x: bigint): Fpv.Result>; function percentageOf(x: Fpv): Fpv.Result>; function percentageOf(x: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.percentageOf(_v, x, decimals()); } function percentageGain(newValue: bigint): Fpv.Result>; function percentageGain(newValue: Fpv): Fpv.Result>; function percentageGain(newValue: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.percentageGain(_v, newValue, decimals()); } function percentageLoss(newValue: bigint): Fpv.Result>; function percentageLoss(newValue: Fpv): Fpv.Result>; function percentageLoss(newValue: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.percentageLoss(_v, newValue, decimals()); } function percentageChange(newValue: bigint): Fpv.Result>; function percentageChange(newValue: Fpv): Fpv.Result>; function percentageChange(newValue: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.percentageChange(_v, newValue, decimals()); } function sliceOf(percentage: bigint): Fpv.Result>; function sliceOf(percentage: Fpv): Fpv.Result>; function sliceOf(percentage: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.sliceOf(_v, percentage, decimals()); } function addPercentage(percentage: bigint): Fpv.Result>; function addPercentage(percentage: Fpv): Fpv.Result>; function addPercentage(percentage: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.addPercentage(_v, percentage, decimals()); } function subPercentage(percentage: bigint): Fpv.Result>; function subPercentage(percentage: Fpv): Fpv.Result>; function subPercentage(percentage: Fpv.Compatible): Fpv.Result> { return Fpv.Calculator.subPercentage(_v, percentage, decimals()); } function toNumber(): number { return Number(_v) / Number(10n**decimals()); } } export namespace Fpv { export type Result = Result$0; export type ErrorCode = | "FPV.ERR_DIVISION_BY_ZERO" | "FPV.ERR_NEGATIVE_DECIMALS" | "FPV.ERR_NEGATIVE_EXPONENT" | "FPV.ERR_CANNOT_SQUARE_NAGATIVE"; export type Compatible = Fpv | bigint; export type Decimals = bigint; export type Calculator = { unwrap(value: Compatible): bigint; eq(x: bigint, y: bigint): boolean; eq(x: Fpv, y: bigint): boolean; eq(x: bigint, y: Fpv): boolean; eq(x: Fpv, y: Fpv): boolean; eq(x: Compatible, y: Compatible): boolean; lt(x: bigint, y: bigint): boolean; lt(x: Fpv, y: bigint): boolean; lt(x: bigint, y: Fpv): boolean; lt(x: Fpv, y: Fpv): boolean; lt(x: Compatible, y: Compatible): boolean; gt(x: bigint, y: bigint): boolean; gt(x: Fpv, y: bigint): boolean; gt(x: bigint, y: Fpv): boolean; gt(x: Fpv, y: Fpv): boolean; gt(x: Compatible, y: Compatible): boolean; lteq(x: bigint, y: bigint): boolean; lteq(x: Fpv, y: bigint): boolean; lteq(x: bigint, y: Fpv): boolean; lteq(x: Fpv, y: Fpv): boolean; lteq(x: Compatible, y: Compatible): boolean; gteq(x: bigint, y: bigint): boolean; gteq(x: Fpv, y: bigint): boolean; gteq(x: bigint, y: Fpv): boolean; gteq(x: Fpv, y: Fpv): boolean; gteq(x: Compatible, y: Compatible): boolean; add(x: bigint, y: bigint, decimals: T1): Result>; add(x: Fpv, y: bigint, decimals: T1): Result>; add(x: bigint, y: Fpv, decimals: T1): Result>; add(x: Fpv, y: Fpv, decimals: T1): Result>; add(x: Compatible, y: Compatible, decimals: T1): Result>; sub(x: bigint, y: bigint, decimals: T1): Result>; sub(x: Fpv, y: bigint, decimals: T1): Result>; sub(x: bigint, y: Fpv, decimals: T1): Result>; sub(x: Fpv, y: Fpv, decimals: T1): Result>; sub(x: Compatible, y: Compatible, decimals: T1): Result>; mul(x: bigint, y: bigint, decimals: T1): Result>; mul(x: Fpv, y: bigint, decimals: T1): Result>; mul(x: bigint, y: Fpv, decimals: T1): Result>; mul(x: Fpv, y: Fpv, decimals: T1): Result>; mul(x: Compatible, y: Compatible, decimals: T1): Result>; div(x: bigint, y: bigint, decimals: T1): Result>; div(x: Fpv, y: bigint, decimals: T1): Result>; div(x: bigint, y: Fpv, decimals: T1): Result>; div(x: Fpv, y: Fpv, decimals: T1): Result>; div(x: Compatible, y: Compatible, decimals: T1): Result>; pow(x: bigint, y: bigint, decimals: T1): Result>; pow(x: Fpv, y: bigint, decimals: T1): Result>; pow(x: bigint, y: Fpv, decimals: T1): Result>; pow(x: Fpv, y: Fpv, decimals: T1): Result>; pow(x: Compatible, y: Compatible, decimals: T1): Result>; sqrt(x: bigint, decimals: T1): Result>; sqrt(x: Fpv, decimals: T1): Result>; sqrt(x: Compatible, decimals: T1): Result>; convert(x: bigint, oldDecimals: T1, newDecimals: T2): Result>; convert(x: Fpv, oldDecimals: T1, newDecimals: T2): Result>; convert(x: Compatible, oldDecimals: T1, newDecimals: T2): Result>; percentageOf(x: bigint, y: bigint, decimals: T1): Result>; percentageOf(x: Fpv, y: bigint, decimals: T1): Result>; percentageOf(x: bigint, y: Fpv, decimals: T1): Result>; percentageOf(x: Fpv, y: Fpv, decimals: T1): Result>; percentageOf(x: Compatible, y: Compatible, decimals: T1): Result>; percentageGain(oldValue: bigint, newValue: bigint, decimals: T1): Result>; percentageGain(oldValue: Fpv, newValue: bigint, decimals: T1): Result>; percentageGain(oldValue: bigint, newValue: Fpv, decimals: T1): Result>; percentageGain(oldValue: Fpv, newValue: Fpv, decimals: T1): Result>; percentageGain(oldValue: Compatible, newValue: Compatible, decimals: T1): Result>; percentageLoss(oldValue: bigint, newValue: bigint, decimals: T1): Result>; percentageLoss(oldValue: Fpv, newValue: bigint, decimals: T1): Result>; percentageLoss(oldValue: bigint, newValue: Fpv, decimals: T1): Result>; percentageLoss(oldValue: Fpv, newValue: Fpv, decimals: T1): Result>; percentageLoss(oldValue: Compatible, newValue: Compatible, decimals: T1): Result>; percentageChange(oldValue: bigint, newValue: bigint, decimals: T1): Result>; percentageChange(oldValue: Fpv, newValue: bigint, decimals: T1): Result>; percentageChange(oldValue: bigint, newValue: Fpv, decimals: T1): Result>; percentageChange(oldValue: Fpv, newValue: Fpv, decimals: T1): Result>; percentageChange(oldValue: Compatible, newValue: Compatible, decimals: T1): Result>; sliceOf(x: bigint, percentage: bigint, decimals: T1): Result>; sliceOf(x: Fpv, percentage: bigint, decimals: T1): Result>; sliceOf(x: bigint, percentage: Fpv, decimals: T1): Result>; sliceOf(x: Fpv, percentage: Fpv, decimals: T1): Result>; sliceOf(x: Compatible, percentage: Compatible, decimals: T1): Result>; addPercentage(x: bigint, percentage: bigint, decimals: T1): Result>; addPercentage(x: Fpv, percentage: bigint, decimals: T1): Result>; addPercentage(x: bigint, percentage: Fpv, decimals: T1): Result>; addPercentage(x: Fpv, percentage: Fpv, decimals: T1): Result>; addPercentage(x: Compatible, percentage: Compatible, decimals: T1): Result>; subPercentage(x: bigint, percentage: bigint, decimals: T1): Result>; subPercentage(x: Fpv, percentage: bigint, decimals: T1): Result>; subPercentage(x: bigint, percentage: Fpv, decimals: T1): Result>; subPercentage(x: Fpv, percentage: Fpv, decimals: T1): Result>; subPercentage(x: Compatible, percentage: Compatible, decimals: T1): Result>; }; export const Calculator: Calculator = (() => { /***/ { return { unwrap, eq, lt, gt, lteq, gteq, add, sub, mul, div, pow, sqrt, convert, percentageOf, percentageGain, percentageLoss, percentageChange, sliceOf, addPercentage, subPercentage }; } function unwrap(value: Compatible): bigint { return typeof value === "bigint" ? value : value.unwrap(); } function eq(x: bigint, y: bigint): boolean; function eq(x: Fpv, y: bigint): boolean; function eq(x: bigint, y: Fpv): boolean; function eq(x: Fpv, y: Fpv): boolean; function eq(x: Compatible, y: Compatible): boolean { return unwrap(x) === unwrap(y); } function lt(x: bigint, y: bigint): boolean; function lt(x: Fpv, y: bigint): boolean; function lt(x: bigint, y: Fpv): boolean; function lt(x: Fpv, y: Fpv): boolean; function lt(x: Compatible, y: Compatible): boolean { return unwrap(x) < unwrap(y); } function gt(x: bigint, y: bigint): boolean; function gt(x: Fpv, y: bigint): boolean; function gt(x: bigint, y: Fpv): boolean; function gt(x: Fpv, y: Fpv): boolean; function gt(x: Compatible, y: Compatible): boolean { return unwrap(x) > unwrap(y); } function lteq(x: bigint, y: bigint): boolean; function lteq(x: Fpv, y: bigint): boolean; function lteq(x: bigint, y: Fpv): boolean; function lteq(x: Fpv, y: Fpv): boolean; function lteq(x: Compatible, y: Compatible): boolean { return unwrap(x) <= unwrap(y); } function gteq(x: bigint, y: bigint): boolean; function gteq(x: Fpv, y: bigint): boolean; function gteq(x: bigint, y: Fpv): boolean; function gteq(x: Fpv, y: Fpv): boolean; function gteq(x: Compatible, y: Compatible): boolean { return unwrap(x) >= unwrap(y); } function add(x: bigint, y: bigint, decimals: T1): Result>; function add(x: Fpv, y: bigint, decimals: T1): Result>; function add(x: bigint, y: Fpv, decimals: T1): Result>; function add(x: Fpv, y: Fpv, decimals: T1): Result>; function add(x: Compatible, y: Compatible, decimals: T1): Result> { return Fpv(unwrap(x) + unwrap(y), decimals); } function sub(x: bigint, y: bigint, decimals: T1): Result>; function sub(x: Fpv, y: bigint, decimals: T1): Result>; function sub(x: bigint, y: Fpv, decimals: T1): Result>; function sub(x: Fpv, y: Fpv, decimals: T1): Result>; function sub(x: Compatible, y: Compatible, decimals: T1): Result> { return Fpv(unwrap(x) - unwrap(y), decimals); } function mul(x: bigint, y: bigint, decimals: T1): Result>; function mul(x: Fpv, y: bigint, decimals: T1): Result>; function mul(x: bigint, y: Fpv, decimals: T1): Result>; function mul(x: Fpv, y: Fpv, decimals: T1): Result>; function mul(x: Compatible, y: Compatible, decimals: T1): Result> { let x$0: bigint = unwrap(x); let y$0: bigint = unwrap(y); let z: bigint = x$0 * y$0; if (decimals === 0n) return Fpv(z, decimals); return Fpv(z / (10n ** decimals), decimals); } function div(x: bigint, y: bigint, decimals: T1): Result>; function div(x: Fpv, y: bigint, decimals: T1): Result>; function div(x: bigint, y: Fpv, decimals: T1): Result>; function div(x: Fpv, y: Fpv, decimals: T1): Result>; function div(x: Compatible, y: Compatible, decimals: T1): Result> { let x$0: bigint = unwrap(x); let y$0: bigint = unwrap(y); if (y$0 === 0n) return Err("FPV.ERR_DIVISION_BY_ZERO"); if (decimals === 0n) return Ok(Fpv(x$0 / y$0, decimals).expect(INTERNAL_ERROR_MESSAGE)); let z: bigint = x$0 * (10n ** decimals); let q: bigint = z / y$0; return Ok(Fpv(q, decimals).expect(INTERNAL_ERROR_MESSAGE)); } function pow(x: bigint, y: bigint, decimals: T1): Result>; function pow(x: Fpv, y: bigint, decimals: T1): Result>; function pow(x: bigint, y: Fpv, decimals: T1): Result>; function pow(x: Fpv, y: Fpv, decimals: T1): Result>; function pow(x: Compatible, y: Compatible, decimals: T1): Result> { let base: bigint = unwrap(x); let exponent: bigint = unwrap(y); if (exponent < 0n) return Err("FPV.ERR_NEGATIVE_EXPONENT"); let result: bigint = 1n; while (exponent > 0n) { if (exponent % 2n === 1n) result = (result * base) / (10n ** decimals); base = (base * base) / (10n ** decimals); exponent /= 2n; } let result$0: Result> = convert(result, 0n, decimals); if (result$0.err()) return result$0; let result$1: Fpv = result$0.unwrap(); let result$2: bigint = result$1.unwrap(); return Fpv(result$2, decimals); } function sqrt(x: bigint, decimals: T1): Result>; function sqrt(x: Fpv, decimals: T1): Result>; function sqrt(x: Compatible, decimals: T1): Result> { let x$0: bigint = unwrap(x); if (x$0 < 0n) return Err("FPV.ERR_CANNOT_SQUARE_NAGATIVE"); if (x$0 === 0n) return Fpv(0n, decimals); let one: bigint = 10n ** decimals; one *= x$0; let x$1: bigint = one; let y: bigint; do { y = x$1; x$1 = (y + one / y) / 2n; } while(x$1 !== y); return Fpv(x$1, decimals); } function convert(x: bigint, oldDecimals: T1, newDecimals: T2): Result>; function convert(x: Fpv, oldDecimals: T1, newDecimals: T2): Result>; function convert(x: Compatible, oldDecimals: T1, newDecimals: T2): Result> { if (oldDecimals < 0n) return Err("FPV.ERR_NEGATIVE_DECIMALS"); if (newDecimals < 0n) return Err("FPV.ERR_NEGATIVE_DECIMALS"); let x$0: bigint = unwrap(x); let scl: bigint; if (newDecimals > oldDecimals) { scl = 10n ** (newDecimals - oldDecimals as unknown as bigint); x$0 *= scl; } if (newDecimals < oldDecimals) { scl = 10n ** (oldDecimals - newDecimals as unknown as bigint); x$0 /= scl; } return Ok(Fpv(x$0, newDecimals).expect(INTERNAL_ERROR_MESSAGE)); } function percentageOf(x: bigint, y: bigint, decimals: T1): Result>; function percentageOf(x: Fpv, y: bigint, decimals: T1): Result>; function percentageOf(x: bigint, y: Fpv, decimals: T1): Result>; function percentageOf(x: Fpv, y: Fpv, decimals: T1): Result>; function percentageOf(x: Compatible, y: Compatible, decimals: T1): Result> { let x$0: bigint = unwrap(x); let y$0: bigint = unwrap(y); return div(x$0, y$0, decimals) .map(value => { return value.unwrap(); }) .and(value => { return mul(value, 100n * (10n**decimals), decimals); }); } function percentageGain(oldValue: bigint, newValue: bigint, decimals: T1): Result>; function percentageGain(oldValue: Fpv, newValue: bigint, decimals: T1): Result>; function percentageGain(oldValue: bigint, newValue: Fpv, decimals: T1): Result>; function percentageGain(oldValue: Fpv, newValue: Fpv, decimals: T1): Result>; function percentageGain(oldValue: Compatible, newValue: Compatible, decimals: T1): Result> { let oldValue$0: bigint = unwrap(oldValue); let newValue$0: bigint = unwrap(newValue); if (newValue$0 <= oldValue$0) return Fpv(0n, decimals); return sub(newValue$0, oldValue$0, decimals) .and(value => { return div(value, oldValue$0, decimals); }) .and(value => { return mul(value, 100n * (10n**decimals), decimals); }) .mapErr(e => { return e as ErrorCode; }); } function percentageLoss(oldValue: bigint, newValue: bigint, decimals: T1): Result>; function percentageLoss(oldValue: Fpv, newValue: bigint, decimals: T1): Result>; function percentageLoss(oldValue: bigint, newValue: Fpv, decimals: T1): Result>; function percentageLoss(oldValue: Fpv, newValue: Fpv, decimals: T1): Result>; function percentageLoss(oldValue: Compatible, newValue: Compatible, decimals: T1): Result> { let oldValue$0: bigint = unwrap(oldValue); let newValue$0: bigint = unwrap(newValue); if (newValue$0 >= oldValue$0) return Fpv(0n, decimals); return sub(newValue$0, oldValue$0, decimals) .and(value => { return div(value, oldValue$0, decimals) }) .and(value => { return mul(value, 100n * (10n**decimals), decimals); }) .mapErr(e => { return e as ErrorCode; }); } function percentageChange(oldValue: bigint, newValue: bigint, decimals: T1): Result>; function percentageChange(oldValue: Fpv, newValue: bigint, decimals: T1): Result>; function percentageChange(oldValue: bigint, newValue: Fpv, decimals: T1): Result>; function percentageChange(oldValue: Fpv, newValue: Fpv, decimals: T1): Result>; function percentageChange(oldValue: Compatible, newValue: Compatible, decimals: T1): Result> { let oldValue$0: bigint = unwrap(oldValue); let newValue$0: bigint = unwrap(newValue); if (newValue$0 <= oldValue$0) return percentageLoss(oldValue$0, newValue$0, decimals); return percentageGain(oldValue$0, newValue$0, decimals); } function sliceOf(x: bigint, percentage: bigint, decimals: T1): Result>; function sliceOf(x: Fpv, percentage: bigint, decimals: T1): Result>; function sliceOf(x: bigint, percentage: Fpv, decimals: T1): Result>; function sliceOf(x: Fpv, percentage: Fpv, decimals: T1): Result>; function sliceOf(x: Compatible, percentage: Compatible, decimals: T1): Result> { let x$0: bigint = unwrap(x); let percentage$0: bigint = unwrap(percentage); let z: Result> = div(x$0, 100n * (10n**decimals), decimals); if (z.err()) return z; let z$0: Fpv = z.unwrap(); return mul(z$0, percentage$0, decimals); } function addPercentage(x: bigint, percentage: bigint, decimals: T1): Result>; function addPercentage(x: Fpv, percentage: bigint, decimals: T1): Result>; function addPercentage(x: bigint, percentage: Fpv, decimals: T1): Result>; function addPercentage(x: Fpv, percentage: Fpv, decimals: T1): Result>; function addPercentage(x: Compatible, percentage: Compatible, decimals: T1): Result> { let x$0: bigint = unwrap(x); let percentage$0: bigint = unwrap(percentage); return sliceOf(x$0, percentage$0, decimals).and(y => { return add(x$0, y, decimals); }); } function subPercentage(x: bigint, percentage: bigint, decimals: T1): Result>; function subPercentage(x: Fpv, percentage: bigint, decimals: T1): Result>; function subPercentage(x: bigint, percentage: Fpv, decimals: T1): Result>; function subPercentage(x: Fpv, percentage: Fpv, decimals: T1): Result>; function subPercentage(x: Compatible, percentage: Compatible, decimals: T1): Result> { let x$0: bigint = unwrap(x); let percentage$0: bigint = unwrap(percentage); return sliceOf(x$0, percentage$0, decimals).and(y => { return sub(x$0, y, decimals); }); } })(); }