-
Notifications
You must be signed in to change notification settings - Fork 465
🔂 Liquidity Provider Asset Swapper integration #2505
Changes from 18 commits
77d7afe
3c0fd54
8be60e2
9608d8f
7181be8
e5df51a
bcc3e5e
9d2aef5
5d4bbd5
08619e2
7495ac8
fa8e8ad
82b0f85
82de5ad
599af2b
8186d62
b0fd78d
18ce19a
49b7c9c
807904b
99dc4b8
bc7504c
3eb1429
5909189
d0d7d27
61f03b0
32e1ae2
fa886aa
dbc5c0d
36c457f
17b2320
d849813
659e899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||||||
pragma solidity ^0.5.9; | ||||||||||||
pragma experimental ABIEncoderV2; | ||||||||||||
|
||||||||||||
|
||||||||||||
contract DummyLiquidityProvider | ||||||||||||
{ | ||||||||||||
constructor() | ||||||||||||
public | ||||||||||||
// solhint-disable-next-line no-empty-blocks | ||||||||||||
{} | ||||||||||||
|
||||||||||||
/// @dev Quotes the amount of `makerToken` that would be obtained by | ||||||||||||
/// selling `sellAmount` of `takerToken`. | ||||||||||||
/// @param sellAmount Amount of `takerToken` to sell. | ||||||||||||
/// @return makerTokenAmount Amount of `makerToken` that would be obtained. | ||||||||||||
function getSellQuote( | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified that this matches the spec ✅ |
||||||||||||
address, /* takerToken */ | ||||||||||||
address, /* makerToken */ | ||||||||||||
uint256 sellAmount | ||||||||||||
) | ||||||||||||
external | ||||||||||||
view | ||||||||||||
returns (uint256 makerTokenAmount) { | ||||||||||||
makerTokenAmount = sellAmount - 1; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style nit:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||||||
} | ||||||||||||
|
||||||||||||
/// @dev Quotes the amount of `takerToken` that would need to be sold in | ||||||||||||
/// order to obtain `buyAmount` of `makerToken`. | ||||||||||||
/// @param buyAmount Amount of `makerToken` to buy. | ||||||||||||
/// @return takerTokenAmount Amount of `takerToken` that would need to be sold. | ||||||||||||
function getBuyQuote( | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified that this matches the spec ✅ |
||||||||||||
address, /* takerToken */ | ||||||||||||
address, /* makerToken */ | ||||||||||||
uint256 buyAmount | ||||||||||||
) | ||||||||||||
external | ||||||||||||
view | ||||||||||||
returns (uint256 takerTokenAmount) { | ||||||||||||
takerTokenAmount = buyAmount + 1; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||||||
} | ||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||||
pragma solidity ^0.5.9; | ||||||||
pragma experimental ABIEncoderV2; | ||||||||
|
||||||||
|
||||||||
contract DummyLiquidityProviderRegistry | ||||||||
{ | ||||||||
address private constant NULL_ADDRESS = address(0x0); | ||||||||
|
||||||||
constructor() | ||||||||
public | ||||||||
// solhint-disable-next-line no-empty-blocks | ||||||||
{} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no constructor needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||
|
||||||||
mapping (address => mapping (address => address)) internal _gAddressBook; | ||||||||
|
||||||||
/// @dev Sets address of pool for a market given market (xAsset, yAsset). | ||||||||
/// @param takerToken First asset managed by pool. | ||||||||
/// @param makerToken Second asset managed by pool. | ||||||||
/// @param poolAddress Address of pool. | ||||||||
function setLiquidityProviderForMarket( | ||||||||
address takerToken, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit - this naming may be confusing because either asset could be the taker/maker token on a given trade. Something like |
||||||||
address makerToken, | ||||||||
address poolAddress | ||||||||
) external | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||
{ | ||||||||
_gAddressBook[takerToken][makerToken] = poolAddress; | ||||||||
_gAddressBook[makerToken][takerToken] = poolAddress; | ||||||||
} | ||||||||
|
||||||||
/// @dev Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist. | ||||||||
/// @param takerToken First asset managed by pool. | ||||||||
/// @param makerToken Second asset managed by pool. | ||||||||
/// @return Address of pool. | ||||||||
function getLiquidityProviderForMarket( | ||||||||
address takerToken, | ||||||||
address makerToken | ||||||||
) | ||||||||
external | ||||||||
view | ||||||||
returns (address poolAddress) | ||||||||
{ | ||||||||
poolAddress = _gAddressBook[takerToken][makerToken]; | ||||||||
require( | ||||||||
poolAddress != NULL_ADDRESS, | ||||||||
"Registry/MARKET_PAIR_NOT_SET" | ||||||||
); | ||||||||
} | ||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no constructor needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done