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.
This PR is set to close #154. I am reaching out to @Alexangelj and @clemlak since you two are the Solidity gurus 🙂
At the moment, I have scaffolded out a test in
crates/simulate/src/exchange.rs
calledtest_swap_from_x_liquid_exchange
that will swaptoken_x
fortoken_y
. The goal is to have theliquid_exchange.sol
announce a price that only some permissioned agent (e.g., theadmin
agent) can set manually. The liquid exchange can then take in any amount oftoken_x
ortoken_y
and give back the correct amount of the other asset based on the listed price. This, in my mind, requires either some kind of "bank" that holds a large amount oftoken_x
andtoken_y
or it requires active minting and burning. I don't have a preference on which we use, but we should keep track of this accounting somehow.I had issues with allowances not being properly set. Upon calling the
swap
function, I was getting aRevert
result due to unset allowances. This is just not familiar to me, to be honest.Furthermore, I have not gotten the fixed point math set up properly with token decimals whatsoever.
I was also building the test
test_swap_from_x_liquid_exchange
prior to PR #179 so there are some changes to make in this as well.manager
no longer deploys and calls, that is now passed to theadmin
agent. You can see other tests insimulate/lib.rs
for examples. Also, it would be good to write atest_swap_from_y_liquid_exchange
test as well.Please comment if you have questions!
Here is the PR on Arbmod.