tx · 8jgseVAPKgesxBqQ75AK1wtmESPTQKW11Sr3pks8mPjX

3Mty9tvj2nMt3mudiJFGKqKh8Mai1o8oGCA:  -0.01000000 Waves

2022.02.15 12:16 [1924552] smart account 3Mty9tvj2nMt3mudiJFGKqKh8Mai1o8oGCA > SELF 0.00000000 Waves

{ "type": 13, "id": "8jgseVAPKgesxBqQ75AK1wtmESPTQKW11Sr3pks8mPjX", "fee": 1000000, "feeAssetId": null, "timestamp": 1644916622280, "version": 2, "chainId": 84, "sender": "3Mty9tvj2nMt3mudiJFGKqKh8Mai1o8oGCA", "senderPublicKey": "D5AsfVE6mgvKZXPLeW3vHDhcVwbypV8qcT64Kmn4UQ3D", "proofs": [ "hToRrY4GpCY87iWXah8xomKY6c5NGpMrSLgmBi3a2wvrBCZeDPabxkjPqZ6ZDnC5KhdjowGYS5PBsQGft2LiZvB" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgECAAAABgAAAAAObG9hbkZlZVBlcmNlbnQJAABpAAAAAgAAAAAAAAAACQAAAAAAAAAAZAAAAAAEVVNETgEAAAAgImQ/Hr5gRukRahMT3KYz/hZ+B/l36bPyFfyZSSowCjcAAAAABVdBVkVTAQAAAAQTq9kzAAAAABtleGNoYW5nZXJVU0ROdG9XYXZlc0FkZHJlc3MJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVRlO0iZAZuQgWXZn5GJMYy9wBUgW1m44o4AAAAAG2V4Y2hhbmdlcldhdmVzVG9VU0ROQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVN4Pvno4pLzl6yPdHWZAu26THq7fS7YWLAAAAAANbG9hbmVyQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVDdtURHBzP3NwchbOzttKqJMBcxR9RiMgwAAAAEAAAABaQEAAAAFdHJhZGUAAAABAAAACGJvcnJvd2VyBAAAAApsb2FuQW1vdW50AwkAAAAAAAACCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAA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ZlcgAAAAMJAQAAAAdBZGRyZXNzAAAAAQUAAAAIYm9ycm93ZXIFAAAABnByb2ZpdAUAAAAEVVNETgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAA1sb2FuZXJBZGRyZXNzBQAAAARkZWJ0BQAAAARVU0ROBQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAADUSNVE=", "height": 1924552, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 658xfvoL8LtSc544dNxbXwyTdPNKxvM6raLhtfL2GVKj Next: D464jY3gKNHcn73ZA1uGyao3JxZEXFjsjaY66355MHJm Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let loanFeePercent = (9 / 100)
5+
46 let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
57
6-let loanFeePercent = (9 / 100)
8+let WAVES = base58'WAVES'
9+
10+let exchangerUSDNtoWavesAddress = Address(base58'3My9M3PdtDPdsvHwX4t1epYFJjhLDrQFP49')
11+
12+let exchangerWavesToUSDNAddress = Address(base58'3NAAEeRUgAj7D4pTPGR7n4yPCX2JGF3vUXm')
13+
14+let loanerAddress = Address(base58'3Mty9tvj2nMt3mudiJFGKqKh8Mai1o8oGCA')
715
816 @Callable(i)
9-func flashloan (amount,callback,borrower) = {
10- let startBalance = assetBalance(this, USDN)
11- if ((startBalance == startBalance))
17+func trade (borrower) = {
18+ let loanAmount = if ((i.payments[0].assetId == USDN))
19+ then i.payments[0].amount
20+ else throw("Unexpected payment asset")
21+ let startBalanceWAVES = assetBalance(this, WAVES)
22+ if ((startBalanceWAVES == startBalanceWAVES))
1223 then {
13- let r = invoke(Address(fromBase58String(borrower)), callback, [i.caller.bytes], [AttachedPayment(USDN, amount)])
14- if ((r == r))
24+ let r1 = invoke(exchangerUSDNtoWavesAddress, "exchangeUSDNtoWAVES", nil, [AttachedPayment(USDN, loanAmount)])
25+ if ((r1 == r1))
1526 then {
16- let balanceDiff = (assetBalance(this, USDN) - startBalance)
17- let profit = fraction(amount, loanFeePercent, 100)
18- if ((profit > balanceDiff))
19- then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
20- else nil
27+ let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
28+ if ((diffWAVES == diffWAVES))
29+ then {
30+ let r2 = invoke(exchangerWavesToUSDNAddress, "exchangeWAVEStoUSDN", nil, [AttachedPayment(WAVES, diffWAVES)])
31+ if ((r2 == r2))
32+ then {
33+ let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
34+ let profit = (assetBalance(this, USDN) - debt)
35+[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(loanerAddress, debt, USDN)]
36+ }
37+ else throw("Strict value is not equal to itself.")
38+ }
39+ else throw("Strict value is not equal to itself.")
2140 }
2241 else throw("Strict value is not equal to itself.")
2342 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let loanFeePercent = (9 / 100)
5+
46 let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
57
6-let loanFeePercent = (9 / 100)
8+let WAVES = base58'WAVES'
9+
10+let exchangerUSDNtoWavesAddress = Address(base58'3My9M3PdtDPdsvHwX4t1epYFJjhLDrQFP49')
11+
12+let exchangerWavesToUSDNAddress = Address(base58'3NAAEeRUgAj7D4pTPGR7n4yPCX2JGF3vUXm')
13+
14+let loanerAddress = Address(base58'3Mty9tvj2nMt3mudiJFGKqKh8Mai1o8oGCA')
715
816 @Callable(i)
9-func flashloan (amount,callback,borrower) = {
10- let startBalance = assetBalance(this, USDN)
11- if ((startBalance == startBalance))
17+func trade (borrower) = {
18+ let loanAmount = if ((i.payments[0].assetId == USDN))
19+ then i.payments[0].amount
20+ else throw("Unexpected payment asset")
21+ let startBalanceWAVES = assetBalance(this, WAVES)
22+ if ((startBalanceWAVES == startBalanceWAVES))
1223 then {
13- let r = invoke(Address(fromBase58String(borrower)), callback, [i.caller.bytes], [AttachedPayment(USDN, amount)])
14- if ((r == r))
24+ let r1 = invoke(exchangerUSDNtoWavesAddress, "exchangeUSDNtoWAVES", nil, [AttachedPayment(USDN, loanAmount)])
25+ if ((r1 == r1))
1526 then {
16- let balanceDiff = (assetBalance(this, USDN) - startBalance)
17- let profit = fraction(amount, loanFeePercent, 100)
18- if ((profit > balanceDiff))
19- then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
20- else nil
27+ let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
28+ if ((diffWAVES == diffWAVES))
29+ then {
30+ let r2 = invoke(exchangerWavesToUSDNAddress, "exchangeWAVEStoUSDN", nil, [AttachedPayment(WAVES, diffWAVES)])
31+ if ((r2 == r2))
32+ then {
33+ let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
34+ let profit = (assetBalance(this, USDN) - debt)
35+[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(loanerAddress, debt, USDN)]
36+ }
37+ else throw("Strict value is not equal to itself.")
38+ }
39+ else throw("Strict value is not equal to itself.")
2140 }
2241 else throw("Strict value is not equal to itself.")
2342 }
2443 else throw("Strict value is not equal to itself.")
2544 }
2645
2746

github/deemru/w8io/026f985 
32.26 ms