-
Notifications
You must be signed in to change notification settings - Fork 465
asset-swapper V3 rebase, pay protocol fees, etc. #2350
asset-swapper V3 rebase, pay protocol fees, etc. #2350
Conversation
c3a4b7e
to
a6a09ef
Compare
} | ||
// TODO(dorothy-zbornak): Handle signature request denied |
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 removed the try/catch
that was here because it was doing nothing. ContractError.SignatureRequestDenied
didn't actually get thrown by contract wrappers, and sendTransactionAsync()
only mines the TX immediately on ganache, so you won't detect a failure on mainnet.
ContractError.SignatureRequestDenied
denied is easy enough to detect, but maybe the logic should live in another package. Detecting a CompleteFillFailed
will have to be accomplished by doing a callAsync()
at the same block - 1 the TX was mined. Let's add tasks for this.
} | ||
// TODO(dorothy-zbornak): Handle signature request denied |
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 removed the try/catch
that was here because it was doing nothing. ContractError.SignatureRequestDenied
didn't actually get thrown by contract wrappers, and sendTransactionAsync()
only mines the TX immediately on ganache, so you won't detect a failure on mainnet.
ContractError.SignatureRequestDenied
denied is easy enough to detect, but maybe the logic should live in another package. Detecting a IncompleteFill
will have to be accomplished by doing a callAsync()
at the same block -1 the TX was mined. Let's add tasks for this.
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, yeah that try-catch was residual from asset-buyer
, I do want to ask though, not very familiar with the nuances of the wrappers, how are errors handled? One of the large feedbacks I received at EthWaterloo was the vague errors thrown, don't want us to make asset-swapper
more opaque with errors.
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.
SignatureRequestDenied
was just running a regex against the thrown error message (by Metamask or w/e).
If the use awaitTransactionSuccessAsync()
instead of sendTransactionAsync()
, it will throw if the TX fails. Then we can use callAsync()
to replay the TX and get the actual rich revert, which gives us deeper detail.
|
||
const ethAmountWithFees = affiliateFeeUtils | ||
.getTotalEthAmountWithAffiliateFee(worstCaseQuoteInfo, feePercentage) | ||
.plus(worstCaseQuoteInfo.protocolFeeInEthAmount); |
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.
Not sure if this is what we want, but here I just add protocol fees to the total payable amount.
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.
getTotalEthAmountWithAffiliateFee
will consider protocol fees since affiliateFee is dependent on protocolFee (as of current forwarder design).
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.
ahh, yeah, that makes sense
// if no ethAmount is provided, default to the worst totalTakerAssetAmount | ||
const ethAmountWithFees = affiliateFeeUtils | ||
.getTotalEthAmountWithAffiliateFee(worstCaseQuoteInfo, feePercentage) | ||
.plus(worstCaseQuoteInfo.protocolFeeInEthAmount); |
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.
ditto
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.
same case, do not need to add protocolFee
methodAbi, | ||
ethAmount: quote.worstCaseQuoteInfo.protocolFeeInEthAmount, |
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.
Added to pay protocol fees.
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.
nice catch, I completely forgot about adding that in.
} else { | ||
throw err; | ||
} | ||
const value = ethAmount || quote.worstCaseQuoteInfo.protocolFeeInEthAmount; |
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.
Added to pay protocol fees.
a6a09ef
to
7ee46f3
Compare
|
const FAKE_ERC20_TAKER_ASSET_DATA = '0xf47261b22222222222222222222222222222222222222222222222222222222222222222'; | ||
const FAKE_ERC20_MAKER_ASSET_DATA = '0xf47261b11111111111111111111111111111111111111111111111111111111111111111'; | ||
|
||
describe('sortingUtils', () => { |
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.
Nice work! Very cleanly communicates / tests the sorting.
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 didn't write like 99% of this PR (it just looks that way because of the rebase), so props to @dave4506
} | ||
|
||
// tslint:disable-next-line: prefer-function-over-method | ||
private _filterForFillableAndPermittedFeeTypeOrders( |
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.
There's a lot going on in this function. Could be good to add some inline comments.
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.
Nice job, it's clear a lot of meticulous work went into this 👏👏👏. I mostly dug into the new logic. I think it looks great - very clear and thoroughly tested.
I skimmed the upgrades to existing logic and from what I can see they make sense. Although it would be good to have a engineer who's more intimately familiar with these packages to read through these areas as well.
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.
Lets MERGEEEEEEEEEEE
554658c
to
362c7c5
Compare
} | ||
// TODO(dorothy-zbornak): Handle signature request denied |
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, yeah that try-catch was residual from asset-buyer
, I do want to ask though, not very familiar with the nuances of the wrappers, how are errors handled? One of the large feedbacks I received at EthWaterloo was the vague errors thrown, don't want us to make asset-swapper
more opaque with errors.
|
||
const ethAmountWithFees = affiliateFeeUtils | ||
.getTotalEthAmountWithAffiliateFee(worstCaseQuoteInfo, feePercentage) | ||
.plus(worstCaseQuoteInfo.protocolFeeInEthAmount); |
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.
getTotalEthAmountWithAffiliateFee
will consider protocol fees since affiliateFee is dependent on protocolFee (as of current forwarder design).
// if no ethAmount is provided, default to the worst totalTakerAssetAmount | ||
const ethAmountWithFees = affiliateFeeUtils | ||
.getTotalEthAmountWithAffiliateFee(worstCaseQuoteInfo, feePercentage) | ||
.plus(worstCaseQuoteInfo.protocolFeeInEthAmount); |
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.
same case, do not need to add protocolFee
Description
development
.@0x/asset-swapper
now pays protocol fees (now that staking gets hooked up during migration).@0x/asset-swapper
removed dependency on@0x/contract-wrappers
.@0x/migrations
now deploysForwarder
AFTER staking is attached to the Exchange.Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.