From a870354990918192ebb656df400234ada7575272 Mon Sep 17 00:00:00 2001 From: anasbelbaz Date: Wed, 24 Jul 2024 15:16:13 +0000 Subject: [PATCH] chore: format --- src/actions/open-markets.test.ts | 5 +-- src/actions/open-markets.ts | 59 +++++++++++++++---------------- src/builder/open-markets.ts | 17 ++++----- src/types/actions/open-markets.ts | 15 ++++---- 4 files changed, 42 insertions(+), 54 deletions(-) diff --git a/src/actions/open-markets.test.ts b/src/actions/open-markets.test.ts index 9062fb7..30a0af5 100644 --- a/src/actions/open-markets.test.ts +++ b/src/actions/open-markets.test.ts @@ -31,9 +31,8 @@ describe('Getting the open markets', () => { const openMarkets = await getOpenMarkets(client, params) console.log(openMarkets.marketsConfig) - // expect(openMarkets.markets).toEqual({ - // monitor: '0x0000000000000000000000000000000000000000', + // monitor: '0x0000000000000000000000000000000000000000', // useOracle: false, // notify: false, // gasprice: 1680n, @@ -46,6 +45,4 @@ describe('Getting the open markets', () => { // expect(book.bidsConfig.active).toBeTruthy() // expect(book.asksConfig.active).toBeTruthy() }) - - }) diff --git a/src/actions/open-markets.ts b/src/actions/open-markets.ts index b1f5047..8ae1f51 100644 --- a/src/actions/open-markets.ts +++ b/src/actions/open-markets.ts @@ -1,43 +1,40 @@ // import type { SimulationParams } from '~mgv/types/actions/simulation.js' // import type { openMarketsABI } from '../builder/open-markets.js' -import type { Client} from 'viem' +import type { Client } from 'viem' import { multicall } from 'viem/actions' -import { openMarketsParams } from '../builder/open-markets.js' -import type { MangroveActionsDefaultParams } from '~mgv/types/index.js' import type { OpenMarketsResult } from '~mgv/types/actions/open-markets.js' +import type { MangroveActionsDefaultParams } from '~mgv/types/index.js' +import { openMarketsParams } from '../builder/open-markets.js' import { getAction } from '../utils/getAction.js' - export async function getOpenMarkets( - client: Client, - actionParams: MangroveActionsDefaultParams, - ): Promise { - const { mgvReader } = actionParams - - const result = - await getAction( - client, - multicall, - 'multicall', - )({ - contracts: [ - { - address: mgvReader, - ...openMarketsParams(), - }, - ], - allowFailure: false, - }) + client: Client, + actionParams: MangroveActionsDefaultParams, +): Promise { + const { mgvReader } = actionParams - console.log(result[0][0], result[0][1]) + const result = await getAction( + client, + multicall, + 'multicall', + )({ + contracts: [ + { + address: mgvReader, + ...openMarketsParams(), + }, + ], + allowFailure: false, + }) - // const markets = parseMarkets(markets) - // const marketsConfigs = parseMarketsConfigs(marketsConfigs) + console.log(result[0][0], result[0][1]) - return { - markets: result[0][0], - marketsConfigs: result[0][1] - } as unknown as OpenMarketsResult - } + // const markets = parseMarkets(markets) + // const marketsConfigs = parseMarketsConfigs(marketsConfigs) + return { + markets: result[0][0], + marketsConfigs: result[0][1], + } as unknown as OpenMarketsResult +} diff --git a/src/builder/open-markets.ts b/src/builder/open-markets.ts index b1eae0a..9316b43 100644 --- a/src/builder/open-markets.ts +++ b/src/builder/open-markets.ts @@ -1,4 +1,8 @@ -import { type ContractFunctionParameters, parseAbi, type ContractFunctionReturnType } from 'viem' +import { + type ContractFunctionParameters, + type ContractFunctionReturnType, + parseAbi, +} from 'viem' export const openMarketsABI = parseAbi([ 'struct Market { address tkn0; address tkn1; uint tickSpacing; }', @@ -29,16 +33,11 @@ export function openMarketsParams() { functionName: 'openMarkets', args: [], } satisfies Omit< - ContractFunctionParameters< - typeof openMarketsABI, - 'view', - 'openMarkets' - >, + ContractFunctionParameters, 'address' > } - export type ParseOpenMarketsParams = { result: ContractFunctionReturnType< typeof openMarketsABI, @@ -47,7 +46,6 @@ export type ParseOpenMarketsParams = { > } - /** * * @param result the result of open markets @@ -74,6 +72,3 @@ export function parseBookResult({ } }) } - - - diff --git a/src/types/actions/open-markets.ts b/src/types/actions/open-markets.ts index 48470cf..7c57a36 100644 --- a/src/types/actions/open-markets.ts +++ b/src/types/actions/open-markets.ts @@ -5,15 +5,14 @@ import type { openMarketsABI } from '~mgv/builder/open-markets.js' // [ [0x4300000000000000000000000000000000000003,0x4300000000000000000000000000000000000004,1], ... ] // [ [true,2,320,2,1125899906842624,134,576460752303423488,1,300,false,58172,true,2,273,1,274878955520,13835058055282163712,16,2,300,false,56246], ... ] - export type OpenMarketsResult = { - markets: { - tkn0: Address, - tkn1: Address, - tickSpacing: bigint - }[] - marketsConfig: {config01: LocalConfig, config10: LocalConfig}[] - request: SimulateContractReturnType< + markets: { + tkn0: Address + tkn1: Address + tickSpacing: bigint + }[] + marketsConfig: { config01: LocalConfig; config10: LocalConfig }[] + request: SimulateContractReturnType< typeof openMarketsABI, 'openMarkets' >['request']