PTT評價

Re: [閒聊] 今年散戶應該都離場了吧

看板DigiCurrency標題Re: [閒聊] 今年散戶應該都離場了吧作者
blackjj3110
(小碗魯肉飯)
時間推噓 7 推:7 噓:0 →:23

※ 引述《MACD (MACD)》之銘言:
: 嗨!大家好,我最喜歡講技術的文章了。
: 最近幾個月都研究FlashLoan的技術,也略有心得,這篇來分享一下。
: 我主力目前是DEX之間的幣對價差,MEV黑森林中的一小部分,看到有人想當伸手牌,我大: 概分享幾個關鍵字。DYOR
: 好了,之前發文有人說怎麼沒有作業,我這不就出作業了,我花了點時間寫個合約給大家: 用,flashloan的,現成的大家都可以用,很棒吧,不過我有留一個有趣的彩蛋在裡面,希
: 望大家可以發現,發現的人沒有獎品,謝謝。
: 彩蛋可以透過我的測試交易發現。
: 如果你可以完成作業,恭喜你,前端操作合約技能+1,尤其最近AC不玩了,這技能值得你: 花心力點一下。
: 作業完成目標:參照我的測試tx,跟我部屬的合約互動,發起一筆你自己的flashloan。: TIP:因為是flashloan,你不用做任何合約授權,你只需要付gas fee,這樣大家放心了吧: ,你可以另外生成一個帳號放點gas fee跟合約做安全的神魂交流。
: TIP2:如果你發起的flashloan無法還款,那交易會失敗並出現以下錯誤訊息
: Not enough amount to return loan會記錄在tx裡時刻的羞辱你喔。
: 部屬鏈:polygon
: 測試tx:0x8be86f4af8e44d57ebdca4eccff335925abeb1990f9727d9907273bc078af0a3
: 合約地址 0xcFb2168Bad58D505aC0D857017CD0cbF7408E81C
恕刪......
首先謝謝MACD大,常常分享寶貴經驗跟技術給大家..
行情不好的時候,就是靜下心來開始學習最好的時候..反正也被割得差不多了..XD

主要還是冒昧想請問M大作業問題..因為 TIP2..果然順利達成
我的測試tx: 0x25c394257baff2e6d2bd0abecaae7ed74faa403d1895435fdc6691518b984455原本MACD大的 TX 分析如下
{
hash: '0x8be86f4af8e44d57ebdca4eccff335925abeb1990f9727d9907273bc078af0a3', from: '0xDcc43055f22A87b0041F368d158a63e7dD7ff4db',
to: '0xcFb2168Bad58D505aC0D857017CD0cbF7408E81C',
gasPrice: 42680000000,
gasLimit: 483277,
nonce: 6,
blockNumber: 25702154
}
TransactionDescription {
args: [
'0x581c7DB44F2616781C86C331d31c1F09db87A746',
BigNumber { _hex: '0x03e8', _isBigNumber: true },
'0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
'0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
'0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff',
'0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506',
flashLoanPool: '0x581c7DB44F2616781C86C331d31c1F09db87A746',
loanAmount: BigNumber { _hex: '0x03e8', _isBigNumber: true },
loanToken: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
metaToken: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
router1: '0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff',
router2: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506'
],
我自己的發起 tx 如下
{
hash: '0x25c394257baff2e6d2bd0abecaae7ed74faa403d1895435fdc6691518b984455', from: '0xafF61F8B106CFc5CAb922FCbE9ce87292C980203',
to: '0xcFb2168Bad58D505aC0D857017CD0cbF7408E81C',
gasPrice: 43000000000,
gasLimit: 483277,
nonce: 0,
blockNumber: 30159826
}
TransactionDescription {
args: [
'0x581c7DB44F2616781C86C331d31c1F09db87A746',
BigNumber { _hex: '0x03e8', _isBigNumber: true },
'0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
'0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
'0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff',
'0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506',
flashLoanPool: '0x581c7DB44F2616781C86C331d31c1F09db87A746',
loanAmount: BigNumber { _hex: '0x03e8', _isBigNumber: true },
loanToken: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
metaToken: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
router1: '0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff',
router2: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506'
],

不知道哪邊出了問題? 還是必須自己架設 local polygon node? 以上我是先用
ALCHEMY_POLYGON_RPC 擋擋先...

另外追了一下MACD大的 TX log 中
[SC]
0xcfb2168bad58d505ac0d857017cd0cbf7408e81c
[INPUT RAW DATA]
0x53485e5a
0x000000000000000000000000581c7db44f2616781c86c331d31c1f09db87a746 <== DLP
0x00000000000000000000000000000000000000000000000000000000000003e8 <==
LoanAmount
0x000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f <==
(POS)USDT
0x0000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619 <== WETH
0x000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff <==
QuickSWAP:Router
0x0000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b47997506 <==
SushiSwap:Router
內部 18 Logs
0xf6422b997c7f54d1c6a6e103bcb1499eea0a7046 <== Uniswap V2
0xc2755915a85c6f6c1c0f3a86ac8c058f11caa9c9 <== SushiSwap LP Token (SLP)
0x0000000000000000000000000000000000001010 <== Polygon: MATIC Token

[log 129] USDT, DLP -> SC (0x3e8= 1000 = 0.001 USDT)
[log 130] USDT, SC -> QuickSWAP:Router (ff..fff)
[log 131] USDT, SC -> Uniswap V2 (0x3e8=1000= 0.001 USDT)
[log 132] USDT, SC -> QuickSWAP:Router (ff..c17)
[log 133] WETH, Uniswap V2 -> SC (0x5cc1df6fc1=0.000000398389637057 WETH ~
2510.105452)
[log 134] Uniswap V2 (0x10fc9e0097ca0d88257, 0xb6950491ea2)
[log 135] Uniswap V2 (QuickSWAP:Router, SC)(0, 0x3e8, 0x5cc1df6fc1, 0)
[log 136] WETH, SC -> SushiSwap:Router (ff..ffff)
[log 137] WETH, SC -> SLP (0x5cc1df6fc1)
[log 138] WETH, SC -> SushiSwap:Router (ff..a33e20903e)
[log 139] USDT, SLP -> SC (0x3e3= 995 = 0.0095 USDT)
[log 140] SLP , (0x2a2df0342d25923b9b, 0x1c5dedefcb0)
[log 141] SLP, SushiSwap:Router -> SC (0x5cc1df6fc1, 0, 0, 0x3e3)
[log 142] USDT, SC -> DLP (0x3e8)
[log 143] USDT, SC -> Caller (0x1b97=7063 = 0.007063 USDT)
[log 144] USDT, SC -> Caller (0x1b97=7063 = 0.007063 USDT)
[log 145] DLP , (SC, SC, 0, 0x3e8)
[log 146] MATIC,(MATIC, Caller, ???)(0x32509143f829da, 0x10803618b77c1606,
0x147e1fff4a5616db85d30, 0x104de5877383ec2c, 0x147e20026f5f2b1b0870a)

對應到 8 Actions
[log 129] ==> From 0x581c7db44f2616781c86c331d31c1f09db87a746 To
0xcfb2168bad58d505ac0d857017cd0cbf7408e81c For 0.001 ($0.00) (PoS) Tether...
(USDT)
[log 131] ==> From 0xcfb2168bad58d505ac0d857017cd0cbf7408e81c To
0xf6422b997c7f54d1c6a6e103bcb1499eea0a7046 For 0.001 ($0.00) (PoS) Tether...
(USDT)
[log 133] ==> From 0xf6422b997c7f54d1c6a6e103bcb1499eea0a7046 To
0xcfb2168bad58d505ac0d857017cd0cbf7408e81c For 0.000000398389637057 ($0.00)
Wrapped Ethe... (WETH)
[log 137] ==> From 0xcfb2168bad58d505ac0d857017cd0cbf7408e81c To
0xc2755915a85c6f6c1c0f3a86ac8c058f11caa9c9 For 0.000000398389637057 ($0.00)
Wrapped Ethe... (WETH)
[log 141] ==> From 0xc2755915a85c6f6c1c0f3a86ac8c058f11caa9c9 To
0xcfb2168bad58d505ac0d857017cd0cbf7408e81c For 0.000995 ($0.00) (PoS)
Tether... (USDT)
[log 142] ==> From 0xcfb2168bad58d505ac0d857017cd0cbf7408e81c To
0x581c7db44f2616781c86c331d31c1f09db87a746 For 0.001 ($0.00) (PoS) Tether...
(USDT)
[log 143] ==> From 0xcfb2168bad58d505ac0d857017cd0cbf7408e81c To
0xdcc43055f22a87b0041f368d158a63e7dd7ff4db For 0.007063 ($0.01) (PoS)
Tether... (USDT)
[log 144] ==> From 0xcfb2168bad58d505ac0d857017cd0cbf7408e81c To
0xdcc43055f22a87b0041f368d158a63e7dd7ff4db For 0.007063 ($0.01) (PoS)
Tether... (USDT)

應該是我太笨蛋..還是看不出那邊是彩蛋ㄟ.(胡亂猜一下..多了Uniswap V2 ?)
斗膽請MACD大明示, 非常感謝~~






--

※ PTT 留言評論
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.136.81.55 (臺灣)
PTT 網址

natukage06/30 13:21大大你太強大了 我早就放棄了 我連節點都架不出來orz

MACD06/30 13:25既然還有人記得,你如果要成功

MACD06/30 13:25要嘛轉一點token進去合約補足還款

MACD06/30 13:25要嘛剛好兩個池有價差可以還款

MACD06/30 13:25彩蛋就是還完款後剩下只有一半會退給sender

MACD06/30 13:25另外一半就給0xdcc這個帳號當作合約使用費

MACD06/30 13:31你看ERC-20 Token Txn第一筆就是我有轉一點USDT進去合約測

MACD06/30 13:31試有沒有問題,所以最後會退跟匯進去USDT差不多的錢出來

justwedave06/30 13:57我猜這合約就是flashloan去套利 只是你呼叫時

justwedave06/30 13:57沒有交易對給你套 所以才失敗

blackjj311006/30 14:00謝謝MACD大解答

blackjj311006/30 14:02我原本以為"stateMutability": "nonpayable" 是不能

blackjj311006/30 14:03往合約送 token的..

blackjj311006/30 14:07natukage大,這裡大神太多,我還在學習中,node我也沒架

MACD06/30 14:09是兩個LP套完沒有獲利還不了錢,所以會失敗

blackjj311006/30 14:09建議先去https://www.alchemy.com 申請免費的URL使用

blackjj311006/30 14:21想請問MACD大,如果想測試第一點轉usdt去合約補足還

blackjj311006/30 14:21款,時間點,該如何拿捏?

blackjj311006/30 14:21是不是在同一個block,呼叫合約前,先轉usdt 進合約

blackjj311006/30 14:21

blackjj311006/30 14:21還是只要合約裡,有足夠的usdt 就可以?非常感謝。

MACD06/30 14:21合約怎麼寫可以參考這個系列文minminpp分享的國外github

MACD06/30 14:21裡面有code可以參考

MACD06/30 14:22只要合約有足夠的錢就可以,不用同一個block

MACD06/30 14:22轉一點點就可以了0.001USDT就夠了

blackjj311006/30 14:33謝謝MACD大,也謝謝minminpp大

blackjj311006/30 16:08謝謝MACD大,這次成功了,tx=0x93549e05593f6c8d104f

blackjj311006/30 16:083e3e581e1113f7198877cb79363c838c3ec7aa31769f

MACD06/30 16:22恭喜你學會手動跟合約互動XD