UNPKG

@swaptoshi/dex-module

Version:

Klayr decentralized exchange (dex) on-chain module

38 lines 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PositionInfoStore = exports.defaultPositionInfo = void 0; const klayr_framework_1 = require("klayr-framework"); const db = require("@liskhq/lisk-db"); const utils = require("@klayr/utils"); const schema_1 = require("../schema"); exports.defaultPositionInfo = Object.freeze({ liquidity: '0', feeGrowthInside0LastX128: '0', feeGrowthInside1LastX128: '0', tokensOwed0: '0', tokensOwed1: '0', }); class PositionInfoStore extends klayr_framework_1.Modules.BaseStore { constructor() { super(...arguments); this.schema = schema_1.positionInfoStoreSchema; this.default = { ...exports.defaultPositionInfo }; } getKey(poolAddress, key) { return Buffer.concat([poolAddress, key]); } async getOrDefault(context, key) { try { const positionInfo = await this.get(context, key); return positionInfo; } catch (error) { if (!(error instanceof db.NotFoundError)) { throw error; } return utils.objects.cloneDeep(exports.defaultPositionInfo); } } } exports.PositionInfoStore = PositionInfoStore; //# sourceMappingURL=position_info.js.map