@marinade.finance/kamino-sdk
Version:
160 lines • 6.82 kB
JavaScript
"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.CollateralInfo = void 0;
const web3_js_1 = require("@solana/web3.js"); // 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("@project-serum/borsh"));
class CollateralInfo {
mint;
lowerHeuristic;
upperHeuristic;
expHeuristic;
maxTwapDivergenceBps;
scopePriceIdTwap;
scopePriceChain;
name;
maxAgePriceSeconds;
maxAgeTwapSeconds;
maxIgnorableAmountAsReward;
disabled;
padding0;
padding;
constructor(fields) {
this.mint = fields.mint;
this.lowerHeuristic = fields.lowerHeuristic;
this.upperHeuristic = fields.upperHeuristic;
this.expHeuristic = fields.expHeuristic;
this.maxTwapDivergenceBps = fields.maxTwapDivergenceBps;
this.scopePriceIdTwap = fields.scopePriceIdTwap;
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.padding = fields.padding;
}
static layout(property) {
return borsh.struct([
borsh.publicKey("mint"),
borsh.u64("lowerHeuristic"),
borsh.u64("upperHeuristic"),
borsh.u64("expHeuristic"),
borsh.u64("maxTwapDivergenceBps"),
borsh.u64("scopePriceIdTwap"),
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.u64(), 9, "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,
scopePriceIdTwap: obj.scopePriceIdTwap,
scopePriceChain: obj.scopePriceChain,
name: obj.name,
maxAgePriceSeconds: obj.maxAgePriceSeconds,
maxAgeTwapSeconds: obj.maxAgeTwapSeconds,
maxIgnorableAmountAsReward: obj.maxIgnorableAmountAsReward,
disabled: obj.disabled,
padding0: obj.padding0,
padding: obj.padding,
});
}
static toEncodable(fields) {
return {
mint: fields.mint,
lowerHeuristic: fields.lowerHeuristic,
upperHeuristic: fields.upperHeuristic,
expHeuristic: fields.expHeuristic,
maxTwapDivergenceBps: fields.maxTwapDivergenceBps,
scopePriceIdTwap: fields.scopePriceIdTwap,
scopePriceChain: fields.scopePriceChain,
name: fields.name,
maxAgePriceSeconds: fields.maxAgePriceSeconds,
maxAgeTwapSeconds: fields.maxAgeTwapSeconds,
maxIgnorableAmountAsReward: fields.maxIgnorableAmountAsReward,
disabled: fields.disabled,
padding0: fields.padding0,
padding: fields.padding,
};
}
toJSON() {
return {
mint: this.mint.toString(),
lowerHeuristic: this.lowerHeuristic.toString(),
upperHeuristic: this.upperHeuristic.toString(),
expHeuristic: this.expHeuristic.toString(),
maxTwapDivergenceBps: this.maxTwapDivergenceBps.toString(),
scopePriceIdTwap: this.scopePriceIdTwap.toString(),
scopePriceChain: this.scopePriceChain,
name: this.name,
maxAgePriceSeconds: this.maxAgePriceSeconds.toString(),
maxAgeTwapSeconds: this.maxAgeTwapSeconds.toString(),
maxIgnorableAmountAsReward: this.maxIgnorableAmountAsReward.toString(),
disabled: this.disabled,
padding0: this.padding0,
padding: this.padding.map((item) => item.toString()),
};
}
static fromJSON(obj) {
return new CollateralInfo({
mint: new web3_js_1.PublicKey(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),
scopePriceIdTwap: new bn_js_1.default(obj.scopePriceIdTwap),
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,
padding: obj.padding.map((item) => new bn_js_1.default(item)),
});
}
toEncodable() {
return CollateralInfo.toEncodable(this);
}
}
exports.CollateralInfo = CollateralInfo;
//# sourceMappingURL=CollateralInfo.js.map