UNPKG

kamino-sdk-beta

Version:

Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol

147 lines 6.03 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; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.InitPresetParametersIx = void 0; const borsh = __importStar(require("@coral-xyz/borsh")); class InitPresetParametersIx { /** Bin step. Represent the price increment / decrement. */ binStep; /** Used for base fee calculation. base_fee_rate = base_factor * bin_step */ baseFactor; /** Filter period determine high frequency trading time window. */ filterPeriod; /** Decay period determine when the volatile fee start decay / decrease. */ decayPeriod; /** Reduction factor controls the volatile fee rate decrement rate. */ reductionFactor; /** Used to scale the variable fee component depending on the dynamic of the market */ variableFeeControl; /** Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate. */ maxVolatilityAccumulator; /** Min bin id supported by the pool based on the configured bin step. */ minBinId; /** Max bin id supported by the pool based on the configured bin step. */ maxBinId; /** Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee */ protocolShare; constructor(fields) { this.binStep = fields.binStep; this.baseFactor = fields.baseFactor; this.filterPeriod = fields.filterPeriod; this.decayPeriod = fields.decayPeriod; this.reductionFactor = fields.reductionFactor; this.variableFeeControl = fields.variableFeeControl; this.maxVolatilityAccumulator = fields.maxVolatilityAccumulator; this.minBinId = fields.minBinId; this.maxBinId = fields.maxBinId; this.protocolShare = fields.protocolShare; } static layout(property) { return borsh.struct([ borsh.u16("binStep"), borsh.u16("baseFactor"), borsh.u16("filterPeriod"), borsh.u16("decayPeriod"), borsh.u16("reductionFactor"), borsh.u32("variableFeeControl"), borsh.u32("maxVolatilityAccumulator"), borsh.i32("minBinId"), borsh.i32("maxBinId"), borsh.u16("protocolShare"), ], property); } // eslint-disable-next-line @typescript-eslint/no-explicit-any static fromDecoded(obj) { return new InitPresetParametersIx({ binStep: obj.binStep, baseFactor: obj.baseFactor, filterPeriod: obj.filterPeriod, decayPeriod: obj.decayPeriod, reductionFactor: obj.reductionFactor, variableFeeControl: obj.variableFeeControl, maxVolatilityAccumulator: obj.maxVolatilityAccumulator, minBinId: obj.minBinId, maxBinId: obj.maxBinId, protocolShare: obj.protocolShare, }); } static toEncodable(fields) { return { binStep: fields.binStep, baseFactor: fields.baseFactor, filterPeriod: fields.filterPeriod, decayPeriod: fields.decayPeriod, reductionFactor: fields.reductionFactor, variableFeeControl: fields.variableFeeControl, maxVolatilityAccumulator: fields.maxVolatilityAccumulator, minBinId: fields.minBinId, maxBinId: fields.maxBinId, protocolShare: fields.protocolShare, }; } toJSON() { return { binStep: this.binStep, baseFactor: this.baseFactor, filterPeriod: this.filterPeriod, decayPeriod: this.decayPeriod, reductionFactor: this.reductionFactor, variableFeeControl: this.variableFeeControl, maxVolatilityAccumulator: this.maxVolatilityAccumulator, minBinId: this.minBinId, maxBinId: this.maxBinId, protocolShare: this.protocolShare, }; } static fromJSON(obj) { return new InitPresetParametersIx({ binStep: obj.binStep, baseFactor: obj.baseFactor, filterPeriod: obj.filterPeriod, decayPeriod: obj.decayPeriod, reductionFactor: obj.reductionFactor, variableFeeControl: obj.variableFeeControl, maxVolatilityAccumulator: obj.maxVolatilityAccumulator, minBinId: obj.minBinId, maxBinId: obj.maxBinId, protocolShare: obj.protocolShare, }); } toEncodable() { return InitPresetParametersIx.toEncodable(this); } } exports.InitPresetParametersIx = InitPresetParametersIx; //# sourceMappingURL=InitPresetParametersIx.js.map