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

fix write off logic #1511

Merged
merged 6 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ REACT_APP_POOL_CREATION_TYPE=immediate
REACT_APP_RELAY_WSS_URL=wss://fullnode-relay.development.cntrfg.com
REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-development
REACT_APP_SUBSCAN_URL=
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_TINLAKE_NETWORK=mainnet
jpangelle marked this conversation as resolved.
Show resolved Hide resolved
REACT_APP_INFURA_KEY=bf808e7d3d924fbeb74672d9341d0550
REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
Expand Down
84 changes: 41 additions & 43 deletions centrifuge-app/src/pages/Loan/PricingValues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ type Props = {
}

export function PricingValues({ loan: { pricing }, pool }: Props) {
const isOutstandingDebtOrDiscountedCashFlow =
'valuationMethod' in pricing &&
(pricing.valuationMethod === 'outstandingDebt' || pricing.valuationMethod === 'discountedCashFlow')

if ('valuationMethod' in pricing && pricing.valuationMethod === 'oracle') {
const today = new Date()
today.setUTCHours(0, 0, 0, 0)
Expand All @@ -32,49 +36,43 @@ export function PricingValues({ loan: { pricing }, pool }: Props) {
)
}

if (
'valuationMethod' in pricing &&
(pricing.valuationMethod === 'outstandingDebt' || pricing.valuationMethod === 'discountedCashFlow')
)
return (
<>
{pricing.maturityDate && <LabelValueStack label="Maturity date" value={formatDate(pricing.maturityDate)} />}
{pricing.advanceRate && (
<LabelValueStack
label="Advance rate"
value={pricing.advanceRate && formatPercentage(pricing.advanceRate.toPercent())}
/>
)}
return (
<>
{pricing.maturityDate && <LabelValueStack label="Maturity date" value={formatDate(pricing.maturityDate)} />}
{isOutstandingDebtOrDiscountedCashFlow && (
<LabelValueStack
label="Financing fee"
value={pricing.interestRate && formatPercentage(pricing.interestRate.toPercent())}
label="Advance rate"
value={pricing.advanceRate && formatPercentage(pricing.advanceRate.toPercent())}
/>
{pricing.valuationMethod === 'discountedCashFlow' && (
<>
<LabelValueStack
label="Probability of default"
value={pricing.probabilityOfDefault && formatPercentage(pricing.probabilityOfDefault.toPercent())}
/>
<LabelValueStack
label="Loss given default"
value={pricing.lossGivenDefault && formatPercentage(pricing.lossGivenDefault.toPercent())}
/>
<LabelValueStack
label="Expected loss"
value={
pricing.lossGivenDefault &&
pricing.probabilityOfDefault &&
formatPercentage(pricing.lossGivenDefault.toFloat() * pricing.probabilityOfDefault.toFloat() * 100)
}
/>
<LabelValueStack
label="Discount rate"
value={pricing.discountRate && formatPercentage(pricing.discountRate.toPercent())}
/>
</>
)}
</>
)

return null
)}
<LabelValueStack
label="Financing fee"
value={pricing.interestRate && formatPercentage(pricing.interestRate.toPercent())}
/>
{isOutstandingDebtOrDiscountedCashFlow && pricing.valuationMethod === 'discountedCashFlow' && (
<>
<LabelValueStack
label="Probability of default"
value={pricing.probabilityOfDefault && formatPercentage(pricing.probabilityOfDefault.toPercent())}
/>
<LabelValueStack
label="Loss given default"
value={pricing.lossGivenDefault && formatPercentage(pricing.lossGivenDefault.toPercent())}
/>
<LabelValueStack
label="Expected loss"
value={
pricing.lossGivenDefault &&
pricing.probabilityOfDefault &&
formatPercentage(pricing.lossGivenDefault.toFloat() * pricing.probabilityOfDefault.toFloat() * 100)
}
/>
<LabelValueStack
label="Discount rate"
value={pricing.discountRate && formatPercentage(pricing.discountRate.toPercent())}
/>
</>
)}
</>
)
}
4 changes: 2 additions & 2 deletions centrifuge-app/src/pages/Loan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ const Loan: React.FC<{ setShowOraclePricing?: () => void }> = ({ setShowOraclePr
{
label: <Tooltips type={isTinlakePool ? 'riskGroup' : 'collateralValue'} />,
value: isTinlakePool
? 'riskGroup' in loan
: 'value' in loan.pricing
? 'riskGroup' in loan && loan.riskGroup
: 'value' in loan.pricing && loan.pricing.value
? formatBalance(loan.pricing.value, pool?.currency.symbol)
: 'TBD',
},
Expand Down
Loading
Loading