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
Building an Out-of-Order CPU
latte72
1
750
スマート反転とウェブアクセシビリティ
camiha
0
180
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
2
290
XHTMLが残したもの
yosuke_furukawa
PRO
2
680
Foundry Localでエージェント開発
seosoft
0
170
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
150
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
360
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
240
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.7k
自分的「カンファレンスの楽しみ方」
syumai
0
200
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
520
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
430
Typedesign – Prime Four
hannesfritz
42
3.2k
How GitHub (no longer) Works
holman
316
150k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Embracing the Ebb and Flow
colly
88
5.2k
The Pragmatic Product Professional
lauravandoore
37
7.4k
The Language of Interfaces
destraynor
162
27k
Leo the Paperboy
mayatellez
9
2.3k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
The Curious Case for Waylosing
cassininazir
1
500
Technical Leadership for Architectural Decision Making
baasie
3
560
AI: The stuff that nobody shows you
jnunemaker
PRO
9
990
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