Skip to content

Commit

Permalink
Update token price of all deployed domains (#2478)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn authored Oct 9, 2024
1 parent a183e21 commit 2a2ea42
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,18 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) {
const { execute, isLoading } = useCentrifugeTransaction(
'Update NAV',
(cent) => (args: [values: FormValues], options) => {
const domain = domains?.find((domain) => domain.isActive && domain.hasDeployedLp)
const updateTokenPrices = domain
? Object.entries(domain.liquidityPools).flatMap(([tid, poolsByCurrency]) => {
return domain.currencies
.filter((cur) => !!poolsByCurrency[cur.address])
.map((cur) => [tid, cur.key] satisfies [string, CurrencyKey])
.map(([tid, curKey]) =>
cent.liquidityPools.updateTokenPrice([poolId, tid, curKey, domain.chainId], { batch: true })
)
})
const deployedDomains = domains?.filter((domain) => domain.hasDeployedLp)
const updateTokenPrices = deployedDomains
? deployedDomains.flatMap((domain) =>
Object.entries(domain.liquidityPools).flatMap(([tid, poolsByCurrency]) => {
return domain.currencies
.filter((cur) => !!poolsByCurrency[cur.address])
.map((cur) => [tid, cur.key] satisfies [string, CurrencyKey])
.map(([tid, curKey]) =>
cent.liquidityPools.updateTokenPrice([poolId, tid, curKey, domain.chainId], { batch: true })
)
})
)
: []

return combineLatest([cent.pools.closeEpoch([poolId, false], { batch: true }), ...updateTokenPrices]).pipe(
Expand Down

0 comments on commit 2a2ea42

Please sign in to comment.