@swaptoshi/dex-module
Version:
Klayr decentralized exchange (dex) on-chain module
35 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MintCommand = void 0;
const klayr_framework_1 = require("klayr-framework");
const schema_1 = require("../schema");
const position_manager_1 = require("../stores/position_manager");
const context_1 = require("../stores/context");
const periphery_1 = require("../stores/library/periphery");
const utils_1 = require("../utils");
class MintCommand extends klayr_framework_1.Modules.BaseCommand {
constructor() {
super(...arguments);
this.schema = schema_1.mintCommandSchema;
}
async verify(_context) {
try {
(0, utils_1.verifyMintParam)(_context.params);
}
catch (error) {
return {
status: klayr_framework_1.StateMachine.VerifyStatus.FAIL,
error: new Error(error.message),
};
}
return { status: klayr_framework_1.StateMachine.VerifyStatus.OK };
}
async execute(_context) {
const positionManagerStore = this.stores.get(position_manager_1.PositionManagerStore);
const context = (0, context_1.commandSwapContext)(_context);
const positionManager = await positionManagerStore.getMutablePositionManager(context, periphery_1.PoolAddress.computeAddress(periphery_1.PoolAddress.getPoolKey(_context.params.token0, _context.params.token1, _context.params.fee)));
await positionManager.mint(_context.params);
}
}
exports.MintCommand = MintCommand;
//# sourceMappingURL=mint_command.js.map