Skip to content

Commit

Permalink
fix supply redirect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shan57blocks committed Jan 25, 2024
1 parent daf2965 commit db4abd9
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 56 deletions.
34 changes: 31 additions & 3 deletions packages/huma-shared/src/v2/metadata/humaTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChainEnum } from '../../utils/chain'
import { POOL_NAME, POOL_TYPE } from '../../utils/pool'
import { FirstLossCoverIndex } from '../types'
import { PoolsInfoV2 } from '../utils'
import { KYC_PROVIDER, PoolsInfoV2 } from '../utils'

export const HUMA_TESTNET_METADATA: PoolsInfoV2 = {
JiaV2: {
Expand All @@ -27,7 +27,35 @@ export const HUMA_TESTNET_METADATA: PoolsInfoV2 = {
juniorAPY: '10-20%',
title: 'Jia V2 Testing Pool',
desc: 'Jia brings real-world asset returns to crypto investors while tackling the multi-trillion-dollar credit gap in emerging markets. By providing blockchain-based financing to small businesses and rewarding borrowers who repay with ownership, Jia enables them to create wealth and prosperity for themselves and their communities.',
supplyLink: 'https://app.huma.finance',
KYC: {
provider: KYC_PROVIDER.Securitize,
signInRequired: {
title: 'Sign In',
description:
'Please sign in to verify that you are the owner of the wallet.',
},
verifyIdentity: {
title: 'Verify Identity',
description: `This pool is only available to accredited investors at the moment, with minimum investments of $10,000. Please complete identity verification and investor accreditation via ${KYC_PROVIDER.Securitize}.`,
buttonText: 'VERIFY MY IDENTITY',
},
emailSignatureLink: {
title: 'Pool Documents',
description: `By lending to this pool, you become a subscriber member of the Jia Pioneer Fund LLC. Please sign the LLC Agreement via DocuSign, securing your off-chain claim to the Fund's returns and collateral.`,
buttonText: 'EMAIL DOCUSIGN LINK',
},
resendSignatureLink: {
title: 'Resend Documents',
description: `Please check your inbox for the LLC Agreement sent via DocuSign. If you haven't received it, check your spam folder or click below to resend.`,
buttonText: 'RESEND DOCUSIGN LINK',
},
docUnderReview: {
title: 'Under Review',
description:
'Your documents are being reviewed and you will be notified upon approval. Thank you for your patience. Any questions? Email [email protected].',
buttonText: 'THANK YOU',
},
},
},
ArfCreditPoolV2: {
chainId: ChainEnum.HumaTestnet,
Expand All @@ -52,6 +80,6 @@ export const HUMA_TESTNET_METADATA: PoolsInfoV2 = {
juniorAPY: '10-20%',
title: 'Arf V2 Testing Pool',
desc: 'Arf provides an innovative on-chain liquidity solution that simplifies cross-border payments by facilitating immediate USDC-based settlements and tokenizing payment orders, enhancing transparency in the process.',
supplyLink: 'https://app.huma.finance',
supplyLink: 'https://uer4clyybno.typeform.com/arfcreditline',
},
}
34 changes: 31 additions & 3 deletions packages/huma-shared/src/v2/metadata/localhost.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChainEnum } from '../../utils/chain'
import { POOL_NAME, POOL_TYPE } from '../../utils/pool'
import { FirstLossCoverIndex } from '../types'
import { PoolsInfoV2 } from '../utils'
import { KYC_PROVIDER, PoolsInfoV2 } from '../utils'

export const LOCALHOST_METADATA: PoolsInfoV2 = {
JiaV2: {
Expand All @@ -27,7 +27,35 @@ export const LOCALHOST_METADATA: PoolsInfoV2 = {
juniorAPY: '10-20%',
title: 'Jia V2 Testing Pool',
desc: 'Jia brings real-world asset returns to crypto investors while tackling the multi-trillion-dollar credit gap in emerging markets. By providing blockchain-based financing to small businesses and rewarding borrowers who repay with ownership, Jia enables them to create wealth and prosperity for themselves and their communities.',
supplyLink: 'https://app.huma.finance',
KYC: {
provider: KYC_PROVIDER.Securitize,
signInRequired: {
title: 'Sign In',
description:
'Please sign in to verify that you are the owner of the wallet.',
},
verifyIdentity: {
title: 'Verify Identity',
description: `This pool is only available to accredited investors at the moment, with minimum investments of $10,000. Please complete identity verification and investor accreditation via ${KYC_PROVIDER.Securitize}.`,
buttonText: 'VERIFY MY IDENTITY',
},
emailSignatureLink: {
title: 'Pool Documents',
description: `By lending to this pool, you become a subscriber member of the Jia Pioneer Fund LLC. Please sign the LLC Agreement via DocuSign, securing your off-chain claim to the Fund's returns and collateral.`,
buttonText: 'EMAIL DOCUSIGN LINK',
},
resendSignatureLink: {
title: 'Resend Documents',
description: `Please check your inbox for the LLC Agreement sent via DocuSign. If you haven't received it, check your spam folder or click below to resend.`,
buttonText: 'RESEND DOCUSIGN LINK',
},
docUnderReview: {
title: 'Under Review',
description:
'Your documents are being reviewed and you will be notified upon approval. Thank you for your patience. Any questions? Email [email protected].',
buttonText: 'THANK YOU',
},
},
},
ArfCreditPoolV2: {
chainId: ChainEnum.Localhost,
Expand All @@ -52,6 +80,6 @@ export const LOCALHOST_METADATA: PoolsInfoV2 = {
juniorAPY: '10-20%',
title: 'Arf V2 Testing Pool',
desc: 'Arf provides an innovative on-chain liquidity solution that simplifies cross-border payments by facilitating immediate USDC-based settlements and tokenizing payment orders, enhancing transparency in the process.',
supplyLink: 'https://app.huma.finance',
supplyLink: 'https://uer4clyybno.typeform.com/arfcreditline',
},
}
34 changes: 31 additions & 3 deletions packages/huma-shared/src/v2/metadata/mumbai.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChainEnum } from '../../utils/chain'
import { POOL_NAME, POOL_TYPE } from '../../utils/pool'
import { FirstLossCoverIndex } from '../types'
import { PoolsInfoV2 } from '../utils'
import { KYC_PROVIDER, PoolsInfoV2 } from '../utils'

export const MUMBAI_METADATA: PoolsInfoV2 = {
JiaV2: {
Expand All @@ -27,7 +27,35 @@ export const MUMBAI_METADATA: PoolsInfoV2 = {
juniorAPY: '10-20%',
title: 'Jia V2 Testing Pool',
desc: 'Jia brings real-world asset returns to crypto investors while tackling the multi-trillion-dollar credit gap in emerging markets. By providing blockchain-based financing to small businesses and rewarding borrowers who repay with ownership, Jia enables them to create wealth and prosperity for themselves and their communities.',
supplyLink: 'https://app.huma.finance',
KYC: {
provider: KYC_PROVIDER.Securitize,
signInRequired: {
title: 'Sign In',
description:
'Please sign in to verify that you are the owner of the wallet.',
},
verifyIdentity: {
title: 'Verify Identity',
description: `This pool is only available to accredited investors at the moment, with minimum investments of $10,000. Please complete identity verification and investor accreditation via ${KYC_PROVIDER.Securitize}.`,
buttonText: 'VERIFY MY IDENTITY',
},
emailSignatureLink: {
title: 'Pool Documents',
description: `By lending to this pool, you become a subscriber member of the Jia Pioneer Fund LLC. Please sign the LLC Agreement via DocuSign, securing your off-chain claim to the Fund's returns and collateral.`,
buttonText: 'EMAIL DOCUSIGN LINK',
},
resendSignatureLink: {
title: 'Resend Documents',
description: `Please check your inbox for the LLC Agreement sent via DocuSign. If you haven't received it, check your spam folder or click below to resend.`,
buttonText: 'RESEND DOCUSIGN LINK',
},
docUnderReview: {
title: 'Under Review',
description:
'Your documents are being reviewed and you will be notified upon approval. Thank you for your patience. Any questions? Email [email protected].',
buttonText: 'THANK YOU',
},
},
},
ArfCreditPoolV2: {
chainId: ChainEnum.Mumbai,
Expand All @@ -52,6 +80,6 @@ export const MUMBAI_METADATA: PoolsInfoV2 = {
juniorAPY: '10-20%',
title: 'Arf V2 Testing Pool',
desc: 'Arf provides an innovative on-chain liquidity solution that simplifies cross-border payments by facilitating immediate USDC-based settlements and tokenizing payment orders, enhancing transparency in the process.',
supplyLink: 'https://app.huma.finance',
supplyLink: 'https://uer4clyybno.typeform.com/arfcreditline',
},
}
4 changes: 4 additions & 0 deletions packages/huma-shared/src/v2/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { BigNumber } from 'ethers'

export const BP_FACTOR = BigNumber.from(10000)

export enum KYC_PROVIDER {
Securitize = 'Securitize',
}

export enum CreditStateV2 {
Deleted,
Paused,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
openInNewTab,
PoolInfoV2,
TrancheType,
UnderlyingTokenInfo,
useLenderApprovedV2,
} from '@huma-finance/shared'
import { TrancheType, UnderlyingTokenInfo } from '@huma-finance/shared'
import {
css,
FormControl,
Expand All @@ -14,47 +8,27 @@ import {
RadioGroup,
useTheme,
} from '@mui/material'
import { useWeb3React } from '@web3-react/core'
import React from 'react'

import { useAppDispatch } from '../../../hooks/useRedux'
import { setStep } from '../../../store/widgets.reducers'
import { WIDGET_STEP } from '../../../store/widgets.store'
import { BottomButton } from '../../BottomButton'
import { WrapperModal } from '../../WrapperModal'
import { LoadingModal } from '../../LoadingModal'

type Props = {
poolInfo: PoolInfoV2
poolUnderlyingToken: UnderlyingTokenInfo
selectedTranche: TrancheType | undefined
changeTranche: (tranche: TrancheType) => void
}

export function ChooseTranche({
poolInfo,
poolUnderlyingToken,
selectedTranche,
changeTranche,
}: Props): React.ReactElement | null {
const theme = useTheme()
const { poolName } = poolInfo
const dispatch = useAppDispatch()
const { account, provider } = useWeb3React()
const [lenderApprovedSenior] = useLenderApprovedV2(
poolName,
'senior',
account,
provider,
)
const [lenderApprovedJunior] = useLenderApprovedV2(
poolName,
'junior',
account,
provider,
)
const isLoading =
lenderApprovedSenior === undefined || lenderApprovedJunior === undefined

const styles = {
subTitle: css`
Expand Down Expand Up @@ -84,16 +58,7 @@ export function ChooseTranche({
}

const handleNext = () => {
if (
(selectedTranche === 'senior' && lenderApprovedSenior) ||
(selectedTranche === 'junior' && lenderApprovedJunior)
) {
dispatch(setStep(WIDGET_STEP.ChooseAmount))
} else if (poolInfo.KYC) {
dispatch(setStep(WIDGET_STEP.Evaluation))
} else if (poolInfo.supplyLink) {
openInNewTab(poolInfo.supplyLink)
}
dispatch(setStep(WIDGET_STEP.ChooseAmount))
}

const items: {
Expand All @@ -110,10 +75,6 @@ export function ChooseTranche({
},
]

if (isLoading) {
return <LoadingModal title={`Supply ${poolUnderlyingToken.symbol}`} />
}

return (
<WrapperModal title={`Supply ${poolUnderlyingToken.symbol}`}>
<FormControl>
Expand Down
60 changes: 54 additions & 6 deletions packages/huma-widget/src/components/Lend/supplyV2/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
POOL_NAME,
TrancheType,
openInNewTab,
useLenderApprovedV2,
usePoolInfoV2,
usePoolUnderlyingTokenInfoV2,
} from '@huma-finance/shared'
Expand Down Expand Up @@ -42,19 +44,66 @@ export function LendSupplyV2({
}: LendSupplyPropsV2): React.ReactElement | null {
const dispatch = useDispatch()
const poolName = POOL_NAME[poolNameStr]
const { chainId, provider } = useWeb3React()
const { chainId, provider, account } = useWeb3React()
const poolInfo = usePoolInfoV2(poolName, chainId)
const { step, errorMessage } = useAppSelector(selectWidgetState)
const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider)

const [lenderApprovedSenior] = useLenderApprovedV2(
poolName,
'senior',
account,
provider,
)
const [lenderApprovedJunior] = useLenderApprovedV2(
poolName,
'junior',
account,
provider,
)

const lenderApproveStatusFetched =
lenderApprovedSenior !== undefined && lenderApprovedJunior !== undefined

useEffect(() => {
if (!step) {
dispatch(setStep(WIDGET_STEP.ChooseTranche))
if (!step && poolInfo && lenderApproveStatusFetched) {
if (lenderApprovedJunior && !lenderApprovedSenior) {
setSelectedTranche('junior')
dispatch(setStep(WIDGET_STEP.ChooseAmount))
return
}

if (lenderApprovedSenior && !lenderApprovedJunior) {
setSelectedTranche('senior')
dispatch(setStep(WIDGET_STEP.ChooseAmount))
return
}

if (lenderApprovedJunior && lenderApprovedSenior) {
dispatch(setStep(WIDGET_STEP.ChooseTranche))
return
}

if (poolInfo.KYC) {
dispatch(setStep(WIDGET_STEP.Evaluation))
return
}

if (poolInfo.supplyLink) {
openInNewTab(poolInfo.supplyLink)
}
}
}, [dispatch, step])
}, [
dispatch,
lenderApproveStatusFetched,
lenderApprovedJunior,
lenderApprovedSenior,
poolInfo,
step,
])

if (!poolInfo || !poolUnderlyingToken) {
if (!poolInfo || !poolUnderlyingToken || !lenderApproveStatusFetched) {
return (
<WidgetWrapper
isOpen
Expand All @@ -75,7 +124,6 @@ export function LendSupplyV2({
>
{step === WIDGET_STEP.ChooseTranche && (
<ChooseTranche
poolInfo={poolInfo}
poolUnderlyingToken={poolUnderlyingToken}
selectedTranche={selectedTranche}
changeTranche={setSelectedTranche}
Expand Down

0 comments on commit db4abd9

Please sign in to comment.