tx · 9aoRaPpF9qKuMtm2i4xrpGnFF5uWWPvAQLttZ4awfqdq

3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8:  -0.01000000 Waves

2022.03.14 21:45 [1964010] smart account 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8 > SELF 0.00000000 Waves

{ "type": 13, "id": "9aoRaPpF9qKuMtm2i4xrpGnFF5uWWPvAQLttZ4awfqdq", "fee": 1000000, "feeAssetId": null, "timestamp": 1647283522276, "version": 2, "chainId": 84, "sender": "3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8", "senderPublicKey": "7KdKmjfPuTXGRNZv4VEz9mZiC2qb9JPzuji5z6jszZyo", "proofs": [ "4NzARdfuRyPxhiKtxfoAsUB5BpFj4oAtiNcCHaCNw747Pux7SBcmZLjEVYNdUH2UJsSiLTecRCGH1jwqXXyxVsHC" ], "script": "base64:AAIFAAAAAAAAAAoIAhIGCgQBCAICAAAACgAAAAAMZXhjaGFuZ2VSYXRlAAAAAAAAAAAKAAAAABdleGNoYW5nZVJhdGVEaWZmUGVyY2VudAAAAAAAAAAAFAAAAAAPVVNETnRvV0FWRVNyYXRlCQAAawAAAAMFAAAADGV4Y2hhbmdlUmF0ZQkAAGUAAAACAAAAAAAAAABkBQAAABdleGNoYW5nZVJhdGVEaWZmUGVyY2VudAAAAAAAAAAAZAAAAAAEVVNETgEAAAAgImQ/Hr5gRukRahMT3KYz/hZ+B/l36bPyFfyZSSowCjcAAAAABVdBVkVTAQAAAAQTq9kzAAAAAA9VU0ROdG9XQVZFU1JhdGUAAAAAAAAAAAUAAAAADmxvYW5GZWVQZXJjZW50CQAAaQAAAAIAAAAAAAAAAAkAAAAAAAAAAGQBAAAAE2V4Y2hhbmdlV0FWRVN0b1VTRE4AAAADAAAABmFtb3VudAAAAAdhc3NldElkAAAABmNhbGxlcgMJAAAAAAAAAgUAAAAHYXNzZXRJZAUAAAAFV0FWRVMJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmV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AAAABHRlc3QEAAAAC2JhbGFuY2VEaWZmCQAAZQAAAAIJAAPwAAAAAgUAAAAEdGhpcwUAAAAEVVNETgUAAAAMc3RhcnRCYWxhbmNlBAAAAAZwcm9maXQJAABrAAAAAwUAAAAGYW1vdW50BQAAAA5sb2FuRmVlUGVyY2VudAAAAAAAAAAAZAMJAABmAAAAAgUAAAAGcHJvZml0BQAAAAtiYWxhbmNlRGlmZgkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAB5EZWJ0IG5vdCBwYWlkLCBiZWNhdXNlIGRpZmYgPSAJAAGkAAAAAQUAAAALYmFsYW5jZURpZmYCAAAAEi4gRXhwZWN0ZWQgZGlmZiA9IAkAAaQAAAABBQAAAAZwcm9maXQFAAAAA25pbAkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAJhQFrI=", "height": 1964010, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: SaccSsukgB19YRm7ZiP7NJxuRxTwvnBGRA3dL6sN1bi Next: DCEqFhc7FHgYtHouoTq1SG1y4KYuMyZXeUdVvRn8rBwZ Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let exchangeRate = 5
4+let exchangeRate = 10
55
66 let exchangeRateDiffPercent = 20
77
1515
1616 let loanFeePercent = (9 / 100)
1717
18-let exchangerUSDNtoWavesAddress = Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8')
18+func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
19+ then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN)]
20+ else throw("Unexpected Token")
1921
20-let exchangerWavesToUSDNAddress = Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8')
2122
22-let loanerAddress = Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8')
23+func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
24+ then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES)]
25+ else throw("Unexpected Token")
2326
24-@Callable(i)
25-func trade (borrower) = {
26- let loanAmount = if ((i.payments[0].assetId == USDN))
27- then i.payments[0].amount
27+
28+func trade (borrower,amount,assetId) = {
29+ let loanAmount = if ((assetId == USDN))
30+ then amount
2831 else throw("Unexpected payment asset")
2932 let startBalanceWAVES = assetBalance(this, WAVES)
3033 if ((startBalanceWAVES == startBalanceWAVES))
3134 then {
32- let r1 = invoke(exchangerUSDNtoWavesAddress, "exchangeUSDNtoWAVES", nil, [AttachedPayment(USDN, loanAmount)])
35+ let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
3336 if ((r1 == r1))
3437 then {
3538 let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
3639 if ((diffWAVES == diffWAVES))
3740 then {
38- let r2 = invoke(exchangerWavesToUSDNAddress, "exchangeWAVEStoUSDN", nil, [AttachedPayment(WAVES, diffWAVES)])
41+ let r2 = exchangeWAVEStoUSDN(amount, assetId, borrower)
3942 if ((r2 == r2))
4043 then {
4144 let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
4245 let profit = (assetBalance(this, USDN) - debt)
43-[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(loanerAddress, debt, USDN)]
46+[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)]
4447 }
4548 else throw("Strict value is not equal to itself.")
4649 }
5255 }
5356
5457
55-
5658 @Callable(i)
57-func exchangeWAVEStoUSDN () = if ((i.payments[0].assetId == WAVES))
58- then [ScriptTransfer(i.caller, (i.payments[0].amount / USDNtoWAVESrate), USDN)]
59- else throw("Unexpected Token")
60-
61-
62-
63-@Callable(i)
64-func exchangeUSDNtoWAVES () = if ((i.payments[0].assetId == USDN))
65- then [ScriptTransfer(i.caller, (i.payments[0].amount * USDNtoWAVESRate), WAVES)]
66- else throw("Unexpected Token")
67-
68-
69-
70-@Callable(i)
71-func flashloan (amount,callback,borrower) = {
59+func flashloan (amount,callback,borrower,assetId) = {
7260 let startBalance = assetBalance(this, USDN)
7361 if ((startBalance == startBalance))
7462 then {
75- let r = invoke(Address(fromBase58String(borrower)), callback, [i.caller.bytes], [AttachedPayment(USDN, amount)])
76- if ((r == r))
63+ let test = trade(borrower, amount, assetId)
64+ if ((test == test))
7765 then {
7866 let balanceDiff = (assetBalance(this, USDN) - startBalance)
7967 let profit = fraction(amount, loanFeePercent, 100)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let exchangeRate = 5
4+let exchangeRate = 10
55
66 let exchangeRateDiffPercent = 20
77
88 let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100)
99
1010 let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
1111
1212 let WAVES = base58'WAVES'
1313
1414 let USDNtoWAVESRate = 5
1515
1616 let loanFeePercent = (9 / 100)
1717
18-let exchangerUSDNtoWavesAddress = Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8')
18+func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
19+ then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN)]
20+ else throw("Unexpected Token")
1921
20-let exchangerWavesToUSDNAddress = Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8')
2122
22-let loanerAddress = Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8')
23+func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
24+ then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES)]
25+ else throw("Unexpected Token")
2326
24-@Callable(i)
25-func trade (borrower) = {
26- let loanAmount = if ((i.payments[0].assetId == USDN))
27- then i.payments[0].amount
27+
28+func trade (borrower,amount,assetId) = {
29+ let loanAmount = if ((assetId == USDN))
30+ then amount
2831 else throw("Unexpected payment asset")
2932 let startBalanceWAVES = assetBalance(this, WAVES)
3033 if ((startBalanceWAVES == startBalanceWAVES))
3134 then {
32- let r1 = invoke(exchangerUSDNtoWavesAddress, "exchangeUSDNtoWAVES", nil, [AttachedPayment(USDN, loanAmount)])
35+ let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
3336 if ((r1 == r1))
3437 then {
3538 let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
3639 if ((diffWAVES == diffWAVES))
3740 then {
38- let r2 = invoke(exchangerWavesToUSDNAddress, "exchangeWAVEStoUSDN", nil, [AttachedPayment(WAVES, diffWAVES)])
41+ let r2 = exchangeWAVEStoUSDN(amount, assetId, borrower)
3942 if ((r2 == r2))
4043 then {
4144 let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
4245 let profit = (assetBalance(this, USDN) - debt)
43-[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(loanerAddress, debt, USDN)]
46+[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)]
4447 }
4548 else throw("Strict value is not equal to itself.")
4649 }
4750 else throw("Strict value is not equal to itself.")
4851 }
4952 else throw("Strict value is not equal to itself.")
5053 }
5154 else throw("Strict value is not equal to itself.")
5255 }
5356
5457
55-
5658 @Callable(i)
57-func exchangeWAVEStoUSDN () = if ((i.payments[0].assetId == WAVES))
58- then [ScriptTransfer(i.caller, (i.payments[0].amount / USDNtoWAVESrate), USDN)]
59- else throw("Unexpected Token")
60-
61-
62-
63-@Callable(i)
64-func exchangeUSDNtoWAVES () = if ((i.payments[0].assetId == USDN))
65- then [ScriptTransfer(i.caller, (i.payments[0].amount * USDNtoWAVESRate), WAVES)]
66- else throw("Unexpected Token")
67-
68-
69-
70-@Callable(i)
71-func flashloan (amount,callback,borrower) = {
59+func flashloan (amount,callback,borrower,assetId) = {
7260 let startBalance = assetBalance(this, USDN)
7361 if ((startBalance == startBalance))
7462 then {
75- let r = invoke(Address(fromBase58String(borrower)), callback, [i.caller.bytes], [AttachedPayment(USDN, amount)])
76- if ((r == r))
63+ let test = trade(borrower, amount, assetId)
64+ if ((test == test))
7765 then {
7866 let balanceDiff = (assetBalance(this, USDN) - startBalance)
7967 let profit = fraction(amount, loanFeePercent, 100)
8068 if ((profit > balanceDiff))
8169 then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
8270 else nil
8371 }
8472 else throw("Strict value is not equal to itself.")
8573 }
8674 else throw("Strict value is not equal to itself.")
8775 }
8876
8977

github/deemru/w8io/169f3d6 
37.98 ms