Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0ffd8c2
Add an animated, key-stepped version of the Options figures
mikemaccana Oct 22, 2026
6b8d126
Lay the Options animation out for a 16:9 screen, in a dark theme
mikemaccana Oct 22, 2026
9e3ccc2
Animate the whole Options chapter, from a standing start
mikemaccana Oct 22, 2026
9cdb024
Present the Options animation as a deck in the Quicknode slides' style
mikemaccana Oct 22, 2026
2912adb
Introduce each person in the Options talk when they first act
mikemaccana Oct 22, 2026
2feb637
Show both mints on the Options talk's mint step
mikemaccana Oct 22, 2026
f2a5885
Open the Options talk with options trading, before any Solana
mikemaccana Oct 22, 2026
8d83316
Explain calls and puts where the Options talk first needs them
mikemaccana Oct 22, 2026
970d4ab
Define each term in the Options talk where it is first needed
mikemaccana Oct 22, 2026
09cfc26
Add a Managed Fund talk on the same animation engine
mikemaccana Oct 22, 2026
e5a16ee
Make the running handler, and every touched account, easy to see
mikemaccana Oct 22, 2026
25c5946
Run the curve to the frame's edges, and point the closing QR at the book
mikemaccana Oct 22, 2026
a2b331c
Mark changed values, add a Questions slide, and close on the book
mikemaccana Oct 22, 2026
97afa17
Open both talks on "This is Solana Devnet", one idea a line
mikemaccana Oct 22, 2026
074db6c
Show a token transfer on the closing slide, not a coin riding the curve
mikemaccana Oct 22, 2026
640452c
Say on the first step how addresses are made
mikemaccana Oct 22, 2026
c3a2597
Say on the first step that financial products are programs
mikemaccana Oct 22, 2026
a4e0375
Add talks for seven more of the book's programs
mikemaccana Oct 23, 2026
01a6bb4
Add the Lending and Borrowing talk
mikemaccana Oct 23, 2026
9e02603
Bold every handler, plain endings, an index of talks, and the payout …
mikemaccana Oct 23, 2026
1b10889
Bold only the running handler
mikemaccana Oct 23, 2026
904b325
Make "a talk always matches its chapter" a stated rule
mikemaccana Oct 23, 2026
221964e
Match nine talks to their chapters
mikemaccana Oct 23, 2026
c98b907
Set each person's name on the "versus" slides as a badge
mikemaccana Oct 23, 2026
cb91f81
Rebuild the Lending talk from its chapter, and title every outcome
mikemaccana Oct 23, 2026
86f2dd6
Give every derived account its own seed list
mikemaccana Oct 23, 2026
00f74e0
Refuse two derived accounts with the same seeds
mikemaccana Oct 23, 2026
428f8f1
Escrow talk: a price tag for the offer
mikemaccana Oct 23, 2026
2572cf4
Options talk: a sealed document for the contract
mikemaccana Oct 26, 2026
deea7b3
Drop the Questions slide from every talk
mikemaccana Oct 26, 2026
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
147 changes: 147 additions & 0 deletions animations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Animated figures

A chapter's figures, stepped through on screen: press a key and the next thing the program does happens.
Accounts are created, fields change, and tokens travel along their arrows. Every step is drawn in the book's
own figure vocabulary (`DIAGRAMS.md` in the companion plugin), with the chapter figures' columns, so the
screen version and the printed figures show the same map.

The screen has no print limits, so a scene is drawn on a 16:9 canvas (1120 by 630 units). The extra width
puts every public-key account, mints included, beneath the one cluster curve. Colours live in `THEME` at
the top of `engine.js`. Each step has a title, with its caption in the frame beneath.

There is a talk for every program in Part II, each a directory named for its chapter:

| Directory | Chapter | Program |
| --- | --- | --- |
| `escrow/` | 11 Escrow | `finance/escrow` |
| `fundraiser/` | 12 The Fundraiser | `finance/fundraiser` |
| `betting-market/` | 13 The Betting Market | `finance/betting-market` |
| `order-book/` | 14 The Order Book Exchange | `finance/order-book` |
| `constant-product-amm/` | 15 The Constant-Product AMM | `finance/token-swap` |
| `prop-amm/` | 16 The Prop AMM | `finance/prop-amm` |
| `lending/` | 17 Lending and Borrowing | `finance/lending` |
| `managed-fund/` | 18 The Managed Fund | `finance/managed-fund` |
| `options/` | 19 Options | `finance/options` |
| `perpetual-futures/` | 20 Perpetual Futures | `finance/perpetual-futures` |

`index.html` here links to every talk. Open a talk's own `index.html` in a browser. No build step and no server: it runs straight from disk. A talk's
own icons in `assets/icons` carry its directory's prefix (`escrow-`, `perps-`, ...); unprefixed icons are
shared, and mean the same idea in every talk.

| Key | Does |
| --- | --- |
| `→`, `Space`, `PageDown`, `Enter`, click | next step |
| `←`, `PageUp`, `Backspace` | previous step |
| `Home` / `End` | first / last step |
| `P` | play / pause: each finished step holds for `hold` ms (3 seconds), then the next plays |
| `F` | full screen |

A step plays once and then holds until the next key. A key pressed while a step is animating finishes that
step at once. `PageDown` and `PageUp` are what presentation remotes send. Open `index.html?autoplay` to start
playing on load.

## The talk around the diagrams

`index.html` opens a slide deck in the look of the Quicknode Solana Finance Keynote: a title slide, what you
should know and what you'll learn, card slides between the runs of diagram steps, where everyone ended up,
and the closing slides. One key advances through all of it: a diagram step plays its animation, and a slide
of cards builds them one at a time.

- `deck.js` and `deck.css` are shared by every talk. A slide kind is a template filled from data, and
`[word]` in any text is set on the green highlight, `{word}` on the purple one. The kinds follow the
Quicknode Keynote template's layouts:

| Kind | Layout |
| --- | --- |
| `title` | the series tag, a large title, the mark in a green square |
| `columns` | what you should know, and what you'll learn |
| `statement` | one large centred sentence |
| `versus` | two people side by side, a full-height panel each |
| `split` | the heading on the left, a stack of wide icon cards on the right |
| `grid` | the heading across the top, a grid of centred icon cards (`columns`: 2, 3 or 4) |
| `numbered` | cards tagged `// 01`, `// 02` |
| `cards` | tall cards in the slides' three tones |
| `chart` | a payoff chart, one line per side |
| `allocation` | a bar split by value: a fund's weights, or who owns its shares; with `from`, the parts move from earlier values to their own, to or from nothing (a losing stake paying the winners), after `delay` ms |
| `qr`, `follow` | the closing slides |

Any slide with cards, or a chart's lines, builds one per key press unless it sets `build: false`.
A card's `icon` is one of the book's account glyphs (`wallet`, `token`, ...) or, as `tpl:name`, one of
the template's icons in `assets/icons`, named for the idea it stands for (`premium`, `price-rises`,
`insurance`). One icon means one idea throughout a talk: reuse it where the idea comes back, and never
give it to anything else.
- **A talk always matches its chapter.** Its people, assets, events, order of events and numbers are the
chapter's. A talk never invents a scenario, swaps one person for another, adds an event the chapter
doesn't describe, or shows a number the chapter doesn't state. A balance may follow from the chapter's
numbers by plain arithmetic, marked in a comment; a number the chapter leaves out stays out. A talk may
leave a minor branch out for time, never replace one.
- A term is defined where the talk first needs it: not before, where it means nothing yet, and not after,
where it was already used unexplained. Calls are defined just before Alice writes one, "covered" in the
step where her collateral lands in the vault, and "in the money" in the step where Bob exercises.
- `<chapter>/slides.js` lists the talk's slides. A `diagram` slide names the scene steps it shows, `from`
and `to` by index, and together the diagram slides show every step once, in order; the deck refuses to
start otherwise.
- `assets/` holds the Quicknode mark (inlined in `deck.css` as a mask), a QR code generated from
solanabook.org, and in `assets/icons` the icons taken from the Quicknode Keynote template.

The diagrams take the same palette: accounts are pastel cards on near-black (white for wallets, green for
token accounts, lavender for programs, grey for data accounts, cream for mints), a faded account is a dark
slab, and the step's action is the bright green. A step title marks its keyword in brackets, `Maria runs
[collect_fees()]`, and the step number sits in the corner as `// STEP n`.

## How a scene is built

- `engine.js` is shared by every scene. It draws accounts, arrows and coins, and animates each step's actions.
- `<chapter>/scene.js` holds that chapter's layout and steps, and nothing else.

The layout is placed by hand, as the figures are: each column's position and width is chosen in the scene.
A public-key account's dot is put on the curve with `clusterCurve().yAt()` and its box hangs 9.3 below it,
and a derived account's dot and seed list sit above its box, so the dots never drift off the curve. No two derived accounts share a seed list: the same seeds are the
same address, so a scene that repeats one is wrong, and the engine refuses to draw it. Name the seed that
tells them apart, the index, the order ID or the reserve, as the program does. A step
is a title, a caption, and a list of actions:

| Action | Shows |
| --- | --- |
| `show` | accounts that already exist on chain fade in, with their lines; `focus: "shown"` draws them in full |
| `hide` | accounts the rest of the story no longer needs fade out, so others can take their columns |
| `focus` | which accounts are drawn in full; the rest fade to their heading |
| `call` | a handler lights up in the program box, and the focus moves to the accounts it touches; `also` lights handlers it calls in other programs, and a `call` with no handler is a step no program takes, such as a price moving |
| `highlight` | the lit handlers change within a call, as a deposit moves from one swap to the next |
| `create` | a new account grows in, with a `NEW` badge |
| `set` | fields or titles change; numbers count from the old value to the new |
| `transfer` | the arrow draws, a coin rides it, and both balances count to their new values; with `alone` it replaces the step's earlier arrows, and a side with no `value` (a router trading on the far side) shows no balance |
| `close` | an account is marked `CLOSED` and fades out, taking the step's arrows with it |

A person appears in the step where they first do something, with the accounts that step uses: Bob and his
USDC when he buys, Maria when she opens the venue and her USDC only when she collects the fees. A scene
opens on one person and builds outward, so an audience new to Solana meets one account at a time.

The running handler's line in a program box is bold, on the green band, in a face with a real bold weight:
Andale Mono has none, and a browser's made-up bold is too faint to pick out. Handler names elsewhere are
set like the words around them.

A step can also carry a `key`, and a later step can start `from` that key instead of from the step before
it. That is how another possible ending branches off the story (the call expiring unused starts from the purchase,
not from the exercise before it) and how the story resumes afterwards. The jump between endings fades out
and back in, so it never reads as the program doing something. Each ending opens on a `statement`
slide that names it, "Outcome 1: nobody takes Alice's offer", "Outcome 2: Bob takes Alice's offer", and
a return to the main story on "Back to Outcome 1: …". A brief aside that is not an ending opens on
"What if …?". The steps after such a slide go straight to what happens, without "It's possible that".

Every step's end state is computed by replaying the actions without motion. Going back, jumping, or
cutting an animation short therefore lands on exactly the picture the forward animation ends on.

Order the actions as the handler in `quicknode/solana-program-examples` orders its work, not as the prose
lists it. `buy_option()` writes the holder, the status and `fees_owed`, and runs `check_custody()`, before
either transfer, so the scene does the same.

## Checking a scene

```
node scripts/animation-frames.mjs options # each step's end state as build/animation-options-NN.png and .svg
node scripts/animation-frames.mjs managed-fund # the same for the Managed Fund talk
node scripts/animation-frames.mjs options --video # the whole animation, each step held, as build/animation-options.webm
```

The script fails if the page throws an error.
Binary file added animations/assets/book-cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/amm-fee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/amm-formula.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/amm-instant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/amm-pool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/bargain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-against.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-backs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-fee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-film.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-house.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-odds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-pool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-stake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/betting-won.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-atomic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-buy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-fee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-maker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-middleman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-offer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-sell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-swap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-taker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added animations/assets/icons/escrow-vault.png
Binary file added animations/assets/icons/expertise.png
Binary file added animations/assets/icons/expire.png
Binary file added animations/assets/icons/expiry.png
Binary file added animations/assets/icons/fundraiser-backer.png
Binary file added animations/assets/icons/fundraiser-claim.png
Binary file added animations/assets/icons/fundraiser-deadline.png
Binary file added animations/assets/icons/fundraiser-maker.png
Binary file added animations/assets/icons/fundraiser-receipt.png
Binary file added animations/assets/icons/fundraiser-refund.png
Binary file added animations/assets/icons/fundraiser-target.png
Binary file added animations/assets/icons/holder.png
Binary file added animations/assets/icons/income.png
Binary file added animations/assets/icons/insurance.png
Binary file added animations/assets/icons/later.png
Binary file added animations/assets/icons/lending-cash.png
Binary file added animations/assets/icons/lending-collateral.png
Binary file added animations/assets/icons/lending-interest.png
Binary file added animations/assets/icons/lending-liquidation.png
Binary file added animations/assets/icons/lending-ltv.png
Binary file added animations/assets/icons/lending-short.png
Binary file added animations/assets/icons/orderbook-ask.png
Binary file added animations/assets/icons/orderbook-bid.png
Binary file added animations/assets/icons/orderbook-book.png
Binary file added animations/assets/icons/orderbook-cross.png
Binary file added animations/assets/icons/orderbook-limit.png
Binary file added animations/assets/icons/orderbook-spread.png
Binary file added animations/assets/icons/perps-collateral.png
Binary file added animations/assets/icons/perps-haircut.png
Binary file added animations/assets/icons/perps-leverage.png
Binary file added animations/assets/icons/perps-liquidation.png
Binary file added animations/assets/icons/perps-no-expiry.png
Binary file added animations/assets/icons/perps-pool.png
Binary file added animations/assets/icons/perps-price-falls.png
Binary file added animations/assets/icons/perps-size.png
Binary file added animations/assets/icons/premium.png
Binary file added animations/assets/icons/price-rises.png
Binary file added animations/assets/icons/propamm-ask.png
Binary file added animations/assets/icons/propamm-bid.png
Binary file added animations/assets/icons/propamm-instant.png
Binary file added animations/assets/icons/propamm-inventory.png
Binary file added animations/assets/icons/propamm-maker.png
Binary file added animations/assets/icons/propamm-oracle.png
Binary file added animations/assets/icons/propamm-spread.png
Binary file added animations/assets/icons/savings.png
Binary file added animations/assets/icons/strike.png
Binary file added animations/assets/icons/underlying.png
Binary file added animations/assets/icons/venue.png
Binary file added animations/assets/icons/vetting.png
Binary file added animations/assets/icons/writer.png
2 changes: 2 additions & 0 deletions animations/assets/qr-solanabook.svg
Binary file added animations/assets/quicknode-mark.png
Binary file added animations/assets/sky.jpg
50 changes: 50 additions & 0 deletions animations/betting-market/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Betting Market Talk</title>
<link rel="stylesheet" href="../deck.css">
</head>
<body>
<div id="stage"><svg viewBox="0 0 1120 630" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" fill="#f4f4f4" role="img" aria-label="Animated account diagram"></svg></div>
<div id="hint"><kbd>→</kbd> next · <kbd>←</kbd> back · <kbd>P</kbd> play / pause · <kbd>F</kbd> full screen</div>
<script src="../engine.js"></script>
<script src="../deck.js"></script>
<script src="scene.js"></script>
<script src="slides.js"></script>
<script>
const scene = window.BETTING_SCENE;
const stage = document.getElementById("stage");
stage.querySelector("svg").setAttribute("viewBox", `0 0 ${scene.canvas.width} ${scene.canvas.height}`);
const deck = new AccountDeck.Deck(window.BETTING_DECK, scene, stage);
// Exposed for scripts/animation-frames.mjs and the browser console.
window.player = deck;

const hint = document.getElementById("hint");
let hintTimer = setTimeout(() => hint.classList.add("hidden"), 4000);
const touch = () => {
hint.classList.remove("hidden");
clearTimeout(hintTimer);
hintTimer = setTimeout(() => hint.classList.add("hidden"), 2500);
};

// Each key press plays one diagram step or builds one card, then holds
// until the next; autoplay holds each for scene.hold. Presentation remotes
// send PageDown and PageUp.
document.addEventListener("keydown", (e) => {
touch();
if (["ArrowRight", " ", "PageDown", "Enter"].includes(e.key)) { e.preventDefault(); deck.stopAutoplay(); deck.next(); }
else if (["ArrowLeft", "PageUp", "Backspace"].includes(e.key)) { e.preventDefault(); deck.prev(); }
else if (e.key === "Home") { deck.stopAutoplay(); deck.goto(0); }
else if (e.key === "End") { deck.stopAutoplay(); deck.goto(deck.count - 1); }
else if (e.key === "p" || e.key === "P") { deck.autoplay ? deck.stopAutoplay() : deck.startAutoplay(); }
else if (e.key === "f" || e.key === "F") {
document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen();
}
});
stage.addEventListener("click", () => { deck.stopAutoplay(); deck.next(); });
if (new URLSearchParams(location.search).has("autoplay")) deck.startAutoplay();
</script>
</body>
</html>
Loading
Loading