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

Merge WithdrawObligationCollateral and RedeemReserveCollateral #14

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

DaSichuan
Copy link

Combines WithdrawObligationCollateral and RedeemReserveCollateral
into a single function

clock,
token_program_id,
)?;

Copy link
Author

Choose a reason for hiding this comment

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

So we don't have to refresh anything here because _withdraw_obligation_collateral requires the reserve to be refreshed, and does not mark it as stale (only reads from it as far as I can tell)

Copy link
Member

Choose a reason for hiding this comment

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

oh hm maybe my flow chart is wrong then

Copy link
Author

Choose a reason for hiding this comment

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

Its not strictly wrong, since it does require a refreshed reserve.
If someone were to do these in separate transactions, you might need to re-refresh it.

Copy link
Member

Choose a reason for hiding this comment

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

i guess it makes sense since removing the collateral doesn't change anything about the deposited liquidity so no interest calculations need to happen

Copy link
Member

@oxrooter oxrooter Jul 13, 2021

Choose a reason for hiding this comment

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

Just got around to checking this, it does seem like it needs to be refreshed?

image
_withdraw_obligation_collateral marks stale

image
_redeem_reserve_collateral checks if stale

EDIT: oops, one's the obligation and the other is the reserve

Copy link
Author

Choose a reason for hiding this comment

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

Thats just the obligation thats getting marked stale right?

Copy link
Member

Choose a reason for hiding this comment

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

ye

Copy link
Member

Choose a reason for hiding this comment

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

Did the frontend PR, works like a charm! https://github.com/solendprotocol/web/pull/114

@DaSichuan DaSichuan merged commit b7f7207 into master Jul 12, 2021
let obligation_info = next_account_info(account_info_iter)?;
let lending_market_info = next_account_info(account_info_iter)?;
let lending_market_authority_info = next_account_info(account_info_iter)?;
let user_liquidity_info = next_account_info(account_info_iter)?;
Copy link
Member

Choose a reason for hiding this comment

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

Should call it destination_liquidity_info to be consistent with how _redeem_reserve_collateral refers to it.

Also for whatever reason, a user may not want to withdraw to themselves. We see this with proxy wallets and gassless txs in Ethereum. Basically the naive way to implement in Solidity is to withdraw to the caller (msg.sender), but for gasless txs the user signs a message that the smart contract verifies, and a relayer submits the tx (so they're the msg.sender). The result is an improved UX where the user signs something but doesn't have to spend the gas, and maybe doesn't even need a web3 wallet like Metamask at all.

Anyway just some Ethereum history.

@nope-finance nope-finance deleted the join_fns branch January 11, 2022 07:55
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.

3 participants