Skip to content

Commit

Permalink
Merge pull request #3241 from OlympusDAO/develop
Browse files Browse the repository at this point in the history
[Release] - V3 Clearinghouse Support. Minor Governance Improvements
  • Loading branch information
brightiron authored Nov 30, 2024
2 parents cd73b0c + e532f99 commit ec5f0ed
Show file tree
Hide file tree
Showing 31 changed files with 1,575 additions and 601 deletions.
780 changes: 780 additions & 0 deletions src/abi/CoolerClearingHouseV3.json

Large diffs are not rendered by default.

838 changes: 419 additions & 419 deletions src/abi/CoolerFactoryV2.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/assets/tokens/usds.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/Migration/MigrationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function MigrationModal({ open, handleClose }: { open: boolean; handleClose: any
isMigrationComplete || !oldAssetsDetected
? `Migration complete`
: isAllApproved
? `You are now ready to migrate`
: `You have assets ready to migrate to v2`
? `You are now ready to migrate`
: `You have assets ready to migrate to v2`
}
>
<>
Expand Down
5 changes: 5 additions & 0 deletions src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ export const COOLER_CLEARING_HOUSE_V2_ADDRESSES = {
[NetworkId.TESTNET_GOERLI]: "0xbfe14B5950a530A5CE572Cd2FaC6d44c718A3C47",
};

export const COOLER_CLEARING_HOUSE_V3_ADDRESSES = {
[NetworkId.MAINNET]: "0x1e094fE00E13Fd06D64EeA4FB3cD912893606fE0",
[NetworkId.TESTNET_GOERLI]: "",
};

export const OLYMPUS_GOVERNANCE_ADDRESSES = {
[NetworkId.MAINNET]: "0x0941233c964e7d7Efeb05D253176E5E634cEFfcD",
[NetworkId.TESTNET_GOERLI]: "0x0941233c964e7d7Efeb05D253176E5E634cEFfcD",
Expand Down
8 changes: 8 additions & 0 deletions src/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
BOND_FIXED_TERM_TELLER_ADDRESSES,
COOLER_CLEARING_HOUSE_V1_ADDRESSES,
COOLER_CLEARING_HOUSE_V2_ADDRESSES,
COOLER_CLEARING_HOUSE_V3_ADDRESSES,
COOLER_CONSOLIDATION_ADDRESSES,
CROSS_CHAIN_BRIDGE_ADDRESSES,
CROSS_CHAIN_BRIDGE_ADDRESSES_TESTNET,
Expand All @@ -29,6 +30,7 @@ import {
BondFixedExpiryTeller__factory,
BondFixedTermTeller__factory,
CoolerClearingHouse__factory,
CoolerClearingHouseV3__factory,
CoolerConsolidation__factory,
CrossChainBridge__factory,
CrossChainBridgeTestnet__factory,
Expand Down Expand Up @@ -167,6 +169,12 @@ export const COOLER_CLEARING_HOUSE_CONTRACT_V2 = new Contract({
addresses: COOLER_CLEARING_HOUSE_V2_ADDRESSES,
});

export const COOLER_CLEARING_HOUSE_CONTRACT_V3 = new Contract({
factory: CoolerClearingHouseV3__factory,
name: "Cooler Clearing House Contract V3",
addresses: COOLER_CLEARING_HOUSE_V3_ADDRESSES,
});

export const GOVERNANCE_CONTRACT = new Contract({
factory: OlympusGovernorBravo__factory,
name: "Governance Contract",
Expand Down
38 changes: 25 additions & 13 deletions src/generated/coolerLoans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ export type GetSnapshotsParams = {
* Represents the state of the Treasury at the time of the snapshot.
*/
export type SnapshotTreasury = {
/** Total balance of DAI in the active treasury */
/** Total balance of the DAI token in the active treasury */
daiBalance: number;
/** Total balance of sDAI in the active treasury */
/** Total balance of the sDAI token in the active treasury */
sDaiBalance: number;
/** Total balance of sDAI in terms of DAI in the active treasury */
/** Total balance of the sDAI token in terms of DAI in the active treasury */
sDaiInDaiBalance: number;
/** Total balance of the sUSDS token in the active treasury */
sUsdsBalance: number;
/** Total balance of the sUSDS token in terms of USDS in the active treasury */
sUsdsInUsdsBalance: number;
/** Total balance of the USDS token in the active treasury */
usdsBalance: number;
};

/**
Expand Down Expand Up @@ -86,12 +92,18 @@ export type SnapshotExpiryBuckets = {
* Totals for the Clearinghouses at the time of the snapshot.
*/
export type SnapshotClearinghouseTotals = {
/** Total balance of DAI across all Clearinghouses */
/** Total balance of the DAI token across all Clearinghouses */
daiBalance: number;
/** Total balance of sDAI across all Clearinghouses */
/** Total balance of the sDAI token across all Clearinghouses */
sDaiBalance: number;
/** Total balance of sDAI in terms of DAI across all Clearinghouses */
/** Total balance of the sDAI token in terms of DAI across all Clearinghouses */
sDaiInDaiBalance: number;
/** Total balance of the sUSDS token across all Clearinghouses */
sUsdsBalance: number;
/** Total balance of the sUSDS token in terms of USDS across all Clearinghouses */
sUsdsInUsdsBalance: number;
/** Total balance of the USDS token across all Clearinghouses */
usdsBalance: number;
};

export type SnapshotClearinghousesItem = {
Expand All @@ -101,18 +113,18 @@ export type SnapshotClearinghousesItem = {
collateralAddress: string;
/** The address of the CoolerFactory */
coolerFactoryAddress: string;
/** Balance of DAI */
daiBalance: number;
/** The address of the debt */
debtAddress: string;
/** Amount of DAI that the Clearinghouse should be funded with */
/** Amount of the reserve token that the Clearinghouse should be funded with */
fundAmount: number;
/** The cadence of the funding */
fundCadence: number;
/** Balance of sDAI */
sDaiBalance: number;
/** Balance of sDAI in terms of DAI */
sDaiInDaiBalance: number;
/** Balance of the reserve token */
reserveBalance: number;
/** Balance of the sReserve token */
sReserveBalance: number;
/** Balance of the sReserve token in terms of the reserve token */
sReserveInReserveBalance: number;
};

export type Snapshot = {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function formatCurrency(c: number, precision = 0, currency = "USD") {
minimumFractionDigits: precision,
}).format(c);
if (currency === "OHM") return `${formatted} Ω`;
if (currency === "DAI") return `${formatted} DAI`;
if (currency) return `${formatted} ${currency}`;
return formatted;
}

Expand Down
16 changes: 8 additions & 8 deletions src/hooks/useScreenSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ export const useScreenSize = (size: "xs" | "sm" | "md" | "lg" | "xl") => {
size === "xs"
? "(max-width: 0px)"
: size === "sm"
? "(max-width: 600px)"
: size === "md"
? "(max-width: 900px)"
: size === "lg"
? "(max-width: 1200px)"
: size === "xl"
? "(max-width: 153600px)"
: "";
? "(max-width: 600px)"
: size === "md"
? "(max-width: 900px)"
: size === "lg"
? "(max-width: 1200px)"
: size === "xl"
? "(max-width: 153600px)"
: "";

return useMediaQuery(breakpoint);
};
4 changes: 2 additions & 2 deletions src/hooks/useTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const useTheme = (): [string, (e: KeyboardEvent) => void, boolean] => {
window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches && !localTheme
? setMode("dark")
: localTheme
? setTheme(localTheme)
: setMode("dark");
? setTheme(localTheme)
: setMode("dark");
setMounted(true);
}, []);

Expand Down
4 changes: 2 additions & 2 deletions src/views/Bond/components/BondModal/BondModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ const TokenPrice: React.VFC<{ token: Token; isInverseBond?: boolean; baseSymbol:
const price = sameToken
? formatNumber(1, 2)
: isInverseBond
? formatNumber(ohmPrice, 2)
: `${formatNumber(Number(priceToken.toString({ decimals: 2, format: true, trim: false })), 2)}`;
? formatNumber(ohmPrice, 2)
: `${formatNumber(Number(priceToken.toString({ decimals: 2, format: true, trim: false })), 2)}`;
return price ? (
<>
{price} {isInverseBond ? baseSymbol : quoteSymbol}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ export const BondInputArea: React.VFC<{
{isInverseBond
? `${quoteTokenString} (≈${baseTokenString})`
: props.bond.baseToken === props.bond.quoteToken
? `${baseTokenString}`
: `${baseTokenString} (≈${quoteTokenString})`}
? `${baseTokenString}`
: `${baseTokenString} (≈${quoteTokenString})`}
</span>
}
/>
Expand Down
14 changes: 8 additions & 6 deletions src/views/Bridge/components/BridgeConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ export const BridgeConfirmModal = (props: {
{props.amountExceedsBalance
? "Amount exceeds balance"
: !props.amount || parseFloat(props.amount) === 0
? "Enter an amount"
: !isValidAddress
? `Invalid recipient address: ${shorten(props.recipientAddress)}`
: props.bridgeMutation.isLoading
? "Confirming Bridging in your wallet"
: `Bridge OHM to ${BRIDGE_CHAINS[props.destinationChainId as keyof typeof BRIDGE_CHAINS].name}`}
? "Enter an amount"
: !isValidAddress
? `Invalid recipient address: ${shorten(props.recipientAddress)}`
: props.bridgeMutation.isLoading
? "Confirming Bridging in your wallet"
: `Bridge OHM to ${
BRIDGE_CHAINS[props.destinationChainId as keyof typeof BRIDGE_CHAINS].name
}`}
</PrimaryButton>
</>
</TokenAllowanceGuard>
Expand Down
20 changes: 12 additions & 8 deletions src/views/Governance/Components/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ export const Status = ({ proposalId }: { proposalId: number }) => {
<Typography fontWeight="500">Queued for Execution</Typography>
</div>
)}
<div>
<Typography fontSize="12px">{proposalDetails.etaDate.toLocaleString()}</Typography>
<Typography fontWeight="500">Estimated Execution Time</Typography>
</div>
{proposalDetails.etaDate && (
<div>
<Typography fontSize="12px">{proposalDetails.etaDate.toLocaleString()}</Typography>
<Typography fontWeight="500">Estimated Execution Time</Typography>
</div>
)}
</>
)}
{proposalDetails?.status === "Expired" && (
Expand All @@ -69,10 +71,12 @@ export const Status = ({ proposalId }: { proposalId: number }) => {
<Typography fontWeight="500">Queued for Execution</Typography>
</div>
)}
<div>
<Typography fontSize="12px">{proposalDetails.etaDate.toLocaleString()}</Typography>
<Typography fontWeight="500">Execution Expired</Typography>
</div>
{proposalDetails.etaDate && (
<div>
<Typography fontSize="12px">{proposalDetails.etaDate.toLocaleString()}</Typography>
<Typography fontWeight="500">Execution Expired</Typography>
</div>
)}
</>
)}
{proposalDetails?.status === "Executed" && (
Expand Down
2 changes: 1 addition & 1 deletion src/views/Governance/Components/VoteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ This behavior is intended to prevent users from changing the outcome of a vote i
)
}
>
{Number(votingWeight) > 0 ? "Cast Vote" : "No Voting Power"}
{Number(votingWeight) > 0 ? (castVote.isLoading ? "Casting Vote" : "Cast Vote") : "No Voting Power"}
</PrimaryButton>
</Box>
<Typography fontSize="12px" textAlign="center" fontWeight="600">
Expand Down
4 changes: 3 additions & 1 deletion src/views/Governance/Proposals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export const ProposalPage = () => {

const currentBlockTime = currentBlock?.timestamp ? new Date(currentBlock?.timestamp * 1000) : new Date();
const pending = !pendingActivation && proposalDetails.status === "Pending";
const pendingExecution = Boolean(proposalDetails.status === "Queued" && currentBlockTime >= proposalDetails.etaDate);
const pendingExecution = Boolean(
proposalDetails.status === "Queued" && proposalDetails.etaDate && currentBlockTime >= proposalDetails.etaDate,
);

return (
<div id="stake-view">
Expand Down
2 changes: 1 addition & 1 deletion src/views/Governance/hooks/useGetProposalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useGetProposalDetails = ({ proposalId }: { proposalId: number }) =>
startBlock: proposalDetails.startBlock.toNumber(),
endBlock: proposalDetails.endBlock.toNumber(),
eta: proposalDetails.eta.toNumber(),
etaDate: new Date(Number(proposalDetails?.eta) * 1000),
etaDate: proposalDetails?.eta ? new Date(Number(proposalDetails.eta) * 1000) : undefined,
quorumVotes: Number(formatEther(proposalDetails.quorumVotes)),
proposalThreshold: Number(formatEther(proposalDetails.proposalThreshold)),
startDate: startDateBlockTimestamp?.timestamp ? new Date(startDateBlockTimestamp.timestamp * 1000) : startDate,
Expand Down
11 changes: 11 additions & 0 deletions src/views/Governance/hooks/useGovernanceDelegationCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useGovernanceDelegationCheck = () => {

const { data: clearingHouseV1 } = useGetClearingHouse({ clearingHouse: "clearingHouseV1" });
const { data: clearingHouseV2 } = useGetClearingHouse({ clearingHouse: "clearingHouseV2" });
const { data: clearingHouseV3 } = useGetClearingHouse({ clearingHouse: "clearingHouseV3" });
const { data: coolerAddressV1 } = useGetCoolerForWallet({
walletAddress: address,
factoryAddress: clearingHouseV1?.factory,
Expand All @@ -25,9 +26,17 @@ export const useGovernanceDelegationCheck = () => {
debtAddress: clearingHouseV2?.debtAddress,
clearingHouseVersion: "clearingHouseV2",
});
const { data: coolerAddressV3 } = useGetCoolerForWallet({
walletAddress: address,
factoryAddress: clearingHouseV3?.factory,
collateralAddress: clearingHouseV3?.collateralAddress,
debtAddress: clearingHouseV3?.debtAddress,
clearingHouseVersion: "clearingHouseV3",
});
const { data: gOHMDelegationAddress } = useCheckDelegation({ address });
const { data: coolerV1DelegationAddress } = useCheckDelegation({ address: coolerAddressV1 });
const { data: coolerV2DelegationAddress } = useCheckDelegation({ address: coolerAddressV2 });
const { data: coolerV3DelegationAddress } = useCheckDelegation({ address: coolerAddressV3 });

const { data: gohmCoolerV2Balance } = useBalance({
address: coolerAddressV2 as `0x${string}`,
Expand All @@ -45,10 +54,12 @@ export const useGovernanceDelegationCheck = () => {
gOHMDelegationAddress,
coolerV1DelegationAddress,
coolerV2DelegationAddress,
coolerV3DelegationAddress,
gohmBalance,
gohmCoolerV1Balance,
gohmCoolerV2Balance,
coolerAddressV1,
coolerAddressV2,
coolerAddressV3,
};
};
24 changes: 20 additions & 4 deletions src/views/Lending/Cooler/dashboard/Metrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,23 @@ export const OutstandingPrincipal = () => {
);
};

export const WeeklyCapacityRemaining = ({ capacity }: { capacity?: BigNumber }) => {
export const WeeklyCapacityRemaining = ({
capacity,
reserveAsset,
}: {
capacity?: BigNumber;
reserveAsset?: string;
}) => {
return (
<Metric
label="Weekly Capacity Remaining"
metric={capacity ? formatCurrency(Number(ethers.utils.formatUnits(capacity.toString())), 0, "DAI") : <Skeleton />}
metric={
capacity && reserveAsset ? (
formatCurrency(Number(ethers.utils.formatUnits(capacity.toString())), 0, reserveAsset)
) : (
<Skeleton />
)
}
isLoading={capacity === undefined}
/>
);
Expand All @@ -108,15 +120,19 @@ export const TotalCapacityRemaining = () => {
label="Total Capacity Remaining"
metric={formatCurrency(getTotalCapacity(latestSnapshot), 0, "DAI")}
isLoading={latestSnapshot === undefined}
tooltip={`The capacity remaining is the sum of the DAI and sDAI in the clearinghouse and treasury. As of the latest snapshot, the values (in DAI) are:
tooltip={`The capacity remaining is the sum of the DAI/sDAI and USDS/sUSDS in the clearinghouse and treasury. As of the latest snapshot, the values are:
Clearinghouse:
DAI: ${formatCurrency(latestSnapshot?.clearinghouseTotals.daiBalance || 0, 0, "DAI")}
sDAI: ${formatCurrency(latestSnapshot?.clearinghouseTotals.sDaiInDaiBalance || 0, 0, "DAI")}
USDS: ${formatCurrency(latestSnapshot?.clearinghouseTotals.usdsBalance || 0, 0, "USDS")}
sUSDS: ${formatCurrency(latestSnapshot?.clearinghouseTotals.sUsdsInUsdsBalance || 0, 0, "USDS")}
Treasury:
DAI: ${formatCurrency(latestSnapshot?.treasury?.daiBalance || 0, 0, "DAI")}
sDAI: ${formatCurrency(latestSnapshot?.treasury?.sDaiInDaiBalance || 0, 0, "DAI")}`}
sDAI: ${formatCurrency(latestSnapshot?.treasury?.sDaiInDaiBalance || 0, 0, "DAI")}
USDS: ${formatCurrency(latestSnapshot?.treasury?.usdsBalance || 0, 0, "USDS")}
sUSDS: ${formatCurrency(latestSnapshot?.treasury?.sUsdsInUsdsBalance || 0, 0, "USDS")}`}
/>
);
};
Expand Down
Loading

0 comments on commit ec5f0ed

Please sign in to comment.