UNPKG

@ixily/activ

Version:

Alpha Capture Trade Idea Verification. Blockchain ownership proven trade ideas and strategies.

717 lines (716 loc) 30.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QueryViewsModule = void 0; const __1 = require("../.."); const views_source_gate_module_1 = require("./views-source-gate.module"); const bignumber_js_1 = require("bignumber.js"); const listContracts = async (network) => { if (network === undefined) { const contract = __1.ContractModule.thisOrGet(); network = contract.recipe.chain; } return views_source_gate_module_1.ViewsSourceGateModule.listContracts(); }; // queries updated ITradeIdeaCreator data details from latest trade idea of the creator const getWalletInfoDetails = async (creatorWallet, contract) => { contract = __1.ContractModule.thisOrGet(contract); const contractReference = (0, __1.uniqueKeyJoin)([ contract.recipe.chain, contract.gate.address, ]); __1.LogModule.dev('contractReference', contractReference); __1.LogModule.dev('creatorWallet', creatorWallet); if (creatorWallet === undefined) { creatorWallet = await contract.gate.signer.getAddress(); } return views_source_gate_module_1.ViewsSourceGateModule.getCreator(contractReference, creatorWallet); }; const getValidatedStrategyInfoDetails = async (uniqueStrategyKey, contract) => { contract = __1.ContractModule.thisOrGet(contract); const decomposed = (0, __1.uniqueKeySplit)(uniqueStrategyKey); const chain = decomposed[0]; const contractAddress = decomposed[1]; const creatorAddress = decomposed[2]; const strategyKey = decomposed[3]; if (contract.recipe.chain === chain && contract.gate.address === contractAddress) { const signerUser = await __1.ContractModule.thisOrGetCreator(undefined, contract); if (signerUser === creatorAddress) { const stgChainWithCache = await __1.ProvableIdeasModule.chain.getValidatedStrategyChainWithCache(strategyKey, creatorAddress); if (stgChainWithCache.cache?.cachedStrategy === undefined) { throw new Error('Strategy does not exists'); } stgChainWithCache.cache.cachedStrategy.strategy.uniqueKey = (0, __1.uniqueKeyJoin)([ chain, contractAddress, creatorAddress, strategyKey, ]); return { strategy: stgChainWithCache.cache.cachedStrategy.strategy, creator: stgChainWithCache.cache.cachedStrategy.creator, }; } } return views_source_gate_module_1.ViewsSourceGateModule.getStrategyWithCreator(uniqueStrategyKey); }; const listMyStrategies = async (page = 1, limit = 5) => { return listCreatorStrategies(undefined, page, limit); }; const listCreatorStrategies = async (creatorWallet, page = 1, limit = 5) => { const contract = __1.ContractModule.thisOrGet(); const contractReference = (0, __1.uniqueKeyJoin)([ contract.recipe.chain, contract.gate.address, ]); __1.LogModule.dev('contractReference', contractReference); if (creatorWallet === undefined) { creatorWallet = await contract.gate.signer.getAddress(); } __1.LogModule.dev('creatorWallet', creatorWallet); return views_source_gate_module_1.ViewsSourceGateModule.listCreatorStrategies(contractReference, creatorWallet, page, limit); }; const listPublicStrategies = async (page = 1, limit = 5, contractUniqueKey, network) => { if (contractUniqueKey === undefined && network === undefined) { const contract = __1.ContractModule.thisOrGet(); network = contract.recipe.chain; } return views_source_gate_module_1.ViewsSourceGateModule.listStrategiesPublic(contractUniqueKey, page, limit, network); }; const listStrategiesWithAccessibleIdeas = async (accessorWallet, page = 1, limit = 5) => { const contract = __1.ContractModule.thisOrGet(); const contractReference = (0, __1.uniqueKeyJoin)([ contract.recipe.chain, contract.gate.address, ]); if (accessorWallet === undefined) { accessorWallet = await contract.gate.signer.getAddress(); } return views_source_gate_module_1.ViewsSourceGateModule.listStrategiesWithAccessibleIdeasBy(contractReference, accessorWallet, page, limit); }; const listStrategiesSubscribedTo = async (subscriberWallet, page = 1, limit = 5) => { const contract = __1.ContractModule.thisOrGet(); const contractReference = (0, __1.uniqueKeyJoin)([ contract.recipe.chain, contract.gate.address, ]); if (subscriberWallet === undefined) { subscriberWallet = await contract.gate.signer.getAddress(); } return views_source_gate_module_1.ViewsSourceGateModule.listStrategiesSubscribedToBy(contractReference, subscriberWallet, page, limit); }; const listStrategiesByCreator = async (creatorWallet, type = 'all', page = 1, limit = 5, network) => { const contract = __1.ContractModule.thisOrGet(); if (creatorWallet === undefined) { creatorWallet = await contract.gate.signer.getAddress(); } if (network === undefined) { network = contract.recipe.chain; } __1.LogModule.dev('creatorWallet'); __1.LogModule.dev(creatorWallet); if (type === 'my') { return listCreatorStrategies(creatorWallet, page, limit); } else if (type === 'public') { return listPublicStrategies(page, limit, network); } else if (type === 'accesible') { return listStrategiesWithAccessibleIdeas(creatorWallet, page, limit); } else { const createdList = await listCreatorStrategies(creatorWallet, page, limit); __1.LogModule.dev('createdList'); __1.LogModule.dev(createdList); const accessibleList = await listStrategiesWithAccessibleIdeas(creatorWallet, page, limit); __1.LogModule.dev('accessibleList'); __1.LogModule.dev(accessibleList); const publicList = await listPublicStrategies(page, limit, network); __1.LogModule.dev('publicList'); __1.LogModule.dev(publicList); const data = __1.CONTRACT_TOOLS.deterministicEvenlyMixedArray([ createdList.data, accessibleList.data, publicList.data, ]); const errors = createdList.errors === undefined && accessibleList.errors === undefined && publicList.errors === undefined ? undefined : [ ...(createdList.errors || []), ...(accessibleList.errors || []), ...(publicList.errors || []), ]; const result = { data, paging: { page, limit: limit * 3, }, total: createdList.total + accessibleList.total + publicList.total, errors, }; return result; } }; const listIdeasByStrategyUniqueKeyFromChain = async (strategyUniqueKey, validatedOnly = true, page = 1, limit = 5, filterType = 'bypass', filterIncludeEncrypted = false, bypassPaginationAndGetAll = false) => { const { contract, strategyKey, creatorAddress } = await solveContractAndKeys(strategyUniqueKey); const { cache } = await __1.ProvableIdeasModule.chain.getValidatedStrategyChainWithCache(strategyKey, creatorAddress, contract); let ideas; if (validatedOnly) { ideas = await __1.CONTRACT_TOOLS.queryChain.getValidatedIdeas(cache.cachedStrategy); } else { ideas = await __1.CONTRACT_TOOLS.queryChain.getAllIdeas(cache.cachedStrategy); } return (0, __1.postQueryIdeasFilterAndPagination)(ideas, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); }; const listValidatedIdeasByStrategyUniqueKeyFromChainOnlyLatestStagesByLatest = async (strategyUniqueKey, page = 1, limit = 5, filterType = 'bypass', filterIncludeEncrypted = false, bypassPaginationAndGetAll = false) => { const { contract, strategyKey, creatorAddress } = await solveContractAndKeys(strategyUniqueKey); const { cache } = await __1.ProvableIdeasModule.chain.getValidatedStrategyChainWithCache(strategyKey, creatorAddress, contract); const ideas = await __1.CONTRACT_TOOLS.queryChain.getOnlyLastStageOfEachIdea(cache.cachedStrategy); ideas.reverse(); return (0, __1.postQueryIdeasFilterAndPagination)(ideas, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); }; const getValidatedIdeasByStrategy = async (strategyUniqueKey, page = 1, limit = 5, filterType = 'bypass', filterIncludeEncrypted = true, bypassPaginationAndGetAll = false) => { return listValidatedIdeasByStrategyUniqueKeyFromChainOnlyLatestStagesByLatest(strategyUniqueKey, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); }; const listIdeasByStrategy = async (strategyUniqueKey, creator, page = 1, limit = 5, filterType = 'bypass', filterIncludeEncrypted = true, bypassPaginationAndGetAll = false) => { const ideas = await views_source_gate_module_1.ViewsSourceGateModule.listStrategyIdeas(strategyUniqueKey, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); if (filterIncludeEncrypted) { creator = await __1.ContractModule.thisOrGetCreator(creator); if (creator !== undefined) { await doDecryptableIdeasOnPagingIfAccessible(ideas, creator); } } return ideas; }; const getIdeasCreatedBy = async (page = 1, limit = 5, creator, filterType = 'bypass', filterIncludeEncrypted = false, bypassPaginationAndGetAll = false, contract) => { contract = __1.ContractModule.thisOrGet(contract); const contractCreator = await contract.gate.signer.getAddress(); creator = creator || contractCreator; const contractReference = (0, __1.uniqueKeyJoin)([ contract.recipe.chain, contract.gate.address, ]); const ideas = await views_source_gate_module_1.ViewsSourceGateModule.listCreatorIdeas(contractReference, creator, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); await doDecryptableIdeasOnPagingIfAccessible(ideas, creator); return ideas; }; const getIdeasOwnedBy = async (page = 1, limit = 5, // filterType: ITradeIdeaIdeaKind[] = [], owner, filterType = 'bypass', filterIncludeEncrypted = false, bypassPaginationAndGetAll = false, contract) => { contract = __1.ContractModule.thisOrGet(contract); const contractCreator = await contract.gate.signer.getAddress(); owner = owner || contractCreator; const contractReference = (0, __1.uniqueKeyJoin)([ contract.recipe.chain, contract.gate.address, ]); const ideas = await views_source_gate_module_1.ViewsSourceGateModule.listOwnedIdeas(contractReference, owner, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); await doDecryptableIdeasOnPagingIfAccessible(ideas, owner); return ideas; }; const listIdeaNftsByStrategyUniqueKey = async (strategyUniqueKey, validatedOnly = true, page = 1, limit = 5, filterType = 'bypass', filterIncludeEncrypted = false, bypassPaginationAndGetAll = false) => { const ideas = await listIdeasByStrategyUniqueKeyFromChain(strategyUniqueKey, validatedOnly, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); return ideas.data.map((idea) => idea.nftId); }; const solveContract = async (strategyUniqueKey) => { const { chain, contractAddress } = (0, __1.decomposeUniqueStrategyReference)(strategyUniqueKey); let contract = await __1.ContractModule.thisOrGet(); if (contract.recipe.chain !== chain) { contract = await __1.ContractModule.changeToContract(chain, 'v4'); } if (contract.gate.address !== contractAddress) { throw new Error('Contract mismatch error.'); } return contract; }; const solveContractAndKeys = async (strategyUniqueKey, contract) => { const { chain, contractAddress, creatorAddress, strategyKey } = (0, __1.decomposeUniqueStrategyReference)(strategyUniqueKey); if (contract === undefined) { contract = await __1.ContractModule.thisOrGet(); if (contract.recipe.chain !== chain) { contract = await __1.ContractModule.changeToContract(chain, 'v4'); } if (contract.gate.address !== contractAddress) { throw new Error('Contract mismatch error.'); } } return { contract, chain, contractAddress, creatorAddress, strategyKey, }; }; const getClosedIdeasHistoryByStrategy = async (payload, contract) => { if (contract === undefined) { await solveContract(payload.strategyUniqueKey); } let nftIds = await listIdeasByStrategyUniqueKeyFromChain(payload.strategyUniqueKey); // console.log('nftIds:') // console.log(nftIds) nftIds.data = nftIds.data.filter((each) => { if (typeof each.idea === 'string') { return false; } else { return each.idea.kind === 'close'; } }); // console.log('nftIds') // console.log(nftIds) // const allTokens = [...nftIds?.map((each) => each.id)] const ideas = nftIds.data.reverse(); // console.log('ideas') // console.log(ideas) const results = ideas.map((idea) => { const ticker = idea.idea.asset.ticker; const chainIdeas = idea.idea.chainIdeas; const open = chainIdeas.find((each) => each.idea.kind === 'open').idea; const close = idea.idea; const summary = idea.idea.result.summary; const obj = { nftId: idea.nftId, opents: open.priceInfo.price.timestamp, closets: close.priceInfo.price.timestamp, ticker: ticker, direction: open.trade.direction, percentage: Number(summary.percentage.toFixed(6)), profit: summary.profit, capital: summary.capital, stages: [], }; if ((0, __1.getBoolean)(payload.stages)) { obj.stages = chainIdeas?.map((each, index) => { const idea = each.idea; const response = { stage: index, nftId: each.nftId, type: idea.kind, adjtype: undefined, adjmt: undefined, bid: idea.priceInfo.price.ask || idea.priceInfo.price.globalPrice, ask: idea.priceInfo.price.bid || idea.priceInfo.price.globalPrice, }; if (idea.kind === 'adjust') { response.adjtype = idea.adjustment.kind; response.adjmt = idea.adjustment.percentage; } return response; }); // to attach the close idea obj.stages.push({ stage: chainIdeas.length, nftId: idea.nftId, type: close.kind, bid: close.priceInfo.price.ask || close.priceInfo.price.globalPrice, ask: close.priceInfo.price.bid || close.priceInfo.price.globalPrice, adjtype: undefined, adjmt: undefined, }); } return obj; }); const strategy = ideas[ideas.length - 1]?.strategy; if (!strategy) { throw new Error('Strategy not found'); } return { summary: { strategyReference: strategy.reference, strategyName: strategy.name, profit: Number(results.reduce((a, b) => a + b.capital, 0).toFixed(6)), percentage: Number((results.reduce((a, b) => a + b.percentage, 0) / results.length).toFixed(6)), ideas: results.length || 0, }, data: results, }; }; const listLatestPublicIdeas = async (page = 1, limit = 5, contract, network) => { /* // contract = ContractModule.thisOrGet(contract) const { data } = await CacheService.getData({ contract: 'public_one', key: `getPublicIdeas_${page}_${limit}`, init: async () => { contract = await ContractModule.thisOrGet(contract) const chain = contract.recipe.chain const address = contract.gate!.address const uniqueContractReference = uniqueKeyJoin([chain, address]) const publicNfts = return publicNfts }, }) const contractCreator = await contract.gate!.signer.getAddress() await doDecryptableIdeasOnPagingIfAccessible(data, contractCreator) return data */ if (contract === undefined && network === undefined) { const contract = __1.ContractModule.thisOrGet(); network = contract.recipe.chain; } return views_source_gate_module_1.ViewsSourceGateModule.listLatestPublicIdeas(contract, page, limit, network); }; const listLatestIdeas = async (page = 1, limit = 5, contract) => { contract = __1.ContractModule.thisOrGet(contract); const { data } = await __1.CacheService.getData({ contract: contract.gate, key: `listLatestIdeas${page}_${limit}`, init: async () => { contract = await __1.ContractModule.thisOrGet(contract); const chain = contract.recipe.chain; const address = contract.gate.address; const uniqueContractReference = (0, __1.uniqueKeyJoin)([chain, address]); const publicNfts = await views_source_gate_module_1.ViewsSourceGateModule.listLatestIdeas(uniqueContractReference, page, limit); return publicNfts; }, }); const contractCreator = await contract.gate.signer.getAddress(); await doDecryptableIdeasOnPagingIfAccessible(data, contractCreator); return data; }; const seekAll = async (seekFunction) => { let page = 1; const limit = 10; let total = 0; let data = []; let result = { data: [], paging: { page, limit, }, total: 0, }; do { result = await seekFunction(page, limit); data = [...data, ...result.data]; total += result.data.length; page++; } while (result.data.length > 0 && result.data.length === limit); result.total = total; return result; }; const listAllMyStrategies = async () => { return (await seekAll(listMyStrategies)).data; }; const getAllMyCachedStrategies = async () => { const myStrategies = await listAllMyStrategies(); const myCachedStrategies = await Promise.all(myStrategies.map((strategy) => __1.ProvableIdeasModule.chain.getValidatedStrategyChainWithCache(strategy.strategy.reference, strategy.creator.walletAddress))); return myCachedStrategies; }; const getCachedStrategyOpenPositions = (cachedStrategy) => { return __1.querychain.getAllStillNotClosedLatestIdeas(cachedStrategy); }; const getAllMyCachedStrategiesWithStillOpenPositions = async () => { const myCachedStrategies = await getAllMyCachedStrategies(); let allOpenPositions = []; const strategies = []; for (const myCachedStrategy of myCachedStrategies) { const openPositions = getCachedStrategyOpenPositions(myCachedStrategy.cache.cachedStrategy); if (openPositions.length !== 0) { strategies.push({ cachedStrategy: myCachedStrategy, strategy: myCachedStrategy.cache.cachedStrategy.strategy, openPositions, }); } allOpenPositions = [...allOpenPositions, ...openPositions]; } return { allOpenPositions, strategies, }; }; const getMyOpenPositions = async (page = 1, limit = 5) => { const allData = await getAllMyCachedStrategiesWithStillOpenPositions(); return (0, __1.postQueryIdeasFilterAndPagination)([...allData.allOpenPositions].reverse(), page, limit, 'bypass'); }; const getAllMyIdeas = async () => { const myCachedStrategies = await getAllMyCachedStrategies(); const myIdeas = myCachedStrategies.map((strategy) => { return __1.CONTRACT_TOOLS.queryChain.getAllIdeas(strategy.cache.cachedStrategy); }); return (await Promise.all(myIdeas)).flat(); }; const getMyIdeas = async (page = 1, limit = 5, filterType = 'bypass', filterIncludeEncrypted = false, bypassPaginationAndGetAll = false) => { const ideas = await getAllMyIdeas(); ideas.reverse(); return (0, __1.postQueryIdeasFilterAndPagination)(ideas, page, limit, filterType, filterIncludeEncrypted, bypassPaginationAndGetAll); }; const getAllMyOpenIdeas = async () => { const allIdeas = await getAllMyIdeas(); return allIdeas.filter((idea) => idea.idea.kind === 'open'); }; const getMyOpenIdeas = async (page = 1, limit = 5, filterIncludeEncrypted = false) => { return getMyIdeas(page, limit, ['open'], filterIncludeEncrypted, false); }; const getAllMyAdjustIdeas = async () => { const allIdeas = await getAllMyIdeas(); return allIdeas.filter((idea) => idea.idea.kind === 'adjust'); }; const getMyAdjustIdeas = async (page = 1, limit = 5, filterIncludeEncrypted = false) => { return getMyIdeas(page, limit, ['adjust'], filterIncludeEncrypted, false); }; const getAllMyCloseIdeas = async () => { const allIdeas = await getAllMyIdeas(); return allIdeas.filter((idea) => idea.idea.kind === 'close'); }; const getMyCloseIdeas = async (page = 1, limit = 5, filterIncludeEncrypted = false) => { return getMyIdeas(page, limit, ['close'], filterIncludeEncrypted, false); }; const decryptIdea = async (idea, inflateImages = false) => { await __1.CryptoIdeasModule.restoreIdeaByNftId(idea, inflateImages); }; const doDecryptableIdea = async (idea, wallet, inflateImages = false) => { if ((0, __1.isDecryptableIdea)(idea, wallet)) { await decryptIdea(idea, inflateImages); } }; const doDecryptableIdeas = async (ideas, wallet, inflateImages = false) => { await Promise.all(ideas.map((idea) => doDecryptableIdea(idea, wallet, inflateImages))); }; const doDecryptableIdeasOnPagingIfAccessible = async (ideas, wallet, accessible = true) => { if (accessible) { await doDecryptableIdeas(ideas.data, wallet, false); } }; const getStrategyPortfolio = async (uniqueStrategyKey) => { const fromViews = await views_source_gate_module_1.ViewsSourceGateModule.getStrategyPortfolio(uniqueStrategyKey); if (fromViews !== 'ENCRYPTED') { return fromViews; } else { const rebal = (await listStrategyRebalances(uniqueStrategyKey, 1, 1)) .data[0]; if (rebal.totalAllocation === undefined) { return 'ENCRYPTED'; } const entries = []; for (const asset of rebal.assets) { const idea = asset.lastIdea.idea; let firstIdea = undefined; if (asset.prevIdeas) { if (asset.prevIdeas.length > 0) { firstIdea = asset.prevIdeas[0].idea; } } if (firstIdea === undefined) { firstIdea = idea; } const entry = { reference: asset.lastIdea.content.reference, pricing: asset.lastIdea.pricing, price: idea.priceInfo.price, notes: idea.notes.commentary, title: idea.title, asset: idea.asset, direction: firstIdea.trade.direction, allocation: asset.allocation, }; entries.push(entry); } const view = { strategyKey: rebal.strategyKey, totalEntries: rebal.totalAssets, totalAllocation: rebal.totalAllocation, entries, }; return view; } }; const decryptEnrichRebalance = async (opaque, userWallet) => { opaque.assets = await Promise.all(opaque.assets.map(async (asset) => { asset.prevIdeas = []; const strategyReference = asset.lastIdea.strategy.reference; const creatorWallet = asset.lastIdea.creator.walletAddress; const ideaKey = asset.lastIdea.content.ideaKey; for (let index = 0; index < asset.lastIdea.content.ideaStageKey; index++) { const ideaToSeek = await __1.ProvableIdeasModule.general.getIdeaByKeys(strategyReference, ideaKey, index, creatorWallet); const nftId = await __1.ProvableIdeasModule.general.getIdeaNftIdByKeys(creatorWallet, strategyReference, ideaKey, index); ideaToSeek.nftId = nftId; asset.prevIdeas.push(ideaToSeek); } return asset; })); let allPublic = true; for (const asset of opaque.assets) { if (typeof asset.lastIdea.idea === 'string') { allPublic = false; break; } for (const prevIdea of asset.prevIdeas || []) { if (typeof prevIdea.idea === 'string') { allPublic = false; break; } } } if (!allPublic) { // try decrypt all userWallet = (await __1.ContractModule.thisOrGetCreator(userWallet)); opaque.assets = await Promise.all(opaque.assets.map(async (asset) => { await doDecryptableIdea(asset.lastIdea, userWallet); asset.prevIdeas = await Promise.all(asset.prevIdeas.map(async (prevIdea) => { await doDecryptableIdea(prevIdea, userWallet); return prevIdea; })); return asset; })); } allPublic = true; for (const asset of opaque.assets) { if (typeof asset.lastIdea.idea === 'string') { allPublic = false; break; } for (const prevIdea of asset.prevIdeas || []) { if (typeof prevIdea.idea === 'string') { allPublic = false; break; } } } if (allPublic) { let totalAllocation = 0; const assets = []; for (const asset of opaque.assets) { let allocation = 0; const ideaIdea = asset.lastIdea.idea; const ticker = ideaIdea.asset.ticker; if (asset.prevIdeas.length === 0) { allocation = ideaIdea.trade.allocation; } else { for (const prevIdea of [...asset.prevIdeas, asset.lastIdea]) { const prevIdeaIdea = prevIdea.idea; if (allocation === 0) { allocation = prevIdeaIdea.trade.allocation; } else { const howMuchToIncDec = (0, bignumber_js_1.BigNumber)(allocation).times((0, bignumber_js_1.BigNumber)(prevIdeaIdea.adjustment.percentage).dividedBy(100)); if (prevIdeaIdea.adjustment.kind === 'increase') { allocation = +(0, bignumber_js_1.BigNumber)(allocation) .plus(howMuchToIncDec) .toFixed(2); } else { allocation = +(0, bignumber_js_1.BigNumber)(allocation) .minus(howMuchToIncDec) .toFixed(2); } } } } totalAllocation = +(0, bignumber_js_1.BigNumber)(totalAllocation) .plus(allocation) .toFixed(2); const assetEnriched = { ...asset, ticker, allocation, prevIdeas: asset.prevIdeas, }; assets.push(assetEnriched); } const result = { ...opaque, totalAllocation, assets, }; return result; } else { return opaque; } }; const listStrategyRebalances = async (uniqueStrategyKey, page = 1, limit = 5, userWallet) => { const fromViews = await views_source_gate_module_1.ViewsSourceGateModule.listStrategyRebalances(uniqueStrategyKey, page, limit); const dataEnriched = await Promise.all(fromViews.data.map(async (each) => { return decryptEnrichRebalance(each, userWallet); })); const enriched = { ...fromViews, data: dataEnriched, }; return enriched; }; const getStrategyRebalance = async (uniqueStrategyKey, rebalanceReference, userWallet) => { const fromViews = await views_source_gate_module_1.ViewsSourceGateModule.getStrategyRebalance(uniqueStrategyKey, rebalanceReference); return decryptEnrichRebalance(fromViews, userWallet); }; const listStrategyRebalancesInPeriod = async (uniqueStrategyKey, from, to, page = 1, limit = 5, userWallet) => { const fromViews = await views_source_gate_module_1.ViewsSourceGateModule.listStrategyRebalancesInPeriod(uniqueStrategyKey, from, to, page, limit); const dataEnriched = await Promise.all(fromViews.data.map(async (each) => { return decryptEnrichRebalance(each, userWallet); })); const enriched = { ...fromViews, data: dataEnriched, }; return enriched; }; exports.QueryViewsModule = { seekAll, listContracts, getWalletInfoDetails, getValidatedStrategyInfoDetails, listMyStrategies, listCreatorStrategies, listPublicStrategies, listLatestIdeas, listLatestPublicIdeas, listAllMyStrategies, getIdeasCreatedBy, getIdeasOwnedBy, // getIdeaByNftId, // listStrategiesWithAccessibleIdeas, listStrategiesSubscribedTo, listStrategiesByCreator, getClosedIdeasHistoryByStrategy, listIdeasByStrategy, getValidatedIdeasByStrategy, // getAllMyCachedStrategies, getAllMyIdeas, getAllMyOpenIdeas, getAllMyAdjustIdeas, getAllMyCloseIdeas, // getMyIdeas, getMyOpenIdeas, getMyAdjustIdeas, getMyCloseIdeas, getMyOpenPositions, // getAllMyCachedStrategiesWithStillOpenPositions, // decryptIdea, doDecryptableIdea, doDecryptableIdeas, doDecryptableIdeasOnPagingIfAccessible, // listIdeasByStrategyUniqueKeyFromChain, listIdeaNftsByStrategyUniqueKey, getStrategyPortfolio, listStrategyRebalances, getStrategyRebalance, listStrategyRebalancesInPeriod, public: { getIdeaByUniqueContractAndId: views_source_gate_module_1.ViewsSourceGateModule.getIdeaByUniqueContractAndId, getIdeaByUniqueId: views_source_gate_module_1.ViewsSourceGateModule.getIdeaByUniqueId, getStrategyWithCreator: views_source_gate_module_1.ViewsSourceGateModule.getPublicStrategyWithCreator, }, }; //# sourceMappingURL=query-views.module.js.map