@kamino-finance/scope-sdk
Version:
Scope Oracle SDK
225 lines • 10.6 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 () {
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.State = 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 types = __importStar(require("../types")); // eslint-disable-line @typescript-eslint/no-unused-vars
const borsh = __importStar(require("@coral-xyz/borsh"));
const utils_1 = require("../utils");
class State {
msolMint;
adminAuthority;
operationalSolAccount;
treasuryMsolAccount;
reserveBumpSeed;
msolMintAuthorityBumpSeed;
rentExemptForTokenAcc;
rewardFee;
stakeSystem;
validatorSystem;
liqPool;
availableReserveBalance;
msolSupply;
msolPrice;
/** count tickets for delayed-unstake */
circulatingTicketCount;
/** total lamports amount of generated and not claimed yet tickets */
circulatingTicketBalance;
lentFromReserve;
minDeposit;
minWithdraw;
stakingSolCap;
emergencyCoolingDown;
constructor(fields) {
this.msolMint = fields.msolMint;
this.adminAuthority = fields.adminAuthority;
this.operationalSolAccount = fields.operationalSolAccount;
this.treasuryMsolAccount = fields.treasuryMsolAccount;
this.reserveBumpSeed = fields.reserveBumpSeed;
this.msolMintAuthorityBumpSeed = fields.msolMintAuthorityBumpSeed;
this.rentExemptForTokenAcc = fields.rentExemptForTokenAcc;
this.rewardFee = new types.Fee({ ...fields.rewardFee });
this.stakeSystem = new types.StakeSystem({ ...fields.stakeSystem });
this.validatorSystem = new types.ValidatorSystem({
...fields.validatorSystem,
});
this.liqPool = new types.LiqPool({ ...fields.liqPool });
this.availableReserveBalance = fields.availableReserveBalance;
this.msolSupply = fields.msolSupply;
this.msolPrice = fields.msolPrice;
this.circulatingTicketCount = fields.circulatingTicketCount;
this.circulatingTicketBalance = fields.circulatingTicketBalance;
this.lentFromReserve = fields.lentFromReserve;
this.minDeposit = fields.minDeposit;
this.minWithdraw = fields.minWithdraw;
this.stakingSolCap = fields.stakingSolCap;
this.emergencyCoolingDown = fields.emergencyCoolingDown;
}
static layout(property) {
return borsh.struct([
(0, utils_1.borshAddress)("msolMint"),
(0, utils_1.borshAddress)("adminAuthority"),
(0, utils_1.borshAddress)("operationalSolAccount"),
(0, utils_1.borshAddress)("treasuryMsolAccount"),
borsh.u8("reserveBumpSeed"),
borsh.u8("msolMintAuthorityBumpSeed"),
borsh.u64("rentExemptForTokenAcc"),
types.Fee.layout("rewardFee"),
types.StakeSystem.layout("stakeSystem"),
types.ValidatorSystem.layout("validatorSystem"),
types.LiqPool.layout("liqPool"),
borsh.u64("availableReserveBalance"),
borsh.u64("msolSupply"),
borsh.u64("msolPrice"),
borsh.u64("circulatingTicketCount"),
borsh.u64("circulatingTicketBalance"),
borsh.u64("lentFromReserve"),
borsh.u64("minDeposit"),
borsh.u64("minWithdraw"),
borsh.u64("stakingSolCap"),
borsh.u64("emergencyCoolingDown"),
], property);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static fromDecoded(obj) {
return new State({
msolMint: obj.msolMint,
adminAuthority: obj.adminAuthority,
operationalSolAccount: obj.operationalSolAccount,
treasuryMsolAccount: obj.treasuryMsolAccount,
reserveBumpSeed: obj.reserveBumpSeed,
msolMintAuthorityBumpSeed: obj.msolMintAuthorityBumpSeed,
rentExemptForTokenAcc: obj.rentExemptForTokenAcc,
rewardFee: types.Fee.fromDecoded(obj.rewardFee),
stakeSystem: types.StakeSystem.fromDecoded(obj.stakeSystem),
validatorSystem: types.ValidatorSystem.fromDecoded(obj.validatorSystem),
liqPool: types.LiqPool.fromDecoded(obj.liqPool),
availableReserveBalance: obj.availableReserveBalance,
msolSupply: obj.msolSupply,
msolPrice: obj.msolPrice,
circulatingTicketCount: obj.circulatingTicketCount,
circulatingTicketBalance: obj.circulatingTicketBalance,
lentFromReserve: obj.lentFromReserve,
minDeposit: obj.minDeposit,
minWithdraw: obj.minWithdraw,
stakingSolCap: obj.stakingSolCap,
emergencyCoolingDown: obj.emergencyCoolingDown,
});
}
static toEncodable(fields) {
return {
msolMint: fields.msolMint,
adminAuthority: fields.adminAuthority,
operationalSolAccount: fields.operationalSolAccount,
treasuryMsolAccount: fields.treasuryMsolAccount,
reserveBumpSeed: fields.reserveBumpSeed,
msolMintAuthorityBumpSeed: fields.msolMintAuthorityBumpSeed,
rentExemptForTokenAcc: fields.rentExemptForTokenAcc,
rewardFee: types.Fee.toEncodable(fields.rewardFee),
stakeSystem: types.StakeSystem.toEncodable(fields.stakeSystem),
validatorSystem: types.ValidatorSystem.toEncodable(fields.validatorSystem),
liqPool: types.LiqPool.toEncodable(fields.liqPool),
availableReserveBalance: fields.availableReserveBalance,
msolSupply: fields.msolSupply,
msolPrice: fields.msolPrice,
circulatingTicketCount: fields.circulatingTicketCount,
circulatingTicketBalance: fields.circulatingTicketBalance,
lentFromReserve: fields.lentFromReserve,
minDeposit: fields.minDeposit,
minWithdraw: fields.minWithdraw,
stakingSolCap: fields.stakingSolCap,
emergencyCoolingDown: fields.emergencyCoolingDown,
};
}
toJSON() {
return {
msolMint: this.msolMint,
adminAuthority: this.adminAuthority,
operationalSolAccount: this.operationalSolAccount,
treasuryMsolAccount: this.treasuryMsolAccount,
reserveBumpSeed: this.reserveBumpSeed,
msolMintAuthorityBumpSeed: this.msolMintAuthorityBumpSeed,
rentExemptForTokenAcc: this.rentExemptForTokenAcc.toString(),
rewardFee: this.rewardFee.toJSON(),
stakeSystem: this.stakeSystem.toJSON(),
validatorSystem: this.validatorSystem.toJSON(),
liqPool: this.liqPool.toJSON(),
availableReserveBalance: this.availableReserveBalance.toString(),
msolSupply: this.msolSupply.toString(),
msolPrice: this.msolPrice.toString(),
circulatingTicketCount: this.circulatingTicketCount.toString(),
circulatingTicketBalance: this.circulatingTicketBalance.toString(),
lentFromReserve: this.lentFromReserve.toString(),
minDeposit: this.minDeposit.toString(),
minWithdraw: this.minWithdraw.toString(),
stakingSolCap: this.stakingSolCap.toString(),
emergencyCoolingDown: this.emergencyCoolingDown.toString(),
};
}
static fromJSON(obj) {
return new State({
msolMint: (0, kit_1.address)(obj.msolMint),
adminAuthority: (0, kit_1.address)(obj.adminAuthority),
operationalSolAccount: (0, kit_1.address)(obj.operationalSolAccount),
treasuryMsolAccount: (0, kit_1.address)(obj.treasuryMsolAccount),
reserveBumpSeed: obj.reserveBumpSeed,
msolMintAuthorityBumpSeed: obj.msolMintAuthorityBumpSeed,
rentExemptForTokenAcc: new bn_js_1.default(obj.rentExemptForTokenAcc),
rewardFee: types.Fee.fromJSON(obj.rewardFee),
stakeSystem: types.StakeSystem.fromJSON(obj.stakeSystem),
validatorSystem: types.ValidatorSystem.fromJSON(obj.validatorSystem),
liqPool: types.LiqPool.fromJSON(obj.liqPool),
availableReserveBalance: new bn_js_1.default(obj.availableReserveBalance),
msolSupply: new bn_js_1.default(obj.msolSupply),
msolPrice: new bn_js_1.default(obj.msolPrice),
circulatingTicketCount: new bn_js_1.default(obj.circulatingTicketCount),
circulatingTicketBalance: new bn_js_1.default(obj.circulatingTicketBalance),
lentFromReserve: new bn_js_1.default(obj.lentFromReserve),
minDeposit: new bn_js_1.default(obj.minDeposit),
minWithdraw: new bn_js_1.default(obj.minWithdraw),
stakingSolCap: new bn_js_1.default(obj.stakingSolCap),
emergencyCoolingDown: new bn_js_1.default(obj.emergencyCoolingDown),
});
}
toEncodable() {
return State.toEncodable(this);
}
}
exports.State = State;
//# sourceMappingURL=State.js.map