Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
k06a committed Jul 7, 2020
1 parent 7e83e3f commit a9e65b7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 65 deletions.
10 changes: 8 additions & 2 deletions KyberReserves.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# Kyber Reserves

There are 3 diffrent prefixes of reserve ids:
- `0xAA` for [Automated Price Reserve](https://developer.kyber.network/docs/Reserves-AutomatedPriceReserve/)
- `0xFF` for [Fed Price Reserve](https://developer.kyber.network/docs/Reserves-FedPriceReserve/)
- `0xBB` for Bridged Price Reserves

## Multiple token reserves

- Reserve 1 [`0x63825c174ab367968EC60f061753D3bbD36A0D8F`](https://etherscan.io/address/0x63825c174ab367968EC60f061753D3bbD36A0D8F) (Reserve Id: `0xff4b796265722046707200000000000000000000000000000000000000000000`)
- Reserve 2 [`0x7a3370075a54B187d7bD5DceBf0ff2B5552d4F7D`](https://etherscan.io/address/0x7a3370075a54B187d7bD5DceBf0ff2B5552d4F7D) (Reserve Id: `0xffabcd0000000000000000000000000000000000000000000000000000000000`)
- Reserve 3 [`0x4f32BbE8dFc9efD54345Fc936f9fEF1048746fCF`](https://etherscan.io/address/0x4f32BbE8dFc9efD54345Fc936f9fEF1048746fCF) (Reserve Id: `0xff4f6e65426974205175616e7400000000000000000000000000000000000000`)

## Bridge Reserves
## Bridged Reserves

- Oasis (Eth2Dai) [`0x1E158c0e93c30d24e918Ef83d1e0bE23595C3c0f`](https://etherscan.io/address/0x1E158c0e93c30d24e918Ef83d1e0bE23595C3c0f) (Reserve Id: `0xbb4f617369730000000000000000000000000000000000000000000000000000`)
- Uniswap [`0x31E085Afd48a1d6e51Cc193153d625e8f0514C7F`](https://etherscan.io/address/0x31E085Afd48a1d6e51Cc193153d625e8f0514C7F) (Reserve Id: `0xbb756e6973776170563100000000000000000000000000000000000000000000`)
- Uniswap V2 [`0x10908C875D865C66f271F5d3949848971c9595C9`](https://etherscan.io/address/0x10908C875D865C66f271F5d3949848971c9595C9) (Reserve Id: `0xbb756e6973776170563200000000000000000000000000000000000000000000`)
- Bancor Token Reserve [`1fE867bFE9cbE0045467605B959A355223E3885D`](https://etherscan.io/address/0x1fE867bFE9cbE0045467605B959A355223E3885D) (ReserveId: `0xbb42414e434f5230305632000000000000000000000000000000000000000000`)


## Single token reserves

Expand All @@ -32,7 +39,6 @@
- [SPIKE](https://etherscan.io/address/0xA7fC5D2453E3F68aF0cc1B78bcFEe94A1B293650) Token Reserve [`8ea5CF9f61824E8A3cA8AA370AB37e0202B2CC7D`](https://etherscan.io/address/0x8ea5CF9f61824E8A3cA8AA370AB37e0202B2CC7D) (ReserveId: `0xaa88888888888888888888888888888888888888888888888888888888888888`)
- [SAN](https://etherscan.io/address/0x7C5A0CE9267ED19B22F8cae653F198e3E8daf098) Token Reserve [`a9742Ee9a5407f4C2f8a49f65E3a440f3694960a`](https://etherscan.io/address/0xa9742Ee9a5407f4C2f8a49f65E3a440f3694960a) (ReserveId: `0xaa53414e20415052000000000000000000000000000000000000000000000000`)
- [KNC](https://etherscan.io/address/0xdd974D5C2e2928deA5F71b9825b8b646686BD200) Token Reserve [`607d7751d9F4845C5a1dE9eeD39c56f4fC0F855d`](https://etherscan.io/address/0x607d7751d9F4845C5a1dE9eeD39c56f4fC0F855d) (ReserveId: `0xaa4b4e435f4d4547414c41444f4e000000000000000000000000000000000000`)
- [BNT](https://etherscan.io/address/0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C) Token Reserve [`1fE867bFE9cbE0045467605B959A355223E3885D`](https://etherscan.io/address/0x1fE867bFE9cbE0045467605B959A355223E3885D) (ReserveId: `0xbb42414e434f5230305632000000000000000000000000000000000000000000`)
- [EKG](https://etherscan.io/address/0x6A9b3E36436B7abde8C4E2E2a98Ea40455E615cf) Token Reserve [`4e6d0F492fd139151DE4728caC47dAce56C56Af4`](https://etherscan.io/address/0x4e6d0F492fd139151DE4728caC47dAce56C56Af4) (ReserveId: `0xff454b4700000000000000000000000000000000000000000000000000000000`)
- [ANT](https://etherscan.io/address/0x960b236A07cf122663c4303350609A66A7B288C0) Token Reserve [`0994c18Ed0C328F38d2C451B2a2e1cEb1Ae6A812`](https://etherscan.io/address/0x0994c18Ed0C328F38d2C451B2a2e1cEb1Ae6A812) (ReserveId: `0xaa414e5400000000000000000000000000000000000000000000000000000000`)
- [GDC](https://etherscan.io/address/0x301C755bA0fcA00B1923768Fffb3Df7f4E63aF31) Token Reserve [`2485a4e3Dd95a3Ef445B786acf7bacc5C99986F7`](https://etherscan.io/address/0x2485a4e3Dd95a3Ef445B786acf7bacc5C99986F7) (ReserveId: `0xaa676463746f6b656e0000000000000000000000000000000000000000000000`)
Expand Down
2 changes: 1 addition & 1 deletion OneSplit.full.bin

Large diffs are not rendered by default.

43 changes: 12 additions & 31 deletions OneSplit.full.sol
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,9 @@ pragma solidity ^0.5.0;


interface IKyberStorage {
function getReserveAddressesPerTokenSrc(
IERC20 token,
uint256 startIndex,
uint256 endToken
) external view returns (address[] memory);

function getReserveId(
address reserve
) external view returns (bytes32);
function getReserveIdsPerTokenSrc(
IERC20 token
) external view returns (bytes32[] memory);
}

// File: contracts/interface/IKyberHintHandler.sol
Expand Down Expand Up @@ -1644,30 +1638,17 @@ contract OneSplitRoot is IOneSplitView {
return 0;
}

address payable[6] memory multiTokenReserves = [
0x63825c174ab367968EC60f061753D3bbD36A0D8F, // Reserve 1
0x7a3370075a54B187d7bD5DceBf0ff2B5552d4F7D, // Reserve 2
0x4f32BbE8dFc9efD54345Fc936f9fEF1048746fCF, // Reserve 3
0x1E158c0e93c30d24e918Ef83d1e0bE23595C3c0f, // Eth2Dai
0x31E085Afd48a1d6e51Cc193153d625e8f0514C7F, // Uniswap
0x10908C875D865C66f271F5d3949848971c9595C9 // Uniswap V2
];

address[] memory reserves = kyberStorage.getReserveAddressesPerTokenSrc(
fromToken.isETH() ? destToken : fromToken, 0, 10
bytes32[] memory reserveIds = kyberStorage.getReserveIdsPerTokenSrc(
fromToken.isETH() ? destToken : fromToken
);

for (uint i = 0; i < reserves.length; i++) {
bool isSingleTokenKyberReserve = true;
for (uint j = 0; j < multiTokenReserves.length; j++) {
if (reserves[i] == multiTokenReserves[j]) {
isSingleTokenKyberReserve = false;
break;
}
}

if (isSingleTokenKyberReserve) {
return kyberStorage.getReserveId(reserves[i]);
for (uint i = 0; i < reserveIds.length; i++) {
if ((uint256(reserveIds[i]) >> 248) != 0xBB && // Bridge
reserveIds[i] != 0xff4b796265722046707200000000000000000000000000000000000000000000 && // Reserve 1
reserveIds[i] != 0xffabcd0000000000000000000000000000000000000000000000000000000000 && // Reserve 2
reserveIds[i] != 0xff4f6e65426974205175616e7400000000000000000000000000000000000000) // Reserve 3
{
return reserveIds[i];
}
}

Expand Down
31 changes: 9 additions & 22 deletions contracts/OneSplitBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,30 +278,17 @@ contract OneSplitRoot is IOneSplitView {
return 0;
}

address payable[6] memory multiTokenReserves = [
0x63825c174ab367968EC60f061753D3bbD36A0D8F, // Reserve 1
0x7a3370075a54B187d7bD5DceBf0ff2B5552d4F7D, // Reserve 2
0x4f32BbE8dFc9efD54345Fc936f9fEF1048746fCF, // Reserve 3
0x1E158c0e93c30d24e918Ef83d1e0bE23595C3c0f, // Eth2Dai
0x31E085Afd48a1d6e51Cc193153d625e8f0514C7F, // Uniswap
0x10908C875D865C66f271F5d3949848971c9595C9 // Uniswap V2
];

address[] memory reserves = kyberStorage.getReserveAddressesPerTokenSrc(
fromToken.isETH() ? destToken : fromToken, 0, 10
bytes32[] memory reserveIds = kyberStorage.getReserveIdsPerTokenSrc(
fromToken.isETH() ? destToken : fromToken
);

for (uint i = 0; i < reserves.length; i++) {
bool isSingleTokenKyberReserve = true;
for (uint j = 0; j < multiTokenReserves.length; j++) {
if (reserves[i] == multiTokenReserves[j]) {
isSingleTokenKyberReserve = false;
break;
}
}

if (isSingleTokenKyberReserve) {
return kyberStorage.getReserveId(reserves[i]);
for (uint i = 0; i < reserveIds.length; i++) {
if ((uint256(reserveIds[i]) >> 248) != 0xBB && // Bridge
reserveIds[i] != 0xff4b796265722046707200000000000000000000000000000000000000000000 && // Reserve 1
reserveIds[i] != 0xffabcd0000000000000000000000000000000000000000000000000000000000 && // Reserve 2
reserveIds[i] != 0xff4f6e65426974205175616e7400000000000000000000000000000000000000) // Reserve 3
{
return reserveIds[i];
}
}

Expand Down
12 changes: 3 additions & 9 deletions contracts/interface/IKyberStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";


interface IKyberStorage {
function getReserveAddressesPerTokenSrc(
IERC20 token,
uint256 startIndex,
uint256 endToken
) external view returns (address[] memory);

function getReserveId(
address reserve
) external view returns (bytes32);
function getReserveIdsPerTokenSrc(
IERC20 token
) external view returns (bytes32[] memory);
}

0 comments on commit a9e65b7

Please sign in to comment.