tx · 41PXRGr3V5pYvwhBEiRqwE8ZcNyVWkbQCUekTdDGmNc9

3Mwm6wcc5SBiMzF2dMWpTJpFFobA236iAZ7:  -0.01000000 Waves

2022.03.14 22:06 [1964030] smart account 3Mwm6wcc5SBiMzF2dMWpTJpFFobA236iAZ7 > SELF 0.00000000 Waves

{ "type": 13, "id": "41PXRGr3V5pYvwhBEiRqwE8ZcNyVWkbQCUekTdDGmNc9", "fee": 1000000, "feeAssetId": null, "timestamp": 1647284793545, "version": 2, "chainId": 84, "sender": "3Mwm6wcc5SBiMzF2dMWpTJpFFobA236iAZ7", "senderPublicKey": "BpvXf9toCinzcKiB63evew28WyjAZX5mTYcnAcRGMAH6", "proofs": [ "5ozdLMJH4TMXMGjZ3x1oSqEUwYmn43Ce4VTjfVB9QiZjx24Pmck4QLkeH4EeUSWQYe3rX5mPabTNsw4vqxBVep2q" ], "script": "base64:AAIFAAAAAAAAAAgIAhIECgIBCAAAAAoAAAAADGV4Y2hhbmdlUmF0ZQAAAAAAAAAACgAAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAAoAAAAAD1VTRE50b1dBVkVTcmF0ZQkAAGsAAAADBQAAAAxleGNoYW5nZVJhdGUJAABlAAAAAgAAAAAAAAAAZAUAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAGQAAAAABFVTRE4BAAAAICJkPx6+YEbpEWoTE9ymM/4Wfgf5d+mz8hX8mUkqMAo3AAAAAAVXQVZFUwEAAAAAAAAAAA9VU0ROdG9XQVZFU1JhdGUAAAAAAAAAAAoAAAAADmxvYW5GZWVQZXJjZW50AAAAAAAAAAAKAQAAABNleGNoYW5nZVdBVkVTdG9VU0ROAAAAAwAAAAZhbW91bnQAAAAHYXNzZXRJZAAAAAZjYWxsZXIDCQAAAAAAAAIFAAAAB2Fzc2V0SWQFAAAABVdBVkVTCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAA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XN0BAAAAAtiYWxhbmNlRGlmZgkAAGUAAAACCQAD8AAAAAIFAAAABHRoaXMFAAAABFVTRE4FAAAADHN0YXJ0QmFsYW5jZQQAAAAGcHJvZml0CQAAawAAAAMFAAAABmFtb3VudAUAAAAObG9hbkZlZVBlcmNlbnQAAAAAAAAAAGQDCQAAZgAAAAIFAAAABnByb2ZpdAUAAAALYmFsYW5jZURpZmYJAAACAAAAAQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAeRGVidCBub3QgcGFpZCwgYmVjYXVzZSBkaWZmID0gCQABpAAAAAEFAAAAC2JhbGFuY2VEaWZmAgAAABIuIEV4cGVjdGVkIGRpZmYgPSAJAAGkAAAAAQUAAAAGcHJvZml0BQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAABsF7+j", "height": 1964030, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HVXSysLEHeHuWvNiyf7sUMQrtahcQHDKhpr23ozLR5nS Next: 3kKQa3X1twvpZtjrLc1EEWkcsLerQHrLjsoL8Ss65LQj Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let loanFeePercent = (9 / 100)
4+let exchangeRate = 10
5+
6+let exchangeRateDiffPercent = 10
7+
8+let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100)
59
610 let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
711
8-let WAVES = base58'WAVES'
12+let WAVES = base58''
913
10-let exchangerUSDNtoWavesAddress = Address(base58'3My9M3PdtDPdsvHwX4t1epYFJjhLDrQFP49')
14+let USDNtoWAVESRate = 10
1115
12-let exchangerWavesToUSDNAddress = Address(base58'3NAAEeRUgAj7D4pTPGR7n4yPCX2JGF3vUXm')
16+let loanFeePercent = 10
1317
14-let loanerAddress = Address(base58'3Mty9tvj2nMt3mudiJFGKqKh8Mai1o8oGCA')
18+func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
19+ then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN)]
20+ else throw("Unexpected Token")
1521
16-@Callable(i)
17-func trade (borrower) = {
18- let loanAmount = if ((i.payments[0].assetId == USDN))
19- then i.payments[0].amount
22+
23+func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
24+ then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES)]
25+ else throw("Unexpected Token")
26+
27+
28+func trade (borrower,amount,assetId) = {
29+ let loanAmount = if ((assetId == USDN))
30+ then amount
2031 else throw("Unexpected payment asset")
2132 let startBalanceWAVES = assetBalance(this, WAVES)
2233 if ((startBalanceWAVES == startBalanceWAVES))
2334 then {
24- let r1 = invoke(exchangerUSDNtoWavesAddress, "exchangeUSDNtoWAVES", nil, [AttachedPayment(USDN, loanAmount)])
35+ let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
2536 if ((r1 == r1))
2637 then {
2738 let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
2839 if ((diffWAVES == diffWAVES))
2940 then {
30- let r2 = invoke(exchangerWavesToUSDNAddress, "exchangeWAVEStoUSDN", nil, [AttachedPayment(WAVES, diffWAVES)])
41+ let r2 = exchangeWAVEStoUSDN(amount, WAVES, borrower)
3142 if ((r2 == r2))
3243 then {
3344 let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
3445 let profit = (assetBalance(this, USDN) - debt)
35-[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(loanerAddress, debt, USDN)]
46+[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)]
3647 }
3748 else throw("Strict value is not equal to itself.")
3849 }
4455 }
4556
4657
58+@Callable(i)
59+func flashloan (amount,borr) = {
60+ let startBalance = assetBalance(this, USDN)
61+ if ((startBalance == startBalance))
62+ then {
63+ let borrower = borr
64+ let test = trade(fromBase58String(borr), amount, USDN)
65+ if ((test == test))
66+ then {
67+ let balanceDiff = (assetBalance(this, USDN) - startBalance)
68+ let profit = fraction(amount, loanFeePercent, 100)
69+ if ((profit > balanceDiff))
70+ then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
71+ else nil
72+ }
73+ else throw("Strict value is not equal to itself.")
74+ }
75+ else throw("Strict value is not equal to itself.")
76+ }
77+
78+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let loanFeePercent = (9 / 100)
4+let exchangeRate = 10
5+
6+let exchangeRateDiffPercent = 10
7+
8+let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100)
59
610 let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
711
8-let WAVES = base58'WAVES'
12+let WAVES = base58''
913
10-let exchangerUSDNtoWavesAddress = Address(base58'3My9M3PdtDPdsvHwX4t1epYFJjhLDrQFP49')
14+let USDNtoWAVESRate = 10
1115
12-let exchangerWavesToUSDNAddress = Address(base58'3NAAEeRUgAj7D4pTPGR7n4yPCX2JGF3vUXm')
16+let loanFeePercent = 10
1317
14-let loanerAddress = Address(base58'3Mty9tvj2nMt3mudiJFGKqKh8Mai1o8oGCA')
18+func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
19+ then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN)]
20+ else throw("Unexpected Token")
1521
16-@Callable(i)
17-func trade (borrower) = {
18- let loanAmount = if ((i.payments[0].assetId == USDN))
19- then i.payments[0].amount
22+
23+func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
24+ then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES)]
25+ else throw("Unexpected Token")
26+
27+
28+func trade (borrower,amount,assetId) = {
29+ let loanAmount = if ((assetId == USDN))
30+ then amount
2031 else throw("Unexpected payment asset")
2132 let startBalanceWAVES = assetBalance(this, WAVES)
2233 if ((startBalanceWAVES == startBalanceWAVES))
2334 then {
24- let r1 = invoke(exchangerUSDNtoWavesAddress, "exchangeUSDNtoWAVES", nil, [AttachedPayment(USDN, loanAmount)])
35+ let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
2536 if ((r1 == r1))
2637 then {
2738 let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
2839 if ((diffWAVES == diffWAVES))
2940 then {
30- let r2 = invoke(exchangerWavesToUSDNAddress, "exchangeWAVEStoUSDN", nil, [AttachedPayment(WAVES, diffWAVES)])
41+ let r2 = exchangeWAVEStoUSDN(amount, WAVES, borrower)
3142 if ((r2 == r2))
3243 then {
3344 let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
3445 let profit = (assetBalance(this, USDN) - debt)
35-[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(loanerAddress, debt, USDN)]
46+[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)]
3647 }
3748 else throw("Strict value is not equal to itself.")
3849 }
3950 else throw("Strict value is not equal to itself.")
4051 }
4152 else throw("Strict value is not equal to itself.")
4253 }
4354 else throw("Strict value is not equal to itself.")
4455 }
4556
4657
58+@Callable(i)
59+func flashloan (amount,borr) = {
60+ let startBalance = assetBalance(this, USDN)
61+ if ((startBalance == startBalance))
62+ then {
63+ let borrower = borr
64+ let test = trade(fromBase58String(borr), amount, USDN)
65+ if ((test == test))
66+ then {
67+ let balanceDiff = (assetBalance(this, USDN) - startBalance)
68+ let profit = fraction(amount, loanFeePercent, 100)
69+ if ((profit > balanceDiff))
70+ then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
71+ else nil
72+ }
73+ else throw("Strict value is not equal to itself.")
74+ }
75+ else throw("Strict value is not equal to itself.")
76+ }
77+
78+

github/deemru/w8io/026f985 
43.61 ms