-
Notifications
You must be signed in to change notification settings - Fork 466
Conversation
f8b7572
to
895ab73
Compare
d9a37c9
to
45c88d2
Compare
returns (uint256[] memory takerTokenAmounts) | ||
{ | ||
if (curveInfo.buyQuoteFunctionSelector == bytes4(0)) { | ||
// Buys not supported on this curve, so approximate it. |
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 native buy quoting on the BTC curves.
{ | ||
struct CurveBridgeData { | ||
address curveAddress; | ||
bytes4 exchangeFunctionSelector; |
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.
BTC curves just use exchange()
instead of exchange_underlying()
.
512b87a
to
a15a014
Compare
{ | ||
struct CurveBridgeData { | ||
address curveAddress; | ||
bytes4 exchangeFunctionSelector; | ||
address fromTokenAddress; |
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.
Easier than figuring out whether to call underlying_coins()
or just coins()
.
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.
saves an SLOAD too
// '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', | ||
// '0xdac17f958d2ee523a2206206994597c13d831ec7', | ||
// ], | ||
// }, |
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.
I was trying to use these in CurveBridge integration tests and they kept reverting when going USDC->DAI no matter what I did. Looking at etherscan they look pretty dead?
@@ -34,10 +34,6 @@ blockchainTests('erc20-bridge-sampler', env => { | |||
const MAKER_TOKEN = randomAddress(); | |||
const TAKER_TOKEN = randomAddress(); | |||
let devUtilsAddress: string; | |||
const FAKE_BUY_OPTS = { |
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.
We no longer pass these opts into the sampler contract. They're hardcoded instead.
9d999f2
to
72f4ab1
Compare
'0x0000000000085d4780b73119b644ae5ecd22b376', | ||
], | ||
}, | ||
// Looks like it's dying. |
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.
Doesn't it?
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.
ya I'd be fine with culling the old Curves with low liquidity now
fromTokenIdx: number; | ||
toTokenIdx: number; | ||
curve: CurveInfo; |
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.
This will impact FeeSchedule
generation code in API.
// exchangeFunctionSelector: CurveFunctionSelectors.exchange_underlying, | ||
// sellQuoteFunctionSelector: CurveFunctionSelectors.get_dy_underlying, | ||
// buyQuoteFunctionSelector: CurveFunctionSelectors.get_dx_underlying, | ||
// poolAddress: '0xa2b47e3d5c44877cca798226b7b8118f9bfb7a56', |
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.
Hmm, seems like some activity today.
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.
mm I think this one might stick around tbh, it's the only Compound based Curve iirc. They ebb and flow with the DeFi tides.
600k here still?
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.
OK. Got the tests working again (I guess forking doesn't play nice with resets
) so apparently these bridges do still work.
72f4ab1
to
7e2065f
Compare
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.
THANK YOU for this refactor holy shit the sampler was out of control
{ | ||
struct CurveBridgeData { | ||
address curveAddress; | ||
bytes4 exchangeFunctionSelector; | ||
address fromTokenAddress; |
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.
saves an SLOAD too
'0x0000000000085d4780b73119b644ae5ecd22b376', | ||
], | ||
}, | ||
// Looks like it's dying. |
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.
ya I'd be fine with culling the old Curves with low liquidity now
contracts/erc20-bridge-sampler/contracts/src/ERC20BridgeSampler.sol
Outdated
Show resolved
Hide resolved
contracts/erc20-bridge-sampler/contracts/src/ApproximateBuys.sol
Outdated
Show resolved
Hide resolved
contracts/erc20-bridge-sampler/contracts/src/UniswapSampler.sol
Outdated
Show resolved
Hide resolved
…ied curves. `@0x/contracts-erc20-bridge-sampler`: Refactor. `@0x/contracts-erc20-bridge-sampler`: Add support for more varied curves. `@0x/contracts-integrations`: Update curve bridge tests.
bb64233
to
2d29014
Compare
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.
You're an absolute beast! What a piece of art this is!
High level the changes look great. Shall we deploy the Bridge and give it a run through the simbot?
// exchangeFunctionSelector: CurveFunctionSelectors.exchange_underlying, | ||
// sellQuoteFunctionSelector: CurveFunctionSelectors.get_dy_underlying, | ||
// buyQuoteFunctionSelector: CurveFunctionSelectors.get_dx_underlying, | ||
// poolAddress: '0xa2b47e3d5c44877cca798226b7b8118f9bfb7a56', |
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.
mm I think this one might stick around tbh, it's the only Compound based Curve iirc. They ebb and flow with the DeFi tides.
600k here still?
All my sims have already been using this bridge contract. |
Description
This adds support for the BTC curves:
0x93054188d876f558f4a66b2ef1d97d16edf0895b
and0x7fc77b5c7614e1533320ea6ddc2eb61fa00a9714
. Things to note:get_dy()
andexchange()
directly. Previously we always usedget_dy_underlying()
andexchange_underlying()
.CurveBridge
andERC20BridgeSampler
had to be updated to allow passing in which functions get called (by selector).get_dx()
function, so buy support must be approximated similar to how we do for Kyber. This motivated a big refactor of the sampler.CurveFillData
has aCurveInfo
object. This impacts the code in 0x-API that generates gas/fee schedules.TODO:
CurveBridge
.Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.