UNPKG

@kamino-finance/scope-sdk

Version:
162 lines 6.88 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.LiqPool = 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 LiqPool { lpMint; lpMintAuthorityBumpSeed; solLegBumpSeed; msolLegAuthorityBumpSeed; msolLeg; /** Liquidity target. If the Liquidity reach this amount, the fee reaches lp_min_discount_fee */ lpLiquidityTarget; /** Liquidity pool max fee */ lpMaxFee; /** SOL/mSOL Liquidity pool min fee */ lpMinFee; /** Treasury cut */ treasuryCut; lpSupply; lentFromSolLeg; liquiditySolCap; constructor(fields) { this.lpMint = fields.lpMint; this.lpMintAuthorityBumpSeed = fields.lpMintAuthorityBumpSeed; this.solLegBumpSeed = fields.solLegBumpSeed; this.msolLegAuthorityBumpSeed = fields.msolLegAuthorityBumpSeed; this.msolLeg = fields.msolLeg; this.lpLiquidityTarget = fields.lpLiquidityTarget; this.lpMaxFee = new types.Fee({ ...fields.lpMaxFee }); this.lpMinFee = new types.Fee({ ...fields.lpMinFee }); this.treasuryCut = new types.Fee({ ...fields.treasuryCut }); this.lpSupply = fields.lpSupply; this.lentFromSolLeg = fields.lentFromSolLeg; this.liquiditySolCap = fields.liquiditySolCap; } static layout(property) { return borsh.struct([ (0, utils_1.borshAddress)("lpMint"), borsh.u8("lpMintAuthorityBumpSeed"), borsh.u8("solLegBumpSeed"), borsh.u8("msolLegAuthorityBumpSeed"), (0, utils_1.borshAddress)("msolLeg"), borsh.u64("lpLiquidityTarget"), types.Fee.layout("lpMaxFee"), types.Fee.layout("lpMinFee"), types.Fee.layout("treasuryCut"), borsh.u64("lpSupply"), borsh.u64("lentFromSolLeg"), borsh.u64("liquiditySolCap"), ], property); } // eslint-disable-next-line @typescript-eslint/no-explicit-any static fromDecoded(obj) { return new LiqPool({ lpMint: obj.lpMint, lpMintAuthorityBumpSeed: obj.lpMintAuthorityBumpSeed, solLegBumpSeed: obj.solLegBumpSeed, msolLegAuthorityBumpSeed: obj.msolLegAuthorityBumpSeed, msolLeg: obj.msolLeg, lpLiquidityTarget: obj.lpLiquidityTarget, lpMaxFee: types.Fee.fromDecoded(obj.lpMaxFee), lpMinFee: types.Fee.fromDecoded(obj.lpMinFee), treasuryCut: types.Fee.fromDecoded(obj.treasuryCut), lpSupply: obj.lpSupply, lentFromSolLeg: obj.lentFromSolLeg, liquiditySolCap: obj.liquiditySolCap, }); } static toEncodable(fields) { return { lpMint: fields.lpMint, lpMintAuthorityBumpSeed: fields.lpMintAuthorityBumpSeed, solLegBumpSeed: fields.solLegBumpSeed, msolLegAuthorityBumpSeed: fields.msolLegAuthorityBumpSeed, msolLeg: fields.msolLeg, lpLiquidityTarget: fields.lpLiquidityTarget, lpMaxFee: types.Fee.toEncodable(fields.lpMaxFee), lpMinFee: types.Fee.toEncodable(fields.lpMinFee), treasuryCut: types.Fee.toEncodable(fields.treasuryCut), lpSupply: fields.lpSupply, lentFromSolLeg: fields.lentFromSolLeg, liquiditySolCap: fields.liquiditySolCap, }; } toJSON() { return { lpMint: this.lpMint, lpMintAuthorityBumpSeed: this.lpMintAuthorityBumpSeed, solLegBumpSeed: this.solLegBumpSeed, msolLegAuthorityBumpSeed: this.msolLegAuthorityBumpSeed, msolLeg: this.msolLeg, lpLiquidityTarget: this.lpLiquidityTarget.toString(), lpMaxFee: this.lpMaxFee.toJSON(), lpMinFee: this.lpMinFee.toJSON(), treasuryCut: this.treasuryCut.toJSON(), lpSupply: this.lpSupply.toString(), lentFromSolLeg: this.lentFromSolLeg.toString(), liquiditySolCap: this.liquiditySolCap.toString(), }; } static fromJSON(obj) { return new LiqPool({ lpMint: (0, kit_1.address)(obj.lpMint), lpMintAuthorityBumpSeed: obj.lpMintAuthorityBumpSeed, solLegBumpSeed: obj.solLegBumpSeed, msolLegAuthorityBumpSeed: obj.msolLegAuthorityBumpSeed, msolLeg: (0, kit_1.address)(obj.msolLeg), lpLiquidityTarget: new bn_js_1.default(obj.lpLiquidityTarget), lpMaxFee: types.Fee.fromJSON(obj.lpMaxFee), lpMinFee: types.Fee.fromJSON(obj.lpMinFee), treasuryCut: types.Fee.fromJSON(obj.treasuryCut), lpSupply: new bn_js_1.default(obj.lpSupply), lentFromSolLeg: new bn_js_1.default(obj.lentFromSolLeg), liquiditySolCap: new bn_js_1.default(obj.liquiditySolCap), }); } toEncodable() { return LiqPool.toEncodable(this); } } exports.LiqPool = LiqPool; //# sourceMappingURL=LiqPool.js.map