Skip to content

Handle add redemption requests for unupgraded v2 pools #430

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1,584 changes: 1,584 additions & 0 deletions packages/huma-shared/src/v2/abis/TrancheVaultNoAutoredemptionUpgrade.json

Large diffs are not rendered by default.

2,408 changes: 2,408 additions & 0 deletions packages/huma-shared/src/v2/abis/types/TrancheVaultNoAutoredemptionUpgrade.ts

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/huma-shared/src/v2/abis/types/factories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export { PoolSafe__factory } from './PoolSafe__factory'
export { Receivable__factory } from './Receivable__factory'
export { ReceivableBackedCreditLine__factory } from './ReceivableBackedCreditLine__factory'
export { TrancheVault__factory } from './TrancheVault__factory'
export { TrancheVaultNoAutoredemptionUpgrade__factory } from './TrancheVaultNoAutoredemptionUpgrade__factory'
2 changes: 2 additions & 0 deletions packages/huma-shared/src/v2/abis/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type { PoolSafe } from './PoolSafe'
export type { Receivable } from './Receivable'
export type { ReceivableBackedCreditLine } from './ReceivableBackedCreditLine'
export type { TrancheVault } from './TrancheVault'
export type { TrancheVaultNoAutoredemptionUpgrade } from './TrancheVaultNoAutoredemptionUpgrade'
export * as factories from './factories'
export { Calendar__factory } from './factories/Calendar__factory'
export { Credit__factory } from './factories/Credit__factory'
Expand All @@ -28,3 +29,4 @@ export { PoolSafe__factory } from './factories/PoolSafe__factory'
export { Receivable__factory } from './factories/Receivable__factory'
export { ReceivableBackedCreditLine__factory } from './factories/ReceivableBackedCreditLine__factory'
export { TrancheVault__factory } from './factories/TrancheVault__factory'
export { TrancheVaultNoAutoredemptionUpgrade__factory } from './factories/TrancheVaultNoAutoredemptionUpgrade__factory'
3 changes: 3 additions & 0 deletions packages/huma-shared/src/v2/metadata/alfajores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ export const ALFAJORES_METADATA: PoolsInfoV2 = {
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://uer4clyybno.typeform.com/arfcreditline',
extra: {
noTrancheAutoredeemUpdate: true,
},
},
}
4 changes: 4 additions & 0 deletions packages/huma-shared/src/v2/metadata/celo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const CELO_METADATA: PoolsInfoV2 = {
redirect: REDIRECTS.Arf,
extra: {
rwrUploader: '0xEA57a8A51377752fFddaa3db4d13CE8F97677F2D',
noTrancheAutoredeemUpdate: true,
},
},
Raincards: {
Expand Down Expand Up @@ -70,5 +71,8 @@ export const CELO_METADATA: PoolsInfoV2 = {
title: 'Rain Receivables Pool',
desc: 'The Rain Receivables Pool is reshaping spend management for Web3 teams, enabling Web3 entities like DAOs and protocols to effortlessly manage fiat expenses through corporate cards.',
redirect: REDIRECTS.Rain,
extra: {
noTrancheAutoredeemUpdate: true,
},
},
}
4 changes: 4 additions & 0 deletions packages/huma-shared/src/v2/utils/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import POOL_ABI from '../abis/Pool.json'
import POOL_CONFIG_ABI from '../abis/PoolConfig.json'
import POOL_SAFE_ABI from '../abis/PoolSafe.json'
import TRANCHE_VAULT_ABI from '../abis/TrancheVault.json'
import TRANCHE_VAULT_NO_AUTOREDEMPTION_ABI from '../abis/TrancheVaultNoAutoredemptionUpgrade.json'
import { ALFAJORES_METADATA } from '../metadata/alfajores'
import { AMOY_METADATA } from '../metadata/amoy'
import { BASE_SEPOLIA_METADATA } from '../metadata/baseSepolia'
Expand Down Expand Up @@ -52,6 +53,7 @@ export type PoolAbis = {
poolSafeAbi: unknown
poolConfigAbi: unknown
trancheVaultAbi: unknown
trancheVaultNoAutoredemptionUpgradeAbi: unknown
firstLossCoverAbi: unknown
epochManagerAbi: unknown
calendarAbi: unknown
Expand Down Expand Up @@ -113,6 +115,7 @@ export type PoolInfoV2 = {
borrower?: string // For single borrower pools
rwrUploader?: string // For single borrower pools where receivables are uploaded by a different wallet
enableGetTestUSDC?: boolean
noTrancheAutoredeemUpdate?: boolean
}
redirect?: REDIRECTS
}
Expand All @@ -133,6 +136,7 @@ export const POOL_ABI_V2: PoolAbis = {
poolSafeAbi: POOL_SAFE_ABI,
poolConfigAbi: POOL_CONFIG_ABI,
trancheVaultAbi: TRANCHE_VAULT_ABI,
trancheVaultNoAutoredemptionUpgradeAbi: TRANCHE_VAULT_NO_AUTOREDEMPTION_ABI,
firstLossCoverAbi: FIRST_LOSS_COVER_ABI,
epochManagerAbi: EPOCH_MANAGER_ABI,
calendarAbi: CALENDAR_ABI,
Expand Down
13 changes: 9 additions & 4 deletions packages/huma-shared/src/v2/utils/trancheVaultContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import {
getContract,
POOL_NAME,
} from '../../utils'
import { TrancheVault } from '../abis/types'
import {
TrancheVault,
TrancheVaultNoAutoredemptionUpgrade,
} from '../abis/types'
import { POOL_ABI_V2, TrancheType } from './pool'
import { getPoolInfoV2 } from './poolContract'

export const getTrancheVaultContractV2 = async (
poolName: POOL_NAME,
trancheType: TrancheType,
provider: JsonRpcProvider | Web3Provider | undefined,
): Promise<TrancheVault | null> => {
): Promise<TrancheVault | TrancheVaultNoAutoredemptionUpgrade | null> => {
const chainId = await getChainIdFromSignerOrProvider(provider)
const poolInfo = getPoolInfoV2(poolName, chainId)
if (!poolInfo) {
Expand All @@ -24,9 +27,11 @@ export const getTrancheVaultContractV2 = async (
const trancheVault = `${trancheType}TrancheVault` as
| 'seniorTrancheVault'
| 'juniorTrancheVault'
return getContract<TrancheVault>(
return getContract<TrancheVault | TrancheVaultNoAutoredemptionUpgrade>(
poolInfo[trancheVault],
POOL_ABI_V2.trancheVaultAbi,
poolInfo.extra?.noTrancheAutoredeemUpdate
? POOL_ABI_V2.trancheVaultNoAutoredemptionUpgradeAbi
: POOL_ABI_V2.trancheVaultAbi,
provider,
)
}
Expand Down
1 change: 1 addition & 0 deletions packages/huma-web-shared/src/hooks/useContractFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const sendTxAtom = atom(
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.error(e)
const contractErrorMessage = getTransactionErrorFromError(e)
if (contractErrorMessage) {
set(txAtom, {
Expand Down
7 changes: 5 additions & 2 deletions packages/huma-web-shared/src/hooks/usePoolV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
PoolSafe,
Receivable,
TrancheVault,
TrancheVaultNoAutoredemptionUpgrade,
} from '@huma-finance/shared/src/v2/abis/types'
import { CreditManager } from '@huma-finance/shared/src/v2/abis/types/CreditManager'
import {
Expand Down Expand Up @@ -113,9 +114,11 @@ export function useTrancheVaultContractV2(
const chainId = provider?.network?.chainId
const poolInfo = usePoolInfoV2(poolName, chainId)
const contractAddr = poolInfo?.[`${trancheType}TrancheVault`]
return useContract<TrancheVault>(
return useContract<TrancheVault | TrancheVaultNoAutoredemptionUpgrade>(
contractAddr,
POOL_ABI_V2.trancheVaultAbi,
poolInfo?.extra?.noTrancheAutoredeemUpdate
? POOL_ABI_V2.trancheVaultNoAutoredemptionUpgradeAbi
: POOL_ABI_V2.trancheVaultAbi,
provider,
account,
)
Expand Down
10 changes: 10 additions & 0 deletions packages/huma-widget/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,11 @@ To be used when re-enabling autopay and other pool actions that require allowanc
<p>Lend pool supply props</p>

**Kind**: global typedef

| Param | Type | Description |
| --- | --- | --- |
| documentHash | <code>string</code> | <p>The subscription file hash.</p> |

**Properties**

| Name | Type | Description |
Expand Down Expand Up @@ -775,6 +780,11 @@ To be used when re-enabling autopay and other pool actions that require allowanc
<p>Lend pool supply props</p>

**Kind**: global typedef

| Param | Type | Description |
| --- | --- | --- |
| documentHash | <code>string</code> | <p>The subscription file hash.</p> |

**Properties**

| Name | Type | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ export function Transfer({
return null
}

return (
return poolInfo.extra?.noTrancheAutoredeemUpdate ? (
<TxSendModalV2
contract={trancheVaultContract}
method='addRedemptionRequest'
params={[redeemSharesBN]}
handleSuccess={handleSuccess}
/>
) : (
<TxSendModalV2
contract={trancheVaultContract}
method='addRedemptionRequest'
Expand Down
Loading