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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
R8 の設定見直しでアプリサイズ削減
andpad
0
220
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
320
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
440
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
700
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
golang-bob.pdf
iwatsukayura
0
130
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
170
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
430
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Building Applications with DynamoDB
mza
96
7.2k
Building AI with AI
inesmontani
PRO
1
1.3k
Typedesign – Prime Four
hannesfritz
42
3.2k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
450
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Scaling GitHub
holman
464
140k
A better future with KSS
kneath
240
18k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
730
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
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