Skip to content

Commit

Permalink
Support diff addresses (#59)
Browse files Browse the repository at this point in the history
* v0.11.0

* support diff addresses

* add addresses
  • Loading branch information
brunobar79 authored Mar 28, 2024
1 parent 9ed5f55 commit 1638260
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
16 changes: 15 additions & 1 deletion sdk/src/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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) }
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
3 changes: 3 additions & 0 deletions smart-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 1638260

Please sign in to comment.