Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Uniswapについて調べてみた
Search
YutaSugimura
May 17, 2019
Programming
440
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Uniswapについて調べてみた
YutaSugimura
May 17, 2019
More Decks by YutaSugimura
See All by YutaSugimura
IOST ハンズオン
yutasugimura
0
370
Other Decks in Programming
See All in Programming
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
480
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
200
What We Talk About When We Talk About XP
m_seki
2
610
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
6
1.8k
Jetpack Compose メカニズム
skydoves
0
370
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
530
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
6.7k
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
160
Building an Out-of-Order CPU
latte72
1
770
VueプロジェクトをTypeScript7に対応させる- Side-by-Side戦略による一部高速化 -
koukimiura
0
110
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
190
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.2k
Featured
See All Featured
Prompt Engineering for Job Search
mfonobong
0
450
Typedesign – Prime Four
hannesfritz
42
3.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
530
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
600
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
A Tale of Four Properties
chriscoyier
163
24k
First, design no harm
axbom
PRO
2
1.3k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Transcript
Uniswapͷ͓ @YutaSugimura ੀଜɹ༏ଠ
Enbowl inc. DEXͱ ࢄܕऔҾॴʢDEXʣͱɺ தԝཧऀΛհͣ͞ ݸਓؒͰ Ծ௨՟ͷަ͕Ͱ͖ΔऔҾॴͷ͜ͱ ex. Uniswap, KyberSwap,
DDEX, … (Decentralized Exchange)
Enbowl inc. Uniswap DeFiͰ4ҐͷϘϦϡʔϜ https://defipulse.com/
Enbowl inc. ɾಛఆͷೋऀؒͷަ͢Δ൘τϨʔυͰͳ͘ɺ ɹݻఆϨʔτͰͷଈ࣌ަΛఏڙ͢Δϓϩτίϧ ɾͦͷଞDEXʹൺͯऔҾʹ͔͔ΔΨε͕͍ ɾऔҾखྉ͕0.3% ɾྲྀಈੑఏڙ͢Δ͜ͱͰऔҾखྉͷҰ෦Λ֫ಘͰ͖Δ Uniswapͷಛ
Enbowl inc. Ψείετ͕͍҆ whitePaper: https://hackmd.io/s/HJ9jLsfTz ग़య:
Enbowl inc. Uniswap Contract ɾUniswap_exchange.vy ɾUniswap_factory.vy UniswapʹަՄೳͳτʔΫϯΛՃ͢Δػೳ τʔΫϯͷަྲྀಈੑఏڙ͢Δػೳ https://etherscan.io/address/0xc0a47dfe034b400b47bdad5fecda2621de6c4d95 https://etherscan.io/address/0xc0a47dfe034b400b47bdad5fecda2621de6c4d95
Exchange Factory ίϯτϥΫτͷߏ
Enbowl inc. factory Contract createExchange() Ճ͍ͨ͠ERC20τʔΫϯͷίϯτϥΫτΞυϨε ΛೖΕ࣮ͯߦ͢Δ͜ͱͰτʔΫϯΛՃ͞ΕΔ https://etherscan.io/accounts/label/uniswap ओʹΘΕΔؔ
Enbowl inc. Uniswap Contract ɾSwap ɾSend ɾPool ETH·ͨτʔΫϯΛଞͷτʔΫϯʹަ ETH·ͨτʔΫϯΛผͷΞυϨεʹૹۚ UniswapʹྲྀಈੑͷఏڙΛ͢Δػೳ
Exchange contract ͷߏ
Enbowl inc. Exchange Contract Swap ަՄೳͳίΠϯ 40छྨҎ্ ex. REP, DAI,
MKR, TUSD, ZRX, … Alice Alice 5ETH DAIʹަ 4ETH ɾETH => ERC20 ɾERC20 => ETH ɾERC20 => ERC20 3ͭͷަํ๏ʹରԠ 0DAI 250DAI 1ETHΛ
Enbowl inc. Exchange Contract Swap ethToTokenSwapInput() ethToTokenSwapOutput() tokenToEthSwapInput() tokenToEthSwapOutput() tokenToTokenSwapInput()
tokenToEthSwapOutput() ͦͷଞ ɾETH => ERC20 ɾERC20 => ETH ɾERC20 => ERC20 https://github.com/Uniswap/contracts-vyper/blob/master/contracts/uniswap_exchange.vy Uniswap contract ͜ΕΒͷؔΛͬͯަ͍ͯ͠Δ
Enbowl inc. Exchange Contract Send ETH => ERC20 ERC20 =>
ETH ERC20 => ERC20 ૹۚͷࡍʹτʔΫϯΛมͯ͠ૹۚ͢Δ͜ͱ͕Ͱ͖Δ Alice Bob 5ETH DAIʹަͯ͠ૹۚ 250DAI swapಉ༷ʹ3ͭͷૹۚʹରԠ 0DAI 1ETHΛ ॴ͍࣋ͯ͠ͳ͍τʔΫϯͷૹ͕ۚεϜʔζ https://github.com/Uniswap/contracts-vyper/blob/master/contracts/uniswap_exchange.vy Uniswap contract
Enbowl inc. Exchange Contract Transfer ETH => ERC20 ERC20 =>
ETH ERC20 => ERC20 ethToTokenTransferInput() tokenToEthTransferInput() tokenToTokenTransferInput() ෦తͰSwapͷ͕࣮ؔߦ͞Ε͓ͯΓɺडऔਓ͕ૹۚ૬खͷΞυϨεʹͳ͍ͬͯΔ ethToTokenTransferOutput() tokenToEthTransferOutput() tokenToEthTransferOutput() ͦͷଞ
Enbowl inc. Exchange Contract ྲྀಈੑͷఏڙ ࠷ॳʹྲྀಈੑΛఏڙ͢Δਓ͕Ձ֨Λઃఆ 5PLFOͱ 5PLFOͱಉྔͷ&5)ΛϩοΫ͢Δ Alice 1ETH
250DAI uniswapʹྲྀಈੑΛఏڙ 1ETH 250DAI uniswap ΑͬͯՁ͕֨ઃఆ͞ΕΔ ͦΕҎ߱ʹఏڙ͢ΔਓͦͷՁ֨ͰϩοΫ͍ͯ͘͠ ఏڙ͢Δ͜ͱͰखྉͷҰ෦ΛΒ͑Δ (0.3%ͷखྉ͔Βఏڙൺ)
Enbowl inc. Exchange Contract ɾྲྀಈੑͷఏڙ ɾaddLiquidity() ɾremoveLiquidity() ྲྀಈੑͷఏڙ ఏڙͷఫୀ ྲྀಈੑఏڙͷઆ໌লུ
Enbowl inc. Exchange Contract (Swap) (input_amount * 997) * output_reserve
(input_reserve * 1000) + (input_amount * 997) Tokens_bought = output_reserve = self.token.balanceOf(self) input_reserve = self.balance -msg.value input_amount = msg.value (Pool͕͍࣋ͬͯΔτʔΫϯྔ) (͜ͷϓʔϧ͕͍࣋ͬͯΔETHྔ) (ߪೖʹ༻͢ΔETHͷྔ) inputͷ߹ (outputͷ߹ҟͳΔ) ethToTokenSwapͷ߹
Enbowl inc. whitePaper: https://hackmd.io/s/HJ9jLsfTz ग़య: Exchange Contract
Enbowl inc. 45.35OMGʹަ token_Pool: eth_Pool: 10 500 ϓʔϧྔ invariant 5000
Exchange Contract Alice 1ETHͰ Bob 1ETHͰߪೖ ड͚औΓྔ 37.8 OMG ಉֹۚ͡Ͱങ͑Δྔ͕ݮΔ AliceߪೖޙBob͕1ETHͰOMGߪೖ͢Δ token_Pool: eth_Pool: 11 454.65 ϓʔϧྔ New invariant 5001.15
Enbowl inc. Exchange Contract 1000ഒͷPoolͩͱ 1ETHͰ49.84OMG token_Pool: eth_Pool: 10000 500000
ϓʔϧྔ Alice ड͚औΔ͜ͱ͕Ͱ͖ͨ ΑͬͯPool͞Ε͍ͯΔτʔΫϯͷྔ͕ଟ͍ͱՁ͕֨҆ఆ͢Δ
Enbowl inc. ΈΜͳτϨʔυԼख͔ͩΒUniswapʹྲྀಈੑΛఏڙ͠Α͏
Enbowl inc. Link https://uniswap.io https://hackmd.io/C-DvwDSfSxuh-Gd4WKE_ig White Paper Official IUUQTVOJTXBQFYDIBOHFTXBQ Exchange
GitHub https://github.com/Uniswap