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
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
160
Foundry Localでエージェント開発
seosoft
0
190
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
820
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
450
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
310
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
190
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
340
Building an Out-of-Order CPU
latte72
1
770
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
160
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
380
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
140
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
330
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
Technical Leadership for Architectural Decision Making
baasie
3
570
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.8k
Between Models and Reality
mayunak
4
450
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
600
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
350
Automating Front-end Workflow
addyosmani
1369
210k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Optimizing for Happiness
mojombo
378
71k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
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