UNPKG

@kamino-finance/scope-sdk

Version:
178 lines 7.61 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 () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __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.CollateralInfo = void 0; const kit_1 = require("@solana/kit"); // eslint-disable-line @typescript-eslint/no-unused-vars const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars const borsh = __importStar(require("@coral-xyz/borsh")); const utils_1 = require("../utils"); class CollateralInfo { mint; lowerHeuristic; upperHeuristic; expHeuristic; maxTwapDivergenceBps; scopeTwapPriceChain; scopePriceChain; name; maxAgePriceSeconds; maxAgeTwapSeconds; maxIgnorableAmountAsReward; disabled; padding0; scopeStakingRateChain; padding; constructor(fields) { this.mint = fields.mint; this.lowerHeuristic = fields.lowerHeuristic; this.upperHeuristic = fields.upperHeuristic; this.expHeuristic = fields.expHeuristic; this.maxTwapDivergenceBps = fields.maxTwapDivergenceBps; this.scopeTwapPriceChain = fields.scopeTwapPriceChain; this.scopePriceChain = fields.scopePriceChain; this.name = fields.name; this.maxAgePriceSeconds = fields.maxAgePriceSeconds; this.maxAgeTwapSeconds = fields.maxAgeTwapSeconds; this.maxIgnorableAmountAsReward = fields.maxIgnorableAmountAsReward; this.disabled = fields.disabled; this.padding0 = fields.padding0; this.scopeStakingRateChain = fields.scopeStakingRateChain; this.padding = fields.padding; } static layout(property) { return borsh.struct([ (0, utils_1.borshAddress)("mint"), borsh.u64("lowerHeuristic"), borsh.u64("upperHeuristic"), borsh.u64("expHeuristic"), borsh.u64("maxTwapDivergenceBps"), borsh.array(borsh.u16(), 4, "scopeTwapPriceChain"), borsh.array(borsh.u16(), 4, "scopePriceChain"), borsh.array(borsh.u8(), 32, "name"), borsh.u64("maxAgePriceSeconds"), borsh.u64("maxAgeTwapSeconds"), borsh.u64("maxIgnorableAmountAsReward"), borsh.u8("disabled"), borsh.array(borsh.u8(), 7, "padding0"), borsh.array(borsh.u16(), 4, "scopeStakingRateChain"), borsh.array(borsh.u64(), 8, "padding"), ], property); } // eslint-disable-next-line @typescript-eslint/no-explicit-any static fromDecoded(obj) { return new CollateralInfo({ mint: obj.mint, lowerHeuristic: obj.lowerHeuristic, upperHeuristic: obj.upperHeuristic, expHeuristic: obj.expHeuristic, maxTwapDivergenceBps: obj.maxTwapDivergenceBps, scopeTwapPriceChain: obj.scopeTwapPriceChain, scopePriceChain: obj.scopePriceChain, name: obj.name, maxAgePriceSeconds: obj.maxAgePriceSeconds, maxAgeTwapSeconds: obj.maxAgeTwapSeconds, maxIgnorableAmountAsReward: obj.maxIgnorableAmountAsReward, disabled: obj.disabled, padding0: obj.padding0, scopeStakingRateChain: obj.scopeStakingRateChain, padding: obj.padding, }); } static toEncodable(fields) { return { mint: fields.mint, lowerHeuristic: fields.lowerHeuristic, upperHeuristic: fields.upperHeuristic, expHeuristic: fields.expHeuristic, maxTwapDivergenceBps: fields.maxTwapDivergenceBps, scopeTwapPriceChain: fields.scopeTwapPriceChain, scopePriceChain: fields.scopePriceChain, name: fields.name, maxAgePriceSeconds: fields.maxAgePriceSeconds, maxAgeTwapSeconds: fields.maxAgeTwapSeconds, maxIgnorableAmountAsReward: fields.maxIgnorableAmountAsReward, disabled: fields.disabled, padding0: fields.padding0, scopeStakingRateChain: fields.scopeStakingRateChain, padding: fields.padding, }; } toJSON() { return { mint: this.mint, lowerHeuristic: this.lowerHeuristic.toString(), upperHeuristic: this.upperHeuristic.toString(), expHeuristic: this.expHeuristic.toString(), maxTwapDivergenceBps: this.maxTwapDivergenceBps.toString(), scopeTwapPriceChain: this.scopeTwapPriceChain, scopePriceChain: this.scopePriceChain, name: this.name, maxAgePriceSeconds: this.maxAgePriceSeconds.toString(), maxAgeTwapSeconds: this.maxAgeTwapSeconds.toString(), maxIgnorableAmountAsReward: this.maxIgnorableAmountAsReward.toString(), disabled: this.disabled, padding0: this.padding0, scopeStakingRateChain: this.scopeStakingRateChain, padding: this.padding.map((item) => item.toString()), }; } static fromJSON(obj) { return new CollateralInfo({ mint: (0, kit_1.address)(obj.mint), lowerHeuristic: new bn_js_1.default(obj.lowerHeuristic), upperHeuristic: new bn_js_1.default(obj.upperHeuristic), expHeuristic: new bn_js_1.default(obj.expHeuristic), maxTwapDivergenceBps: new bn_js_1.default(obj.maxTwapDivergenceBps), scopeTwapPriceChain: obj.scopeTwapPriceChain, scopePriceChain: obj.scopePriceChain, name: obj.name, maxAgePriceSeconds: new bn_js_1.default(obj.maxAgePriceSeconds), maxAgeTwapSeconds: new bn_js_1.default(obj.maxAgeTwapSeconds), maxIgnorableAmountAsReward: new bn_js_1.default(obj.maxIgnorableAmountAsReward), disabled: obj.disabled, padding0: obj.padding0, scopeStakingRateChain: obj.scopeStakingRateChain, padding: obj.padding.map((item) => new bn_js_1.default(item)), }); } toEncodable() { return CollateralInfo.toEncodable(this); } } exports.CollateralInfo = CollateralInfo; //# sourceMappingURL=CollateralInfo.js.map