-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map swap-related transfers #1691
Conversation
Pull Request Test Coverage Report for Build 9662861262Details
💛 - Coveralls |
if (this.isSwapsDecodingEnabled && this.isTwapsDecodingEnabled) { | ||
// If the transaction is a swap-based transfer, we return it immediately | ||
const swapTransfer = | ||
await this.swapTransferInfoMapper.mapSwapTransferInfo({ | ||
sender, | ||
recipient, | ||
direction, | ||
transferInfo, | ||
chainId, | ||
safeAddress: safe.address, | ||
domainTransfer, | ||
}); | ||
|
||
if (swapTransfer) { | ||
return swapTransfer; | ||
} | ||
} | ||
|
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 way (provided the FFs are enabled), there is always a try to map the transfer as a SwapTransferTransactionInfo
.
Alternatively, we could expose an isSwapTransferInfo
method so we can integrate the matching/mapping logic into getTransferByType
. That way we could check if the transfer is actually a SwapTransferTransactionInfo
and then call mapSwapTransferInfo
inside getTransferByType
as we do to map the rest of the transfer types. Wdyt?
In terms of performance, it wouldn't improve the situation much, as mapSwapTransferInfo
already early returns null
if the conditions don't match, but in terms of readability, I think it could make the class API a bit clearer.
Pull Request Test Coverage Report for Build 9684668354Details
💛 - Coveralls |
.with('buyToken', token.address) | ||
.with('executedBuyAmount', BigInt(domainTransfer.value)) |
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.
In these tests, I've just adjusted the Order
payloads to match the logic implemented in SwapTransferInfoMapper.findOrderByTransfer
not to filter out the order, i.e.: executedBuyAmount
needs to match the transfer value, and buyToken
address needs to match the token address. I'm assuming this logic is correct. cc. @iamacook @compojoom
Summary
Incoming/outgoing transfers also cover
transferFrom
transactions. Swaps execute such transfers to/from the GPv2Settlement contract. Currently the decoding of these transactions are "standard".This maps the relative order information to swap-related transfers if the sender/recipient address is the GPv2Settlement contract.
Changes
The following are predominantly code migrations of existing code as transfer mapping was assumed to happen with the
TransactionInfoMapper
, whereas it should in theTransferInfoMapper
:SwapTransferTransactionInfo
SwapTransferHelper
SwapTransferInfoMapper
and include it inTransferInfoMapper