Skip to content
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

What does the "fromAmountOffset" stand for? #4

Closed
huseyin-donmez opened this issue Feb 6, 2022 · 3 comments
Closed

What does the "fromAmountOffset" stand for? #4

huseyin-donmez opened this issue Feb 6, 2022 · 3 comments

Comments

@huseyin-donmez
Copy link

What does the "fromAmountOffset" stand for? When I look at the augustusFromAmountOffsetFromCalldata from ../src/augustus, I saw the values. But what does all that mean? and why there are values just for "swapOnUniswap", "multiSwap" and others. I mean don't "simpleSwap" need that?
Thanks.

@ColonelJ
Copy link
Contributor

ColonelJ commented Feb 6, 2022

It is the offset of the fromAmount parameter in the calldata to the AugustusSwapper method. It is used in ParaSwapLiquiditySwapAdapter only when you want to swap the entire aToken balance (otherwise set to 0). Since you don't know the balance in advance (it is constantly earning interest) this value needs to be modified by the smart contract within the transaction, and that's why it needs to know the offset, so that the data can be inserted at the right location, before performing the swap. The simpleSwap method does not support this use case, since it hardcodes the parameters to external contract calls, so that is why the offset for that is not included, and also why the simpleSwap method is excluded in all the swapAll test scripts when using ParaSwap SDK (but if not doing swap all balance, it is fine to use simpleSwap).

@huseyin-donmez
Copy link
Author

Thanks for replying,
I got it properly. so to do a swap, I need to have aToken which is swapFrom an asset in liquidity pool to use Paraswap Adapter. I just want to swap with flashloan. When I saw this contract in Aave adapter folder in github repo I suppose that this contract receives the flashloan then swaps the amount with paraswap and then deposits the srcAmount. I understand it's not like that now. So is there a way to do that? I think I can do that with my contract using BaseParaSwapAdapter. but I just want to ask can I use ParaswapLiquiditySwap contract to just swap?

@ColonelJ
Copy link
Contributor

ColonelJ commented Feb 7, 2022

I'm not sure exactly what you're trying to do, you might find it better to write your own smart contract that fits whatever use case you have in mind (you need to pay back the flashloan somehow). This is specifically for swapping aTokens for other aTokens, and the flashloan lets you swap when you don't have enough collateral, paying off the loan using the old collateral.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants