This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
🔂 Liquidity Provider Asset Swapper integration #2505
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
77d7afe
created DummyPLPRegistry and DummyPLP + generated wrappers for these …
3c0fd54
generated wrappers for ERC20 sampler
8be60e2
initial unit tests for DEX sampler
9608d8f
added more unit tests for PLP DEX sampling
7181be8
added more unit tests, reinforced existing tests, added more implemen…
e5df51a
tidy up tests, add other tests
bcc3e5e
refactor tests, and add more tests
9d2aef5
Added linting and prettifying
5d4bbd5
Merge branch 'development' of github.com:0xProject/0x-monorepo into f…
08619e2
re-generate ERC20BridgeSampler artifacts
7495ac8
performed a rename
fa8e8ad
Update artifacts after rename
82b0f85
transformed the new artifacts
82de5ad
refactored sampler operations into a single external file
599af2b
factored out interfaces in `types.ts`
8186d62
fixed a bug with imports
b0fd78d
added linting to the contracts
18ce19a
refactored imports
49b7c9c
update sampler address
807904b
addressed PR comments
99dc4b8
refactor more code
bc7504c
refresh wrappers and artifacts
3eb1429
adds possibility to exclude PLP
5909189
Merge branch 'development' of github.com:0xProject/0x-monorepo into f…
d0d7d27
upgrades contracts-erc20-bridge-sampler dependency
61f03b0
invert maker and taker token variable
32e1ae2
added unit tests to avoid regression due to variable order
fa886aa
prettify and lint
dbc5c0d
moved unit tests to the appropriate sections
36c457f
added unit tests for the Liquidity Provider
17b2320
remove unit tests that were ported to `erc20-bridge-sampler` package
d849813
Merge branch 'development' of github.com:0xProject/0x-monorepo into f…
659e899
Completed feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
contracts/erc20-bridge-sampler/contracts/src/DummyLiquidityProvider.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
pragma solidity ^0.5.9; | ||
pragma experimental ABIEncoderV2; | ||
|
||
|
||
contract DummyLiquidityProvider | ||
{ | ||
/// @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( | ||
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. Could be good to use |
||
} | ||
|
||
/// @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; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
contracts/erc20-bridge-sampler/contracts/src/DummyLiquidityProviderRegistry.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
pragma solidity ^0.5.9; | ||
pragma experimental ABIEncoderV2; | ||
|
||
|
||
contract DummyLiquidityProviderRegistry | ||
{ | ||
address private constant NULL_ADDRESS = address(0x0); | ||
|
||
mapping (address => mapping (address => address)) internal _gAddressBook; | ||
|
||
/// @dev Sets address of pool for a market given market (xAsset, yAsset). | ||
/// @param xToken First asset managed by pool. | ||
/// @param yToken Second asset managed by pool. | ||
/// @param poolAddress Address of pool. | ||
function setLiquidityProviderForMarket( | ||
address xToken, | ||
address yToken, | ||
address poolAddress | ||
) | ||
external | ||
{ | ||
_gAddressBook[xToken][yToken] = poolAddress; | ||
_gAddressBook[yToken][xToken] = poolAddress; | ||
} | ||
|
||
/// @dev Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist. | ||
/// @param xToken First asset managed by pool. | ||
/// @param yToken Second asset managed by pool. | ||
/// @return Address of pool. | ||
function getLiquidityProviderForMarket( | ||
address xToken, | ||
address yToken | ||
) | ||
external | ||
view | ||
returns (address poolAddress) | ||
{ | ||
poolAddress = _gAddressBook[xToken][yToken]; | ||
require( | ||
poolAddress != NULL_ADDRESS, | ||
"Registry/MARKET_PAIR_NOT_SET" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Verified that this matches the spec ✅