From bbfb6b56cfa3271183d62492477989aa638e233e Mon Sep 17 00:00:00 2001 From: shan-57blocks Date: Tue, 31 Dec 2024 21:49:00 +0800 Subject: [PATCH 1/7] update scroll config --- .../huma-shared/src/v2/metadata/scroll.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/huma-shared/src/v2/metadata/scroll.ts b/packages/huma-shared/src/v2/metadata/scroll.ts index e8ec2858..106d9d05 100644 --- a/packages/huma-shared/src/v2/metadata/scroll.ts +++ b/packages/huma-shared/src/v2/metadata/scroll.ts @@ -10,14 +10,14 @@ export const SCROLL_METADATA: PoolsInfoV2 = { industry: 'Remittance Financing', poolName: POOL_NAME.ArfCreditPool3Months, poolType: POOL_TYPE.ReceivableBackedCreditLine, - pool: '0x5227254a6aCa397e95F310b52f6D3143A5A9Ee14', - poolConfig: '0xEBA0756b813e49bA84Cb3B8E2d717bcF0C07fC99', - poolCredit: '0xc6F10af4746784a0DD095f4E5718d53ff94eB4a0', - poolCreditManager: '0x061411d05074Bc974f814AC86309D2204f4c265d', - poolSafe: '0x7F4f55fAeE753D8dbB3E5F04861dB38E9DB70c3D', - seniorTrancheVault: '0x4cdCedcF50266aD9ed809048BC9874320EC902bC', - juniorTrancheVault: '0x483D02C11f8F1E31C267040A6C86AaB80c428BaB', - epochManager: '0x1a2C87Be5e785493310526faA7739Bbe4E10c0F6', + pool: '0x51051d2E2bac59b525C7f001E91d31193c4CafFe', + poolConfig: '0xcEC52856813d5061FdCDEC8A7464B685294c5cad', + poolCredit: '0x7eb695ad4D4ffC80548b520F3f0E277b14c564db', + poolCreditManager: '0xA4Ab74C3618Eda38DB4E63bA4D91fb5b9aB2b209', + poolSafe: '0x7DFB8cF225e760D69939496eE6BaDA4d660D351b', + seniorTrancheVault: '0xD8208374c5E358031e7A81392F705c04106bB990', + juniorTrancheVault: '0xB135B9cfE868D456B5Fa480817E830960BdE80b3', + epochManager: '0x7297862107E73794BF44332B1654bf3708018310', receivable: '0x89B599dCc82c42Ef2f17ae39c44e4F6764003518', poolUnderlyingToken: { address: '0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4', @@ -27,8 +27,8 @@ export const SCROLL_METADATA: PoolsInfoV2 = { }, firstLossCovers: { [FirstLossCoverIndex.borrower]: - '0xceA6753113741f82A7a3d86355D4d9BB7126F25E', - [FirstLossCoverIndex.admin]: '0x4222372912cc6554a11ecBeC141cBf6b7d62B630', + '0xb3629a52e5FC292d1f0f8EB927ADabe872b5e5a3', + [FirstLossCoverIndex.admin]: '0xc4E07CFa7Ae39f595895B43bd35dc078f7FE6eF1', }, seniorAPY: '10-20%', juniorAPY: '10-20%', From 0a1fefaf5b349c015ffaa5145340b10be2ac9835 Mon Sep 17 00:00:00 2001 From: shan-57blocks Date: Tue, 31 Dec 2024 22:22:28 +0800 Subject: [PATCH 2/7] add useRedemptionStatusV2 --- .../huma-web-shared/src/hooks/usePoolV2.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/huma-web-shared/src/hooks/usePoolV2.ts b/packages/huma-web-shared/src/hooks/usePoolV2.ts index 3a787863..00fb6ffc 100644 --- a/packages/huma-web-shared/src/hooks/usePoolV2.ts +++ b/packages/huma-web-shared/src/hooks/usePoolV2.ts @@ -636,6 +636,52 @@ export function useCancellableRedemptionInfoV2( return [redemptionInfo, refresh] } +type RedemptionStatus = { + numSharesRequested: string + withdrawableAssets: string + cancellableRedemptionShares: string + cancellableRedemptionAssets: string +} + +export function useRedemptionStatusV2( + poolName: POOL_NAME, + trancheType: TrancheType, + account: string | undefined, + provider: JsonRpcProvider | Web3Provider | undefined, +): [RedemptionStatus | undefined, () => void] { + const [redemptionStatus, setRedemptionStatus] = useState() + const vaultContract = useTrancheVaultContractV2( + poolName, + trancheType, + provider, + ) + const [refreshCount, refresh] = useForceRefresh() + + useEffect(() => { + if (account && vaultContract) { + const fetchData = async () => { + const redemptionRecords = await vaultContract.lenderRedemptionRecords( + account, + ) + const cancellableRedemptionShares = + await vaultContract.cancellableRedemptionShares(account) + const cancellableRedemptionAssets = await vaultContract.convertToAssets( + cancellableRedemptionShares, + ) + setRedemptionStatus({ + numSharesRequested: redemptionRecords.numSharesRequested.toString(), + withdrawableAssets: redemptionRecords.totalAmountProcessed.toString(), + cancellableRedemptionShares: cancellableRedemptionShares.toString(), + cancellableRedemptionAssets: cancellableRedemptionAssets.toString(), + }) + } + fetchData() + } + }, [account, vaultContract, refreshCount]) + + return [redemptionStatus, refresh] +} + export function useCreditStatsV2( poolName: POOL_NAME, account: string | undefined, From 75ab86b398138b4969a5494620979ddcffffa636 Mon Sep 17 00:00:00 2001 From: shan-57blocks Date: Tue, 31 Dec 2024 22:58:20 +0800 Subject: [PATCH 3/7] map old arf 3 months pool scroll receivables --- packages/huma-sdk/src/services/SubgraphService.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/huma-sdk/src/services/SubgraphService.ts b/packages/huma-sdk/src/services/SubgraphService.ts index 32365369..1d1f84f7 100644 --- a/packages/huma-sdk/src/services/SubgraphService.ts +++ b/packages/huma-sdk/src/services/SubgraphService.ts @@ -1,13 +1,13 @@ import { + CHAIN_POOLS_INFO_V2, + ChainEnum, CreditEvent, + isV2Pool, POOL_NAME, POOL_TYPE, PoolContractMap, PoolSubgraphMap, RealWorldReceivableInfoBase, - CHAIN_POOLS_INFO_V2, - ChainEnum, - isV2Pool, requestPost, } from '@huma-finance/shared' import { gql } from 'graphql-request' @@ -258,6 +258,14 @@ function getReceivableV2Info( poolAddress = CHAIN_POOLS_INFO_V2[chainId as ChainEnum]?.[poolName]?.pool } + const ARF_3_MONTH_POOL_SCROLL_OLD = + '0x5227254a6aCa397e95F310b52f6D3143A5A9Ee14' + const ARF_3_MONTH_POOL_SCROLL_NEW = + '0x51051d2E2bac59b525C7f001E91d31193c4CafFe' + if (poolAddress === ARF_3_MONTH_POOL_SCROLL_NEW) { + poolAddress = ARF_3_MONTH_POOL_SCROLL_OLD + } + const ReceivablesV2Query = ` query { rwreceivables( From 96b33728642e4750cb31f74ddf1df2c843b7a3a9 Mon Sep 17 00:00:00 2001 From: shan-57blocks Date: Tue, 31 Dec 2024 23:04:00 +0800 Subject: [PATCH 4/7] map old arf pool to new pool --- packages/huma-sdk/src/services/SubgraphService.ts | 9 +++------ packages/huma-shared/src/v2/utils/const.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/huma-sdk/src/services/SubgraphService.ts b/packages/huma-sdk/src/services/SubgraphService.ts index 1d1f84f7..7c164f9a 100644 --- a/packages/huma-sdk/src/services/SubgraphService.ts +++ b/packages/huma-sdk/src/services/SubgraphService.ts @@ -1,4 +1,5 @@ import { + ARF_3_MONTH_POOL_SCROLL_MAP, CHAIN_POOLS_INFO_V2, ChainEnum, CreditEvent, @@ -258,12 +259,8 @@ function getReceivableV2Info( poolAddress = CHAIN_POOLS_INFO_V2[chainId as ChainEnum]?.[poolName]?.pool } - const ARF_3_MONTH_POOL_SCROLL_OLD = - '0x5227254a6aCa397e95F310b52f6D3143A5A9Ee14' - const ARF_3_MONTH_POOL_SCROLL_NEW = - '0x51051d2E2bac59b525C7f001E91d31193c4CafFe' - if (poolAddress === ARF_3_MONTH_POOL_SCROLL_NEW) { - poolAddress = ARF_3_MONTH_POOL_SCROLL_OLD + if (poolAddress === ARF_3_MONTH_POOL_SCROLL_MAP.poolNew) { + poolAddress = ARF_3_MONTH_POOL_SCROLL_MAP.poolOld } const ReceivablesV2Query = ` diff --git a/packages/huma-shared/src/v2/utils/const.ts b/packages/huma-shared/src/v2/utils/const.ts index 461b359a..d63659e4 100644 --- a/packages/huma-shared/src/v2/utils/const.ts +++ b/packages/huma-shared/src/v2/utils/const.ts @@ -57,3 +57,12 @@ export const ARF_PERSONA_KYC_COPY = { buttonText: 'GO TO PURCHASE AGREEMENT', }, } + +export const ARF_3_MONTH_POOL_SCROLL_MAP = { + poolOld: '0x5227254a6aCa397e95F310b52f6D3143A5A9Ee14', + poolNew: '0x51051d2E2bac59b525C7f001E91d31193c4CafFe', + seniorTrancheOld: '0x4cdCedcF50266aD9ed809048BC9874320EC902bC', + seniorTrancheNew: '0xD8208374c5E358031e7A81392F705c04106bB990', + juniorTrancheOld: '0x483D02C11f8F1E31C267040A6C86AaB80c428BaB', + juniorTrancheNew: '0xB135B9cfE868D456B5Fa480817E830960BdE80b3', +} From 18dbd92e4f6ac32dd735dfab567b6057a580b289 Mon Sep 17 00:00:00 2001 From: shan-57blocks Date: Tue, 31 Dec 2024 23:35:51 +0800 Subject: [PATCH 5/7] update useRedemptionStatusV2 --- packages/huma-web-shared/src/hooks/usePoolV2.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/huma-web-shared/src/hooks/usePoolV2.ts b/packages/huma-web-shared/src/hooks/usePoolV2.ts index 00fb6ffc..638f965c 100644 --- a/packages/huma-web-shared/src/hooks/usePoolV2.ts +++ b/packages/huma-web-shared/src/hooks/usePoolV2.ts @@ -660,7 +660,7 @@ export function useRedemptionStatusV2( useEffect(() => { if (account && vaultContract) { const fetchData = async () => { - const redemptionRecords = await vaultContract.lenderRedemptionRecords( + const redemptionRecord = await vaultContract.lenderRedemptionRecords( account, ) const cancellableRedemptionShares = @@ -668,9 +668,12 @@ export function useRedemptionStatusV2( const cancellableRedemptionAssets = await vaultContract.convertToAssets( cancellableRedemptionShares, ) + const withdrawableAssets = await vaultContract.withdrawableAssets( + account, + ) setRedemptionStatus({ - numSharesRequested: redemptionRecords.numSharesRequested.toString(), - withdrawableAssets: redemptionRecords.totalAmountProcessed.toString(), + numSharesRequested: redemptionRecord.numSharesRequested.toString(), + withdrawableAssets: withdrawableAssets.toString(), cancellableRedemptionShares: cancellableRedemptionShares.toString(), cancellableRedemptionAssets: cancellableRedemptionAssets.toString(), }) From f94b94b68ecedab04ef74cebe559145e0b27c6ce Mon Sep 17 00:00:00 2001 From: shan-57blocks Date: Wed, 1 Jan 2025 00:12:45 +0800 Subject: [PATCH 6/7] update useRedemptionStatusV2 --- .../huma-web-shared/src/hooks/usePoolV2.ts | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/packages/huma-web-shared/src/hooks/usePoolV2.ts b/packages/huma-web-shared/src/hooks/usePoolV2.ts index 638f965c..8ffea915 100644 --- a/packages/huma-web-shared/src/hooks/usePoolV2.ts +++ b/packages/huma-web-shared/src/hooks/usePoolV2.ts @@ -14,6 +14,7 @@ import { getDueDetailV2, getPoolUnderlyingTokenBalanceV2, getPoolUnderlyingTokenInfoV2, + getTrancheRedemptionStatusV2, isChainEnum, POOL_ABI_V2, POOL_CONFIG_V2_ABI, @@ -650,37 +651,32 @@ export function useRedemptionStatusV2( provider: JsonRpcProvider | Web3Provider | undefined, ): [RedemptionStatus | undefined, () => void] { const [redemptionStatus, setRedemptionStatus] = useState() - const vaultContract = useTrancheVaultContractV2( - poolName, - trancheType, - provider, - ) const [refreshCount, refresh] = useForceRefresh() useEffect(() => { - if (account && vaultContract) { + if (account) { const fetchData = async () => { - const redemptionRecord = await vaultContract.lenderRedemptionRecords( - account, - ) - const cancellableRedemptionShares = - await vaultContract.cancellableRedemptionShares(account) - const cancellableRedemptionAssets = await vaultContract.convertToAssets( - cancellableRedemptionShares, - ) - const withdrawableAssets = await vaultContract.withdrawableAssets( + const redemptionStatus = await getTrancheRedemptionStatusV2( + poolName, + trancheType, account, + provider, ) - setRedemptionStatus({ - numSharesRequested: redemptionRecord.numSharesRequested.toString(), - withdrawableAssets: withdrawableAssets.toString(), - cancellableRedemptionShares: cancellableRedemptionShares.toString(), - cancellableRedemptionAssets: cancellableRedemptionAssets.toString(), - }) + if (redemptionStatus) { + setRedemptionStatus({ + numSharesRequested: + redemptionStatus.lenderRedemptionRecords.numSharesRequested.toString(), + withdrawableAssets: redemptionStatus.withdrawableAssets.toString(), + cancellableRedemptionShares: + redemptionStatus.cancellableRedemptionShares.toString(), + cancellableRedemptionAssets: + redemptionStatus.cancellableRedemptionAssets.toString(), + }) + } } fetchData() } - }, [account, vaultContract, refreshCount]) + }, [account, poolName, provider, trancheType, refreshCount]) return [redemptionStatus, refresh] } From 772a8c7e877698bdd1e64dc1a153affe9e1e56ac Mon Sep 17 00:00:00 2001 From: shan-57blocks Date: Wed, 1 Jan 2025 00:19:43 +0800 Subject: [PATCH 7/7] remove unused useRedemptionStatusV2 --- .../huma-web-shared/src/hooks/usePoolV2.ts | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/packages/huma-web-shared/src/hooks/usePoolV2.ts b/packages/huma-web-shared/src/hooks/usePoolV2.ts index 8ffea915..3a787863 100644 --- a/packages/huma-web-shared/src/hooks/usePoolV2.ts +++ b/packages/huma-web-shared/src/hooks/usePoolV2.ts @@ -14,7 +14,6 @@ import { getDueDetailV2, getPoolUnderlyingTokenBalanceV2, getPoolUnderlyingTokenInfoV2, - getTrancheRedemptionStatusV2, isChainEnum, POOL_ABI_V2, POOL_CONFIG_V2_ABI, @@ -637,50 +636,6 @@ export function useCancellableRedemptionInfoV2( return [redemptionInfo, refresh] } -type RedemptionStatus = { - numSharesRequested: string - withdrawableAssets: string - cancellableRedemptionShares: string - cancellableRedemptionAssets: string -} - -export function useRedemptionStatusV2( - poolName: POOL_NAME, - trancheType: TrancheType, - account: string | undefined, - provider: JsonRpcProvider | Web3Provider | undefined, -): [RedemptionStatus | undefined, () => void] { - const [redemptionStatus, setRedemptionStatus] = useState() - const [refreshCount, refresh] = useForceRefresh() - - useEffect(() => { - if (account) { - const fetchData = async () => { - const redemptionStatus = await getTrancheRedemptionStatusV2( - poolName, - trancheType, - account, - provider, - ) - if (redemptionStatus) { - setRedemptionStatus({ - numSharesRequested: - redemptionStatus.lenderRedemptionRecords.numSharesRequested.toString(), - withdrawableAssets: redemptionStatus.withdrawableAssets.toString(), - cancellableRedemptionShares: - redemptionStatus.cancellableRedemptionShares.toString(), - cancellableRedemptionAssets: - redemptionStatus.cancellableRedemptionAssets.toString(), - }) - } - } - fetchData() - } - }, [account, poolName, provider, trancheType, refreshCount]) - - return [redemptionStatus, refresh] -} - export function useCreditStatsV2( poolName: POOL_NAME, account: string | undefined,