@parifi/sdk
Version:
Parifi SDK with common utility functions
1 lines • 2.96 kB
Source Map (JSON)
{"version":3,"sources":["../../src/utils/subgraph-helper.ts"],"sourcesContent":["import { Contract, ethers } from 'ethers';\nimport { Chain, contracts } from '@parifi/references';\nimport { contracts as parifiContracts } from '@parifi/references';\n\n// import { SUBGRAPH_HELPER_ADDRESS } from '../../common';\n// import { getPositionsToRefresh } from '../../subgraph';\n\nconst subgraphHelperAbi = [\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: 'bytes32[]', name: 'orderIds', type: 'bytes32[]' }],\n name: 'OrderUpdateRequest',\n type: 'event',\n },\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: 'bytes32[]', name: 'positionIds', type: 'bytes32[]' }],\n name: 'PositionUpdateRequest',\n type: 'event',\n },\n {\n inputs: [{ internalType: 'bytes32[]', name: 'orderIds', type: 'bytes32[]' }],\n name: 'triggerOrderUpdate',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [{ internalType: 'bytes32[]', name: 'positionIds', type: 'bytes32[]' }],\n name: 'triggerPositionUpdate',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n];\n\n// Returns Subgraph Helper contract instance without signer\nexport const getSubgraphHelperInstance = (chain: Chain): Contract => {\n try {\n // @todo Need to fix the references library to allow chainId as ArbSepolia has some issues\n return new ethers.Contract(contracts[42161].SubgraphHelper.address, subgraphHelperAbi);\n } catch (error) {\n throw error;\n }\n};\n\n// // Returns tx data to refresh positions on subgraph using the Subgraph Helper contract\n// export const getPositionRefreshTxData = async (\n// chainId: Chain,\n// subgraphEndpoint: string,\n// ): Promise<{ txData: string }> => {\n// const positionsCount = 25;\n// const positionsToRefresh = await getPositionsToRefresh(subgraphEndpoint, positionsCount);\n// const subgraphHelper = getSubgraphHelperInstance(chainId);\n// const { data: txData } = await subgraphHelper.triggerPositionUpdate.populateTransaction(positionsToRefresh);\n// return { txData };\n// };\n"],"mappings":";AAAA,SAAmB,cAAc;AACjC,SAAgB,iBAAiB;AAMjC,IAAM,oBAAoB;AAAA,EACxB;AAAA,IACE,WAAW;AAAA,IACX,QAAQ,CAAC,EAAE,SAAS,OAAO,cAAc,aAAa,MAAM,YAAY,MAAM,YAAY,CAAC;AAAA,IAC3F,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,QAAQ,CAAC,EAAE,SAAS,OAAO,cAAc,aAAa,MAAM,eAAe,MAAM,YAAY,CAAC;AAAA,IAC9F,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,QAAQ,CAAC,EAAE,cAAc,aAAa,MAAM,YAAY,MAAM,YAAY,CAAC;AAAA,IAC3E,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,iBAAiB;AAAA,IACjB,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,QAAQ,CAAC,EAAE,cAAc,aAAa,MAAM,eAAe,MAAM,YAAY,CAAC;AAAA,IAC9E,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,iBAAiB;AAAA,IACjB,MAAM;AAAA,EACR;AACF;AAGO,IAAM,4BAA4B,CAAC,UAA2B;AACnE,MAAI;AAEF,WAAO,IAAI,OAAO,SAAS,UAAU,KAAK,EAAE,eAAe,SAAS,iBAAiB;AAAA,EACvF,SAAS,OAAO;AACd,UAAM;AAAA,EACR;AACF;","names":[]}