Skip to content

Commit 785f779

Browse files
authored
Add helper functions to query spread and slippage in rate helper contract.
* get spread API will query rate spreads for a token. will calculate spread for all reserves listed for that token. * get slippage: buy and sell slippage for token. for all reserves listed for that token. * supports default query amounts (when user sets amount 0) * all amounts are in wei
1 parent 4e1b34b commit 785f779

File tree

9 files changed

+657
-100
lines changed

9 files changed

+657
-100
lines changed

contracts/sol6/wrappers/IKyberRateHelper.sol

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import "../IKyberReserve.sol";
66
interface IKyberRateHelper {
77
function getRatesForToken(
88
IERC20 token,
9-
uint256 optionalBuyAmount,
10-
uint256 optionalSellAmount
9+
uint256 optionalBuyAmountWei,
10+
uint256 optionalSellAmountTwei
1111
)
1212
external
1313
view
@@ -20,8 +20,8 @@ interface IKyberRateHelper {
2020

2121
function getPricesForToken(
2222
IERC20 token,
23-
uint256 optionalBuyAmount,
24-
uint256 optionalSellAmount
23+
uint256 optionalBuyAmountWei,
24+
uint256 optionalSellAmountTwei
2525
)
2626
external
2727
view
@@ -34,8 +34,8 @@ interface IKyberRateHelper {
3434

3535
function getRatesForTokenWithCustomFee(
3636
IERC20 token,
37-
uint256 optionalBuyAmount,
38-
uint256 optionalSellAmount,
37+
uint256 optionalBuyAmountWei,
38+
uint256 optionalSellAmountTwei,
3939
uint256 networkFeeBps
4040
)
4141
external
@@ -46,4 +46,33 @@ interface IKyberRateHelper {
4646
bytes32[] memory sellReserves,
4747
uint256[] memory sellRates
4848
);
49+
50+
function getReservesRates(IERC20 token, uint256 optionalAmountWei)
51+
external
52+
view
53+
returns (
54+
bytes32[] memory buyReserves,
55+
uint256[] memory buyRates,
56+
bytes32[] memory sellReserves,
57+
uint256[] memory sellRates
58+
);
59+
60+
function getSpreadInfo(IERC20 token, uint256 optionalAmountWei)
61+
external
62+
view
63+
returns (bytes32[] memory reserves, int256[] memory spreads);
64+
65+
function getSlippageRateInfo(
66+
IERC20 token,
67+
uint256 optionalAmountWei,
68+
uint256 optionalSlippageAmountWei
69+
)
70+
external
71+
view
72+
returns (
73+
bytes32[] memory buyReserves,
74+
int256[] memory buySlippageRateBps,
75+
bytes32[] memory sellReserves,
76+
int256[] memory sellSlippageRateBps
77+
);
4978
}

0 commit comments

Comments
 (0)