From 16382604cf4b65fe2ade417f4d61eb58817066cd Mon Sep 17 00:00:00 2001 From: Bruno Barbieri <1247834+brunobar79@users.noreply.github.com> Date: Thu, 28 Mar 2024 16:45:14 -0400 Subject: [PATCH] Support diff addresses (#59) * v0.11.0 * support diff addresses * add addresses --- sdk/src/quotes.ts | 16 +++++++++++++++- sdk/src/utils/constants.ts | 3 +++ smart-contracts/README.md | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sdk/src/quotes.ts b/sdk/src/quotes.ts index fdbe9f7..5db7ba6 100644 --- a/sdk/src/quotes.ts +++ b/sdk/src/quotes.ts @@ -25,12 +25,26 @@ import { MAX_INT, PERMIT_EXPIRATION_TS, RAINBOW_ROUTER_CONTRACT_ADDRESS, + RAINBOW_ROUTER_CONTRACT_ADDRESS_ZORA, SOCKET_GATEWAY_CONTRACT_ADDRESSESS, WRAPPED_ASSET, } from './utils/constants'; import { signPermit } from './utils/permit'; import { getReferrerCode } from './utils/referrer'; +/** + * Function to get the rainbow router contract address based on the chainId + * + * @param {ChainId} chainId + * @returns {string} + */ +export const getRainbowRouterContractAddress = (chainId: ChainId) => { + if (chainId === ChainId.zora) { + return RAINBOW_ROUTER_CONTRACT_ADDRESS_ZORA; + } + return RAINBOW_ROUTER_CONTRACT_ADDRESS; +}; + /** * Function to get a swap formatted quote url to use with backend * @@ -81,7 +95,7 @@ const buildRainbowQuoteUrl = ({ // When buying ETH, we need to tell the aggregator // to return the funds to the contract if we need to take a fee ...(buyTokenAddress === ETH_ADDRESS - ? { destReceiver: RAINBOW_ROUTER_CONTRACT_ADDRESS } + ? { destReceiver: getRainbowRouterContractAddress(chainId) } : {}), ...(feePercentageBasisPoints !== undefined ? { feePercentageBasisPoints: String(feePercentageBasisPoints) } diff --git a/sdk/src/utils/constants.ts b/sdk/src/utils/constants.ts index 9b62a6a..7f678e6 100644 --- a/sdk/src/utils/constants.ts +++ b/sdk/src/utils/constants.ts @@ -5,6 +5,9 @@ export const API_BASE_URL = 'https://swap.p.rainbow.me'; export const RAINBOW_ROUTER_CONTRACT_ADDRESS = '0x00000000009726632680fb29d3f7a9734e3010e2'; +export const RAINBOW_ROUTER_CONTRACT_ADDRESS_ZORA = + '0xa61550e9ddd2797e16489db09343162be98d9483'; + // SOCKET_GATEWAY_CONTRACT_ADDRESSES is mapped by int chain ID to avoid a breaking change export const SOCKET_GATEWAY_CONTRACT_ADDRESSESS = new Map([ [ChainId.mainnet, '0x3a23F943181408EAC424116Af7b7790c94Cb97a5'], diff --git a/smart-contracts/README.md b/smart-contracts/README.md index 0e984f6..416b877 100644 --- a/smart-contracts/README.md +++ b/smart-contracts/README.md @@ -13,6 +13,9 @@ Run tests with: `MAINNET_RPC_ENDPOINT=https://eth-mainnet.g.alchemy.com/v2/{ALCH - Base Mainnet: [0x00000000009726632680fb29d3f7a9734e3010e2](https://basescan.io/address/0x00000000009726632680fb29d3f7a9734e3010e2) - BSC Mainnet: [0x00000000009726632680fb29d3f7a9734e3010e2](https://bscscan.com/address/0x00000000009726632680fb29d3f7a9734e3010e2) - AVAX Mainnet: [0x00000000009726632680fb29d3f7a9734e3010e2](https://snowtrace.io/address/0x00000000009726632680fb29d3f7a9734e3010e2) +- Blast Mainnet: [0x00000000009726632680fb29d3f7a9734e3010e2](https://blastscan.io/address/0x00000000009726632680fb29d3f7a9734e3010e2) +- Zora Mainnet: [0xA61550E9ddD2797E16489db09343162BE98d9483](https://explorer.zora.energy/address/0xA61550E9ddD2797E16489db09343162BE98d9483) + ## Audits - [OpenZeppelin (2022/01/10 - 2022/02/25)](audits/2022-02-25-OpenZeppelin-Rainbow-Swap-Aggregator.pdf)