From 2ef3bbf3353dd70458d17191e58952612e0129b3 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 10 Oct 2024 15:00:36 +0100 Subject: [PATCH 01/12] explorer UI updated --- packages/explorer-ui/components/ChainChart/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/explorer-ui/components/ChainChart/index.tsx b/packages/explorer-ui/components/ChainChart/index.tsx index a99f02dbb7..35ae42acb6 100644 --- a/packages/explorer-ui/components/ChainChart/index.tsx +++ b/packages/explorer-ui/components/ChainChart/index.tsx @@ -320,6 +320,12 @@ export const OverviewChart: React.FC = ({ stackId="a" fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#000000'} /> + )} From 6cf146a9ca80e10d89bb98272c16d7c1e20d9926 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 10 Oct 2024 15:03:08 +0100 Subject: [PATCH 02/12] rfq-indexer update --- .../api/src/constants/networkConfig.ts | 12 +++++++++ .../conflictingProofsController.ts | 2 +- .../api/src/controllers/disputesController.ts | 2 +- .../pendingTransactionsController.ts | 2 +- .../controllers/transactionIdController.ts | 4 +-- packages/rfq-indexer/indexer/.env.example | 2 +- packages/rfq-indexer/indexer/ponder.config.ts | 25 +++++++++++++++++++ .../rfq-indexer/indexer/src/utils/chains.ts | 1 + 8 files changed, 44 insertions(+), 6 deletions(-) diff --git a/packages/rfq-indexer/api/src/constants/networkConfig.ts b/packages/rfq-indexer/api/src/constants/networkConfig.ts index 8d2dc78e3f..579f8f7273 100644 --- a/packages/rfq-indexer/api/src/constants/networkConfig.ts +++ b/packages/rfq-indexer/api/src/constants/networkConfig.ts @@ -8,6 +8,7 @@ import { linea, bsc, blast, + worldchain, } from 'viem/chains' import { FastBridgeV2Abi } from './abis/FastBridgeV2' @@ -114,4 +115,15 @@ export const networkConfig: NetworkConfig = { transport: http(), }), }, + 480: { + name: 'Worldchain', + FastBridgeV2: { + address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + abi: FastBridgeV2Abi, + }, + client: createPublicClient({ + chain: worldchain, + transport: http(), + }), + }, } as const diff --git a/packages/rfq-indexer/api/src/controllers/conflictingProofsController.ts b/packages/rfq-indexer/api/src/controllers/conflictingProofsController.ts index 7f1de3137a..879473b32e 100644 --- a/packages/rfq-indexer/api/src/controllers/conflictingProofsController.ts +++ b/packages/rfq-indexer/api/src/controllers/conflictingProofsController.ts @@ -13,7 +13,7 @@ export const conflictingProofsController = async ( const query = db .with('deposits', () => qDeposits()) .with('relays', () => qRelays()) - .with('proofs', () => qProofs({activeOnly: true})) + .with('proofs', () => qProofs({ activeOnly: true })) .with('combined', (qb) => qb .selectFrom('deposits') diff --git a/packages/rfq-indexer/api/src/controllers/disputesController.ts b/packages/rfq-indexer/api/src/controllers/disputesController.ts index 2e65632c77..840d133db8 100644 --- a/packages/rfq-indexer/api/src/controllers/disputesController.ts +++ b/packages/rfq-indexer/api/src/controllers/disputesController.ts @@ -7,7 +7,7 @@ import { nest_results } from '../utils/nestResults' export const disputesController = async (req: Request, res: Response) => { try { const query = db - .with('disputes', () => qDisputes({activeOnly: true})) + .with('disputes', () => qDisputes({ activeOnly: true })) .selectFrom('disputes') .selectAll() .orderBy('blockTimestamp_dispute', 'desc') diff --git a/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts b/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts index a2012c53c4..cf2d195f84 100644 --- a/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts +++ b/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts @@ -62,7 +62,7 @@ export const pendingTransactionsMissingProofController = async ( const query = db .with('deposits', () => qDeposits()) .with('relays', () => qRelays()) - .with('proofs', () => qProofs({activeOnly: true})) + .with('proofs', () => qProofs({ activeOnly: true })) .with('combined', (qb) => qb .selectFrom('deposits') diff --git a/packages/rfq-indexer/api/src/controllers/transactionIdController.ts b/packages/rfq-indexer/api/src/controllers/transactionIdController.ts index 586590220a..f389d06025 100644 --- a/packages/rfq-indexer/api/src/controllers/transactionIdController.ts +++ b/packages/rfq-indexer/api/src/controllers/transactionIdController.ts @@ -13,8 +13,8 @@ export const getTransactionById = async (req: Request, res: Response) => { qDeposits().where('transactionId', '=', transactionId as string) ) .with('relays', () => qRelays()) - .with('proofs', () => qProofs({activeOnly: false})) // display proofs even if they have been invalidated/replaced by a dispute - .with('disputes', () => qDisputes({activeOnly: true})) // do not show disputes that have been invalidated/replaced by a proof + .with('proofs', () => qProofs({ activeOnly: false })) // display proofs even if they have been invalidated/replaced by a dispute + .with('disputes', () => qDisputes({ activeOnly: true })) // do not show disputes that have been invalidated/replaced by a proof .with('claims', () => qClaims()) .with('refunds', () => qRefunds()) .with('combined', (qb) => diff --git a/packages/rfq-indexer/indexer/.env.example b/packages/rfq-indexer/indexer/.env.example index 33ca569c2c..b1361bc84e 100644 --- a/packages/rfq-indexer/indexer/.env.example +++ b/packages/rfq-indexer/indexer/.env.example @@ -8,7 +8,7 @@ BLAST_MAINNET_RPC= SCROLL_MAINNET_RPC= LINEA_MAINNET_RPC= BNB_MAINNET_RPC= +WORLDCHAIN_MAINNET_RPC= # (Optional) Postgres database URL. If not provided, SQLite will be used. DATABASE_URL= - \ No newline at end of file diff --git a/packages/rfq-indexer/indexer/ponder.config.ts b/packages/rfq-indexer/indexer/ponder.config.ts index df73b39d5e..edfea0e144 100644 --- a/packages/rfq-indexer/indexer/ponder.config.ts +++ b/packages/rfq-indexer/indexer/ponder.config.ts @@ -13,6 +13,7 @@ const blastChainId = 81457 const scrollChainId = 534352 const lineaChainId = 59144 const bnbChainId = 56 +const worldchainChainId = 480 const configByChainId = { [1]: { @@ -69,6 +70,12 @@ const configByChainId = { FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', FastBridgeV2StartBlock: 40497843, // first block and new block }, + [480]: { + transport: http(process.env.WORLDCHAIN_MAINNET_RPC), + chainName: 'worldchain', + FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + FastBridgeV2StartBlock: 4616214, // first block and new block + }, disableCache: true, } @@ -137,6 +144,14 @@ export const networkDetails = { startBlock: configByChainId[bnbChainId].FastBridgeV2StartBlock, }, }, + [worldchainChainId]: { + name: configByChainId[worldchainChainId].chainName, + FastBridgeV2: { + address: configByChainId[worldchainChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[worldchainChainId].FastBridgeV2StartBlock, + }, + }, } as Record const config = createConfig({ @@ -181,6 +196,11 @@ const config = createConfig({ transport: configByChainId[bnbChainId].transport, // disableCache: configByChainId.disableCache, }, + [configByChainId[worldchainChainId].chainName]: { + chainId: worldchainChainId, + transport: configByChainId[worldchainChainId].transport, + // disableCache: configByChainId.disableCache, + }, }, contracts: { FastBridgeV2: { @@ -217,6 +237,11 @@ const config = createConfig({ address: networkDetails[bnbChainId]?.FastBridgeV2.address, startBlock: networkDetails[bnbChainId]?.FastBridgeV2.startBlock, }, + [configByChainId[worldchainChainId].chainName]: { + address: networkDetails[worldchainChainId]?.FastBridgeV2.address, + startBlock: + networkDetails[worldchainChainId]?.FastBridgeV2.startBlock, + }, }, abi: FastBridgeV2Abi, }, diff --git a/packages/rfq-indexer/indexer/src/utils/chains.ts b/packages/rfq-indexer/indexer/src/utils/chains.ts index e521f65def..121f48c546 100644 --- a/packages/rfq-indexer/indexer/src/utils/chains.ts +++ b/packages/rfq-indexer/indexer/src/utils/chains.ts @@ -7,6 +7,7 @@ export const chainIdToName: { [key: number]: string } = { 534352: 'scroll', 59144: 'linea', 56: 'bnb', + 480: 'worldchain', } export const getChainName = (chainId: number): string => { From 451a2d7df892e12085851d3503f7bd6d36da11d0 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 10 Oct 2024 15:03:33 +0100 Subject: [PATCH 03/12] explorer backend update --- services/explorer/api/server_test.go | 49 ++++----- .../consumer/parser/tokendata/cache.go | 5 + services/explorer/graphql/client/client.go | 50 ++++----- .../graphql/client/queries/queries.graphql | 1 + .../graphql/server/graph/model/models_gen.go | 49 ++++----- .../explorer/graphql/server/graph/partials.go | 6 ++ .../graphql/server/graph/resolver/server.go | 102 +++++++++++++----- .../graphql/server/graph/schema/types.graphql | 1 + services/explorer/static/chainIDs.yaml | 1 + .../explorer/static/tokenIDToCoinGeckoID.yaml | 1 + .../static/tokenSymbolToCoinGeckoID.yaml | 1 + .../explorer/static/tokenSymbolToTokenID.yaml | 1 + 12 files changed, 171 insertions(+), 96 deletions(-) diff --git a/services/explorer/api/server_test.go b/services/explorer/api/server_test.go index 6a5a0b27df..1125854ecb 100644 --- a/services/explorer/api/server_test.go +++ b/services/explorer/api/server_test.go @@ -35,30 +35,31 @@ func TestHandleJSONDailyStat(t *testing.T) { // nolint valueStruct := gqlClient.GetDailyStatisticsByChain{ Response: []*struct { - Date *string "json:\"date\" graphql:\"date\"" - Ethereum *float64 "json:\"ethereum\" graphql:\"ethereum\"" - Optimism *float64 "json:\"optimism\" graphql:\"optimism\"" - Cronos *float64 "json:\"cronos\" graphql:\"cronos\"" - Bsc *float64 "json:\"bsc\" graphql:\"bsc\"" - Polygon *float64 "json:\"polygon\" graphql:\"polygon\"" - Fantom *float64 "json:\"fantom\" graphql:\"fantom\"" - Boba *float64 "json:\"boba\" graphql:\"boba\"" - Metis *float64 "json:\"metis\" graphql:\"metis\"" - Moonbeam *float64 "json:\"moonbeam\" graphql:\"moonbeam\"" - Moonriver *float64 "json:\"moonriver\" graphql:\"moonriver\"" - Klaytn *float64 "json:\"klaytn\" graphql:\"klaytn\"" - Arbitrum *float64 "json:\"arbitrum\" graphql:\"arbitrum\"" - Avalanche *float64 "json:\"avalanche\" graphql:\"avalanche\"" - Dfk *float64 "json:\"dfk\" graphql:\"dfk\"" - Aurora *float64 "json:\"aurora\" graphql:\"aurora\"" - Harmony *float64 "json:\"harmony\" graphql:\"harmony\"" - Canto *float64 "json:\"canto\" graphql:\"canto\"" - Dogechain *float64 "json:\"dogechain\" graphql:\"dogechain\"" - Base *float64 "json:\"base\" graphql:\"base\"" - Blast *float64 "json:\"blast\" graphql:\"blast\"" - Scroll *float64 "json:\"scroll\" graphql:\"scroll\"" - Linea *float64 "json:\"linea\" graphql:\"linea\"" - Total *float64 "json:\"total\" graphql:\"total\"" + Date *string "json:\"date\" graphql:\"date\"" + Ethereum *float64 "json:\"ethereum\" graphql:\"ethereum\"" + Optimism *float64 "json:\"optimism\" graphql:\"optimism\"" + Cronos *float64 "json:\"cronos\" graphql:\"cronos\"" + Bsc *float64 "json:\"bsc\" graphql:\"bsc\"" + Polygon *float64 "json:\"polygon\" graphql:\"polygon\"" + Fantom *float64 "json:\"fantom\" graphql:\"fantom\"" + Boba *float64 "json:\"boba\" graphql:\"boba\"" + Metis *float64 "json:\"metis\" graphql:\"metis\"" + Moonbeam *float64 "json:\"moonbeam\" graphql:\"moonbeam\"" + Moonriver *float64 "json:\"moonriver\" graphql:\"moonriver\"" + Klaytn *float64 "json:\"klaytn\" graphql:\"klaytn\"" + Arbitrum *float64 "json:\"arbitrum\" graphql:\"arbitrum\"" + Avalanche *float64 "json:\"avalanche\" graphql:\"avalanche\"" + Dfk *float64 "json:\"dfk\" graphql:\"dfk\"" + Aurora *float64 "json:\"aurora\" graphql:\"aurora\"" + Harmony *float64 "json:\"harmony\" graphql:\"harmony\"" + Canto *float64 "json:\"canto\" graphql:\"canto\"" + Dogechain *float64 "json:\"dogechain\" graphql:\"dogechain\"" + Base *float64 "json:\"base\" graphql:\"base\"" + Blast *float64 "json:\"blast\" graphql:\"blast\"" + Scroll *float64 "json:\"scroll\" graphql:\"scroll\"" + Linea *float64 "json:\"linea\" graphql:\"linea\"" + Worldchain *float64 "json:\"worldchain\" graphql:\"worldchain\"" + Total *float64 "json:\"total\" graphql:\"total\"" }{ { Total: &valueFloat, diff --git a/services/explorer/consumer/parser/tokendata/cache.go b/services/explorer/consumer/parser/tokendata/cache.go index ab52591c94..b9eb33e54b 100644 --- a/services/explorer/consumer/parser/tokendata/cache.go +++ b/services/explorer/consumer/parser/tokendata/cache.go @@ -287,5 +287,10 @@ var tokenDataMap = map[string]TokenData{ "8453_0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb": {"DAI", 18, "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"}, "1_0xAdF7C35560035944e805D98fF17d58CDe2449389": {"SPEC", 18, "0xAdF7C35560035944e805D98fF17d58CDe2449389"}, "8453_0x96419929d7949D6A801A6909c145C8EEf6A40431": {"SPEC", 18, "0x96419929d7949D6A801A6909c145C8EEf6A40431"}, + "480_0x2cFc85d8E48F8EAB294be644d9E25C3030863003": {"WLD", 18, "0x2cFc85d8E48F8EAB294be644d9E25C3030863003"}, + "10_0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1": {"WLD", 18, "0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1"}, + "480_0x79A02482A880bCE3F13e09Da970dC34db4CD24d1": {"USDC.e", 6, "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1"}, + "480_0x4200000000000000000000000000000000000006": {"WETH", 18, "0x4200000000000000000000000000000000000006"}, + "1_0x163f8c2467924be0ae7b5347228cabf260318753": {"WLD", 18, "0x163f8c2467924be0ae7b5347228cabf260318753"}, // Add additional tokens that are not part of the cache yet (and not by nature in bridge config) here } diff --git a/services/explorer/graphql/client/client.go b/services/explorer/graphql/client/client.go index 04f5498f6d..704c82de6b 100644 --- a/services/explorer/graphql/client/client.go +++ b/services/explorer/graphql/client/client.go @@ -106,30 +106,31 @@ type GetAmountStatistic struct { } type GetDailyStatisticsByChain struct { Response []*struct { - Date *string "json:\"date\" graphql:\"date\"" - Ethereum *float64 "json:\"ethereum\" graphql:\"ethereum\"" - Optimism *float64 "json:\"optimism\" graphql:\"optimism\"" - Cronos *float64 "json:\"cronos\" graphql:\"cronos\"" - Bsc *float64 "json:\"bsc\" graphql:\"bsc\"" - Polygon *float64 "json:\"polygon\" graphql:\"polygon\"" - Fantom *float64 "json:\"fantom\" graphql:\"fantom\"" - Boba *float64 "json:\"boba\" graphql:\"boba\"" - Metis *float64 "json:\"metis\" graphql:\"metis\"" - Moonbeam *float64 "json:\"moonbeam\" graphql:\"moonbeam\"" - Moonriver *float64 "json:\"moonriver\" graphql:\"moonriver\"" - Klaytn *float64 "json:\"klaytn\" graphql:\"klaytn\"" - Arbitrum *float64 "json:\"arbitrum\" graphql:\"arbitrum\"" - Avalanche *float64 "json:\"avalanche\" graphql:\"avalanche\"" - Dfk *float64 "json:\"dfk\" graphql:\"dfk\"" - Aurora *float64 "json:\"aurora\" graphql:\"aurora\"" - Harmony *float64 "json:\"harmony\" graphql:\"harmony\"" - Canto *float64 "json:\"canto\" graphql:\"canto\"" - Dogechain *float64 "json:\"dogechain\" graphql:\"dogechain\"" - Base *float64 "json:\"base\" graphql:\"base\"" - Blast *float64 "json:\"blast\" graphql:\"blast\"" - Scroll *float64 "json:\"scroll\" graphql:\"scroll\"" - Linea *float64 "json:\"linea\" graphql:\"linea\"" - Total *float64 "json:\"total\" graphql:\"total\"" + Date *string "json:\"date\" graphql:\"date\"" + Ethereum *float64 "json:\"ethereum\" graphql:\"ethereum\"" + Optimism *float64 "json:\"optimism\" graphql:\"optimism\"" + Cronos *float64 "json:\"cronos\" graphql:\"cronos\"" + Bsc *float64 "json:\"bsc\" graphql:\"bsc\"" + Polygon *float64 "json:\"polygon\" graphql:\"polygon\"" + Fantom *float64 "json:\"fantom\" graphql:\"fantom\"" + Boba *float64 "json:\"boba\" graphql:\"boba\"" + Metis *float64 "json:\"metis\" graphql:\"metis\"" + Moonbeam *float64 "json:\"moonbeam\" graphql:\"moonbeam\"" + Moonriver *float64 "json:\"moonriver\" graphql:\"moonriver\"" + Klaytn *float64 "json:\"klaytn\" graphql:\"klaytn\"" + Arbitrum *float64 "json:\"arbitrum\" graphql:\"arbitrum\"" + Avalanche *float64 "json:\"avalanche\" graphql:\"avalanche\"" + Dfk *float64 "json:\"dfk\" graphql:\"dfk\"" + Aurora *float64 "json:\"aurora\" graphql:\"aurora\"" + Harmony *float64 "json:\"harmony\" graphql:\"harmony\"" + Canto *float64 "json:\"canto\" graphql:\"canto\"" + Dogechain *float64 "json:\"dogechain\" graphql:\"dogechain\"" + Base *float64 "json:\"base\" graphql:\"base\"" + Blast *float64 "json:\"blast\" graphql:\"blast\"" + Scroll *float64 "json:\"scroll\" graphql:\"scroll\"" + Linea *float64 "json:\"linea\" graphql:\"linea\"" + Worldchain *float64 "json:\"worldchain\" graphql:\"worldchain\"" + Total *float64 "json:\"total\" graphql:\"total\"" } "json:\"response\" graphql:\"response\"" } type GetMessageBusTransactions struct { @@ -502,6 +503,7 @@ const GetDailyStatisticsByChainDocument = `query GetDailyStatisticsByChain ($cha blast scroll linea + worldchain total } } diff --git a/services/explorer/graphql/client/queries/queries.graphql b/services/explorer/graphql/client/queries/queries.graphql index 60eb3d63eb..3d351f3cc1 100644 --- a/services/explorer/graphql/client/queries/queries.graphql +++ b/services/explorer/graphql/client/queries/queries.graphql @@ -155,6 +155,7 @@ query GetDailyStatisticsByChain($chainID: Int, $type: DailyStatisticType, $durat blast scroll linea + worldchain total } } diff --git a/services/explorer/graphql/server/graph/model/models_gen.go b/services/explorer/graphql/server/graph/model/models_gen.go index d3eeb60af4..c090c167e4 100644 --- a/services/explorer/graphql/server/graph/model/models_gen.go +++ b/services/explorer/graphql/server/graph/model/models_gen.go @@ -81,30 +81,31 @@ type DateResult struct { // DateResult is a given statistic for a given date. type DateResultByChain struct { - Date *string `json:"date,omitempty"` - Ethereum *float64 `json:"ethereum,omitempty"` - Optimism *float64 `json:"optimism,omitempty"` - Cronos *float64 `json:"cronos,omitempty"` - Bsc *float64 `json:"bsc,omitempty"` - Polygon *float64 `json:"polygon,omitempty"` - Fantom *float64 `json:"fantom,omitempty"` - Boba *float64 `json:"boba,omitempty"` - Metis *float64 `json:"metis,omitempty"` - Moonbeam *float64 `json:"moonbeam,omitempty"` - Moonriver *float64 `json:"moonriver,omitempty"` - Klaytn *float64 `json:"klaytn,omitempty"` - Arbitrum *float64 `json:"arbitrum,omitempty"` - Avalanche *float64 `json:"avalanche,omitempty"` - Dfk *float64 `json:"dfk,omitempty"` - Aurora *float64 `json:"aurora,omitempty"` - Harmony *float64 `json:"harmony,omitempty"` - Canto *float64 `json:"canto,omitempty"` - Dogechain *float64 `json:"dogechain,omitempty"` - Base *float64 `json:"base,omitempty"` - Blast *float64 `json:"blast,omitempty"` - Scroll *float64 `json:"scroll,omitempty"` - Linea *float64 `json:"linea,omitempty"` - Total *float64 `json:"total,omitempty"` + Date *string `json:"date,omitempty"` + Ethereum *float64 `json:"ethereum,omitempty"` + Optimism *float64 `json:"optimism,omitempty"` + Cronos *float64 `json:"cronos,omitempty"` + Bsc *float64 `json:"bsc,omitempty"` + Polygon *float64 `json:"polygon,omitempty"` + Fantom *float64 `json:"fantom,omitempty"` + Boba *float64 `json:"boba,omitempty"` + Metis *float64 `json:"metis,omitempty"` + Moonbeam *float64 `json:"moonbeam,omitempty"` + Moonriver *float64 `json:"moonriver,omitempty"` + Klaytn *float64 `json:"klaytn,omitempty"` + Arbitrum *float64 `json:"arbitrum,omitempty"` + Avalanche *float64 `json:"avalanche,omitempty"` + Dfk *float64 `json:"dfk,omitempty"` + Aurora *float64 `json:"aurora,omitempty"` + Harmony *float64 `json:"harmony,omitempty"` + Canto *float64 `json:"canto,omitempty"` + Dogechain *float64 `json:"dogechain,omitempty"` + Base *float64 `json:"base,omitempty"` + Blast *float64 `json:"blast,omitempty"` + Scroll *float64 `json:"scroll,omitempty"` + Linea *float64 `json:"linea,omitempty"` + Worldchain *float64 `json:"worldchain,omitempty"` + Total *float64 `json:"total,omitempty"` } type HeroType struct { diff --git a/services/explorer/graphql/server/graph/partials.go b/services/explorer/graphql/server/graph/partials.go index 85519e442b..da436a4096 100644 --- a/services/explorer/graphql/server/graph/partials.go +++ b/services/explorer/graphql/server/graph/partials.go @@ -401,6 +401,7 @@ const dailyVolumeBridgeMvPt1 = ` results[81457] AS blast, results[534352] AS scroll, results[59144] AS linea, + results[480] AS worldchain, arraySum(mapValues(results)) AS total FROM (SELECT date, maxMap(map(chain_id, total)) AS results FROM (SELECT coalesce(toString(b.date), toString(s.date)) AS date, @@ -445,6 +446,7 @@ const dailyVolumeBridge = ` results[81457] AS blast, results[534352] AS scroll, results[59144] AS linea, + results[480] AS worldchain, arraySum(mapValues(results)) AS total FROM (SELECT date, maxMap(map(chain_id, total)) AS results FROM (SELECT coalesce(toString(b.date), toString(s.date)) AS date, @@ -541,6 +543,7 @@ SELECT date, results[81457] AS blast, results[534352] AS scroll, results[59144] AS linea, + results[480] AS worldchain, arraySum(mapValues(results)) AS total FROM (SELECT date, maxMap(map(chain_id, total)) AS results FROM (SELECT coalesce(toString(b.date), toString(s.date), toString(m.date)) AS date, @@ -643,6 +646,7 @@ SELECT date, results[81457] AS blast, results[534352] AS scroll, results[59144] AS linea, + results[480] AS worldchain, arraySum(mapValues(results)) AS total FROM ( SELECT date, @@ -674,6 +678,7 @@ SELECT date, results[81457] AS blast, results[534352] AS scroll, results[59144] AS linea, + results[480] AS worldchain, arraySum(mapValues(results)) AS total FROM ( SELECT date, @@ -706,6 +711,7 @@ SELECT date, results[81457] AS blast, results[534352] AS scroll, results[59144] AS linea, + results[480] AS worldchain, arraySum(mapValues(results)) AS total FROM ( SELECT date, diff --git a/services/explorer/graphql/server/graph/resolver/server.go b/services/explorer/graphql/server/graph/resolver/server.go index 8abe58001c..29689da5c4 100644 --- a/services/explorer/graphql/server/graph/resolver/server.go +++ b/services/explorer/graphql/server/graph/resolver/server.go @@ -100,30 +100,31 @@ type ComplexityRoot struct { } DateResultByChain struct { - Arbitrum func(childComplexity int) int - Aurora func(childComplexity int) int - Avalanche func(childComplexity int) int - Base func(childComplexity int) int - Blast func(childComplexity int) int - Boba func(childComplexity int) int - Bsc func(childComplexity int) int - Canto func(childComplexity int) int - Cronos func(childComplexity int) int - Date func(childComplexity int) int - Dfk func(childComplexity int) int - Dogechain func(childComplexity int) int - Ethereum func(childComplexity int) int - Fantom func(childComplexity int) int - Harmony func(childComplexity int) int - Klaytn func(childComplexity int) int - Linea func(childComplexity int) int - Metis func(childComplexity int) int - Moonbeam func(childComplexity int) int - Moonriver func(childComplexity int) int - Optimism func(childComplexity int) int - Polygon func(childComplexity int) int - Scroll func(childComplexity int) int - Total func(childComplexity int) int + Arbitrum func(childComplexity int) int + Aurora func(childComplexity int) int + Avalanche func(childComplexity int) int + Base func(childComplexity int) int + Blast func(childComplexity int) int + Boba func(childComplexity int) int + Bsc func(childComplexity int) int + Canto func(childComplexity int) int + Cronos func(childComplexity int) int + Date func(childComplexity int) int + Dfk func(childComplexity int) int + Dogechain func(childComplexity int) int + Ethereum func(childComplexity int) int + Fantom func(childComplexity int) int + Harmony func(childComplexity int) int + Klaytn func(childComplexity int) int + Linea func(childComplexity int) int + Metis func(childComplexity int) int + Moonbeam func(childComplexity int) int + Moonriver func(childComplexity int) int + Optimism func(childComplexity int) int + Polygon func(childComplexity int) int + Scroll func(childComplexity int) int + Total func(childComplexity int) int + Worldchain func(childComplexity int) int } HeroType struct { @@ -660,6 +661,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.DateResultByChain.Total(childComplexity), true + case "DateResultByChain.worldchain": + if e.complexity.DateResultByChain.Worldchain == nil { + break + } + + return e.complexity.DateResultByChain.Worldchain(childComplexity), true + case "HeroType.heroID": if e.complexity.HeroType.HeroID == nil { break @@ -1664,6 +1672,7 @@ type DateResultByChain { blast: Float scroll: Float linea: Float + worldchain: Float total: Float } @@ -4832,6 +4841,47 @@ func (ec *executionContext) fieldContext_DateResultByChain_linea(ctx context.Con return fc, nil } +func (ec *executionContext) _DateResultByChain_worldchain(ctx context.Context, field graphql.CollectedField, obj *model.DateResultByChain) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DateResultByChain_worldchain(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Worldchain, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*float64) + fc.Result = res + return ec.marshalOFloat2ᚖfloat64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_DateResultByChain_worldchain(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DateResultByChain", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _DateResultByChain_total(ctx context.Context, field graphql.CollectedField, obj *model.DateResultByChain) (ret graphql.Marshaler) { fc, err := ec.fieldContext_DateResultByChain_total(ctx, field) if err != nil { @@ -7190,6 +7240,8 @@ func (ec *executionContext) fieldContext_Query_dailyStatisticsByChain(ctx contex return ec.fieldContext_DateResultByChain_scroll(ctx, field) case "linea": return ec.fieldContext_DateResultByChain_linea(ctx, field) + case "worldchain": + return ec.fieldContext_DateResultByChain_worldchain(ctx, field) case "total": return ec.fieldContext_DateResultByChain_total(ctx, field) } @@ -10434,6 +10486,8 @@ func (ec *executionContext) _DateResultByChain(ctx context.Context, sel ast.Sele out.Values[i] = ec._DateResultByChain_scroll(ctx, field, obj) case "linea": out.Values[i] = ec._DateResultByChain_linea(ctx, field, obj) + case "worldchain": + out.Values[i] = ec._DateResultByChain_worldchain(ctx, field, obj) case "total": out.Values[i] = ec._DateResultByChain_total(ctx, field, obj) default: diff --git a/services/explorer/graphql/server/graph/schema/types.graphql b/services/explorer/graphql/server/graph/schema/types.graphql index 9b8bebdbd0..084c2da036 100644 --- a/services/explorer/graphql/server/graph/schema/types.graphql +++ b/services/explorer/graphql/server/graph/schema/types.graphql @@ -180,6 +180,7 @@ type DateResultByChain { blast: Float scroll: Float linea: Float + worldchain: Float total: Float } diff --git a/services/explorer/static/chainIDs.yaml b/services/explorer/static/chainIDs.yaml index 84add22b21..250c5db0a6 100644 --- a/services/explorer/static/chainIDs.yaml +++ b/services/explorer/static/chainIDs.yaml @@ -19,3 +19,4 @@ 81457: 'Blast' 534352: 'Scroll' 59144: 'Linea' +480: 'Worldchain' diff --git a/services/explorer/static/tokenIDToCoinGeckoID.yaml b/services/explorer/static/tokenIDToCoinGeckoID.yaml index 6c618da717..574cc7edc8 100644 --- a/services/explorer/static/tokenIDToCoinGeckoID.yaml +++ b/services/explorer/static/tokenIDToCoinGeckoID.yaml @@ -40,3 +40,4 @@ USDbC: 'usd-coin' crvUSD: 'usd-coin' USDB: 'usdb' SPEC: 'spectral' +WLD: 'worldcoin' diff --git a/services/explorer/static/tokenSymbolToCoinGeckoID.yaml b/services/explorer/static/tokenSymbolToCoinGeckoID.yaml index 231aa8ef74..6288259e8d 100644 --- a/services/explorer/static/tokenSymbolToCoinGeckoID.yaml +++ b/services/explorer/static/tokenSymbolToCoinGeckoID.yaml @@ -40,3 +40,4 @@ usdbc: 'usd-coin' crvusd: 'usd-coin' usdb: 'usdb' spec: 'spectral' +wld: 'worldcoin' diff --git a/services/explorer/static/tokenSymbolToTokenID.yaml b/services/explorer/static/tokenSymbolToTokenID.yaml index 83bac16402..eaf7f01c7d 100644 --- a/services/explorer/static/tokenSymbolToTokenID.yaml +++ b/services/explorer/static/tokenSymbolToTokenID.yaml @@ -42,3 +42,4 @@ usdbc: 'usd-coin' crvusd: 'usd-coin' usdb: 'usdb' spec: 'spectral' +wld: 'worldcoin' From 6c0251712ed39e30ac93e1344a9aa051cba0fa29 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 10 Oct 2024 15:09:35 +0100 Subject: [PATCH 04/12] [goreleaser] trigger explorer version bump --- services/explorer/consumer/parser/tokendata/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/explorer/consumer/parser/tokendata/cache.go b/services/explorer/consumer/parser/tokendata/cache.go index b9eb33e54b..aaf76877e2 100644 --- a/services/explorer/consumer/parser/tokendata/cache.go +++ b/services/explorer/consumer/parser/tokendata/cache.go @@ -292,5 +292,5 @@ var tokenDataMap = map[string]TokenData{ "480_0x79A02482A880bCE3F13e09Da970dC34db4CD24d1": {"USDC.e", 6, "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1"}, "480_0x4200000000000000000000000000000000000006": {"WETH", 18, "0x4200000000000000000000000000000000000006"}, "1_0x163f8c2467924be0ae7b5347228cabf260318753": {"WLD", 18, "0x163f8c2467924be0ae7b5347228cabf260318753"}, - // Add additional tokens that are not part of the cache yet (and not by nature in bridge config) here + // Add additional tokens that are not part of the cache yet (and is not by nature in bridge config) here } From a932e29b1ace9611d091edb8ab6b922fd4ff337e Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 10 Oct 2024 16:55:21 +0100 Subject: [PATCH 05/12] rfq indexer with the right contracts --- .../controllers/pendingTransactionsController.ts | 11 ++--------- .../src/controllers/transactionIdController.ts | 15 +++++++++++++-- packages/rfq-indexer/indexer/ponder.config.ts | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts b/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts index cf2d195f84..0cbb2defa8 100644 --- a/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts +++ b/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts @@ -1,14 +1,7 @@ import { Request, Response } from 'express' import { db } from '../db' -import { - qDeposits, - qRelays, - qProofs, - qClaims, - qRefunds, - qDisputes, -} from '../queries' +import { qDeposits, qRelays, qProofs, qClaims, qRefunds } from '../queries' import { nest_results } from '../utils/nestResults' const sevenDaysAgo = Math.floor(Date.now() / 1000) - 7 * 24 * 60 * 60 @@ -21,7 +14,7 @@ export const pendingTransactionsMissingClaimController = async ( const query = db .with('deposits', () => qDeposits()) .with('relays', () => qRelays()) - .with('proofs', () => qProofs({activeOnly: true})) + .with('proofs', () => qProofs({ activeOnly: true })) .with('claims', () => qClaims()) .with('combined', (qb) => qb diff --git a/packages/rfq-indexer/api/src/controllers/transactionIdController.ts b/packages/rfq-indexer/api/src/controllers/transactionIdController.ts index f389d06025..578020ef1a 100644 --- a/packages/rfq-indexer/api/src/controllers/transactionIdController.ts +++ b/packages/rfq-indexer/api/src/controllers/transactionIdController.ts @@ -1,7 +1,14 @@ import { Request, Response } from 'express' import { db } from '../db' -import { qDeposits, qRelays, qProofs, qClaims, qRefunds, qDisputes } from '../queries' +import { + qDeposits, + qRelays, + qProofs, + qClaims, + qRefunds, + qDisputes, +} from '../queries' import { nest_results } from '../utils/nestResults' export const getTransactionById = async (req: Request, res: Response) => { @@ -22,7 +29,11 @@ export const getTransactionById = async (req: Request, res: Response) => { .selectFrom('deposits') .leftJoin('relays', 'transactionId_deposit', 'transactionId_relay') .leftJoin('proofs', 'transactionId_deposit', 'transactionId_proof') - .leftJoin('disputes', 'transactionId_deposit', 'transactionId_dispute') + .leftJoin( + 'disputes', + 'transactionId_deposit', + 'transactionId_dispute' + ) .leftJoin('claims', 'transactionId_deposit', 'transactionId_claim') .leftJoin('refunds', 'transactionId_deposit', 'transactionId_refund') .selectAll('deposits') diff --git a/packages/rfq-indexer/indexer/ponder.config.ts b/packages/rfq-indexer/indexer/ponder.config.ts index edfea0e144..2329d0e89f 100644 --- a/packages/rfq-indexer/indexer/ponder.config.ts +++ b/packages/rfq-indexer/indexer/ponder.config.ts @@ -73,8 +73,8 @@ const configByChainId = { [480]: { transport: http(process.env.WORLDCHAIN_MAINNET_RPC), chainName: 'worldchain', - FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', - FastBridgeV2StartBlock: 4616214, // first block and new block + FastBridgeV2Address: '0x05C62156C7C47E76223A560210EA648De5e6B53B', + FastBridgeV2StartBlock: 4598830, // first block and new block }, disableCache: true, } From 3e9071592ba2a646b841b16adc0b08e0d54db142 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Thu, 10 Oct 2024 17:32:05 +0100 Subject: [PATCH 06/12] [goreleaser] adding catch --- services/explorer/consumer/parser/rfqparser.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/explorer/consumer/parser/rfqparser.go b/services/explorer/consumer/parser/rfqparser.go index 65da0f5bd7..8342b7efb1 100644 --- a/services/explorer/consumer/parser/rfqparser.go +++ b/services/explorer/consumer/parser/rfqparser.go @@ -120,6 +120,11 @@ func (p *RFQParser) MatureLogs(ctx context.Context, rfqEvent *model.RFQEvent, iF rfqEvent.TokenDecimal = new(uint8) *rfqEvent.TokenDecimal = 18 curCoinGeckoID = ethCoinGeckoID + } else if strings.EqualFold(tokenAddressStr, "0x2cFc85d8E48F8EAB294be644d9E25C3030863003") || strings.EqualFold(tokenAddressStr, "0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1") { + rfqEvent.TokenSymbol = "WLD" + rfqEvent.TokenDecimal = new(uint8) + *rfqEvent.TokenDecimal = 18 + curCoinGeckoID = "worldchain" } else { // Assuming any other token is USDC rfqEvent.TokenSymbol = "USDC" From 9bd00381293fb425b0e9aff8edf9ecc7d24254d3 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Mon, 14 Oct 2024 09:02:42 -0500 Subject: [PATCH 07/12] response error fixes and wld decimals --- .../src/controllers/pendingTransactionsController.ts | 8 ++++---- .../api/src/routes/conflictingProofsRoute.ts | 2 +- packages/rfq-indexer/api/src/routes/disputesRoute.ts | 2 +- .../rfq-indexer/api/src/routes/invalidRelaysRoute.ts | 2 +- .../api/src/routes/pendingTransactionsRoute.ts | 8 ++++---- .../api/src/routes/refundedAndRelayedRoute.ts | 2 +- .../rfq-indexer/api/src/routes/transactionIdRoute.ts | 2 +- packages/rfq-indexer/indexer/src/utils/formatAmount.ts | 10 +++++++--- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts b/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts index 0cbb2defa8..5d235e92cc 100644 --- a/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts +++ b/packages/rfq-indexer/api/src/controllers/pendingTransactionsController.ts @@ -38,7 +38,7 @@ export const pendingTransactionsMissingClaimController = async ( res.json(nestedResults) } else { res - .status(404) + .status(200) .json({ message: 'No pending transactions missing claim found' }) } } catch (error) { @@ -76,7 +76,7 @@ export const pendingTransactionsMissingProofController = async ( res.json(nestedResults) } else { res - .status(404) + .status(200) .json({ message: 'No pending transactions missing proof found' }) } } catch (error) { @@ -121,7 +121,7 @@ export const pendingTransactionsMissingRelayController = async ( res.json(nestedResults) } else { res - .status(404) + .status(200) .json({ message: 'No pending transactions missing relay found' }) } } catch (error) { @@ -166,7 +166,7 @@ export const pendingTransactionsMissingRelayExceedDeadlineController = async ( res.json(nestedResults) } else { res - .status(404) + .status(200) .json({ message: 'No pending transactions missing relay found' }) } } catch (error) { diff --git a/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts b/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts index aa48c89e07..0a03dc5a1f 100644 --- a/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts +++ b/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts @@ -41,7 +41,7 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 404: + * 200: * description: No conflicting proofs found * content: * application/json: diff --git a/packages/rfq-indexer/api/src/routes/disputesRoute.ts b/packages/rfq-indexer/api/src/routes/disputesRoute.ts index de964220b0..ee1b2f9bf4 100644 --- a/packages/rfq-indexer/api/src/routes/disputesRoute.ts +++ b/packages/rfq-indexer/api/src/routes/disputesRoute.ts @@ -41,7 +41,7 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 404: + * 200: * description: No disputes found * content: * application/json: diff --git a/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts b/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts index 31356156f2..df20c8f60e 100644 --- a/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts +++ b/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts @@ -41,7 +41,7 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 404: + * 200: * description: No recent invalid relays found * content: * application/json: diff --git a/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts b/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts index e80dbd7fac..5bd3f0ba1a 100644 --- a/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts +++ b/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts @@ -46,7 +46,7 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 404: + * 200: * description: No pending transactions missing claim found * content: * application/json: @@ -87,7 +87,7 @@ router.get('/missing-claim', pendingTransactionsMissingClaimController) * type: object * relay: * type: object - * 404: + * 200: * description: No pending transactions missing proof found * content: * application/json: @@ -126,7 +126,7 @@ router.get('/missing-proof', pendingTransactionsMissingProofController) * properties: * deposit: * type: object - * 404: + * 200: * description: No pending transactions missing relay found * content: * application/json: @@ -165,7 +165,7 @@ router.get('/missing-relay', pendingTransactionsMissingRelayController) * properties: * deposit: * type: object - * 404: + * 200: * description: No pending transactionst that exceed the deadline found * content: * application/json: diff --git a/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts b/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts index cd38b3b33e..ab54203ed7 100644 --- a/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts +++ b/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts @@ -41,7 +41,7 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 404: + * 200: * description: No refunded and relayed transactions found * content: * application/json: diff --git a/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts b/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts index 253060dcdf..0a654e8d30 100644 --- a/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts +++ b/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts @@ -46,7 +46,7 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 404: + * 200: * description: Transaction not found * content: * application/json: diff --git a/packages/rfq-indexer/indexer/src/utils/formatAmount.ts b/packages/rfq-indexer/indexer/src/utils/formatAmount.ts index 9cbc1b2768..54787d3a91 100644 --- a/packages/rfq-indexer/indexer/src/utils/formatAmount.ts +++ b/packages/rfq-indexer/indexer/src/utils/formatAmount.ts @@ -1,8 +1,12 @@ import { formatUnits } from 'viem' -const ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' +const ADDRESSES_WITH_18_DECIMALS = [ + '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // ETH + '0x2cFc85d8E48F8EAB294be644d9E25C3030863003', // WLD + '0x163f8c2467924be0ae7b5347228cabf260318753', // WLD +].map(address => address.toLowerCase()) export function formatAmount(amount: bigint, tokenAddress: string): string { - const decimals = tokenAddress.toLowerCase() === ETH_ADDRESS.toLowerCase() ? 18 : 6 + const decimals = ADDRESSES_WITH_18_DECIMALS.includes(tokenAddress.toLowerCase()) ? 18 : 6 return formatUnits(amount, decimals) -} \ No newline at end of file +} From 1dbcd96868ad10ca7ed4033a83737168d2ae5489 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Tue, 15 Oct 2024 10:56:37 -0400 Subject: [PATCH 08/12] adding address --- packages/rfq-indexer/indexer/src/utils/formatAmount.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/rfq-indexer/indexer/src/utils/formatAmount.ts b/packages/rfq-indexer/indexer/src/utils/formatAmount.ts index 54787d3a91..2ea80247e9 100644 --- a/packages/rfq-indexer/indexer/src/utils/formatAmount.ts +++ b/packages/rfq-indexer/indexer/src/utils/formatAmount.ts @@ -4,6 +4,7 @@ const ADDRESSES_WITH_18_DECIMALS = [ '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // ETH '0x2cFc85d8E48F8EAB294be644d9E25C3030863003', // WLD '0x163f8c2467924be0ae7b5347228cabf260318753', // WLD + '0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1', // WLD ].map(address => address.toLowerCase()) export function formatAmount(amount: bigint, tokenAddress: string): string { From 6b4c78e81c6f00d973a30ec772bcf2e42894daca Mon Sep 17 00:00:00 2001 From: vro <168573323+golangisfun123@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:12:02 -0500 Subject: [PATCH 09/12] feat(rfq-indexer): add `request` column to `BridgeRequested` for refunds (#3287) * feat(rfq-relayer): add MaxRelayAmount (#3259) * Feat: add quoteParams helper for test * Feat: add MaxQuoteAmount to relconfig * Feat: use MaxQuoteAmount * Feat: handle MaxQuoteAmount in quoter test * Replace: MaxQuoteAmount -> MaxRelayAmount * Feat: shouldProcess() returns false if max relay amount exceeded * Feat: add test for MaxRelayAmount * add request field for refunds * adding to events typing --------- Co-authored-by: dwasse Co-authored-by: defi-moses --- .../rfq-indexer/api/src/graphql/resolvers.ts | 1 + .../api/src/graphql/types/events.graphql | 1 + .../api/src/queries/depositsQueries.ts | 1 + packages/rfq-indexer/api/src/types/index.ts | 1 + packages/rfq-indexer/indexer/ponder.schema.ts | 1 + packages/rfq-indexer/indexer/src/index.ts | 2 + services/rfq/relayer/quoter/quoter.go | 21 ++++- services/rfq/relayer/quoter/quoter_test.go | 82 ++++++++++++++++--- services/rfq/relayer/relconfig/config.go | 2 + services/rfq/relayer/relconfig/getters.go | 35 ++++++++ 10 files changed, 135 insertions(+), 12 deletions(-) diff --git a/packages/rfq-indexer/api/src/graphql/resolvers.ts b/packages/rfq-indexer/api/src/graphql/resolvers.ts index 1deb7950d9..b346371ec7 100644 --- a/packages/rfq-indexer/api/src/graphql/resolvers.ts +++ b/packages/rfq-indexer/api/src/graphql/resolvers.ts @@ -20,6 +20,7 @@ const qDeposits = () => { 'BridgeRequestEvents.originAmountFormatted', 'BridgeRequestEvents.destAmountFormatted', 'BridgeRequestEvents.sender', + 'BridgeRequestEvents.request', 'BridgeRequestEvents.sendChainGas', ]) .where('BridgeRequestEvents.blockTimestamp', '>', 1722729600) diff --git a/packages/rfq-indexer/api/src/graphql/types/events.graphql b/packages/rfq-indexer/api/src/graphql/types/events.graphql index 2e3716de0e..45fcf930db 100644 --- a/packages/rfq-indexer/api/src/graphql/types/events.graphql +++ b/packages/rfq-indexer/api/src/graphql/types/events.graphql @@ -17,6 +17,7 @@ scalar BigInt destAmountFormatted: String! destChainId: Int! destChain: String! + request: String! sendChainGas: Boolean! } diff --git a/packages/rfq-indexer/api/src/queries/depositsQueries.ts b/packages/rfq-indexer/api/src/queries/depositsQueries.ts index 61e33aa3d1..e765e032d5 100644 --- a/packages/rfq-indexer/api/src/queries/depositsQueries.ts +++ b/packages/rfq-indexer/api/src/queries/depositsQueries.ts @@ -17,6 +17,7 @@ export const qDeposits = () => { 'BridgeRequestEvents.originAmountFormatted', 'BridgeRequestEvents.destAmountFormatted', 'BridgeRequestEvents.sender', + 'BridgeRequestEvents.request', 'BridgeRequestEvents.sendChainGas', ]) .where('BridgeRequestEvents.blockTimestamp', '>', 1722729600) diff --git a/packages/rfq-indexer/api/src/types/index.ts b/packages/rfq-indexer/api/src/types/index.ts index 738e9469fd..503563e741 100644 --- a/packages/rfq-indexer/api/src/types/index.ts +++ b/packages/rfq-indexer/api/src/types/index.ts @@ -10,6 +10,7 @@ export interface BridgeRequestEvents { originChainId: ColumnType originChain: ColumnType sender: ColumnType + request: ColumnType originToken: ColumnType destToken: ColumnType originAmount: ColumnType diff --git a/packages/rfq-indexer/indexer/ponder.schema.ts b/packages/rfq-indexer/indexer/ponder.schema.ts index 8d32ea595c..24f80bdf00 100644 --- a/packages/rfq-indexer/indexer/ponder.schema.ts +++ b/packages/rfq-indexer/indexer/ponder.schema.ts @@ -5,6 +5,7 @@ export default createSchema((p) => ({ id: p.string(), transactionId: p.string(), sender: p.string(), + request: p.string(), originToken: p.string(), destToken: p.string(), originAmount: p.bigint().optional(), diff --git a/packages/rfq-indexer/indexer/src/index.ts b/packages/rfq-indexer/indexer/src/index.ts index 3a6a71380f..f61146c7d6 100644 --- a/packages/rfq-indexer/indexer/src/index.ts +++ b/packages/rfq-indexer/indexer/src/index.ts @@ -16,6 +16,7 @@ ponder.on('FastBridgeV2:BridgeRequested', async ({ event, context }) => { args: { transactionId, sender, + request, destChainId, originToken, destToken, @@ -33,6 +34,7 @@ ponder.on('FastBridgeV2:BridgeRequested', async ({ event, context }) => { data: { transactionId, sender: trim(sender), + request: request, originChainId: Number(chainId), originChain: getChainName(Number(chainId)), destChainId: Number(destChainId), diff --git a/services/rfq/relayer/quoter/quoter.go b/services/rfq/relayer/quoter/quoter.go index 3b5ecc8352..2cd3dfcf94 100644 --- a/services/rfq/relayer/quoter/quoter.go +++ b/services/rfq/relayer/quoter/quoter.go @@ -207,6 +207,15 @@ func (m *Manager) ShouldProcess(parentCtx context.Context, quote reldb.QuoteRequ return false, nil } + // check relay amount + maxRelayAmount := m.config.GetMaxRelayAmount(int(quote.Transaction.OriginChainId), quote.Transaction.OriginToken) + if maxRelayAmount != nil { + if quote.Transaction.OriginAmount.Cmp(maxRelayAmount) > 0 { + span.AddEvent("origin amount is greater than max relay amount") + return false, nil + } + } + // all checks have passed return true, nil } @@ -713,7 +722,7 @@ func (m *Manager) getOriginAmount(parentCtx context.Context, input QuoteInput) ( } } - // Finally, clip the quoteAmount by the dest balance + // Clip the quoteAmount by the dest balance if quoteAmount.Cmp(input.DestBalance) > 0 { span.AddEvent("quote amount greater than destination balance", trace.WithAttributes( attribute.String("quote_amount", quoteAmount.String()), @@ -722,6 +731,16 @@ func (m *Manager) getOriginAmount(parentCtx context.Context, input QuoteInput) ( quoteAmount = input.DestBalance } + // Clip the quoteAmount by the maxQuoteAmount + maxQuoteAmount := m.config.GetMaxRelayAmount(input.DestChainID, input.DestTokenAddr) + if maxQuoteAmount != nil && quoteAmount.Cmp(maxQuoteAmount) > 0 { + span.AddEvent("quote amount greater than max quote amount", trace.WithAttributes( + attribute.String("quote_amount", quoteAmount.String()), + attribute.String("max_quote_amount", maxQuoteAmount.String()), + )) + quoteAmount = maxQuoteAmount + } + // Deduct gas cost from the quote amount, if necessary quoteAmount, err = m.deductGasCost(ctx, quoteAmount, input.DestTokenAddr, input.DestChainID) if err != nil { diff --git a/services/rfq/relayer/quoter/quoter_test.go b/services/rfq/relayer/quoter/quoter_test.go index 1d6a52c7de..321d55b189 100644 --- a/services/rfq/relayer/quoter/quoter_test.go +++ b/services/rfq/relayer/quoter/quoter_test.go @@ -136,6 +136,13 @@ func (s *QuoterSuite) TestShouldProcess() { s.False(s.manager.ShouldProcess(s.GetTestContext(), quote)) s.manager.SetRelayPaused(false) s.True(s.manager.ShouldProcess(s.GetTestContext(), quote)) + + // Set max relay amount + originTokenCfg := s.config.Chains[int(s.origin)].Tokens["USDC"] + originTokenCfg.MaxRelayAmount = "900" // less than balance + s.config.Chains[int(s.origin)].Tokens["USDC"] = originTokenCfg + s.manager.SetConfig(s.config) + s.False(s.manager.ShouldProcess(s.GetTestContext(), quote)) } func (s *QuoterSuite) TestIsProfitable() { @@ -173,13 +180,23 @@ func (s *QuoterSuite) TestGetOriginAmount() { originAddr := common.HexToAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48") balance := big.NewInt(1000_000_000) // 1000 USDC - setQuoteParams := func(quotePct, quoteOffset float64, minQuoteAmount, maxBalance string) { - s.config.BaseChainConfig.QuotePct = "ePct + type quoteParams struct { + quotePct float64 + quoteOffset float64 + minQuoteAmount string + maxBalance string + maxQuoteAmount string + } + + setQuoteParams := func(params quoteParams) { + s.config.BaseChainConfig.QuotePct = ¶ms.quotePct destTokenCfg := s.config.Chains[dest].Tokens["USDC"] - destTokenCfg.MinQuoteAmount = minQuoteAmount + destTokenCfg.MinQuoteAmount = params.minQuoteAmount + destTokenCfg.MaxRelayAmount = params.maxQuoteAmount originTokenCfg := s.config.Chains[origin].Tokens["USDC"] - originTokenCfg.QuoteOffsetBps = quoteOffset - originTokenCfg.MaxBalance = &maxBalance + originTokenCfg.QuoteOffsetBps = params.quoteOffset + originTokenCfg.MaxBalance = ¶ms.maxBalance + originTokenCfg.MaxRelayAmount = params.maxQuoteAmount s.config.Chains[dest].Tokens["USDC"] = destTokenCfg s.config.Chains[origin].Tokens["USDC"] = originTokenCfg s.manager.SetConfig(s.config) @@ -201,42 +218,85 @@ func (s *QuoterSuite) TestGetOriginAmount() { s.Equal(expectedAmount, quoteAmount) // Set QuotePct to 50 with MinQuoteAmount of 0; should be 50% of balance. - setQuoteParams(50, 0, "0", "0") + setQuoteParams(quoteParams{ + quotePct: 50, + quoteOffset: 0, + minQuoteAmount: "0", + maxBalance: "0", + }) quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(500_000_000) s.Equal(expectedAmount, quoteAmount) // Set QuotePct to 50 with QuoteOffset of -1%. Should be 1% less than 50% of balance. - setQuoteParams(50, -100, "0", "0") + setQuoteParams(quoteParams{ + quotePct: 50, + quoteOffset: -100, + minQuoteAmount: "0", + maxBalance: "0", + }) quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(495_000_000) s.Equal(expectedAmount, quoteAmount) // Set QuotePct to 25 with MinQuoteAmount of 500; should be 50% of balance. - setQuoteParams(25, 0, "500", "0") + setQuoteParams(quoteParams{ + quotePct: 25, + quoteOffset: 0, + minQuoteAmount: "500", + maxBalance: "0", + }) quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(500_000_000) s.Equal(expectedAmount, quoteAmount) // Set QuotePct to 25 with MinQuoteAmount of 500; should be 50% of balance. - setQuoteParams(25, 0, "500", "0") + setQuoteParams(quoteParams{ + quotePct: 25, + quoteOffset: 0, + minQuoteAmount: "500", + maxBalance: "0", + }) quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(500_000_000) s.Equal(expectedAmount, quoteAmount) // Set QuotePct to 25 with MinQuoteAmount of 1500; should be total balance. - setQuoteParams(25, 0, "1500", "0") + setQuoteParams(quoteParams{ + quotePct: 25, + quoteOffset: 0, + minQuoteAmount: "1500", + maxBalance: "0", + }) quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(1000_000_000) s.Equal(expectedAmount, quoteAmount) + // Set QuotePct to 100 with MinQuoteAmount of 0 and MaxRelayAmount of 500; should be 500. + setQuoteParams(quoteParams{ + quotePct: 100, + quoteOffset: 0, + minQuoteAmount: "0", + maxBalance: "0", + maxQuoteAmount: "500", + }) + quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) + s.NoError(err) + expectedAmount = big.NewInt(500_000_000) + s.Equal(expectedAmount, quoteAmount) + // Set QuotePct to 25 with MinQuoteAmount of 1500 and MaxBalance of 1200; should be 200. - setQuoteParams(25, 0, "1500", "1200") + setQuoteParams(quoteParams{ + quotePct: 25, + quoteOffset: 0, + minQuoteAmount: "1500", + maxBalance: "1200", + }) quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(200_000_000) diff --git a/services/rfq/relayer/relconfig/config.go b/services/rfq/relayer/relconfig/config.go index a4449bf8db..220627e13a 100644 --- a/services/rfq/relayer/relconfig/config.go +++ b/services/rfq/relayer/relconfig/config.go @@ -124,6 +124,8 @@ type TokenConfig struct { PriceUSD float64 `yaml:"price_usd"` // MinQuoteAmount is the minimum amount to quote for this token in human-readable units. MinQuoteAmount string `yaml:"min_quote_amount"` + // MaxRelayAmount is the maximum amount to quote and relay for this token in human-readable units. + MaxRelayAmount string `yaml:"max_relay_amount"` // RebalanceMethods are the supported methods for rebalancing. RebalanceMethods []string `yaml:"rebalance_methods"` // MaintenanceBalancePct is the percentage of the total balance under which a rebalance will be triggered. diff --git a/services/rfq/relayer/relconfig/getters.go b/services/rfq/relayer/relconfig/getters.go index 2cb4880712..a3fbb25cc7 100644 --- a/services/rfq/relayer/relconfig/getters.go +++ b/services/rfq/relayer/relconfig/getters.go @@ -746,6 +746,41 @@ func (c Config) GetMinQuoteAmount(chainID int, addr common.Address) *big.Int { return quoteAmountScaled } +var defaultMaxRelayAmount *big.Int // nil + +// GetMaxRelayAmount returns the quote amount for the given chain and address. +// Note that this getter returns the value in native token decimals. +func (c Config) GetMaxRelayAmount(chainID int, addr common.Address) *big.Int { + chainCfg, ok := c.Chains[chainID] + if !ok { + return defaultMaxRelayAmount + } + + var tokenCfg *TokenConfig + for _, cfg := range chainCfg.Tokens { + if common.HexToAddress(cfg.Address).Hex() == addr.Hex() { + cfgCopy := cfg + tokenCfg = &cfgCopy + break + } + } + if tokenCfg == nil { + return defaultMaxRelayAmount + } + quoteAmountFlt, ok := new(big.Float).SetString(tokenCfg.MaxRelayAmount) + if !ok { + return defaultMaxRelayAmount + } + if quoteAmountFlt.Cmp(big.NewFloat(0)) <= 0 { + return defaultMaxRelayAmount + } + + // Scale the minQuoteAmount by the token decimals. + denomDecimalsFactor := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(tokenCfg.Decimals)), nil) + quoteAmountScaled, _ := new(big.Float).Mul(quoteAmountFlt, new(big.Float).SetInt(denomDecimalsFactor)).Int(nil) + return quoteAmountScaled +} + var defaultMinRebalanceAmount = big.NewInt(1000) // GetMinRebalanceAmount returns the min rebalance amount for the given chain and address. From 684462f7afa98d48cc7e0d6abfed696805d4f28b Mon Sep 17 00:00:00 2001 From: defi-moses Date: Sun, 27 Oct 2024 15:12:34 +0000 Subject: [PATCH 10/12] fix api docs --- .../api/src/routes/conflictingProofsRoute.ts | 11 +--- .../api/src/routes/disputesRoute.ts | 11 +--- .../api/src/routes/invalidRelaysRoute.ts | 11 +--- .../src/routes/pendingTransactionsRoute.ts | 44 ++------------ .../api/src/routes/refundedAndRelayedRoute.ts | 11 +--- .../api/src/routes/transactionIdRoute.ts | 59 ++++++++----------- 6 files changed, 33 insertions(+), 114 deletions(-) diff --git a/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts b/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts index 0a03dc5a1f..6ed5871c52 100644 --- a/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts +++ b/packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts @@ -12,7 +12,7 @@ const router = express.Router() * description: Retrieves a list of transactions where the relayer in the proof differs from the relayer in the relay event * responses: * 200: - * description: Successful response + * description: Successful response (may be an empty array if no conflicting proofs found) * content: * application/json: * schema: @@ -41,15 +41,6 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 200: - * description: No conflicting proofs found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: diff --git a/packages/rfq-indexer/api/src/routes/disputesRoute.ts b/packages/rfq-indexer/api/src/routes/disputesRoute.ts index ee1b2f9bf4..bbb0b5ac83 100644 --- a/packages/rfq-indexer/api/src/routes/disputesRoute.ts +++ b/packages/rfq-indexer/api/src/routes/disputesRoute.ts @@ -12,7 +12,7 @@ const router = express.Router() * description: Retrieves a list of all active disputes * responses: * 200: - * description: Successful response + * description: Successful response (may be an empty array) * content: * application/json: * schema: @@ -41,15 +41,6 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 200: - * description: No disputes found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: diff --git a/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts b/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts index df20c8f60e..44d2ecf8db 100644 --- a/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts +++ b/packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts @@ -12,7 +12,7 @@ const router = express.Router() * description: Retrieves a list of recent invalid relay events from the past 2 weeks * responses: * 200: - * description: Successful response + * description: Successful response (may be an empty array) * content: * application/json: * schema: @@ -41,15 +41,6 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 200: - * description: No recent invalid relays found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: diff --git a/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts b/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts index 5bd3f0ba1a..24922add1a 100644 --- a/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts +++ b/packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts @@ -17,7 +17,7 @@ const router = express.Router() * description: Retrieves a list of transactions that have been deposited, relayed, and proven, but not yet claimed * responses: * 200: - * description: Successful response + * description: Successful response (may be an empty array) * content: * application/json: * schema: @@ -46,15 +46,6 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 200: - * description: No pending transactions missing claim found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: @@ -75,7 +66,7 @@ router.get('/missing-claim', pendingTransactionsMissingClaimController) * description: Retrieves a list of transactions that have been deposited and relayed, but not yet proven * responses: * 200: - * description: Successful response +* description: Successful response (may be an empty array) * content: * application/json: * schema: @@ -87,15 +78,6 @@ router.get('/missing-claim', pendingTransactionsMissingClaimController) * type: object * relay: * type: object - * 200: - * description: No pending transactions missing proof found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: @@ -116,7 +98,7 @@ router.get('/missing-proof', pendingTransactionsMissingProofController) * description: Retrieves a list of transactions that have been deposited, but not yet relayed or refunded * responses: * 200: - * description: Successful response + * description: Successful response (may be an empty array) * content: * application/json: * schema: @@ -126,15 +108,6 @@ router.get('/missing-proof', pendingTransactionsMissingProofController) * properties: * deposit: * type: object - * 200: - * description: No pending transactions missing relay found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: @@ -155,7 +128,7 @@ router.get('/missing-relay', pendingTransactionsMissingRelayController) * description: Retrieves a list of transactions that have been deposited, but not yet relayed or refunded and have exceeded the deadline * responses: * 200: - * description: Successful response + * description: Successful response (may be an empty array) * content: * application/json: * schema: @@ -165,15 +138,6 @@ router.get('/missing-relay', pendingTransactionsMissingRelayController) * properties: * deposit: * type: object - * 200: - * description: No pending transactionst that exceed the deadline found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: diff --git a/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts b/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts index ab54203ed7..f9ae80ad3b 100644 --- a/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts +++ b/packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts @@ -12,7 +12,7 @@ const router = express.Router() * description: Retrieves a list of transactions that have been both refunded and relayed * responses: * 200: - * description: Successful response + * description: Successful response (may be an empty array) * content: * application/json: * schema: @@ -41,15 +41,6 @@ const router = express.Router() * BridgeDispute: * type: object * description: Dispute information (if available) - * 200: - * description: No refunded and relayed transactions found - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string * 500: * description: Server error * content: diff --git a/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts b/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts index 0a654e8d30..4a85b6329b 100644 --- a/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts +++ b/packages/rfq-indexer/api/src/routes/transactionIdRoute.ts @@ -8,15 +8,15 @@ const router = express.Router() * @openapi * /transaction-id/{transactionId}: * get: - * summary: Get transaction details by ID or the origin transaction hash - * description: Retrieves detailed information about a transaction, including deposit, relay, proof, claim, and refund data if available + * summary: Get transaction details by ID + * description: Retrieves details of a specific transaction by its ID * parameters: * - in: path * name: transactionId * required: true * schema: * type: string - * description: The unique identifier of the transaction or the origin transaction hash + * description: The ID of the transaction to retrieve * responses: * 200: * description: Successful response @@ -25,28 +25,28 @@ const router = express.Router() * schema: * type: object * properties: -* Bridge: -* type: object -* description: General transaction fields -* BridgeRequest: -* type: object -* description: Deposit information -* BridgeRelay: -* type: object -* description: Relay information -* BridgeRefund: -* type: object -* description: Refund information -* BridgeProof: -* type: object -* description: Proof information (if available) -* BridgeClaim: -* type: object -* description: Claim information (if available) -* BridgeDispute: -* type: object -* description: Dispute information (if available) - * 200: + * Bridge: + * type: object + * description: General transaction fields + * BridgeRequest: + * type: object + * description: Deposit information + * BridgeRelay: + * type: object + * description: Relay information + * BridgeRefund: + * type: object + * description: Refund information + * BridgeProof: + * type: object + * description: Proof information (if available) + * BridgeClaim: + * type: object + * description: Claim information (if available) + * BridgeDispute: + * type: object + * description: Dispute information (if available) + * 404: * description: Transaction not found * content: * application/json: @@ -55,15 +55,6 @@ const router = express.Router() * properties: * message: * type: string - * 500: - * description: Server error - * content: - * application/json: - * schema: - * type: object - * properties: - * message: - * type: string */ router.get('/:transactionId', getTransactionById) From c535f9311bd5bbbaee9f6bd86167ea2645805392 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Tue, 29 Oct 2024 16:53:52 +0000 Subject: [PATCH 11/12] linting fixes --- .../rfq-indexer/indexer/abis/FastBridgeV2.ts | 1415 +++++++++-------- packages/rfq-indexer/indexer/src/index.ts | 2 +- .../indexer/src/utils/formatAmount.ts | 10 +- 3 files changed, 781 insertions(+), 646 deletions(-) diff --git a/packages/rfq-indexer/indexer/abis/FastBridgeV2.ts b/packages/rfq-indexer/indexer/abis/FastBridgeV2.ts index 5e355f84cc..fde30f002e 100644 --- a/packages/rfq-indexer/indexer/abis/FastBridgeV2.ts +++ b/packages/rfq-indexer/indexer/abis/FastBridgeV2.ts @@ -1,643 +1,774 @@ export const FastBridgeV2Abi = [ - { - inputs: [ - { internalType: 'address', name: '_owner', type: 'address' }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [], - name: 'AccessControlBadConfirmation', - type: 'error', - }, - { - inputs: [ - { internalType: 'address', name: 'account', type: 'address' }, - { internalType: 'bytes32', name: 'neededRole', type: 'bytes32' }, - ], - name: 'AccessControlUnauthorizedAccount', - type: 'error', - }, - { - inputs: [ - { internalType: 'address', name: 'target', type: 'address' }, - ], - name: 'AddressEmptyCode', - type: 'error', - }, - { - inputs: [ - { internalType: 'address', name: 'account', type: 'address' }, - ], - name: 'AddressInsufficientBalance', - type: 'error', - }, - { - inputs: [], - name: 'AmountIncorrect', - type: 'error', - }, - { - inputs: [], - name: 'ChainIncorrect', - type: 'error', - }, - { - inputs: [], - name: 'DeadlineExceeded', - type: 'error', - }, - { - inputs: [], - name: 'DeadlineNotExceeded', - type: 'error', - }, - { - inputs: [], - name: 'DeadlineTooShort', - type: 'error', - }, - { - inputs: [], - name: 'DisputePeriodNotPassed', - type: 'error', - }, - { - inputs: [], - name: 'DisputePeriodPassed', - type: 'error', - }, - { - inputs: [], - name: 'FailedInnerCall', - type: 'error', - }, - { - inputs: [], - name: 'MsgValueIncorrect', - type: 'error', - }, - { - inputs: [ - { internalType: 'address', name: 'token', type: 'address' }, - ], - name: 'SafeERC20FailedOperation', - type: 'error', - }, - { - inputs: [], - name: 'SenderIncorrect', - type: 'error', - }, - { - inputs: [], - name: 'StatusIncorrect', - type: 'error', - }, - { - inputs: [], - name: 'TokenNotContract', - type: 'error', - }, - { - inputs: [], - name: 'TransactionRelayed', - type: 'error', - }, - { - inputs: [], - name: 'ZeroAddress', - type: 'error', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'relayer', type: 'address' }, - { indexed: true, internalType: 'address', name: 'to', type: 'address' }, - { indexed: false, internalType: 'address', name: 'token', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' }, - ], - name: 'BridgeDepositClaimed', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'to', type: 'address' }, - { indexed: false, internalType: 'address', name: 'token', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' }, - ], - name: 'BridgeDepositRefunded', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'relayer', type: 'address' }, - ], - name: 'BridgeProofDisputed', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'relayer', type: 'address' }, - { indexed: false, internalType: 'bytes32', name: 'transactionHash', type: 'bytes32' }, - ], - name: 'BridgeProofProvided', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'relayer', type: 'address' }, - { indexed: true, internalType: 'address', name: 'to', type: 'address' }, - { indexed: false, internalType: 'uint32', name: 'originChainId', type: 'uint32' }, - { indexed: false, internalType: 'address', name: 'originToken', type: 'address' }, - { indexed: false, internalType: 'address', name: 'destToken', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'originAmount', type: 'uint256' }, - { indexed: false, internalType: 'uint256', name: 'destAmount', type: 'uint256' }, - { indexed: false, internalType: 'uint256', name: 'chainGasAmount', type: 'uint256' }, - ], - name: 'BridgeRelayed', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, - { indexed: false, internalType: 'bytes', name: 'request', type: 'bytes' }, - { indexed: false, internalType: 'uint32', name: 'destChainId', type: 'uint32' }, - { indexed: false, internalType: 'address', name: 'originToken', type: 'address' }, - { indexed: false, internalType: 'address', name: 'destToken', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'originAmount', type: 'uint256' }, - { indexed: false, internalType: 'uint256', name: 'destAmount', type: 'uint256' }, - { indexed: false, internalType: 'bool', name: 'sendChainGas', type: 'bool' }, - ], - name: 'BridgeRequested', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: false, internalType: 'uint256', name: 'oldChainGasAmount', type: 'uint256' }, - { indexed: false, internalType: 'uint256', name: 'newChainGasAmount', type: 'uint256' }, - ], - name: 'ChainGasAmountUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: false, internalType: 'uint256', name: 'oldFeeRate', type: 'uint256' }, - { indexed: false, internalType: 'uint256', name: 'newFeeRate', type: 'uint256' }, - ], - name: 'FeeRateUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: false, internalType: 'address', name: 'token', type: 'address' }, - { indexed: false, internalType: 'address', name: 'recipient', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' }, - ], - name: 'FeesSwept', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { indexed: true, internalType: 'bytes32', name: 'previousAdminRole', type: 'bytes32' }, - { indexed: true, internalType: 'bytes32', name: 'newAdminRole', type: 'bytes32' }, - ], - name: 'RoleAdminChanged', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'account', type: 'address' }, - { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, - ], - name: 'RoleGranted', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { indexed: true, internalType: 'address', name: 'account', type: 'address' }, - { indexed: true, internalType: 'address', name: 'sender', type: 'address' }, - ], - name: 'RoleRevoked', - type: 'event', - }, - { - inputs: [], - name: 'DEFAULT_ADMIN_ROLE', - outputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'DISPUTE_PERIOD', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'FEE_BPS', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'FEE_RATE_MAX', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'GOVERNOR_ROLE', - outputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'GUARD_ROLE', - outputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'MIN_DEADLINE_PERIOD', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'REFUNDER_ROLE', - outputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'REFUND_DELAY', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'RELAYER_ROLE', - outputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - components: [ - { internalType: 'uint32', name: 'dstChainId', type: 'uint32' }, - { internalType: 'address', name: 'sender', type: 'address' }, - { internalType: 'address', name: 'to', type: 'address' }, - { internalType: 'address', name: 'originToken', type: 'address' }, - { internalType: 'address', name: 'destToken', type: 'address' }, - { internalType: 'uint256', name: 'originAmount', type: 'uint256' }, - { internalType: 'uint256', name: 'destAmount', type: 'uint256' }, - { internalType: 'bool', name: 'sendChainGas', type: 'bool' }, - { internalType: 'uint256', name: 'deadline', type: 'uint256' }, - ], - internalType: 'struct IFastBridge.BridgeParams', - name: 'params', - type: 'tuple', - }, - ], - name: 'bridge', - outputs: [], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - name: 'bridgeProofs', - outputs: [ - { internalType: 'uint96', name: 'timestamp', type: 'uint96' }, - { internalType: 'address', name: 'relayer', type: 'address' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - name: 'bridgeRelays', - outputs: [ - { internalType: 'bool', name: '', type: 'bool' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - name: 'bridgeStatuses', - outputs: [ - { internalType: 'enum FastBridge.BridgeStatus', name: '', type: 'uint8' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - { internalType: 'address', name: 'relayer', type: 'address' }, - ], - name: 'canClaim', - outputs: [ - { internalType: 'bool', name: '', type: 'bool' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'chainGasAmount', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes', name: 'request', type: 'bytes' }, - { internalType: 'address', name: 'to', type: 'address' }, - ], - name: 'claim', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'deployBlock', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, - ], - name: 'dispute', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes', name: 'request', type: 'bytes' }, - ], - name: 'getBridgeTransaction', - outputs: [ - { - components: [ - { internalType: 'uint32', name: 'originChainId', type: 'uint32' }, - { internalType: 'uint32', name: 'destChainId', type: 'uint32' }, - { internalType: 'address', name: 'originSender', type: 'address' }, - { internalType: 'address', name: 'destRecipient', type: 'address' }, - { internalType: 'address', name: 'originToken', type: 'address' }, - { internalType: 'address', name: 'destToken', type: 'address' }, - { internalType: 'uint256', name: 'originAmount', type: 'uint256' }, - { internalType: 'uint256', name: 'destAmount', type: 'uint256' }, - { internalType: 'uint256', name: 'originFeeAmount', type: 'uint256' }, - { internalType: 'bool', name: 'sendChainGas', type: 'bool' }, - { internalType: 'uint256', name: 'deadline', type: 'uint256' }, - { internalType: 'uint256', name: 'nonce', type: 'uint256' }, - ], - internalType: 'struct IFastBridge.BridgeTransaction', - name: '', - type: 'tuple', - }, - ], - stateMutability: 'pure', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'role', type: 'bytes32' }, - ], - name: 'getRoleAdmin', - outputs: [ - { internalType: 'bytes32', name: '', type: 'bytes32' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { internalType: 'uint256', name: 'index', type: 'uint256' }, - ], - name: 'getRoleMember', - outputs: [ - { internalType: 'address', name: '', type: 'address' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'role', type: 'bytes32' }, - ], - name: 'getRoleMemberCount', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { internalType: 'address', name: 'account', type: 'address' }, - ], - name: 'grantRole', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { internalType: 'address', name: 'account', type: 'address' }, - ], - name: 'hasRole', - outputs: [ - { internalType: 'bool', name: '', type: 'bool' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'nonce', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'protocolFeeRate', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: '', type: 'address' }, - ], - name: 'protocolFees', - outputs: [ - { internalType: 'uint256', name: '', type: 'uint256' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes', name: 'request', type: 'bytes' }, - { internalType: 'bytes32', name: 'destTxHash', type: 'bytes32' }, - ], - name: 'prove', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes', name: 'request', type: 'bytes' }, - ], - name: 'refund', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes', name: 'request', type: 'bytes' }, - ], - name: 'relay', - outputs: [], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { internalType: 'address', name: 'callerConfirmation', type: 'address' }, - ], - name: 'renounceRole', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32', name: 'role', type: 'bytes32' }, - { internalType: 'address', name: 'account', type: 'address' }, - ], - name: 'revokeRole', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'newChainGasAmount', type: 'uint256' }, - ], - name: 'setChainGasAmount', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'uint256', name: 'newFeeRate', type: 'uint256' }, - ], - name: 'setProtocolFeeRate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }, - ], - name: 'supportsInterface', - outputs: [ - { internalType: 'bool', name: '', type: 'bool' }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'token', type: 'address' }, - { internalType: 'address', name: 'recipient', type: 'address' }, - ], - name: 'sweepProtocolFees', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - ] as const \ No newline at end of file + { + inputs: [{ internalType: 'address', name: '_owner', type: 'address' }], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'AccessControlBadConfirmation', + type: 'error', + }, + { + inputs: [ + { internalType: 'address', name: 'account', type: 'address' }, + { internalType: 'bytes32', name: 'neededRole', type: 'bytes32' }, + ], + name: 'AccessControlUnauthorizedAccount', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'target', type: 'address' }], + name: 'AddressEmptyCode', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'AddressInsufficientBalance', + type: 'error', + }, + { + inputs: [], + name: 'AmountIncorrect', + type: 'error', + }, + { + inputs: [], + name: 'ChainIncorrect', + type: 'error', + }, + { + inputs: [], + name: 'DeadlineExceeded', + type: 'error', + }, + { + inputs: [], + name: 'DeadlineNotExceeded', + type: 'error', + }, + { + inputs: [], + name: 'DeadlineTooShort', + type: 'error', + }, + { + inputs: [], + name: 'DisputePeriodNotPassed', + type: 'error', + }, + { + inputs: [], + name: 'DisputePeriodPassed', + type: 'error', + }, + { + inputs: [], + name: 'FailedInnerCall', + type: 'error', + }, + { + inputs: [], + name: 'MsgValueIncorrect', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'token', type: 'address' }], + name: 'SafeERC20FailedOperation', + type: 'error', + }, + { + inputs: [], + name: 'SenderIncorrect', + type: 'error', + }, + { + inputs: [], + name: 'StatusIncorrect', + type: 'error', + }, + { + inputs: [], + name: 'TokenNotContract', + type: 'error', + }, + { + inputs: [], + name: 'TransactionRelayed', + type: 'error', + }, + { + inputs: [], + name: 'ZeroAddress', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'transactionId', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'relayer', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'address', + name: 'token', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'BridgeDepositClaimed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'transactionId', + type: 'bytes32', + }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'address', + name: 'token', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'BridgeDepositRefunded', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'transactionId', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'relayer', + type: 'address', + }, + ], + name: 'BridgeProofDisputed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'transactionId', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'relayer', + type: 'address', + }, + { + indexed: false, + internalType: 'bytes32', + name: 'transactionHash', + type: 'bytes32', + }, + ], + name: 'BridgeProofProvided', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'transactionId', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'relayer', + type: 'address', + }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + indexed: false, + internalType: 'uint32', + name: 'originChainId', + type: 'uint32', + }, + { + indexed: false, + internalType: 'address', + name: 'originToken', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'destToken', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'originAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'destAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'chainGasAmount', + type: 'uint256', + }, + ], + name: 'BridgeRelayed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'transactionId', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { indexed: false, internalType: 'bytes', name: 'request', type: 'bytes' }, + { + indexed: false, + internalType: 'uint32', + name: 'destChainId', + type: 'uint32', + }, + { + indexed: false, + internalType: 'address', + name: 'originToken', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'destToken', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'originAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'destAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'bool', + name: 'sendChainGas', + type: 'bool', + }, + ], + name: 'BridgeRequested', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'oldChainGasAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'newChainGasAmount', + type: 'uint256', + }, + ], + name: 'ChainGasAmountUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'oldFeeRate', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'newFeeRate', + type: 'uint256', + }, + ], + name: 'FeeRateUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'token', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'FeesSwept', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { + indexed: true, + internalType: 'bytes32', + name: 'previousAdminRole', + type: 'bytes32', + }, + { + indexed: true, + internalType: 'bytes32', + name: 'newAdminRole', + type: 'bytes32', + }, + ], + name: 'RoleAdminChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + ], + name: 'RoleGranted', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + ], + name: 'RoleRevoked', + type: 'event', + }, + { + inputs: [], + name: 'DEFAULT_ADMIN_ROLE', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DISPUTE_PERIOD', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'FEE_BPS', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'FEE_RATE_MAX', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'GOVERNOR_ROLE', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'GUARD_ROLE', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MIN_DEADLINE_PERIOD', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'REFUNDER_ROLE', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'REFUND_DELAY', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'RELAYER_ROLE', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'uint32', name: 'dstChainId', type: 'uint32' }, + { internalType: 'address', name: 'sender', type: 'address' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'address', name: 'originToken', type: 'address' }, + { internalType: 'address', name: 'destToken', type: 'address' }, + { internalType: 'uint256', name: 'originAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'destAmount', type: 'uint256' }, + { internalType: 'bool', name: 'sendChainGas', type: 'bool' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + ], + internalType: 'struct IFastBridge.BridgeParams', + name: 'params', + type: 'tuple', + }, + ], + name: 'bridge', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + name: 'bridgeProofs', + outputs: [ + { internalType: 'uint96', name: 'timestamp', type: 'uint96' }, + { internalType: 'address', name: 'relayer', type: 'address' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + name: 'bridgeRelays', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + name: 'bridgeStatuses', + outputs: [ + { internalType: 'enum FastBridge.BridgeStatus', name: '', type: 'uint8' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, + { internalType: 'address', name: 'relayer', type: 'address' }, + ], + name: 'canClaim', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'chainGasAmount', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes', name: 'request', type: 'bytes' }, + { internalType: 'address', name: 'to', type: 'address' }, + ], + name: 'claim', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'deployBlock', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes32', name: 'transactionId', type: 'bytes32' }, + ], + name: 'dispute', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes', name: 'request', type: 'bytes' }], + name: 'getBridgeTransaction', + outputs: [ + { + components: [ + { internalType: 'uint32', name: 'originChainId', type: 'uint32' }, + { internalType: 'uint32', name: 'destChainId', type: 'uint32' }, + { internalType: 'address', name: 'originSender', type: 'address' }, + { internalType: 'address', name: 'destRecipient', type: 'address' }, + { internalType: 'address', name: 'originToken', type: 'address' }, + { internalType: 'address', name: 'destToken', type: 'address' }, + { internalType: 'uint256', name: 'originAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'destAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'originFeeAmount', type: 'uint256' }, + { internalType: 'bool', name: 'sendChainGas', type: 'bool' }, + { internalType: 'uint256', name: 'deadline', type: 'uint256' }, + { internalType: 'uint256', name: 'nonce', type: 'uint256' }, + ], + internalType: 'struct IFastBridge.BridgeTransaction', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes32', name: 'role', type: 'bytes32' }], + name: 'getRoleAdmin', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { internalType: 'uint256', name: 'index', type: 'uint256' }, + ], + name: 'getRoleMember', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes32', name: 'role', type: 'bytes32' }], + name: 'getRoleMemberCount', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { internalType: 'address', name: 'account', type: 'address' }, + ], + name: 'grantRole', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { internalType: 'address', name: 'account', type: 'address' }, + ], + name: 'hasRole', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'nonce', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'protocolFeeRate', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'protocolFees', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes', name: 'request', type: 'bytes' }, + { internalType: 'bytes32', name: 'destTxHash', type: 'bytes32' }, + ], + name: 'prove', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes', name: 'request', type: 'bytes' }], + name: 'refund', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes', name: 'request', type: 'bytes' }], + name: 'relay', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { internalType: 'address', name: 'callerConfirmation', type: 'address' }, + ], + name: 'renounceRole', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes32', name: 'role', type: 'bytes32' }, + { internalType: 'address', name: 'account', type: 'address' }, + ], + name: 'revokeRole', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'newChainGasAmount', type: 'uint256' }, + ], + name: 'setChainGasAmount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'newFeeRate', type: 'uint256' }], + name: 'setProtocolFeeRate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }], + name: 'supportsInterface', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'token', type: 'address' }, + { internalType: 'address', name: 'recipient', type: 'address' }, + ], + name: 'sweepProtocolFees', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const diff --git a/packages/rfq-indexer/indexer/src/index.ts b/packages/rfq-indexer/indexer/src/index.ts index f61146c7d6..2fe6711830 100644 --- a/packages/rfq-indexer/indexer/src/index.ts +++ b/packages/rfq-indexer/indexer/src/index.ts @@ -34,7 +34,7 @@ ponder.on('FastBridgeV2:BridgeRequested', async ({ event, context }) => { data: { transactionId, sender: trim(sender), - request: request, + request, originChainId: Number(chainId), originChain: getChainName(Number(chainId)), destChainId: Number(destChainId), diff --git a/packages/rfq-indexer/indexer/src/utils/formatAmount.ts b/packages/rfq-indexer/indexer/src/utils/formatAmount.ts index 2ea80247e9..25db6cf46f 100644 --- a/packages/rfq-indexer/indexer/src/utils/formatAmount.ts +++ b/packages/rfq-indexer/indexer/src/utils/formatAmount.ts @@ -5,9 +5,13 @@ const ADDRESSES_WITH_18_DECIMALS = [ '0x2cFc85d8E48F8EAB294be644d9E25C3030863003', // WLD '0x163f8c2467924be0ae7b5347228cabf260318753', // WLD '0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1', // WLD -].map(address => address.toLowerCase()) +].map((address) => address.toLowerCase()) -export function formatAmount(amount: bigint, tokenAddress: string): string { - const decimals = ADDRESSES_WITH_18_DECIMALS.includes(tokenAddress.toLowerCase()) ? 18 : 6 +export const formatAmount = (amount: bigint, tokenAddress: string): string => { + const decimals = ADDRESSES_WITH_18_DECIMALS.includes( + tokenAddress.toLowerCase() + ) + ? 18 + : 6 return formatUnits(amount, decimals) } From 24fbf3e44ef9ee7efe970a314fcccec62691e2fc Mon Sep 17 00:00:00 2001 From: defi-moses Date: Tue, 29 Oct 2024 18:13:33 +0000 Subject: [PATCH 12/12] fixing irrelavent files --- services/rfq/relayer/quoter/quoter_test.go | 30 ---------------------- 1 file changed, 30 deletions(-) diff --git a/services/rfq/relayer/quoter/quoter_test.go b/services/rfq/relayer/quoter/quoter_test.go index 0b0f899779..d9a4822f8b 100644 --- a/services/rfq/relayer/quoter/quoter_test.go +++ b/services/rfq/relayer/quoter/quoter_test.go @@ -253,33 +253,6 @@ func (s *QuoterSuite) TestGetOriginAmount() { minQuoteAmount: "0", maxBalance: "0", }) -<<<<<<< HEAD - quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) - s.NoError(err) - expectedAmount = big.NewInt(500_000_000) - s.Equal(expectedAmount, quoteAmount) - - // Set QuotePct to 50 with QuoteOffset of -1%. Should be 1% less than 50% of balance. - setQuoteParams(quoteParams{ - quotePct: 50, - quoteOffset: -100, - minQuoteAmount: "0", - maxBalance: "0", - }) - quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) - s.NoError(err) - expectedAmount = big.NewInt(495_000_000) - s.Equal(expectedAmount, quoteAmount) - - // Set QuotePct to 25 with MinQuoteAmount of 500; should be 50% of balance. - setQuoteParams(quoteParams{ - quotePct: 25, - quoteOffset: 0, - minQuoteAmount: "500", - maxBalance: "0", - }) -======= ->>>>>>> master quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(500_000_000) @@ -292,8 +265,6 @@ func (s *QuoterSuite) TestGetOriginAmount() { minQuoteAmount: "500", maxBalance: "0", }) -<<<<<<< HEAD -======= quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(500_000_000) @@ -306,7 +277,6 @@ func (s *QuoterSuite) TestGetOriginAmount() { minQuoteAmount: "500", maxBalance: "0", }) ->>>>>>> master quoteAmount, err = s.manager.GetOriginAmount(s.GetTestContext(), input) s.NoError(err) expectedAmount = big.NewInt(500_000_000)