Skip to content
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

Minor Alpha front-end fixes #308

Merged
merged 6 commits into from
Dec 27, 2022
Merged
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
2 changes: 1 addition & 1 deletion packages/front-end/src/assets/CardTab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 15 additions & 13 deletions packages/front-end/src/components/LPStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,21 @@ export const LPStats = () => {
</div>
)}
</div>
<ProgressBar
completed={Math.round(
(Number(showDeposit ? showDeposit : depositedCollateral) /
Number(collateralCap)) *
100
)}
bgColor={"#000"}
height={"24px"}
baseBgColor={"#ebebeb"}
animateOnRender={true}
borderRadius={"9px"}
className={"border-2 border-2 rounded-xl border-black"}
/>
{depositedCollateral && (
<ProgressBar
completed={Math.round(
(Number(showDeposit ? showDeposit : depositedCollateral) /
Number(collateralCap)) *
100
)}
bgColor={"#000"}
height={"24px"}
baseBgColor={"#ebebeb"}
animateOnRender={true}
borderRadius={"9px"}
className={"border-2 border-2 rounded-xl border-black"}
/>
)}
</div>
);
};
97 changes: 50 additions & 47 deletions packages/front-end/src/components/OTC/OTCPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const OTCPageContent = () => {

const [orderId, setOrderId] = useState<string | null>(null);
const [order, setOrder] = useState<Order | null>(null);
const [isBuyer, setIsBuyer] = useState<boolean>(false);

const [optionSeriesContract, setOptionContract] =
useState<ethers.Contract | null>(null);
Expand Down Expand Up @@ -163,12 +164,12 @@ export const OTCPageContent = () => {
]);

useEffect(() => {
if (account && order) {
if (account.toLowerCase() !== order.buyer.toLowerCase()) {
setError(`❌ Please connect with account ${order.buyer}`);
}
if (account && (order || strangle)) {
// NOTE: this presumes buyer of call/put in strangle is same
const buyerAddress = order?.buyer ?? strangle?.call.buyer;
setIsBuyer(account.toLowerCase() === buyerAddress?.toLowerCase());
}
}, [account, order]);
}, [account, order, strangle]);

// Regular order handlers
const handleApprove = useCallback(async () => {
Expand Down Expand Up @@ -512,48 +513,50 @@ export const OTCPageContent = () => {
</div>
</div>
</div>
<div className="flex">
<Button
className={`w-full border-b-0 border-x-0 !py-4`}
onClick={
order
? order.isBuyBack
? handleApproveBuyBack
: handleApprove
: strangle
? handleApprove
: () => {}
}
color="black"
disabled={approveDisabled}
>
{isApproved
? "✅ Approved"
: isListeningForApproval
? "⏱ Awaiting Approval"
: "Approve"}
</Button>
<Button
className={`w-full border-b-0 border-x-0 !py-4 `}
color="black"
onClick={
order
? order.isBuyBack
? handleCompleteBuyBack
: handleComplete
: strangle
? handleComplete
: () => {}
}
disabled={completeDisabled}
>
{isListeningForComplete
? "⏱ Awaiting Completion"
: order?.isBuyBack
? "Complete Sale"
: "Complete Purchase"}
</Button>
</div>
{isBuyer && (
<div className="flex">
<Button
className={`w-full border-b-0 border-x-0 !py-4`}
onClick={
order
? order.isBuyBack
? handleApproveBuyBack
: handleApprove
: strangle
? handleApprove
: () => {}
}
color="black"
disabled={approveDisabled}
>
{isApproved
? "✅ Approved"
: isListeningForApproval
? "⏱ Awaiting Approval"
: "Approve"}
</Button>
<Button
className={`w-full border-b-0 border-x-0 !py-4 `}
color="black"
onClick={
order
? order.isBuyBack
? handleCompleteBuyBack
: handleComplete
: strangle
? handleComplete
: () => {}
}
disabled={completeDisabled}
>
{isListeningForComplete
? "⏱ Awaiting Completion"
: order?.isBuyBack
? "Complete Sale"
: "Complete Purchase"}
</Button>
</div>
)}
</>
) : (
<div className="p-4">
Expand Down
11 changes: 7 additions & 4 deletions packages/front-end/src/components/VaultTrades.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const VaultTrades = () => {
? CHAINID.ARBITRUM_RINKEBY
: CHAINID.ARBITRUM_MAINNET;

const { fetchMore, data, loading } = useQuery(
const { fetchMore, data, loading, error } = useQuery(
gql`
query ($timestamp1: Int, $timestamp2: Int) {
writeOptionsActions(
Expand Down Expand Up @@ -160,11 +160,9 @@ export const VaultTrades = () => {
}
}, [isVisible]);

console.log("trades length:", trades.length);

return (
<div className="w-full overflow-x-auto lg:overflow-x-clip relative">
<FullScreen handle={handle} className="overflow-auto">
<FullScreen handle={handle} className="overflow-auto bg-bone">
<table className="w-full text-sm text-left border-separate border-spacing-0 border-black">
<thead className="text-xs text-gray-700 uppercase sticky top-0 z-1">
<tr>
Expand Down Expand Up @@ -394,6 +392,11 @@ export const VaultTrades = () => {
)}
</tbody>
</table>
{error && (
<div className="m-5 flex flex-row justify-center">
<p>{error.message.slice(0, 100)}</p>
</div>
)}
</FullScreen>
</div>
);
Expand Down
52 changes: 28 additions & 24 deletions packages/front-end/src/components/dashboard/UserOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,42 +115,46 @@ export const UserOptionsList = () => {
// TODO: Add typings here
useQuery(
gql`
query($account: String) {
positions(first: 1000, where: { account_contains: "${account?.toLowerCase()}" }) {
id
amount
oToken {
id
symbol
expiryTimestamp
strikePrice
isPut
underlyingAsset {
id
}
}
writeOptionsTransactions {
query ($account: String) {
positions(first: 1000, where: { account_contains: $account }) {
id
amount
premium
timestamp
}
account {
balances {
balance
token {
oToken {
id
symbol
expiryTimestamp
strikePrice
isPut
underlyingAsset {
id
}
}
writeOptionsTransactions {
id
amount
premium
timestamp
}
account {
balances {
balance
token {
id
}
}
}
}
}
}
`,
`,
{
onCompleted: parsePositions,
onError: (err) => {
console.log(err);
},
variables: {
account: account?.toLowerCase(),
},
skip: !account,
}
);

Expand Down
2 changes: 1 addition & 1 deletion packages/front-end/src/components/vault/VaultContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const VaultContent = () => {

return (
<>
<div className="w-full flex justify-between bg-black text-white items-center p-4 col-start-1 col-end-17 mb-16">
<div className="w-full flex justify-between bg-black text-white items-center p-4 col-start-1 col-end-17 -mt-12 mb-16">
{envChainID && (
<div className="flex items-center w-[240px]">
<p>
Expand Down