Fujicracy / fuji-v2

Cross-chain money market aggregator
https://fuji-v2-frontend.vercel.app
15 stars 10 forks source link

Borrow: Manage open position #41

Closed iafhurtado closed 1 year ago

iafhurtado commented 1 year ago

Meta

Estimation Time: 5 days

View design >

Todo

How to Retrieve balance of user in a vault ? Use BorrowingVault.getBalances(address). If balance is 0. then the user don't have position -> open position form Else -> manage position form

Others

brozorec commented 1 year ago

@doliG Regarding the requirement "I cannot edit network or token" it's valid only for the token. However, we must dig into what it means to manage an open position from another chain.

An open position is bound to a specific vault on a given chain which means that we can't change the chain of an open position (for now). Keep in mind that there will be options allowing the user to hop from one vault to another, but it will be only possible if both vaults live on the same chain.

We assume the open position is in a vault WETH/USDC on chain X.

  1. Deposit and Borrow 1.1. User does everything on chain X 1.2. User starts from chain A and gets the loan on chain X -> bridge WETH from chain A -> deposit and borrow USDC on chain X 1.3. User starts from chain A and gets the loan on chain B -> bridge WETH from chain A -> deposit and borrow USDC on chain X -> bridge USDC to chain B Note: We are NOT handling this case (3-chains path) in the first iteration!

  2. Only Deposit 2.1. User does everything on chain X 2.2. User starts from chain A -> bridge WETH from chain A -> deposit WETH on chain X

  3. Only Borrow 3.1. User does everything on chain X 3.2. User starts from chain A and gets the loan on chain X -> bridge from chain A -> borrow USDC on chain X 3.3. User starts from chain X and gets the loan on chain A -> borrow USDC on chain X -> bridge to chain A 3.4. User starts from chain A and gets the loan on chain B Note: We are NOT handling this case (3-chains path) in the first iteration!

  4. Payback and Withdraw 4.1. User does everything on chain X 4.2. User starts from chain A and pays back the loan on chain X and withdraw the collateral to chain X -> bridge USDC from chain A -> paybackAndWithdraw on chain X 4.3. User starts from chain A, pays back the loan on chain X and withdraw the collateral to chain A -> bridge USDC from chain A -> paybackAndWithdraw on chain X -> bridge WETH back to chain A 4.4. User starts from chain X, pays back the loan on chain X and withdraw the collateral to chain A -> paybackAndWithdraw on chain X -> bridge WETH back to chain A 4.5. User starts from chain A, pays back the loan on chain X and withdraw the collateral to chain B Note: We are NOT handling this case (3-chains path) in the first iteration!

  5. Only Payback 5.1. User does everything on chain X 5.2. User starts from chain A -> bridge USDC from chain A -> payback on chain X

  6. Only Withdraw 6.1. User does everything on chain X 6.2. User starts from chain A and withdraws on chain X -> bridge from chain A -> withdraw WETH on chain X 6.3. User starts from chain X and withdraws to chain A -> withdraw WETH to chain X -> bridge WETH to chain A 6.4. User starts from chain A and withdraws to chain B Note: We are NOT handling this case (3-chains path) in the first iteration!

Hope I have encompassed all the possible paths :) maybe we can represent all this in a more visual way

ferostabio commented 1 year ago

@brozorec Guillaume closed his PR with the message Cancelled and closed. Store refacto can be found on https://github.com/Fujicracy/fuji-v2/pull/280. I guess the work was outdated and it wasn't worth continuing it. Meaning it needs to be done from scratch on a fresh component instead of separating Borrow into two.

brozorec commented 1 year ago

@ferostar yep, that's correct. As we said, he started implementing it on the same components as the borrow page but we wanted to separate them.

ferostabio commented 1 year ago

After having a look at the Figma designs, and what I think it's doable on the screen, I completely agree with Guillaume's initial idea. Our Borrow component would cover both cases perfectly. I'll be careful abstracting the differences.

ferostabio commented 1 year ago

@brozorec I'm sorry, but I remember you showing something about this in one of our first meetings. Checklist says I can see a button add positon but I think you said something on that part should be gone (I'm guessing add position is just borrow and manage is just for editing an existing one, so nothing to 'add') but I could be completely mistaken -and Figma shows everything, but I remember you telling me something wasn't supposed to be there.

brozorec commented 1 year ago

@ferostar maybe we talked about something else. "Add position" is for deposit and/or borrow, meaning we add up to the position, increasing the collateral and/or the debt. "Remove position" is for payback and/or withdraw.

ferostabio commented 1 year ago

Makes all the sense in the world @brozorec . It was in our first meeting I think when we discussed the following steps, and I know you said something along those lines, but I can't remember what, and it's driving me crazy. Thanks for answering.

brozorec commented 1 year ago

Makes all the sense in the world @brozorec . It was in our first meeting I think when we discussed the following steps, and I know you said something along those lines, but I can't remember what, and it's driving me crazy. Thanks for answering.

Wasn't it about the case that when the user is on the borrow page and they have already an open position in the selected vault, we want to redirect them to manage page?

ferostabio commented 1 year ago

Makes all the sense in the world @brozorec . It was in our first meeting I think when we discussed the following steps, and I know you said something along those lines, but I can't remember what, and it's driving me crazy. Thanks for answering.

Wasn't it about the case that when the user is on the borrow page and they have already an open position in the selected vault, we want to redirect them to manage page?

That wasn't it, it was something related to a component. We'll remember it.

0xdcota commented 1 year ago

Adding here this screen shot of the intended design for quick reference.

Image