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

Feat: enable vault withdraw all collateral #727

Merged
merged 7 commits into from
Mar 5, 2024
Merged

Feat: enable vault withdraw all collateral #727

merged 7 commits into from
Mar 5, 2024

Conversation

bvotteler
Copy link
Contributor

@bvotteler bvotteler commented Feb 23, 2024

Resolves #725

Added new endpoints to easier withdraw all collateral for vaults.

Note: Tested manually.
No integration test case sadly, because all the spun up and funded vaults end up with some tokens issued or to-be-issued left over from previous non-idempotent test cases.

@bvotteler bvotteler requested review from sander2 and nakul1010 March 4, 2024 03:47
@bvotteler bvotteler marked this pull request as ready for review March 4, 2024 03:47
Copy link
Member

@sander2 sander2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Would it be useful to provide a canWithdrawAll or something for the UI? Or can UI easily detect that already?

@sander2
Copy link
Member

sander2 commented Mar 4, 2024

No integration test case sadly, because all the spun up and funded vaults end up with some tokens issued or to-be-issued left over from previous non-idempotent test cases.
Could you not do a selfredeem? (there is a special tx for selfredeem that doesn't involve any btc payments)

@bvotteler
Copy link
Contributor Author

bvotteler commented Mar 4, 2024

Could you not do a selfredeem? (there is a special tx for selfredeem that doesn't involve any btc payments)

I tried a few angles with the existing test redeem utility code but had no luck. Or at least it didn't settle immediately.
I can give self redeem a try, I'd expect that requires the vault to get enough tokens issued from somewhere else, right?

@bvotteler
Copy link
Contributor Author

lgtm. Would it be useful to provide a canWithdrawAll or something for the UI? Or can UI easily detect that already?

There are a few methods that should do the trick already. The two first that come to mind are:

  1. vaultsAPI.getVaultCollateralization() (link) returns undefined if no tokens have been issued, or
  2. Fetch vault by account id and collateral currency to get a VaultExt instance, then query for backed tokens which includes both issued and to-be-issued tokens:
const vaultExt = await vaultsApi.get(vaultAccountId, collateralCurrency));
const issuedAmount = vaultExt.getBackedTokens(); // includes to-be-issued

(Link to signature for get, and link to getBackedTokens)

@sander2
Copy link
Member

sander2 commented Mar 4, 2024

Could you not do a selfredeem? (there is a special tx for selfredeem that doesn't involve any btc payments)

I tried a few angles with the existing test redeem utility code but had no luck. Or at least it didn't settle immediately. I can give self redeem a try, I'd expect that requires the vault to get enough tokens issued from somewhere else, right?

Yea that's right (but u could just sudo-mint some if you don't mind some state inconsistencies)

@bvotteler
Copy link
Contributor Author

Could you not do a selfredeem? (there is a special tx for selfredeem that doesn't involve any btc payments)

I tried a few angles with the existing test redeem utility code but had no luck. Or at least it didn't settle immediately. I can give self redeem a try, I'd expect that requires the vault to get enough tokens issued from somewhere else, right?

Yea that's right (but u could just sudo-mint some if you don't mind some state inconsistencies)

Thanks for the self redeem tip!
That helped in adding a test: commit 252682f

@bvotteler bvotteler merged commit 7747549 into interlay:master Mar 5, 2024
2 checks passed
@bvotteler bvotteler deleted the feat-enable-vault-withdraw-all-collateral branch March 5, 2024 04:27
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

Successfully merging this pull request may close these issues.

Enable all collateral to be withdrawn
2 participants