@swaptoshi/dex-module
Version:
Klayr decentralized exchange (dex) on-chain module
34 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExactInputSingleCommand = void 0;
const klayr_framework_1 = require("klayr-framework");
const pool_1 = require("../stores/pool");
const context_1 = require("../stores/context");
const schema_1 = require("../schema");
const utils_1 = require("../utils");
class ExactInputSingleCommand extends klayr_framework_1.Modules.BaseCommand {
constructor() {
super(...arguments);
this.schema = schema_1.exactInputSingleCommandSchema;
}
async verify(_context) {
try {
(0, utils_1.verifyExactInputSingleParam)(_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 poolStore = this.stores.get(pool_1.PoolStore);
const context = (0, context_1.commandSwapContext)(_context);
const router = await poolStore.getMutableRouter(context);
await router.exactInputSingle(_context.params);
}
}
exports.ExactInputSingleCommand = ExactInputSingleCommand;
//# sourceMappingURL=exact_input_single_command.js.map