UNPKG

@node-dlc/core

Version:
47 lines 1.97 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LongPut = void 0; const messaging_1 = require("@node-dlc/messaging"); const bignumber_js_1 = __importDefault(require("bignumber.js")); const HyperbolaPayoutCurve_1 = require("../HyperbolaPayoutCurve"); const buildCurve = (strikePrice, contractSize, oracleBase, oracleDigits) => { const a = new bignumber_js_1.default(1); const b = new bignumber_js_1.default(0); const c = new bignumber_js_1.default(0); const d = new bignumber_js_1.default((strikePrice * contractSize).toString()); const f_1 = new bignumber_js_1.default(0); const f_2 = new bignumber_js_1.default(-Number(contractSize)); const payoutCurve = new HyperbolaPayoutCurve_1.HyperbolaPayoutCurve(a, b, c, d, f_1, f_2); const maxOutcome = BigInt(new bignumber_js_1.default(oracleBase).pow(oracleDigits).minus(1).toString(10)); return { maxOutcome, totalCollateral: contractSize, payoutCurve, }; }; const buildPayoutFunction = (strikePrice, contractSize, totalCollateral, oracleBase, oracleDigits) => { const { maxOutcome, payoutCurve } = buildCurve(strikePrice, contractSize, oracleBase, oracleDigits); const payoutFunction = new messaging_1.PayoutFunctionV0(); payoutFunction.payoutFunctionPieces.push({ endPoint: { eventOutcome: maxOutcome, outcomePayout: BigInt(0), extraPrecision: 0, }, payoutCurvePiece: payoutCurve.toPayoutCurvePiece(), }); payoutFunction.lastEndpoint = { eventOutcome: maxOutcome, outcomePayout: BigInt(0), extraPrecision: 0, }; return { payoutFunction, totalCollateral, }; }; exports.LongPut = { buildCurve, buildPayoutFunction }; //# sourceMappingURL=LongPut.js.map