-
Notifications
You must be signed in to change notification settings - Fork 16
feat: paraswap module #3
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
Merged
Merged
Conversation
This file contains hidden or 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
6292922 to
e50407b
Compare
4be0196 to
316acfa
Compare
Contributor
Author
|
Merged |
QGarchery
reviewed
Dec 2, 2024
QGarchery
reviewed
Dec 2, 2024
QGarchery
reviewed
Dec 2, 2024
…raswap-module refactor: move buy morpho debt action to paraswap module
QGarchery
reviewed
Dec 2, 2024
QGarchery
reviewed
Dec 2, 2024
MathisGD
reviewed
Dec 2, 2024
MathisGD
reviewed
Dec 2, 2024
feat: paraswap receiver for dest + skim for source
MathisGD
reviewed
Dec 2, 2024
Co-authored-by: MathisGD <[email protected]> Signed-off-by: Adrien Husson <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
ParaswapModule. It has the following functions:-
buy: buy exact amount & sell up to limit amount-
sell: sell exact amount & buy at least limit amountContext
The Paraswap module calls Paraswap's Augustus contract, which executes the trade. There is a small integration guide here.
Behavior of the Paraswap module
sellfunctionIf the
sellEntireBalanceboolean is true, the sell amount will be adjusted to the current balance of theParaswapModule. TheminDestAmountwill be adjusted accordingly.buyfunctionIf the
loanTokenof themarketParamsparameter is notaddress(0), the buy amount will be adjusted to the current debt of the initiator on this market. ThemaxSrcAmountwill be adjusted accordingly. This is necessary for debt swap and repay with collateral.In-place calldata modification
The Paraswap module calls Augustus with
callData. When the exact sell/buy amounts are adjusted,callDatais modified in-place.Up to 3 values are used by Paraswap:
All 3 values (exact amount, limit amount, and quote amount) are adjusted in
callDatabefore they are sent to Augustus. Their offsets are given by anOffsetsstructs that contains 3 memory offsets (see offsets). Some Paraswap routes do not use a quote amount. In that case, its offset should be 0.Note that:
received >= limit, and take half ofreceived - quoted(the surplus) up to .5% of the quoted amount.received >= exactandquoted <= limit, and take half ofquoted - spent(the surplus) up to .5% of the quoted amount.Tested bundles
The tests simulate constructing and running the following bundles:
2 * collateral to swap2 * initiator collateral