tx · FuaC1U4VjupdMfWMiQGhteWSsaWkTL26vgh4CRoi8TrA

3N4Fa58WBBWv5MP92u6pA2g7xNYMpPLMvLx:  -0.01000000 Waves

2024.12.06 11:49 [3402561] smart account 3N4Fa58WBBWv5MP92u6pA2g7xNYMpPLMvLx > SELF 0.00000000 Waves

{ "type": 13, "id": "FuaC1U4VjupdMfWMiQGhteWSsaWkTL26vgh4CRoi8TrA", "fee": 1000000, "feeAssetId": null, "timestamp": 1733475001054, "version": 2, "chainId": 84, "sender": "3N4Fa58WBBWv5MP92u6pA2g7xNYMpPLMvLx", "senderPublicKey": "9fRXUJPxTtF7P9bYTs5roJ4c5tzMiBmv93Kuf94JBnQQ", "proofs": [ "5uLwqnmjuz39SYWGWK9e2s9Vys5koCVdHSVj5oenCHUmaPkA8C7J1oaJPaC4beaR6B4spauYgo1Li5bq9EDLGSYr" ], "script": "base64:BgIUCAISBAoCAQESBAoCAQESBAoCAQEMAA13eFBvb2xBZGRyZXNzCQEHQWRkcmVzcwEBGgFXwpqB3QBHc5r208SLwRlX4Ff1uMp3pHChABBzaW1wbGVBbW1BZGRyZXNzCQEHQWRkcmVzcwEBGgFX8TVzade+uoR7uZWuq4RsHviU5ek6RsEUAAV3YXZlcwUEdW5pdAAEdXNkdAEg4Ab+M2BRGawNofT8uvzf4LqfJWpjiEPmNOUmlPCdXw8AAmxwASDCLiMHWN0a+0SIgd4uCXqKdtYFXXiXAxiczjOiag47FgEKZ2V0QmFsYW5jZQECaWQEByRtYXRjaDAFAmlkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAWIFByRtYXRjaDAJAPAHAgUEdGhpcwUBYggJAO8HAQUEdGhpcwlhdmFpbGFibGUBDWFzc2V0VG9TdHJpbmcBAmlkBAckbWF0Y2gwBQJpZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDYBAEFAWICBVdBVkVTAQxzd2FwT25XeFBvb2wCBWFzc2V0BmFtb3VudAQSc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WUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BaQECc3UCBmFtb3VudAltaW5Qcm9maXQEBWNoZWNrAwkAAAIIBQFpBmNhbGxlcgUEdGhpcwYJAAIBAhFwZXJtaXNzaW9uIGRlbmllZAMJAAACBQVjaGVjawUFY2hlY2sJAQlhcmJpdHJhZ2UDBQR1c2R0BQZhbW91bnQFCW1pblByb2ZpdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQNzdXUCBmFtb3VudAltaW5Qcm9maXQEBWNoZWNrAwkAAAIIBQFpBmNhbGxlcgUEdGhpcwYJAAIBAhFwZXJtaXNzaW9uIGRlbmllZAMJAAACBQVjaGVjawUFY2hlY2sEA3JlcwkA/AcEBRBzaW1wbGVBbW1BZGRyZXNzAgxzd2FwUkVBRE9OTFkJAMwIAgIFV0FWRVMJAMwIAgUGYW1vdW50BQNuaWwFA25pbAQJbmV3QW1vdW50BAckbWF0Y2gwBQNyZXMDCQABAgUHJG1hdGNoMAIWKEludCwgSW50LCBCeXRlVmVjdG9yKQQBcgUHJG1hdGNoMAgFAXICXzEJAAIBAg9zb21ldGhpbmcgd3JvbmcEDG5ld01pblByb2ZpdAkAawMFCW1pblByb2ZpdAUJbmV3QW1vdW50BQZhbW91bnQJAQlhcmJpdHJhZ2UDBQR1c2R0BQluZXdBbW91bnQFDG5ld01pblByb2ZpdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgCvzS7R", "height": 3402561, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 7wjuwt5tsZ68Uysqtndt7STZ918DqssSBoHG7fwFjg4N Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let wxPoolAddress = Address(base58'3PKfrupEydU2nZAghVjZAfvCwMBkzuR1F52')
5+
6+let simpleAmmAddress = Address(base58'3PPvHcJjESoUbf9LDpAxEhQKUnpqH1Ea29h')
7+
8+let waves = unit
9+
10+let usdt = base58'G5WWWzzVsWRyzGf32xojbnfp7gXbWrgqJT8RcVWEfLmC'
11+
12+let lp = base58'E4zu2YxX1Tq8Y2nBcXZhh9gG1jctZitisnt6pyQhUBYH'
13+
14+func getBalance (id) = match id {
15+ case b: ByteVector =>
16+ assetBalance(this, b)
17+ case _ =>
18+ wavesBalance(this).available
19+}
20+
21+
22+func assetToString (id) = match id {
23+ case b: ByteVector =>
24+ toBase58String(b)
25+ case _ =>
26+ "WAVES"
27+}
28+
29+
30+func swapOnWxPool (asset,amount) = {
31+ let receiveAssetString = assetToString(asset)
32+ let initLPBalance = getBalance(lp)
33+ if ((initLPBalance == initLPBalance))
34+ then {
35+ let inv1 = invoke(wxPoolAddress, "putOneTkn", [1, false], [AttachedPayment(asset, amount)])
36+ if ((inv1 == inv1))
37+ then {
38+ let lpReceived = (getBalance(lp) - initLPBalance)
39+ if ((lpReceived == lpReceived))
40+ then {
41+ let inv2 = invoke(wxPoolAddress, "getOneTkn", [receiveAssetString, 1], [AttachedPayment(lp, lpReceived)])
42+ if ((inv2 == inv2))
43+ then unit
44+ else throw("Strict value is not equal to itself.")
45+ }
46+ else throw("Strict value is not equal to itself.")
47+ }
48+ else throw("Strict value is not equal to itself.")
49+ }
50+ else throw("Strict value is not equal to itself.")
51+ }
52+
53+
54+func arbitrage (sendAsset,amount,minProfit) = {
55+ let receiveAsset = if ((sendAsset == unit))
56+ then usdt
57+ else unit
58+ let initSendBalance = getBalance(sendAsset)
59+ if ((initSendBalance == initSendBalance))
60+ then {
61+ let initReceiveBalance = getBalance(receiveAsset)
62+ if ((initReceiveBalance == initReceiveBalance))
63+ then {
64+ let inv1 = invoke(simpleAmmAddress, "swap", nil, [AttachedPayment(sendAsset, amount)])
65+ if ((inv1 == inv1))
66+ then {
67+ let received = (getBalance(receiveAsset) - initReceiveBalance)
68+ if ((received == received))
69+ then {
70+ let inv2 = swapOnWxPool(receiveAsset, received)
71+ if ((inv2 == inv2))
72+ then {
73+ let profit = (getBalance(sendAsset) - initSendBalance)
74+ if ((profit == profit))
75+ then if ((profit > minProfit))
76+ then nil
77+ else throw(makeString(["no profit", assetToString(sendAsset), toString(amount), toString(minProfit), toString(profit)], " "))
78+ else throw("Strict value is not equal to itself.")
79+ }
80+ else throw("Strict value is not equal to itself.")
81+ }
82+ else throw("Strict value is not equal to itself.")
83+ }
84+ else throw("Strict value is not equal to itself.")
85+ }
86+ else throw("Strict value is not equal to itself.")
87+ }
88+ else throw("Strict value is not equal to itself.")
89+ }
90+
91+
92+func getWxPoolBalance () = {
93+ let keyAdditionalBalance = makeString(["%s%s", "stakedBalance", "WAVES"], "__")
94+ let usdtBalance = assetBalance(wxPoolAddress, usdt)
95+ let wBalance = (wavesBalance(wxPoolAddress).available + valueOrElse(getInteger(wxPoolAddress, keyAdditionalBalance), 0))
96+ $Tuple2(usdt, wBalance)
97+ }
98+
99+
100+func getAmmBalance () = {
101+ let usdtBalance = assetBalance(simpleAmmAddress, usdt)
102+ let wBalance = wavesBalance(simpleAmmAddress).available
103+ $Tuple2(usdtBalance, wBalance)
104+ }
105+
106+
107+func calcBestDeal (a1,b1,a2,b2) = {
108+ let p2 = ((a1 + a2) * (a1 + a2))
109+ let a1a1b2 = ((a1 * a2) * b1)
110+ let p111 = ((a1a1b2 * p2) * b2)
111+ let p11 = sqrt(p111, 0, 0, DOWN)
112+ let p12 = (-(a1a1b2) - ((a2 * a2) * b1))
113+ let p1 = (p11 + p12)
114+ let bestX = (p1 / p2)
115+ bestX
116+ }
117+
118+
119+@Callable(i)
120+func sw (amount,minProfit) = {
121+ let check = if ((i.caller == this))
122+ then true
123+ else throw("permission denied")
124+ if ((check == check))
125+ then arbitrage(waves, amount, minProfit)
126+ else throw("Strict value is not equal to itself.")
127+ }
128+
129+
130+
131+@Callable(i)
132+func su (amount,minProfit) = {
133+ let check = if ((i.caller == this))
134+ then true
135+ else throw("permission denied")
136+ if ((check == check))
137+ then arbitrage(usdt, amount, minProfit)
138+ else throw("Strict value is not equal to itself.")
139+ }
140+
141+
142+
143+@Callable(i)
144+func suu (amount,minProfit) = {
145+ let check = if ((i.caller == this))
146+ then true
147+ else throw("permission denied")
148+ if ((check == check))
149+ then {
150+ let res = invoke(simpleAmmAddress, "swapREADONLY", ["WAVES", amount], nil)
151+ let newAmount = match res {
152+ case r: (Int, Int, ByteVector) =>
153+ r._1
154+ case _ =>
155+ throw("something wrong")
156+ }
157+ let newMinProfit = fraction(minProfit, newAmount, amount)
158+ arbitrage(usdt, newAmount, newMinProfit)
159+ }
160+ else throw("Strict value is not equal to itself.")
161+ }
162+
163+

github/deemru/w8io/026f985 
13.17 ms