Skip to content

Commit

Permalink
Merge pull request #215 from rabbitholegg/mmackz/okutrade-fix
Browse files Browse the repository at this point in the history
fix(okutrade): update universal router contract address on base
  • Loading branch information
mmackz authored Feb 13, 2024
2 parents 78e80b1 + 14ab4a0 commit 53da871
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 81 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-insects-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rabbitholegg/questdk-plugin-okutrade": patch
---

update universal router contract address for base
8 changes: 4 additions & 4 deletions packages/okutrade/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Chains } from './utils'
import { Chains } from '@rabbitholegg/questdk-plugin-utils'

export const CHAIN_ID_ARRAY = [
Chains.ETHEREUM,
Chains.OPTIMISM,
Chains.ARBITRUM,
Chains.POLYGON,
Chains.ZKSYNC_ERA,
Chains.ARBITRUM_ONE,
Chains.POLYGON_POS,
Chains.ZK_SYNC_ERA,
Chains.BASE,
] as number[]

Expand Down
23 changes: 13 additions & 10 deletions packages/okutrade/src/test-transactions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { SwapActionParams } from '@rabbitholegg/questdk'
import { GreaterThanOrEqual } from '@rabbitholegg/questdk'
import { createTestCase, type TestParams } from './utils'
import {
createTestCase,
type TestParams,
} from '@rabbitholegg/questdk-plugin-utils'
import { parseEther, parseUnits, zeroAddress } from 'viem'

export const V3_NATIVE_TO_TOKENS: TestParams<SwapActionParams> = {
Expand Down Expand Up @@ -66,20 +69,20 @@ export const V3_TOKENS_TO_TOKENS: TestParams<SwapActionParams> = {
export const BASE_V3_TOKENS_TO_TOKENS: TestParams<SwapActionParams> = {
transaction: {
chainId: 8453,
to: '0x198ef79f1f515f02dfe9e3115ed9fc07183f02fc',
from: '0xa0a9d6fdb5190adc0aa448d821739400246816fc',
hash: '0xaa7f17a98303690bd4d82cd26bb54527b9a2c692ef1118c803f4bb922b6c2940',
to: '0xec8b0f7ffe3ae75d7ffab09429e3675bb63503e4',
from: '0xa99f898530df1514a566f1a6562d62809e99557d',
hash: '0xc485ab250274ea1eb6d4beb01ed8b385715e068276bb5fc4e0d4ac524d6c381c',
input:
'0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000659fc28100000000000000000000000000000000000000000000000000000000000000030a000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000065c74e4b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000198ef79f1f515f02dfe9e3115ed9fc07183f02fc00000000000000000000000000000000000000000000000000000000659fc85300000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000413e13097bf41620c571c5aaf6fd64b00b1b7fa93481409121fa17ee479384abad74493013a90eebfd505788b814551b8baa603b4d996ecce11b852475c45848061c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000004fa97600000000000000000000000000000000000000000000000000070d9c80da2ea900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002b833589fcd6edb6e08f4c7c32d4f71b54bda02913000bb842000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000070d9c80da2ea9',
'0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000065cab39800000000000000000000000000000000000000000000000000000000000000020a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001600000000000000000000000004200000000000000000000000000000000000006000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000065d3ee180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ec8b0f7ffe3ae75d7ffab09429e3675bb63503e40000000000000000000000000000000000000000000000000000000065cab39800000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000041def0245e78be02aa42cf5dafea5c8606255f08eb20108bda42fcf50eabc01a703e6406840aa7ec56dd4dd2dd99191231e137ebdc781253f4ebac59d72ffea0da1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a99f898530df1514a566f1a6562d62809e99557d00000000000000000000000000000000000000000000000000071afd498d000000000000000000000000000000000000000000000000000000000000004ff20100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f4d9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca000000000000000000000000000000000000000000',
value: '0',
},
params: {
chainId: 8453,
tokenIn: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC
tokenOut: zeroAddress, // ETH
amountIn: GreaterThanOrEqual(parseUnits('5.220726', 6)),
amountOut: GreaterThanOrEqual(parseEther('0.001985290664')),
recipient: '0xa0a9d6fdb5190adc0aa448d821739400246816fc',
tokenIn: '0x4200000000000000000000000000000000000006', // WETH
tokenOut: '0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca', // USDbC
amountIn: GreaterThanOrEqual(parseEther('0.002')),
amountOut: GreaterThanOrEqual(parseUnits('5.23', 6)),
recipient: '0xa99f898530df1514a566f1a6562d62809e99557d',
},
}

Expand Down
8 changes: 4 additions & 4 deletions packages/okutrade/src/token-addresses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Address, zeroAddress as ETH_ADDRESS } from 'viem'
import { Chains } from './utils'
import { Chains } from '@rabbitholegg/questdk-plugin-utils'

const ethereumTokenAddresses: Address[] = [
ETH_ADDRESS, // ETH
Expand Down Expand Up @@ -84,8 +84,8 @@ const baseTokenAddresses: Address[] = [
export const CHAIN_TO_TOKENS: { [chainId: number]: Address[] | undefined } = {
[Chains.ETHEREUM]: ethereumTokenAddresses,
[Chains.OPTIMISM]: optimismTokenAddresses,
[Chains.ARBITRUM]: arbitrumTokenAddresses,
[Chains.POLYGON]: polygonTokenAddresses,
[Chains.ZKSYNC_ERA]: zkSyncEraTokenAddresses,
[Chains.ARBITRUM_ONE]: arbitrumTokenAddresses,
[Chains.POLYGON_POS]: polygonTokenAddresses,
[Chains.ZK_SYNC_ERA]: zkSyncEraTokenAddresses,
[Chains.BASE]: baseTokenAddresses,
}
73 changes: 10 additions & 63 deletions packages/okutrade/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,6 @@
import type { ActionParams, FilterOperator } from '@rabbitholegg/questdk'
import { getAddress, type Address, type Hash } from 'viem'

export enum Chains {
ETHEREUM = 1,
OPTIMISM = 10,
POLYGON = 137,
ZKSYNC_ERA = 324,
ARBITRUM = 42161,
BASE = 8453,
}

interface Transaction {
chainId: number
from: Address
hash?: Hash
input: string
to: Address
value: string
}

export interface TestCase<T extends ActionParams> {
transaction: Transaction
params: T
description: string
}

export type TestParams<T extends ActionParams> = {
transaction: Transaction
params: T
}

/**
* Creates a test case object for a given action and transaction.
*
* This function takes a `TestParams` object that includes both a `Transaction` and
* `ActionParams`, a description of the test case, and an optional set of overrides
* for the action parameters. It returns a `TestCase` object that contains the transaction,
* the combined action parameters with any overrides applied, and the description.
*
* @param {TestParams<T>} testParams - An object containing the transaction and action parameters.
* @param {string} description - A brief description of the test case.
* @param {Partial<T>} [overrides] - Optional overrides for the action parameters.
* @returns {TestCase<T>} A test case object with the transaction, params, and description.
*/
export function createTestCase<T extends ActionParams>(
testParams: TestParams<T>,
description: string,
overrides: Partial<T> = {},
): TestCase<T> {
return {
transaction: testParams.transaction,
params: { ...testParams.params, ...overrides },
description,
}
}
import type { FilterOperator } from '@rabbitholegg/questdk'
import { getAddress, type Address } from 'viem'
import { Chains } from '@rabbitholegg/questdk-plugin-utils'

export const buildV3PathQuery = (tokenIn?: string, tokenOut?: string) => {
// v3 paths are formatted as 0x<token><fee><token>
Expand Down Expand Up @@ -94,18 +41,18 @@ export const buildV2PathQuery = (tokenIn?: string, tokenOut?: string) => {
const chainToContract: Record<number, Address> = {
[Chains.ETHEREUM]: '0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B',
[Chains.OPTIMISM]: '0xb555edF5dcF85f42cEeF1f3630a52A108E55A654',
[Chains.POLYGON]: '0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5',
[Chains.ZKSYNC_ERA]: '0x28731BCC616B5f51dD52CF2e4dF0E78dD1136C06',
[Chains.ARBITRUM]: '0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5',
[Chains.BASE]: '0x198EF79F1F515F02dFE9e3115eD9fC07183f02fC',
[Chains.POLYGON_POS]: '0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5',
[Chains.ZK_SYNC_ERA]: '0x28731BCC616B5f51dD52CF2e4dF0E78dD1136C06',
[Chains.ARBITRUM_ONE]: '0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5',
[Chains.BASE]: '0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4',
}

const chainToWETH: Record<number, Address> = {
[Chains.ETHEREUM]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
[Chains.OPTIMISM]: '0x4200000000000000000000000000000000000006',
[Chains.ARBITRUM]: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
[Chains.POLYGON]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
[Chains.ZKSYNC_ERA]: '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91',
[Chains.ARBITRUM_ONE]: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
[Chains.POLYGON_POS]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
[Chains.ZK_SYNC_ERA]: '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91',
[Chains.BASE]: '0x4200000000000000000000000000000000000006',
}

Expand Down

0 comments on commit 53da871

Please sign in to comment.