UNPKG

@marinade.finance/kamino-sdk

Version:
94 lines 3.67 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Observation = void 0; const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars const borsh = __importStar(require("@project-serum/borsh")); /** The element of observations in ObservationState */ class Observation { /** The block timestamp of the observation */ blockTimestamp; /** the price of the observation timestamp, Q64.64 */ sqrtPriceX64; /** the cumulative of price during the duration time, Q64.64 */ cumulativeTimePriceX64; /** padding for feature update */ padding; constructor(fields) { this.blockTimestamp = fields.blockTimestamp; this.sqrtPriceX64 = fields.sqrtPriceX64; this.cumulativeTimePriceX64 = fields.cumulativeTimePriceX64; this.padding = fields.padding; } static layout(property) { return borsh.struct([ borsh.u32('blockTimestamp'), borsh.u128('sqrtPriceX64'), borsh.u128('cumulativeTimePriceX64'), borsh.u128('padding'), ], property); } // eslint-disable-next-line @typescript-eslint/no-explicit-any static fromDecoded(obj) { return new Observation({ blockTimestamp: obj.blockTimestamp, sqrtPriceX64: obj.sqrtPriceX64, cumulativeTimePriceX64: obj.cumulativeTimePriceX64, padding: obj.padding, }); } static toEncodable(fields) { return { blockTimestamp: fields.blockTimestamp, sqrtPriceX64: fields.sqrtPriceX64, cumulativeTimePriceX64: fields.cumulativeTimePriceX64, padding: fields.padding, }; } toJSON() { return { blockTimestamp: this.blockTimestamp, sqrtPriceX64: this.sqrtPriceX64.toString(), cumulativeTimePriceX64: this.cumulativeTimePriceX64.toString(), padding: this.padding.toString(), }; } static fromJSON(obj) { return new Observation({ blockTimestamp: obj.blockTimestamp, sqrtPriceX64: new bn_js_1.default(obj.sqrtPriceX64), cumulativeTimePriceX64: new bn_js_1.default(obj.cumulativeTimePriceX64), padding: new bn_js_1.default(obj.padding), }); } toEncodable() { return Observation.toEncodable(this); } } exports.Observation = Observation; //# sourceMappingURL=Observation.js.map