Closed ruuda closed 2 years ago
token-swap
crate as a Cargo dependency.Approve
on the token program to allow some address to modify the token balance, and then one Orca swap, involving that same address.Approve
and Revoke
instruction.archive
branch on github, that seems to have some more information about the code: https://github.com/saber-hq/stable-swap/tree/archive/srcminimum_amount_out
. This is done to avoid high slippage.We need to find the contract data to get the minimum_amount_out
Orca an Mercurial also have this, but I don’t think we need to read the contract data for it. If we set it to a value larger than zero, we should take it as an argument and pass it along. It makes no sense to read the contract state to determine the minimum amount out, because everything will execute in one transaction. No other trades can happen between us reading the state and executing the swap, there can be no slippage. What the minimum_amount_out
is useful for, is when you have the webinterface to do a swap, and you are presented with a tentative exchange rate, which might change before your swap executes. The analog in our case would be somebody calling ClaimRewards
with some idea of what the exchange rate will be.
Considerations:
Orca | Mercurial | Saber | Raydium | |
---|---|---|---|---|
Liquidity | 0 | -1 | +1 | +1 |
Integration | +5 | +6 | +3 | +6 |
Testing | +10 | -10 | 0 | -10 |
Trust | +10 | -10 | +5 | -5 |
Total | 25 | -15 | 9 | -8 |
solana-test-validator
?
Conclusion: We’ll go with Orca.
This was a catch-all tracking issue, but we now have a milestone for the Anchor integration (https://github.com/ChorusOne/solido/milestone/4), with all of the follow-up details, so let’s close this issue.
Background
Integration with Anchor is one of the most requested features. After discussion with the Anchor/Terra team, on a high level it should look like this:
Design
Deposit
andWithdraw
instructions.ClaimRewards
instruction that reads the exchange rate from the Solido state to determine what the excess stSOL is, and then sells it, and sends the rewards to Terra. Proceeds should be in UST.Open questions
How do we sell stSOL? Likely on some AMM that has an stSOL / UST pair. We can create this pair if it doesn’t exist yet. But we need to figure out which AMM is easiest to integrate with programmatically. Ideally it would be one instruction we can call and the swap happens as part of the same transaction.
What do we do with the proceeds ... how do we send them to Terra?
Who calls
ClaimRewards
? A bot would. Let’s not worry right now about who runs it. If needed we could add it to thesolido
maintainer, but would be nice if Anchor can do it.Are there alternatives to waiting for Wormhole? Is there a bridge between Solana and Terra right now?
Next steps
Deposit
andWithdraw
. Let’s put it in this repo so we can reuse a lot of stuff.