Skip to content

Commit

Permalink
implement oracle-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
JP Angelle committed Aug 31, 2023
1 parent bc4a9d3 commit 5dfb4bd
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 245 deletions.
41 changes: 23 additions & 18 deletions centrifuge-app/src/components/PageSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,32 @@ type Props = {
value: React.ReactNode
}[]
children?: React.ReactNode
title?: React.ReactNode
}

export const PageSummary: React.FC<Props> = ({ data, children }) => {
export const PageSummary: React.FC<Props> = ({ data, children, title }) => {
const theme = useTheme()
return (
<Shelf
bg={theme.colors.backgroundSecondary}
gap="6"
pl={[2, 6]}
py="3"
style={{
boxShadow: `0 1px 0 ${theme.colors.borderSecondary}`,
}}
>
{data?.map(({ label, value }, index) => (
<Stack gap="4px" key={`${value}-${label}-${index}`}>
<Text variant="body3">{label}</Text>
<Text variant="heading3">{value}</Text>
</Stack>
))}
{children}
</Shelf>
<Stack bg={theme.colors.backgroundSecondary} pl={3}>
{title}
<Shelf
gap="6"
pl={4}
py="3"
style={{
boxShadow: `0 1px 0 ${theme.colors.borderSecondary}`,
}}
>
{data?.map(({ label, value }, index) => (
<Stack gap="4px" key={`${value}-${label}-${index}`}>
<Text variant="body3" style={{ fontWeight: 500 }}>
{label}
</Text>
<Text variant="body2">{value}</Text>
</Stack>
))}
{children}
</Shelf>
</Stack>
)
}
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Report/AssetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const headers = [
'Total repaid',
'Financing date',
'Maturity date',
'Financing fee',
'Interest rate',
'Advance rate',
'PD',
'LGD',
Expand Down
24 changes: 18 additions & 6 deletions centrifuge-app/src/components/Tooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export const tooltipText = {
label: 'Ongoing assets',
body: 'Number of assets currently being financed in the pool and awaiting repayment.',
},
averageFinancingFee: {
label: 'Average financing fee',
body: 'The average financing fee of the active assets in the pool.',
averageInterestRate: {
label: 'Average interest rate',
body: 'The average interest rate of the active assets in the pool.',
},
averageAmount: {
label: 'Average amount',
Expand Down Expand Up @@ -134,9 +134,9 @@ export const tooltipText = {
label: 'Advance rate',
body: 'The advance rate is the percentage amount of the value of the collateral that an issuer can borrow from the pool against the NFT representing the collateral.',
},
financingFee: {
label: 'Financing fee',
body: 'The financing fee is the rate at which the outstanding amount of an individual financing accrues interest. It is expressed as an "APR" (Annual Percentage Rate) and compounds interest every second.',
interestRate: {
label: 'Interest Rate',
body: 'The interest rate is the rate at which the outstanding amount of an individual financing accrues interest. It is expressed as an APR (Annual Percentage Rate) and compounds every second.',
},
probabilityOfDefault: {
label: 'Prob of default',
Expand Down Expand Up @@ -242,6 +242,18 @@ export const tooltipText = {
label: 'Extension period',
body: 'Number of days the maturity can be extended without restrictions.',
},
maxPriceVariation: {
label: 'Max price variation',
body: 'The maximum price variation defines the price difference between settlement and oracle price.',
},
isin: {
label: 'ISIN',
body: 'An International Securities Identification Number (ISIN) is a code that uniquely identifies a security globally for the purposes of facilitating clearing, reporting and settlement of trades.',
},
notionalValue: {
label: 'Notional value',
body: 'The notional value is the total value of the underlying asset.',
},
}

export type TooltipsProps = {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/pages/IssuerCreatePool/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {
imageFile,
integer,
isin,
maturityDate,
max,
maxDecimals,
maxFileSize,
maxImageSize,
maxLength,
mimeType,
min,
minLength,
nonNegativeNumber,
pattern,
Expand Down Expand Up @@ -49,6 +51,8 @@ export const validate = {
minInvestment: combine(required(), nonNegativeNumber(), max(Number.MAX_SAFE_INTEGER)),
interestRate: combine(required(), positiveNumber(), max(Number.MAX_SAFE_INTEGER)),
minRiskBuffer: combine(required(), positiveNumber(), max(100)),
maxPriceVariation: combine(required(), min(0), max(10000)),
maturityDate: combine(required(), maturityDate()),

// risk groups
groupName: maxLength(30),
Expand Down
38 changes: 15 additions & 23 deletions centrifuge-app/src/pages/IssuerPool/Assets/PricingInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,9 @@ export function PricingInput({ poolId }: { poolId: string }) {
</Field>
{values.pricing.valuationMethod === 'oracle' && (
<>
{/* <FieldWithErrorMessage
as={NumberInput}
label={<Tooltips type="financingFee" variant="secondary" label="Max quantity*" />}
placeholder="0"
name="pricing.maxBorrowQuantity"
validate={validate.maxBorrowQuantity}
/> */}
<FieldWithErrorMessage
as={TextInput}
label={<Tooltips type="financingFee" variant="secondary" label="ISIN*" />}
label={<Tooltips type="isin" variant="secondary" label="ISIN*" />}
placeholder="010101010000"
name="pricing.Isin"
validate={validate.Isin}
Expand All @@ -48,10 +41,9 @@ export function PricingInput({ poolId }: { poolId: string }) {
{({ field, meta, form }: FieldProps) => (
<CurrencyInput
{...field}
label="Notional*"
label={<Tooltips type="notionalValue" variant="secondary" label="Notional value*" />}
placeholder="0.00"
errorMessage={meta.touched ? meta.error : undefined}
currency={pool?.currency.symbol}
onChange={(value) => form.setFieldValue('pricing.notional', value)}
variant="small"
/>
Expand Down Expand Up @@ -94,9 +86,17 @@ export function PricingInput({ poolId }: { poolId: string }) {
</Field>
</>
)}
<FieldWithErrorMessage
as={NumberInput}
label={<Tooltips type="interestRate" variant="secondary" label="Interest rate*" />}
placeholder="0.00"
rightElement="%"
name="pricing.interestRate"
validate={validate.interestRate}
/>
<FieldWithErrorMessage
as={DateInput}
validate={required()}
validate={validate.maturityDate}
name="pricing.maturityDate"
label="Maturity date*"
type="date"
Expand All @@ -107,21 +107,13 @@ export function PricingInput({ poolId }: { poolId: string }) {
/>
<FieldWithErrorMessage
as={NumberInput}
label={<Tooltips type="maturityExtensionDays" variant="secondary" label="Extension period*" />}
label={<Tooltips type="maxPriceVariation" variant="secondary" label="Max price variation*" />}
placeholder={0}
rightElement="days"
name="pricing.maturityExtensionDays"
validate={validate.maturityExtensionDays}
/>

<FieldWithErrorMessage
as={NumberInput}
label={<Tooltips type="financingFee" variant="secondary" label="Financing fee*" />}
placeholder="0.00"
rightElement="%"
name="pricing.interestRate"
validate={validate.fee}
name="pricing.maxPriceVariation"
validate={validate.maxPriceVariation}
/>

{(values.pricing.valuationMethod === 'discountedCashFlow' ||
values.pricing.valuationMethod === 'outstandingDebt') && (
<>
Expand Down
Loading

0 comments on commit 5dfb4bd

Please sign in to comment.