Skip to content

Commit

Permalink
Feat: add diagram + components + packages
Browse files Browse the repository at this point in the history
  • Loading branch information
anegg0 committed Feb 6, 2025
1 parent 61ca053 commit 4f7bfc1
Show file tree
Hide file tree
Showing 7 changed files with 1,414 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ user_story: As a current or prospective Arbitrum user, I want to understand how
content_type: gentle-introduction
---

import { FlowChart } from '@site/src/components/InteractiveDiagrams/Timeboost/CentralizedAuction';
import ImageWithCaption from '@site/src/components/ImageCaptions/';

This introduction will walk you through <a data-quicklook-from='timeboost'>Arbitrum Timeboost</a>: a novel <a data-quicklook-from='transaction-ordering-policy'>transaction ordering policy</a> for Arbitrum chains that allows chain owners to capture the Maximal Extractable Value (MEV) on their chain and reduce spam, all while preserving fast block times and protecting users from harmful types of MEV, such as sandwich attacks and front-running.
Expand Down Expand Up @@ -76,6 +77,8 @@ Control of the express lane in each round (default: 60 seconds) is determined by

![timeboost auction workflow](./images/centralized-timeboost-auction-workflow.jpg)

<FlowChart />;

The auction for a round has a closing time that is `auctionClosingSeconds` (default: 15) seconds before the beginning of the round. This means that, in the default parameters, parties have 45 seconds to submit bids before the auction will no longer accept bids. In the 15 seconds between when bids are no longer accepted and when the new round begins, the autonomous auctioneer will verify all bids, determine the winner, and make a call to the on-chain auction contract to formally resolve the auction.

### Auction contract
Expand Down
4 changes: 4 additions & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.3.2",
"@offchainlabs/prettier-config": "0.2.1",
"@radix-ui/react-dialog": "^1.1.6",
"@react-spring/web": "^9.7.5",
"@stitches/react": "^1.2.8",
"@tsconfig/docusaurus": "^2.0.3",
"@types/node": "^22.10.10",
"docusaurus-plugin-typedoc": "^1.0.1",
"husky": "^9.1.7",
"markdown-link-extractor": "^3.1.0",
"prettier": "^2.8.3",
"styled-components": "^6.1.15",
"ts-node": "^10.9.1",
"typedoc": "^0.25.13",
"typedoc-plugin-frontmatter": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { useSpring, animated } from '@react-spring/web';

export function Circle({ cx = 1170, cy = 490, r = 10, fill = '#c60' }) {
const props = useSpring({
from: { opacity: 0.3 },
to: { opacity: 1 },
config: { duration: 800 },
loop: { reverse: true },
});

return (
<animated.circle
cx={cx}
cy={cy}
r={r}
fill={fill}
style={props}
data-cell-id="tykxDlpcZX9cg9i9ZL_u-31"
pointerEvents="all"
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React, { useState } from 'react';
import { useTransition, animated } from '@react-spring/web';
import styled from 'styled-components';
import * as Dialog from '@radix-ui/react-dialog';
import { createPortal } from 'react-dom';
import { Circle } from './Circle';

export function Modal({ cx = 1170, cy = 490 }) {
const [isOpen, setIsOpen] = useState(false);

const handleDialogChange = (isOpen: boolean) => setIsOpen(isOpen);

const transition = useTransition(isOpen, {
from: {
scale: 0,
opacity: 0,
},
enter: {
scale: 1,
opacity: 1,
},
leave: {
scale: 0,
opacity: 0,
},
});

return (
<>
<g onClick={() => setIsOpen(true)} style={{ cursor: 'pointer' }}>
<Circle cx={cx} cy={cy} r={10} fill="#569AFF" />
</g>
{typeof document !== 'undefined' &&
createPortal(
<Dialog.Root open={isOpen} onOpenChange={handleDialogChange}>
<Dialog.Portal forceMount>
{transition((style, isOpen) => (
<>
{isOpen ? <OverlayBackground style={{ opacity: style.opacity }} /> : null}
{isOpen ? (
<Content forceMount style={style}>
<DialogHeader>
<CloseButton>
<svg
width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M15.9574 14.1689L8.59651 6.75098L6.73232 8.59598L14.1313 16.071L6.71338 23.4129L8.5964 25.2769L15.9574 17.8779L23.3943 25.2769L25.2392 23.4129L17.8213 16.071L25.2202 8.59598L23.3752 6.75098L15.9574 14.1689Z"
fill="currentColor"
/>
</svg>
</CloseButton>
</DialogHeader>
<Title>How to call the sequencer</Title>
<DialogBody>Call the contract's function: bla bla bla</DialogBody>
</Content>
) : null}
</>
))}
</Dialog.Portal>
</Dialog.Root>,
document.body,
)}
</>
);
}

const OverlayBackground = styled(animated(Dialog.Overlay))`
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.5);
pointer-events: all;
position: fixed;
inset: 0;
z-index: 9999;
`;

const Content = styled(animated(Dialog.Content))`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 30vw;
height: 40vh;
background-color: #213147;
border-radius: 4px;
padding: 24px 24px 32px;
z-index: 10000;
`;

const DialogHeader = styled.header`
display: flex;
justify-content: flex-end;
margin-bottom: 16px;
`;

const DialogBody = styled.body`
display: flex;
justify-content: center;
margin-bottom: 6px;
`;

const CloseButton = styled(Dialog.Close)`
background-color: transparent;
border: none;
position: absolute;
top: 16px;
right: 16px;
cursor: pointer;
color: #9dcced;
`;

const Title = styled(Dialog.Title)`
font-size: 20px;
`;

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.hover-frame {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
display: none; /* Hidden by default */
justify-content: center;
align-items: center;
color: white;
font-size: 1.5rem;
z-index: 10; /* Ensure it appears on top */
text-align: center; /* Center text horizontally */
}

.hover-frame.visible {
display: flex; /* Show the frame when visible */
color: white;
font-size: 1.5rem;
}

.diagramContainer {
width: 100%;
height: auto;
position: relative;
}

.hoverOverlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
color: white;
font-size: 1.5rem;
pointer-events: none;
}

.hovered path,
.hovered rect {
fill: #ff0000;
transition: fill 0.3s ease;
}

.flowChartContainer {
width: 100%;
max-width: 1200px;
margin: 0 auto;
overflow-x: auto;
padding: 1rem;
}
Loading

0 comments on commit 4f7bfc1

Please sign in to comment.