📜 [專欄新文章] Gas Efficient Card Drawing in Solidity
✍️ Ping Chen
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
Assign random numbers as the index of newly minted NFTs
Scenario
The fun of generative art NFT projects depends on randomness. The industry standard is “blind box”, where both the images’ serial number and the NFTs’ index are predetermined but will be shifted randomly when the selling period ends. (They call it “reveal”) This approach effectively solves the randomness issue. However, it also requires buyers to wait until the campaign terminates. What if buyers want to know the exact card right away? We’ll need a reliable onchain card drawing solution.
The creator of Astrogator🐊 isn’t a fan of blind boxes; instead, it thinks unpacking cards right after purchase is more interesting.
Spec
When initializing this NFT contract, the creator will determine the total supply of it. And there will be an iterable function that is randomly picking a number from the remaining pool. The number must be in range and must not collide with any existing ones.
Our top priority is accessibility/gas efficiency. Given that gas cost on Ethereum is damn high nowadays, we need an elegant algorithm to control gas expanse at an acceptable range.
Achieving robust randomness isn’t the primary goal here. We assume there’s no strong financial incentive to cheat, so the RNG isn’t specified. Implementers can bring their own source of randomness that they think is good enough.
Implementation
Overview
The implementation is pretty short and straightforward. Imagine there’s an array that contains all remaining(unsold) cards. When drawIndex() is called, it generates a (uniform) random seed to draw a card from the array, shortens the array, and returns the selected card.
Algorithm
Drawing X cards from a deck with the same X amount of cards is equal to shuffling the deck and dealing them sequentially. It’s not a surprise that our algorithm is similar to random shuffling, and the only difference is turning that classic algo into an interactive version.
A typical random shuffle looks like this: for an array with N elements, you randomly pick a number i in (0,N), swap array[0] and array[i], then choose another number i in (1,N), swap array[1] and array[i], and so on. Eventually, you’ll get a mathematically random array in O(N) time.
So, the concept of our random card dealing is the same. When a user mints a new card, the smart contract picks a number in the array as NFT index, then grabs a number from the tail to fill the vacancy, in order to keep the array continuous.
Tweak
Furthermore, as long as the space of the NFT index is known, we don’t need to declare/initialize an array(which is super gas-intensive). Instead, assume there’s such an array that the n-th element is n, we don’t actually initialize it (so it is an array only contains “0”) until the rule is broken.
For the convenience of explanation, let’s call that mapping cache. If cache[i] is empty, it should be interpreted as i instead of 0. On the other hand, when a number is chosen and used, we’ll need to fill it up with another unused number. An intuitive method is to pick a number from the end of the array, since the length of the array is going to decrease by 1.
By doing so, the gas cost in the worst-case scenario is bound to be constant.
Performance and limitation
Comparing with the normal ascending index NFT minting, our random NFT implementation requires two extra SSTORE and one extra SLOAD, which cost 12600 ~ 27600 (5000+20000+2600) excess gas per token minted.
Theoretically, any instantly generated onchain random number is vulnerable. We can restrict contract interaction to mitigate risk. The mitigation is far from perfect, but it is the tradeoff that we have to accept.
ping.eth
Gas Efficient Card Drawing in Solidity was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
同時也有5部Youtube影片,追蹤數超過9萬的網紅Smart Travel,也在其Youtube影片中提到,成為這個頻道的會員並獲得獎勵: https://www.youtube.com/channel/UCIuNPxqDGG08p3EqCwY0XIg/join #大阪周遊卡 #googlemap #travelplanner #travelplan #travelplan2020 #youtube #y...
「where are you going教學」的推薦目錄:
- 關於where are you going教學 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於where are you going教學 在 Eric's English Lounge Facebook 的最讚貼文
- 關於where are you going教學 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於where are you going教學 在 Smart Travel Youtube 的最佳解答
- 關於where are you going教學 在 波波星球泡泡哥哥BoboPopo Youtube 的精選貼文
- 關於where are you going教學 在 哥倫布 Columbus Youtube 的精選貼文
- 關於where are you going教學 在 Moji Today - 改編《This or That?》-Where are you going? 五 ... 的評價
where are you going教學 在 Eric's English Lounge Facebook 的最讚貼文
翻轉視界 18 Changing Perspective
There's not just one road to the destination, but many roads. You just need to take the little step that’s right in front of you, and then the next one, and a few years down the track, they will seem like massive achievements.
通往目的地的路不止一條,有很多路可走。你只需要邁出眼前這一小步,然後再邁出下一步,幾年下來,將會成為巨大成就。
文章來自於New Humans of Australia (有取得授權)
★★★★★★★★★★★★
I didn’t meet my father until I was 6 years old. My parents had a comfortable, middle-class life in Shanghai, or as close as you could get under communism. But they always wanted to live overseas, and just before I was born, my dad came to Sydney to set things up. I don’t know why, but in the end, my mother and I didn’t join him until I was 6.
•a middle-class life 中產階級生活
•set things up 打點一切
•live overseas 往海外生活
•in the end 最後 (表達在經過一段時間或一連串事件之後的結果)
直到六歲前我都未曾見過父親。我的雙親在上海過著舒適的中產階級生活,或著說,在共產階級下所能得到的最接近的生活。他們一直響往海外生活,就在我出生前,我父親來到雪梨打點一切。但不知何故,直到六歲那年我與母親才終於與父親團聚。
★★★★★★★★★★★★
Unfortunately, half a year after we arrived, he left us. That was a huge shock. Our transition had already been quite difficult, as we both didn't speak English. Also, as Shanghai was such a big bustling city, Sydney felt a bit like the countryside, especially on the weekends, as no shops were open back then!
•shock 令人震驚的事件(或經歷);驚愕,震驚 (come as a great shock 讓人倍感震驚)
•transition 轉變;過渡
•a bustling city 繁華都會
不幸的是,就在我跟母親抵達半年後,父親離開了我們。這是個巨大的打擊,因爲我們不會說英文,在適應過渡期本就已過得相當艱辛。此外,不同於上海的繁華都會,雪梨更像鄉下,尤其在週末,那時連商店都不開門。
★★★★★★★★★★★★
We were very much reliant on my dad, not only financially, but also as a conduit into the wider community. So to have that broken was quite distressing. I remember Mum crying a lot. As we had become socially isolated, we didn’t find out anything about Centrelink, so we survived on her savings for a while, and then got some help from her family back in China.
•be reliant on… 依賴...
•a conduit into 進入...的渠道
•distressing (adj.) 令人苦惱的,令人擔憂的
•become socially isolated 變得孤立於社會
•survive on her savings 僅靠的她積蓄過日子
我們相當依賴我父親,不僅是經濟,他也是我們進入更廣泛社區的渠道。因此,當局面被打破時令人相當痛苦,我還記得母親時常哭泣。由於我們孤立於社會,所以我們並不知道澳洲社會福利聯絡中心 (Centrelink)的任何資訊,僅靠母親的積蓄支撐了一段時間,然後從母親在中國的娘家得到一些幫助。
★★★★★★★★★★★★
Eventually, Mum moved us down to Melbourne, where we were able to make some new networks and family friendships. But I was bullied a bit at school about things like my food and clothing! Whenever someone bullied me, I would defend myself, but because I didn’t have the language skills to explain to the teacher why, I got in trouble quite a bit. I ended up having to move school 3 times before I came to Balwyn Primary School, which was relatively multicultural.
•be able to 能夠
•make new networks 建立新的人脈,關係網
•be bullied 被霸凌
•language skills 語言能力
•get in trouble 惹上麻煩
•end up 最後處於;最後成爲;以…告終
•relatively 相對地
•multicultural 多元文化的
最後,母親帶著我搬遷到墨爾本,在那我們能夠建立起新的網絡與家庭情誼。然而。我在學校飽受霸凌,例如我的食物及衣物。每當有人霸凌我,我會自我防衛,但我的語言技巧不足以向老師解釋事發原因,因此常常陷入麻煩。後來我不得不再三轉學,直到就讀相對多元文化的博文小學(Balwyn Primary School)。
★★★★★★★★★★★★
After that, I did alright. Music featured very prominently in my life. I had started learning the violin from the age of 2.5 years old and even with all the troubles that were going on in my life, had somehow still kept up with it. As a result, I got a music scholarship to Trinity Grammar School. But even there I used to get into quite a lot of mischief, and would often skip school to go to the movies.
•do alight 過得不錯,做的不錯
•feature (v.) 以…為特色;給…以顯著的地位
•prominently 重要地;著名地;突出地,顯眼地
之後,我便過得不錯。音樂在我生活中佔有重要的一席之地,我從兩歲半開始學習小提琴,儘管生活中事事不如意,我依然堅持不輟。因此,我獲得三一文法學校( Trinity Grammar School)的音樂獎學金。但即使在那,我也常惡作劇、逃學看電影。
★★★★★★★★★★★★
By the end of year 11, I was told I would have to either repeat the year, or consider going to another school, which was quite humiliating for my mum. I decided to move school and surprisingly, I ended up doing quite well in year 12! As a result, I ended up getting into a double degree in Law and Music at Monash.
•repeat the year 留級 ; 重唸一年
•humiliating 令人感到恥辱的,丟臉的
11年級結束時,我被告知要麽被留級,要麼考慮轉學,這對我母親來說相當丟人。我決定轉學,而令人驚訝的是,我在12年級的時候表現優異,最後錄取蒙納士大學法律與音樂雙學位。
★★★★★★★★★★★★
When I started, my first thought was that I didn’t belong because I had done so badly in school up to year 11 and everyone else seemed so smart. But I put my head down, got through it, and ended up getting a job in the legal department of a major manufacturing company, which was a different approach to what most law students do.
•do not belong 不屬於這
•put my head down 埋頭苦幹
•the legal department of ...的法律部門
•a different approach 不同途徑
•approach (思考問題的)方式,方法,態度
當我開始進入大學,最初的想法是我不屬於這,因為我在11年級前都表現不佳,而這裡的人似乎都聰明絕頂。但我埋頭苦幹,咬牙撐過,最後在一家大型製造公司的法律部門找到工作,這與多數法律系學生的途徑不同。
★★★★★★★★★★★★
I really enjoyed it. It was hard work, but I learned a lot of foundational business, legal and corporate communication skills. After that I worked in corporate governance in RMIT, then started to moonlight as a lecturer in the Law Faculty. Eventually, they asked me if I wanted to do a PhD and I blindly said yes! I next worked at Swinburne University, and then was head-hunted to lead the corporate legal team at the Commercial Passenger Vehicles Commission.
•foundational 基礎的
•communication skills 溝通技巧
•corporate governance
•moonlight (v.) (尤指瞞著僱主)從事第二職業,兼職
•headhunt (v.) 物色(人才); 挖角
•legal team 法律團隊
我非常喜歡這份工作,這是份辛苦的工作,但我學習了很多基礎商業、法律以及公司溝通技巧。之後我在皇家墨爾本理工大學( RMIT)從事公司治理工作,並開始兼職擔任法律系講師。後來他們問我是否想要讀博士,我便盲目地答應了。接下來,我在斯威本大學(Swinburne University)工作,再被挖角到商用小客車委員會領導法律團隊。
★★★★★★★★★★★★
I had a good life, but after a while, I realised I wanted a different kind of job. I could see my seniors were making a lot of money but that their family life was not that good. And looking at my own upbringing, I wanted to be the kind of father who could be present in my own kids’ lives. So I decided on dentistry. It would not only allow me to use the hand skills that I had developed from playing the violin, but also the analytical and reasoning skills that I'd developed in law. Plus it would be flexible, and offer me a stable income and the chance to meet different people every day!
•upbringing 教養
•decide on sth 決定某事或東西
•analytical and reasoning skills 分析和推理能力
•offer a stable income 提供穩定收入
我的生活很不錯,但一段時間後,我意識到自己想要一份不同的工作。我知道前輩們賺了很多錢,但他們的家庭生活並不美滿。看著自己的成長經歷,我想要成為可以在孩子生活中出席的父親,所以我決定改行當牙醫。這項職業能讓我使用從拉小提琴中發展出的手部技巧,也能運用我在法律中發展出的分析與推理技能。此外,這個職業相當靈活,能為我提供穩定收入,並有機會每天與不同的人見面。
★★★★★★★★★★★★
My now fiancée, who was my girlfriend at the time, was also applying for further study, and coincidentally we both got into university in South Australia, so we moved to Adelaide together a few years ago.
•fiancée 未婚妻
•at the time 當時
•apply for 申請
•further study 繼續教育,進修;進一步研究;深造
•coincidentally 碰巧地;巧合地
我的未婚妻,當時的女友,也申請繼續深造,巧的是我們都考上南澳大學(University of South Australia),所以幾年前一起搬到阿得雷德( Adelaide)。
★★★★★★★★★★★★
I was lucky to get a university job at Flinders University. Initially, I started out as a casual lecturer in the law school, but I’ve since transitioned into teaching health law and research, and I’m currently writing a few books on the intersection between law and medicine. And also, obviously, trying to finish my dentistry degree!
•start out as… 起初擔任...
•transition into… 轉變到...
我很幸運的在福林德斯大學(Flinders University)找到工作,起初我在法學院擔任臨時講師,但我後來轉換到醫事法教學及研究。目前我正撰寫幾本關於法律與醫學相接的書籍,並努力完成我的牙醫學位。
★★★★★★★★★★★★
Mum eventually retrained as a Chinese high school teacher, and she’s still teaching to this day. Like most first generation migrants, she struggled quite a lot, and invested heavily in my success. After we’re married, my fiancée and I are planning to have children, and I’m sure they will have it much easier than I did.
•retrain 重新培養;再培訓;再訓練
•to this day 至今
•first generation migrants 第一代移民
•struggle a lot 掙扎奮鬥許久
•have it much easier 過的比較輕鬆
我的母親最終重新接受培訓,成為一名中文高中老師並執教至今。如同大多數第一代移民,她掙扎奮鬥許久,並為我的成功投資甚多。我與未婚妻打算婚後生孩子,我確信孩子會過的比我輕鬆得多。
★★★★★★★★★★★★
Still, a lot of the failures that I’ve had in my life have really informed a lot of my successes. Looking back, I wouldn't really want to change that to have a smoother life.
•inform [正式] 影響某人的態度或意見
https://www.ldoceonline.com/dictionary/inform
•have a smoother life 有一個更順遂的人生
我的生活中的種種失敗確實為我的成功提供借鑑。回首過去,我不會想要改變那些坎坷經歷去擁有一個更順遂的人生。
★★★★★★★★★★★★
Over the years, I've learned that perseverance is very important. I hope that through telling my story, I can be an example to others who might be in a similar position as I was: to show that there's not just one road to the destination, but many roads. You just need to take the little step that’s right in front of you, and then the next one, and a few years down the track, they will seem like massive achievements.
•over the years 多年來
•perseverance 不屈不撓,堅持不懈
•be an example 成為榜樣
•be in a similar position 處於相似的處境
•down the road/line/track 將來(的路)
多年來,我學到堅持不懈是至關重要的。我希望透過講述自己的故事,能成為其他可能與我有相似處境的人的榜樣:向他們展示通往目的地的路不止一條,有很多路可走。你只需要邁出眼前這一小步,然後再邁出下一步,幾年下來,將會成為巨大成就。
有興趣的同學可以支持New Humans of Australia
www.patreon.com/newhumansofaustralia
Photographer: Paul Heinrich instagram.com/paulfheinrich
文章與圖片出處: https://bit.ly/2XJsciq
★★★★★★★★★★★★
翻轉視界: http://bit.ly/3fPvKUs
批判性思考問題大全: http://bit.ly/34rdtJ7
where are you going教學 在 Taipei Ethereum Meetup Facebook 的最佳解答
📜 [專欄新文章] Uniswap v3 Features Explained in Depth
✍️ 田少谷 Shao
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
Once again the game-changing DEX 🦄 👑
Image source: https://uniswap.org/blog/uniswap-v3/
Outline
0. Intro1. Uniswap & AMM recap2. Ticks 3. Concentrated liquidity4. Range orders: reversible limit orders5. Impacts of v36. Conclusion
0. Intro
The announcement of Uniswap v3 is no doubt one of the most exciting news in the DeFi place recently 🔥🔥🔥
While most have talked about the impact v3 can potentially bring on the market, seldom explain the delicate implementation techniques to realize all those amazing features, such as concentrated liquidity, limit-order-like range orders, etc.
Since I’ve covered Uniswap v1 & v2 (if you happen to know Mandarin, here are v1 & v2), there’s no reason for me to not cover v3 as well ✅
Thus, this article aims to guide readers through Uniswap v3, based on their official whitepaper and examples made on the announcement page. However, one needs not to be an engineer, as not many codes are involved, nor a math major, as the math involved is definitely taught in your high school, to fully understand the following content 😊😊😊
If you really make it through but still don’t get shxt, feedbacks are welcomed! 🙏
There should be another article focusing on the codebase, so stay tuned and let’s get started with some background noise!
1. Uniswap & AMM recap
Before diving in, we have to first recap the uniqueness of Uniswap and compare it to traditional order book exchanges.
Uniswap v1 & v2 are a kind of AMMs (automated market marker) that follow the constant product equation x * y = k, with x & y stand for the amount of two tokens X and Y in a pool and k as a constant.
Comparing to order book exchanges, AMMs, such as the previous versions of Uniswap, offer quite a distinct user experience:
AMMs have pricing functions that offer the price for the two tokens, which make their users always price takers, while users of order book exchanges can be both makers or takers.
Uniswap as well as most AMMs have infinite liquidity¹, while order book exchanges don’t. The liquidity of Uniswap v1 & v2 is provided throughout the price range [0,∞]².
Uniswap as well as most AMMs have price slippage³ and it’s due to the pricing function, while there isn’t always price slippage on order book exchanges as long as an order is fulfilled within one tick.
In an order book, each price (whether in green or red) is a tick. Image source: https://ftx.com/trade/BTC-PERP
¹ though the price gets worse over time; AMM of constant sum such as mStable does not have infinite liquidity
² the range is in fact [-∞,∞], while a price in most cases won’t be negative
³ AMM of constant sum does not have price slippage
2. Tick
The whole innovation of Uniswap v3 starts from ticks.
For those unfamiliar with what is a tick:
Source: https://www.investopedia.com/terms/t/tick.asp
By slicing the price range [0,∞] into numerous granular ticks, trading on v3 is highly similar to trading on order book exchanges, with only three differences:
The price range of each tick is predefined by the system instead of being proposed by users.
Trades that happen within a tick still follows the pricing function of the AMM, while the equation has to be updated once the price crosses the tick.
Orders can be executed with any price within the price range, instead of being fulfilled at the same one price on order book exchanges.
With the tick design, Uniswap v3 possesses most of the merits of both AMM and an order book exchange! 💯💯💯
So, how is the price range of a tick decided?
This question is actually somewhat related to the tick explanation above: the minimum tick size for stocks trading above 1$ is one cent.
The underlying meaning of a tick size traditionally being one cent is that one cent (1% of 1$) is the basis point of price changes between ticks, ex: 1.02 — 1.01 = 0.1.
Uniswap v3 employs a similar idea: compared to the previous/next price, the price change should always be 0.01% = 1 basis point.
However, notice the difference is that in the traditional basis point, the price change is defined with subtraction, while here in Uniswap it’s division.
This is how price ranges of ticks are decided⁴:
Image source: https://uniswap.org/whitepaper-v3.pdf
With the above equation, the tick/price range can be recorded in the index form [i, i+1], instead of some crazy numbers such as 1.0001¹⁰⁰ = 1.0100496621.
As each price is the multiplication of 1.0001 of the previous price, the price change is always 1.0001 — 1 = 0.0001 = 0.01%.
For example, when i=1, p(1) = 1.0001; when i=2, p(2) = 1.00020001.
p(2) / p(1) = 1.00020001 / 1.0001 = 1.0001
See the connection between the traditional basis point 1 cent (=1% of 1$) and Uniswap v3’s basis point 0.01%?
Image source: https://tenor.com/view/coin-master-cool-gif-19748052
But sir, are prices really granular enough? There are many shitcoins with prices less than 0.000001$. Will such prices be covered as well?
Price range: max & min
To know if an extremely small price is covered or not, we have to figure out the max & min price range of v3 by looking into the spec: there is a int24 tick state variable in UniswapV3Pool.sol.
Image source: https://uniswap.org/whitepaper-v3.pdf
The reason for a signed integer int instead of an uint is that negative power represents prices less than 1 but greater than 0.
24 bits can cover the range between 1.0001 ^ (2²³ — 1) and 1.0001 ^ -(2)²³. Even Google cannot calculate such numbers, so allow me to offer smaller values to have a rough idea of the whole price range:
1.0001 ^ (2¹⁸) = 242,214,459,604.341
1.0001 ^ -(2¹⁷) = 0.000002031888943
I think it’s safe to say that with a int24 the range can cover > 99.99% of the prices of all assets in the universe 👌
⁴ For implementation concern, however, a square root is added to both sides of the equation.
How about finding out which tick does a price belong to?
Tick index from price
The answer to this question is rather easy, as we know that p(i) = 1.0001^i, simply takes a log with base 1.0001 on both sides of the equation⁴:
Image source: https://www.codecogs.com/latex/eqneditor.php
Let’s try this out, say we wanna find out the tick index of 1000000.
Image source: https://ncalculators.com/number-conversion/log-logarithm-calculator.htm
Now, 1.0001¹³⁸¹⁶² = 999,998.678087146. Voila!
⁵ This formula is also slightly modified to fit the real implementation usage.
3. Concentrated liquidity
Now that we know how ticks and price ranges are decided, let’s talk about how orders are executed in a tick, what is concentrated liquidity and how it enables v3 to compete with stablecoin-specialized DEXs (decentralized exchange), such as Curve, by improving the capital efficiency.
Concentrated liquidity means LPs (liquidity providers) can provide liquidity to any price range/tick at their wish, which causes the liquidity to be imbalanced in ticks.
As each tick has a different liquidity depth, the corresponding pricing function x * y = k also won’t be the same!
Each tick has its own liquidity depth. Image source: https://uniswap.org/blog/uniswap-v3/
Mmm… examples are always helpful for abstract descriptions 😂
Say the original pricing function is 100(x) * 1000(y) = 100000(k), with the price of X token 1000 / 100 = 10 and we’re now in the price range [9.08, 11.08].
If the liquidity of the price range [11.08, 13.08] is the same as [9.08, 11.08], we don’t have to modify the pricing function if the price goes from 10 to 11.08, which is the boundary between two ticks.
The price of X is 1052.63 / 95 = 11.08 when the equation is 1052.63 * 95 = 100000.
However, if the liquidity of the price range [11.08, 13.08] is two times that of the current range [9.08, 11.08], balances of x and y should be doubled, which makes the equation become 2105.26 * 220 = 400000, which is (1052.63 * 2) * (110 * 2) = (100000 * 2 * 2).
We can observe the following two points from the above example:
Trades always follow the pricing function x * y = k, while once the price crosses the current price range/tick, the liquidity/equation has to be updated.
√(x * y) = √k = L is how we represent the liquidity, as I say the liquidity of x * y = 400000 is two times the liquidity of x * y = 100000, as √(400000 / 100000) = 2.
What’s more, compared to liquidity on v1 & v2 is always spread across [0,∞], liquidity on v3 can be concentrated within certain price ranges and thus results in higher capital efficiency from traders’ swapping fees!
Let’s say if I provide liquidity in the range [1200, 2800], the capital efficiency will then be 4.24x higher than v2 with the range [0,∞] 😮😮😮 There’s a capital efficiency comparison calculator, make sure to try it out!
Image source: https://uniswap.org/blog/uniswap-v3/
It’s worth noticing that the concept of concentrated liquidity was proposed and already implemented by Kyper, prior to Uniswap, which is called Automated Price Reserve in their case.⁵
⁶ Thanks to Yenwen Feng for the information.
4. Range orders: reversible limit orders
As explained in the above section, LPs of v3 can provide liquidity to any price range/tick at their wish. Depending on the current price and the targeted price range, there are three scenarios:
current price < the targeted price range
current price > the targeted price range
current price belongs to the targeted price range
The first two scenarios are called range orders. They have unique characteristics and are essentially fee-earning reversible limit orders, which will be explained later.
The last case is the exact same liquidity providing mechanism as the previous versions: LPs provide liquidity in both tokens of the same value (= amount * price).
There’s also an identical product to the case: grid trading, a very powerful investment tool for a time of consolidation. Dunno what’s grid trading? Check out Binance’s explanation on this, as this topic won’t be covered!
In fact, LPs of Uniswap v1 & v2 are grid trading with a range of [0,∞] and the entry price as the baseline.
Range orders
To understand range orders, we’d have to first revisit how price is discovered on Uniswap with the equation x * y = k, for x & y stand for the amount of two tokens X and Y and k as a constant.
The price of X compared to Y is y / x, which means how many Y one can get for 1 unit of X, and vice versa the price of Y compared to X is x / y.
For the price of X to go up, y has to increase and x decrease.
With this pricing mechanism in mind, it’s example time!
Say an LP plans to place liquidity in the price range [15.625, 17.313], higher than the current price of X 10, when 100(x) * 1000(y) = 100000(k).
The price of X is 1250 / 80 = 15.625 when the equation is 80 * 1250 = 100000.
The price of X is 1315.789 / 76 = 17.313 when the equation is 76 * 1315.789 = 100000.
If now the price of X reaches 15.625, the only way for the price of X to go even higher is to further increase y and decrease x, which means exchanging a certain amount of X for Y.
Thus, to provide liquidity in the range [15.625, 17.313], an LP needs only to prepare 80 — 76 = 4 of X. If the price exceeds 17.313, all 4 X of the LP is swapped into 1315.789 — 1250 = 65.798 Y, and then the LP has nothing more to do with the pool, as his/her liquidity is drained.
What if the price stays in the range? It’s exactly what LPs would love to see, as they can earn swapping fees for all transactions in the range! Also, the balance of X will swing between [76, 80] and the balance of Y between [1250, 1315.789].
This might not be obvious, but the example above shows an interesting insight: if the liquidity of one token is provided, only when the token becomes more valuable will it be exchanged for the less valuable one.
…wut? 🤔
Remember that if 4 X is provided within [15.625, 17.313], only when the price of X goes up from 15.625 to 17.313 is 4 X gradually swapped into Y, the less valuable one!
What if the price of X drops back immediately after reaching 17.313? As X becomes less valuable, others are going to exchange Y for X.
The below image illustrates the scenario of DAI/USDC pair with a price range of [1.001, 1.002] well: the pool is always composed entirely of one token on both sides of the tick, while in the middle 1.001499⁶ is of both tokens.
Image source: https://uniswap.org/blog/uniswap-v3/
Similarly, to provide liquidity in a price range < current price, an LP has to prepare a certain amount of Y for others to exchange Y for X within the range.
To wrap up such an interesting feature, we know that:
Only one token is required for range orders.
Only when the current price is within the range of the range order can LP earn trading fees. This is the main reason why most people believe LPs of v3 have to monitor the price more actively to maximize their income, which also means that LPs of v3 have become arbitrageurs 🤯
I will be discussing more the impacts of v3 in 5. Impacts of v3.
⁷ 1.001499988 = √(1.0001 * 1.0002) is the geometric mean of 1.0001 and 1.0002. The implication is that the geometric mean of two prices is the average execution price within the range of the two prices.
Reversible limit orders
As the example in the last section demonstrates, if there is 4 X in range [15.625, 17.313], the 4 X will be completely converted into 65.798 Y when the price goes over 17.313.
We all know that a price can stay in a wide range such as [10, 11] for quite some time, while it’s unlikely so in a narrow range such as [15.625, 15.626].
Thus, if an LP provides liquidity in [15.625, 15.626], we can expect that once the price of X goes over 15.625 and immediately also 15.626, and does not drop back, all X are then forever converted into Y.
The concept of having a targeted price and the order will be executed after the price is crossed is exactly the concept of limit orders! The only difference is that if the range of a range order is not narrow enough, it’s highly possible that the conversion of tokens will be reverted once the price falls back to the range.
As price ranges follow the equation p(i) = 1.0001 ^ i, the range can be quite narrow and a range order can thus effectively serve as a limit order:
When i = 27490, 1.0001²⁷⁴⁹⁰ = 15.6248.⁸
When i = 27491, 1.0001²⁷⁴⁹¹ = 15.6264.⁸
A range of 0.0016 is not THAT narrow but can certainly satisfy most limit order use cases!
⁸ As mentioned previously in note #4, there is a square root in the equation of the price and index, thus the numbers here are for explantion only.
5. Impacts of v3
Higher capital efficiency, LPs become arbitrageurs… as v3 has made tons of radical changes, I’d like to summarize my personal takes of the impacts of v3:
Higher capital efficiency makes one of the most frequently considered indices in DeFi: TVL, total value locked, becomes less meaningful, as 1$ on Uniswap v3 might have the same effect as 100$ or even 2000$ on v2.
The ease of spot exchanging between spot exchanges used to be a huge advantage of spot markets over derivative markets. As LPs will take up the role of arbitrageurs and arbitraging is more likely to happen on v3 itself other than between DEXs, this gap is narrowed … to what extent? No idea though.
LP strategies and the aggregation of NFT of Uniswap v3 liquidity token are becoming the blue ocean for new DeFi startups: see Visor and Lixir. In fact, this might be the turning point for both DeFi and NFT: the two main reasons of blockchain going mainstream now come to the alignment of interest: solving the $$ problem 😏😏😏
In the right venue, which means a place where transaction fees are low enough, such as Optimism, we might see Algo trading firms coming in to share the market of designing LP strategies on Uniswap v3, as I believe Algo trading is way stronger than on-chain strategies or DAO voting to add liquidity that sort of thing.
After reading this article by Parsec.finance: The Dex to Rule Them All, I cannot help but wonder: maybe there is going to be centralized crypto exchanges adopting v3’s approach. The reason is that since orders of LPs in the same tick are executed pro-rata, the endless front-running speeding-competition issue in the Algo trading world, to some degree, is… solved? 🤔
Anyway, personal opinions can be biased and seriously wrong 🙈 I’m merely throwing out a sprat to catch a whale. Having a different voice? Leave your comment down below!
6. Conclusion
That was kinda tough, isn’t it? Glad you make it through here 🥂🥂🥂
There are actually many more details and also a huge section of Oracle yet to be covered. However, since this article is more about features and targeting normal DeFi users, I’ll leave those to the next one; hope there is one 😅
If you have any doubt or find any mistake, please feel free to reach out to me and I’d try to reply AFAP!
Stay tuned and in the meantime let’s wait and see how Uniswap v3 is again pioneering the innovation of DeFi 🌟
Uniswap v3 Features Explained in Depth was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
where are you going教學 在 Smart Travel Youtube 的最佳解答
成為這個頻道的會員並獲得獎勵:
https://www.youtube.com/channel/UCIuNPxqDGG08p3EqCwY0XIg/join
#大阪周遊卡 #googlemap #travelplanner #travelplan #travelplan2020
#youtube #youtuber #關西國際機場 #kansaiairport #大阪必買
Hello大家好, 我叫阿Tsar Hello, everyone.
應承了大家好耐,今次就為大家介紹大阪五日四夜google map行程規劃 Finally I am introducing the google map plan for Osaka 5days 4nites itinerary
影片下面有條link, 可以給大家分享給團友這個Google Map, U can share this Google Map with your friends below this video
無論大家透過影片分享, 抑或用whatsapp都可以好方便 Whether u share it through whatsapp or social media
分享到和你一起去旅行, 或者你想分享資料訊息的對象 Share with people who travel with u, or someone who need these info
影片裏面每一日的行程, 都質到密密麻麻 As u can see the itinerary is very intensive
當然不是叫你一次過行完啦, 只不過如果你多過一個人去旅行 Of course, it's not asking u to finish the trip in one go, but if u r not traveling alone,
自然就會有不同的意見, 我只是寫多幾個地點給大家選擇 There will be different opinions, I just write a few more places for choices
還會配合大阪周遊卡, 令到你的旅程省多些金錢 Together with the use of Osaka Amazing pass to save more money on your journey
這個行程規劃 Google Map, 亦會結合我以往拍過大阪的youtube This itinerary plan Google Map will also be combined with the youtube I took in Osaka in the past
所以就算老人家小學生都看得明白, So even if the elderly or students can easily understand it,
大家亦都可以預先見到我分享的行程規劃, 去旅行之前 Everyone can also see the itinerary plan I shared in advance, before going on a trip
有個預算, 大約去什麼地方, 和用多少錢, 節省多少錢 Have an idea for the budget about where to go, how much to spend n how much to save
一目了然, 我那麼用心去製作, 你沒有理由不給我表情符號以示支持㗎? SO clearly. Do I deserve an emoji for a support?
如果你去的日數是4日3夜, 這個行程規劃都適合你, If u go for 4 days n 3 nights, this itinerary plan is also suitable for u,
只是好簡單, 揀選你認為適合的行程就ok啦, Simply choose the places u want to go
旅行的目的, 除了relax增廣見聞這些很cliche的說法之外 The purpose of travel except for relax n explore
當中包括了好多travel planning、危機處理、靈活變通的意義 There are also a lot of travel planning, crisis management n be flexible
我都會在影片跟大家一一分享 I will also mention in this video
事不宜遲, 快點來看看今日的大阪5日4夜行程規劃, are you ready? Let's take a quick look for the video for today.
第一日, 當你到達關西機場,除了買一張出市區的車票ICOCA Card之外 1st day when u arrive in Kansai Airport, other than buying Icoca card to the city
怎樣買ICOCA Card, 和它的用法, How to buy Icoca card n how to use it
怎樣由關西機場出市區的交通選擇, 亦有影片介紹 There are videos to tell u the transportations from Kansai Airport to the city
我建議你亦買一張大阪周遊卡, 可以幫你節省好多錢 I suggest u also buy an Osaka amazing pass, which can help u save a lot of money
影片的第三日, 會跟大家分享如何可以好flexible的那樣用這張大阪周遊卡 3rd day of this video, I will share how to maximize the usage of this pass
有些人是搭凌晨機出發, 很早就會到關西機場 Some people leave by midnite, they will arrive at Kansai Airport very early
如果你的酒店check in時間要等到中午過後, 那麼你早上到關西機場 If your hotel check-in time has to wait until noon, then u will arrive at Kansai Airport early in the morning
我就建議你去Rinku Town,逛逛一間24小時的超市Trial Supercenter I suggest u go to Rinku Town and visit a 24-hour supermarket Trial Supercenter
亦有一間好平的免稅妝藥店, 再去Rinku Town Premium Outlet 才出市區 There is a cheap duty-free cosmetic drugstore then Rinku Town Premium Outlet before going to the city
我這裏有條影片, 影片的07:53分鐘, Pls watch the video at 07:53mins
有講解買一張叫做Rinku Premium Outlet Stopover Ticket There is an explanation for how to buy a Rinku Premium Outlet Stopover Ticket
這張卡有兩種用法, 你可以由關西機場, 去Rinku Town stop over There are 2 ways to use this pass, u can go to Rinku Town stop over from Kansai Airport
Shopping 完, 用著同一張card出難波 After shopping, use the same pass to Namba
如果你當日班機在晚上到達, 就不建議你用這個方法 If your flight arrives at night, this method is not recommended.
但是這一張card, 是可以在你臨離開大阪當日 But this card can be use the day u leave Osaka
出機場之前, 由難波去Rinku Town Stopover Before going to airport, go to Rinku Town Stopover from Namba
..........
みなさん、こんにちは、Ah Tsarです。
皆様の忍耐へのこだわり、今回は大阪の4泊4日グーグルマップの旅程プランをご紹介します
動画の下にリンクがあります。このGoogleマップを友達と共有できます。
動画で共有するか、whatsappを使用するか
一緒に旅行する人と共有したり、情報を共有したい
映画の毎日の旅程はどんどん密集しています
もちろん、一度に旅行を終えるように求めているわけではありませんが、一人で旅行している場合は、
当然のことながら異なる意見があります、私は誰もが選択できるようにいくつかの場所を書きます
大阪トラベルカードとも連携し、旅費を節約します
この旅程の計画Googleマップは、私が過去に大阪で撮ったYouTubeとも組み合わせられます
だから、小学生の老人が理解できても
旅行に行く前に、事前に共有した旅程の計画も誰でも見ることができます
どこに行くか、どれくらい使うか、どれくらい節約するかについての予算がある
一見、私はそれをとても難しくしました、あなたは私にサポートを示すために絵文字を与えない理由はありません㗎?
あなたが行く日数が4日と3泊であるならば、この旅程計画はあなたに適しています、
とても簡単です。あなたが適切だと思う旅程を選んでください。
これらの決まり文句を緩和し、拡大することに加えて、旅行の目的
多くの旅行計画、危機管理、柔軟な意味を含む
ビデオで一つずつあなたと共有します
請用片右下角調4K睇片。
where are you going教學 在 波波星球泡泡哥哥BoboPopo Youtube 的精選貼文
❤️記得👉訂閱 #波波星球
https://reurl.cc/yZaAm6
❤️記得追蹤
⭐️【YouTube】
泡泡來了:https://reurl.cc/7XqVkl
波波星球:https://reurl.cc/yZaAm6
⭐️【FaceBook】
泡泡哥哥:https://reurl.cc/ZOoNWg
波波星球:https://reurl.cc/1xWO19
⭐️【Instagram】
泡泡哥哥:https://reurl.cc/j7erR2
波波星球:https://reurl.cc/oL3Y7l
⭐️【bilibil 】https://space.bilibili.com/483810421
⭐️【 微博 】https://reurl.cc/d5A09k
⭐️【 蝦皮 】https://shopee.tw/popolee520?smtt=0.0.9
⭐️【 Line 社團 】https://reurl.cc/5oAVOR
❤️合作洽詢
👉LineID:abcd614
👉電話:0988208816 (Denny)
👉Email:asdfghjkl3252@gmail.com
👉更多影片如下
❤️【幼兒舞蹈】https://reurl.cc/Njoxyn
❤️【兒童舞蹈】https://reurl.cc/xZ836b
❤️【廣場舞蹈】https://reurl.cc/8GV9NM
❤️【波波星球主題曲】https://reurl.cc/N6WWLe
❤️【波波星球合作曲】https://reurl.cc/q8EE4E
❤️【泡泡愛旅遊】https://reurl.cc/1xWO3Y
❤️【泡泡愛美食】 https://reurl.cc/oL3YrQ
❤️【泡泡愛聊天】https://reurl.cc/rxVY6N
❤️【表演有哪些】https://reurl.cc/b5omDl
❤️歌曲來源:
anic! At The Disco - Into the Unknown (From "Frozen 2")
https://www.youtube.com/watch?v=jp-CVYGEsjg
❤️Into the Unknown 歌詞❤️
Ah, ah, ah, ah, ah
Ah, ah, ah, ah, ah, ah, ah
Into the unknown
Into the unknown
Into the unknown
Ah, ah, ah, ah, ah
I can hear you, but I won't
Some look for trouble, while others don't
There's a thousand reasons I should go about my day
And ignore your whispers, which I wish would go away
Oh, oh, oh
You're not a voice; you're just a ringing in my ear
And if I heard you (which I don't) I'm spoken for, I fear
Everyone I've ever loved is here within theses walls
I'm sorry, secret siren, but I'm blocking out your calls
I've had my adventure; I don't need something new
I'm afraid of what I'm risking if I follow you
Into the unknown
Into the unknown
Into the unknown
Ah, ah, ah, ah, ah
Ah, ah, ah, ah, ah, ah, ah
What do you want 'cause you've been keeping me awake
Are you here to distract me so I make a big mistake
Or are you someone out there who's a little bit like me
Who knows deep down I'm not where I'm meant to be
Every day's a little harder, as I feel your power grow
Don't you know there's part of me that longs to go
Into the unknown
Into the unknown
Into the unknown
Ah, ah, ah, ah, ah
Ah, ah, ah, ah, ah
Oh, oh, oh, are you out there?
Do you know me?
Can you feel me?
Can you show me?
Ah, ah, ah, ah
Ah, ah, ah, ah
Ah, ah, ah, ah
Ah, ah, ah, ah
Ah, ah, ah, ah
Ah, ah, ah, ah
Where are you going?
Don't leave me alone
How do I follow you
Into the unknown
where are you going教學 在 哥倫布 Columbus Youtube 的精選貼文
我的文法課程 ▶ https://grammar.cool/
我的發音課程 ▶ https://columbus.cool/
✨✨✨✨✨✨✨✨✨✨
我的免費講義 ▶ https://columbus.english.cool/
我的英語教學部落格 ▶ https://english.cool/
我的 FB ▶ https://www.facebook.com/littlecolumbus
我的 IG ▶ @littlecolumbus
✨✨✨✨✨✨✨✨✨✨
課程相關問題請聯絡 ▶ courses@english.cool
合作邀約請聯絡 ▶ columbus@english.cool
✨✨✨✨✨✨✨✨✨✨
我是哥倫布!我是在加拿大長大的香港人!現在喜歡在 YouTube 做出有趣好懂的英文教學內容。
YouTube 頻道外,我在 2020 年創立了 English.Cool 英文庫,目前已成為台灣/香港地區 No.1 英文教學資訊網站!
✨✨✨✨✨✨✨✨✨✨
1. Here's Johnny
2. Greetings (過時了)
3. Salutations (過時了)
4. Greetings and Salutations (過時了)
5. What's the good word? (過時了)
6. Good day
7. Good morning
8. mornin'
9. Good afternoon
10. Good evening
11. How do you do?
12. It's nice to see you
13. It's good to see you
14. It's a pleasure to meet you
15. Pleased to meet you
16. Yo
17. Hi
18. Hi there
19. Hello
20. Hello there
21. Hey
22. Hey there
23. What's up
24. Sup
25. Whazzup
26. Whaddup
27. How are you?
28. How are you doing?
29. How you doin'?
30. How you doin'? (猥瑣版)
31. How's it goin'?
32. How goes it?
33. What's goin' on?
34. What's new?
35. What's happenin'?
36. How's your day?
37. How's your day going?
38. Good to see you
39. Look who it is
40. Look what the cat dragged in!
41. There he is!
42. Ayyy
43. Holla
44. Hiya
45. Heya
46. Yello
47. Howdy
48. Howdy-doo?
49. Howdy, partner? (牛仔愛用)
50. How's tricks?
51. How's it rollin'?
52. How's it hangin'? (有點帶黃)
53. What's up, homeslice?
54. What's up, doc?
55. Whaddup, buttercup!
56. What's good?
57. What's good in the hood?
58. What's the dilly?
59. What's the dizzle?
60. What's trippin'?
61. What's poppin'?
62. What's crackin'?
63. What's crackalackin'?
64. What's cookin'?
65. What's cookin' good lookin'?
66. What's kickin', chicken?
67. What's shakin', bacon?
68. Long time no see
69. It's been such a long time!
70. How long has it been?
71. It's been too long!
72. It's been ages!
73. It's been a while!
74. It's been a minute
75. Where have you been hiding?
76. How have you been?
77. What have you been up to?
78. Whatcha been up to?
79. How are things?
80. How are things comin' along?
81. How are you getting on?
82. How are you holding up?
83. How's life?
84. How's life been treating you?
85. How's everything?
86. How's everything with you?
87. How's everything going?
88. Oi (英國/澳洲)
89. What's the craic? (愛爾蘭)
90. You okay? (英國)
91. You alright? (英國)
92. Alright? (英國)
93. G'day, mate (澳洲)
94. How are you going? (澳洲)
95. Ahoy, matey (海盜用的)
96. Aloha (夏威夷語)
97. Hola (西班牙文)
98. Ciao (義大利語)
99. Namaste (印度教)
100. Nihao (中文)
where are you going教學 在 Moji Today - 改編《This or That?》-Where are you going? 五 ... 的推薦與評價
Game rules: 1.全班起立。 2.全班與老師一同以有節奏的方式唸出”Where are you going? I'm going to the ____.”根據ppt頁面的兩選項說出自己的答案。 3.若答案與老師不同, ... ... <看更多>