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

Asset finance repay redesign #2282

Merged
merged 110 commits into from
Aug 12, 2024
Merged

Conversation

sophialittlejohn
Copy link
Collaborator

@sophialittlejohn sophialittlejohn commented Jul 15, 2024

Description

This PR redesigns finance/repay flow by integratung transfer debt into finance and repay forms.

#2269

Form variations

Internal non cash assets

Finance

  1. source = reserve
  2. source = cash asset

Repay

  1. destination = reserve
  2. destination = cash asset

External oracle assets

Purchase (Finance)

  1. source = reserve
  2. source = cash asset

Sell (Repay)

  1. destination = reserve
  2. destination = cash asset

Cash assets

Deposit (Finance)

  1. source = reserve
  2. source = cash asset
  3. source = other

Withdraw (Repay)

  1. destination = reserve
  2. destination = cash
  3. destination = other

Approvals

  • Dev

Screenshots

Impact

Copy link

github-actions bot commented Jul 15, 2024

PR deployed in Google Cloud
URL: https://pr2282-app-ff-production.k-f.dev
Commit #: ec4306a
To access the functions directly check the corresponding deploy Action

Copy link

github-actions bot commented Jul 15, 2024

PR deployed in Google Cloud
URL: https://app-pr2282.k-f.dev
Commit #: ec4306a
To access the functions directly check the corresponding deploy Action

@sophialittlejohn sophialittlejohn marked this pull request as ready for review August 7, 2024 14:29
sophialittlejohn and others added 6 commits August 7, 2024 12:32
* Fix max quantity and principal

* Update repay boxes

* Update external repay form

* Update finance forms

* Error handling

* Transaction summary

* Add principal amount

* Update principal

* Use ids from dropdown

* Fix asset list report values

* Onchain reserve name

* Update type

* Fix another type

* Change gap
let feeTx = api.tx.poolFees.chargeFee(fee.id, feeAmount.toString())
return cent.remark
.remark([[{ Loan: [poolId, loanId] }], feeTx], { batch: true })
.pipe(switchMap((tx) => [wrapProxyCallsForAccount(api, tx, borrower, 'Borrow')]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

can just be a map (without returning as an array, I guess)

totalRepay,
principalAmount,
}
}, [loan, balance, repayForm.values])
Copy link
Collaborator

Choose a reason for hiding this comment

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

lint warning about the memo. also useMemo is probably overkill here

} else if (destination === 'other') {
if (!repayForm.values.category) throw new Error('No category selected')
const decreaseDebtTx = api.tx.loans.decreaseDebt(pool.id, loan.id, { internal: principal })
const categoryHex = Buffer.from(repayForm.values.category).toString('hex')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Buffer is only incidentally available now because we have it polyfilled because of a dependency. Still would rather not rely on it

maxInterest,
totalRepay,
}
}, [loan, balance, repayForm.values])
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

positiveNumber(),
max(balance.toNumber(), 'Amount exceeds balance'),
max(debt.toNumber(), 'Amount exceeds outstanding')
nonNegativeNumberNotRequired(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the original positiveNumber etc. functions were wrong then, if they made the value implicitly required. if the value is required it should be combine(positiveNumber(), required()) to signal it better. Maybe not essential to fix now, but should probably change that sometime

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I think so too, I didn't want to break every other form on this PR and we're handling errors in the form a bit differently. Will keep in mind for a future refactor

@sophialittlejohn sophialittlejohn merged commit 8c38ff8 into main Aug 12, 2024
14 checks passed
@sophialittlejohn sophialittlejohn deleted the asset-finance-repay-redesign branch August 12, 2024 19:12
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