Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support diff addresses #59

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading