Skip to content

Commit

Permalink
Disable solver for now (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn authored Apr 19, 2023
1 parent e8572a0 commit e59e8fe
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 121 deletions.
180 changes: 91 additions & 89 deletions centrifuge-app/src/components/EpochList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Decimal from 'decimal.js-light'
import * as React from 'react'
import { useParams } from 'react-router'
import { useTheme } from 'styled-components'
import { formatBalance, formatPercentage } from '../utils/formatting'
import { formatBalance } from '../utils/formatting'
import { useLiquidity } from '../utils/useLiquidity'
import { usePool } from '../utils/usePools'
import { Column, DataTable } from './DataTable'
Expand Down Expand Up @@ -34,24 +34,24 @@ const columns: Column[] = [
cell: (row: LiquidityTableRow) => <LockedRow row={row} />,
flex: '3',
},
{
header: 'Executing',
cell: (row: LiquidityTableRow) => <ExecutingRow row={row} />,
flex: '3',
},
{
header: '%',
cell: (row: LiquidityTableRow) => <ExecutingPercentageRow row={row} />,
flex: '1',
},
// {
// header: 'Executing',
// cell: (row: LiquidityTableRow) => <ExecutingRow row={row} />,
// flex: '3',
// },
// {
// header: '%',
// cell: (row: LiquidityTableRow) => <ExecutingPercentageRow row={row} />,
// flex: '1',
// },
]

export const EpochList: React.FC<Props> = ({ pool }) => {
const theme = useTheme()
const {
sumOfExecutableInvestments,
// sumOfExecutableInvestments,
sumOfLockedInvestments,
sumOfExecutableRedemptions,
// sumOfExecutableRedemptions,
sumOfLockedRedemptions,
investments,
redemptions,
Expand All @@ -67,36 +67,36 @@ export const EpochList: React.FC<Props> = ({ pool }) => {
{formatBalance(sumOfLockedInvestments, pool.currency.symbol)}
</Text>
),
executing: (
<Text
variant="body2"
fontWeight={600}
color={
!sumOfLockedInvestments.equals(sumOfExecutableInvestments)
? theme.colors.statusWarning
: theme.colors.textPrimary
}
>
{formatBalance(sumOfExecutableInvestments, pool.currency.symbol)}
</Text>
),
executingPercentage: (
<Text
variant="body2"
fontWeight={600}
color={
!sumOfLockedInvestments.equals(sumOfExecutableInvestments)
? theme.colors.statusWarning
: theme.colors.textPrimary
}
>
{formatPercentage(
Perquintill.fromFloat(
sumOfExecutableInvestments.div(sumOfLockedInvestments.gt(0) ? sumOfLockedInvestments : 1)
)
)}
</Text>
),
// executing: (
// <Text
// variant="body2"
// fontWeight={600}
// color={
// !sumOfLockedInvestments.equals(sumOfExecutableInvestments)
// ? theme.colors.statusWarning
// : theme.colors.textPrimary
// }
// >
// {formatBalance(sumOfExecutableInvestments, pool.currency.symbol)}
// </Text>
// ),
// executingPercentage: (
// <Text
// variant="body2"
// fontWeight={600}
// color={
// !sumOfLockedInvestments.equals(sumOfExecutableInvestments)
// ? theme.colors.statusWarning
// : theme.colors.textPrimary
// }
// >
// {formatPercentage(
// Perquintill.fromFloat(
// sumOfExecutableInvestments.div(sumOfLockedInvestments.gt(0) ? sumOfLockedInvestments : 1)
// )
// )}
// </Text>
// ),
}

const summaryRedemptions: LiquidityTableRow = {
Expand All @@ -110,36 +110,36 @@ export const EpochList: React.FC<Props> = ({ pool }) => {
{formatBalance(sumOfLockedRedemptions, pool.currency.symbol)}
</Text>
),
executing: (
<Text
variant="body2"
fontWeight={600}
color={
!sumOfLockedRedemptions.equals(sumOfExecutableRedemptions)
? theme.colors.statusWarning
: theme.colors.textPrimary
}
>
{formatBalance(sumOfExecutableRedemptions, pool.currency.symbol)}
</Text>
),
executingPercentage: (
<Text
variant="body2"
fontWeight={600}
color={
!sumOfLockedRedemptions.equals(sumOfExecutableRedemptions)
? theme.colors.statusWarning
: theme.colors.textPrimary
}
>
{formatPercentage(
Perquintill.fromFloat(
sumOfExecutableRedemptions.div(sumOfLockedRedemptions.gt(0) ? sumOfLockedRedemptions : 1)
)
)}
</Text>
),
// executing: (
// <Text
// variant="body2"
// fontWeight={600}
// color={
// !sumOfLockedRedemptions.equals(sumOfExecutableRedemptions)
// ? theme.colors.statusWarning
// : theme.colors.textPrimary
// }
// >
// {formatBalance(sumOfExecutableRedemptions, pool.currency.symbol)}
// </Text>
// ),
// executingPercentage: (
// <Text
// variant="body2"
// fontWeight={600}
// color={
// !sumOfLockedRedemptions.equals(sumOfExecutableRedemptions)
// ? theme.colors.statusWarning
// : theme.colors.textPrimary
// }
// >
// {formatPercentage(
// Perquintill.fromFloat(
// sumOfExecutableRedemptions.div(sumOfLockedRedemptions.gt(0) ? sumOfLockedRedemptions : 1)
// )
// )}
// </Text>
// ),
}

return (
Expand All @@ -159,25 +159,27 @@ export const EpochList: React.FC<Props> = ({ pool }) => {
}

const LockedRow: React.VFC<{ row: LiquidityTableRow }> = ({ row }) => {
const { pid: poolId } = useParams<{ pid: string }>()
const pool = usePool(poolId)
return <>{React.isValidElement(row.locked) ? row.locked : formatBalance(row.locked, pool.currency.symbol)}</>
}

const ExecutingRow: React.VFC<{ row: LiquidityTableRow }> = ({ row }) => {
const { pid: poolId } = useParams<{ pid: string }>()
const pool = usePool(poolId)
return (
<>{React.isValidElement(row.executing) ? row.executing : formatBalance(row.executing || 0, pool.currency.symbol)}</>
<>{React.isValidElement(row.locked) ? row.locked : formatBalance(row.locked as Decimal, pool.currency.symbol)}</>
)
}

const ExecutingPercentageRow: React.VFC<{ row: LiquidityTableRow }> = ({ row }) => {
return (
<>
{React.isValidElement(row.executingPercentage)
? row.executingPercentage
: formatPercentage((row?.executingPercentage as Perquintill) || 0)}
</>
)
}
// const ExecutingRow: React.VFC<{ row: LiquidityTableRow }> = ({ row }) => {
// const { pid: poolId } = useParams<{ pid: string }>()
// const pool = usePool(poolId)
// return (
// <>{React.isValidElement(row.executing) ? row.executing : formatBalance(row.executing || 0, pool.currency.symbol)}</>
// )
// }

// const ExecutingPercentageRow: React.VFC<{ row: LiquidityTableRow }> = ({ row }) => {
// return (
// <>
// {React.isValidElement(row.executingPercentage)
// ? row.executingPercentage
// : formatPercentage((row?.executingPercentage as Perquintill) || 0)}
// </>
// )
// }
66 changes: 34 additions & 32 deletions centrifuge-app/src/components/LiquidityEpochSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const EpochStatusOngoing: React.FC<{ pool: Pool }> = ({ pool }) => {

const closeEpoch = async () => {
if (!pool) return
const batchCloseAndSolution = ordersLocked && !ordersFullyExecutable
closeEpochTx([pool.id, batchCloseAndSolution])
// const batchCloseAndSolution = ordersLocked && !ordersFullyExecutable
closeEpochTx([pool.id, false])
}

const ordersLocked = !epochTimeRemaining && sumOfLockedInvestments.add(sumOfLockedRedemptions).gt(0)
Expand All @@ -74,7 +74,7 @@ const EpochStatusOngoing: React.FC<{ pool: Pool }> = ({ pool }) => {
title="Order overview"
headerRight={
<Shelf gap="1">
{!epochTimeRemaining && !ordersLocked && (
{/* {!epochTimeRemaining && !ordersLocked && (
<Text as="small" variant="body2">
No orders locked
</Text>
Expand All @@ -98,7 +98,7 @@ const EpochStatusOngoing: React.FC<{ pool: Pool }> = ({ pool }) => {
<Text as="small" variant="body2">
Pending orders can be executed in {epochTimeRemaining}
</Text>
)}
)} */}

<Button
small
Expand All @@ -114,9 +114,10 @@ const EpochStatusOngoing: React.FC<{ pool: Pool }> = ({ pool }) => {
}
>
{!epochTimeRemaining && !ordersLocked && (
<ExtraInfo>The collection of orders is continuing until orders have been locked and can be executed.</ExtraInfo>
// <ExtraInfo>The collection of orders is continuing until orders have been locked and can be executed.</ExtraInfo>
<ExtraInfo>The collection of orders is continuing until orders have been locked.</ExtraInfo>
)}
{ordersLocked && ordersPartiallyExecutable && (
{/* {ordersLocked && ordersPartiallyExecutable && (
<ExtraInfo>
The collection of orders continues until all orders can be executed. Start the execution of the orders to
partially execute orders and lock the remaining orders into the next cycle of order executions.
Expand All @@ -128,57 +129,58 @@ const EpochStatusOngoing: React.FC<{ pool: Pool }> = ({ pool }) => {
available for redemptions. Closing of the collection of orders epoch will not ensure execution of pending
orders.
</ExtraInfo>
)}
)} */}
<EpochList pool={pool} />
</PageSection>
)
}

const EpochStatusSubmission: React.FC<{ pool: Pool }> = ({ pool }) => {
const [isFeasible, setIsFeasible] = React.useState(true)
const { execute: submitSolutionTx, isLoading: loadingSolution } = useCentrifugeTransaction(
'Submit solution',
(cent) => cent.pools.submitSolution,
{
onSuccess: () => {
console.log('Solution successfully submitted')
},
onError: () => {
setIsFeasible(false)
},
}
)
// const [isFeasible, setIsFeasible] = React.useState(true)
// const { execute: submitSolutionTx, isLoading: loadingSolution } = useCentrifugeTransaction(
// 'Submit solution',
// (cent) => cent.pools.submitSolution,
// {
// onSuccess: () => {
// console.log('Solution successfully submitted')
// },
// onError: () => {
// setIsFeasible(false)
// },
// }
// )

const submitSolution = async () => {
if (!pool) return
submitSolutionTx([pool.id])
}
// const submitSolution = async () => {
// if (!pool) return
// submitSolutionTx([pool.id])
// }

return (
<PageSection
title="Order overview"
titleAddition={<Text variant="body2">In submission period</Text>}
titleAddition={<Text variant="body2">In submission period, please submit a solution manually</Text>}
headerRight={
<Button
small
variant="primary"
onClick={submitSolution}
disabled={loadingSolution || !isFeasible}
loading={loadingSolution}
loadingMessage={loadingSolution ? 'Submitting solution…' : ''}
// onClick={submitSolution}
disabled={true}
// disabled={loadingSolution || !isFeasible}
// loading={loadingSolution}
// loadingMessage={loadingSolution ? 'Submitting solution…' : ''}
>
Submit solution
</Button>
}
>
{!isFeasible && (
{/* {!isFeasible && (
<Shelf mb={2} gap={1}>
<IconInfo size={16} />
<Text variant="body3">
The solution provided by the system is not feasible. Please submit a solution manually.
</Text>
</Shelf>
)}
)} */}
<EpochList pool={pool} />
</PageSection>
)
Expand All @@ -199,7 +201,7 @@ const EpochStatusExecution: React.FC<{ pool: Pool }> = ({ pool }) => {
return (
<PageSection
title="Order overview"
titleAddition={<Text variant="body2">Order executing</Text>}
titleAddition={<Text variant="body2">{loadingExecution && 'Order executing'}</Text>}
headerRight={
<Button
small
Expand Down

0 comments on commit e59e8fe

Please sign in to comment.