tx · EVK7g52TfiX2eSMaZeAxPGCEDV6M7g3untjQGkxf4XSu

3Mwm6wcc5SBiMzF2dMWpTJpFFobA236iAZ7:  -0.00300000 Waves

2022.09.01 12:30 [2209889] smart account 3Mwm6wcc5SBiMzF2dMWpTJpFFobA236iAZ7 > SELF 0.00000000 Waves

{ "type": 13, "id": "EVK7g52TfiX2eSMaZeAxPGCEDV6M7g3untjQGkxf4XSu", "fee": 300000, "feeAssetId": null, "timestamp": 1662024674274, "version": 2, "chainId": 84, "sender": "3Mwm6wcc5SBiMzF2dMWpTJpFFobA236iAZ7", "senderPublicKey": "BpvXf9toCinzcKiB63evew28WyjAZX5mTYcnAcRGMAH6", "proofs": [ "BY8qh2q16CenLTwjancPHM3zzm7WjxpiLpJNgQW9S6auBYYbJ4Znxbg8DHKnYFg6fA3R8h84cSqhKn43nBakQJq" ], "script": "base64:AAIFAAAAAAAAAB0IAhIFCgMBAgISBQoDAQICEgUKAwIBAhIECgIBCAAAAAcAAAAADGV4Y2hhbmdlUmF0ZQAAAAAAAAAACgAAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAAoAAAAAD1VTRE50b1dBVkVTcmF0ZQkAAGsAAAADBQAAAAxleGNoYW5nZVJhdGUJAABlAAAAAgAAAAAAAAAAZAUAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAGQAAAAABFVTRE4BAAAAIA/yHBKs5MQ8muxGGqslqLDsugcrRsxtiHLwteKSSQG0AAAAAAVXQVZFUwEAAAAAAAAAAA9VU0ROdG9XQVZFU1JhdGUAAAAAAAAAAAoAAAAADmxvYW5GZWVQZXJjZW50AAAAAAAAAAABAAAABAAAAAFpAQAAABNleGNoYW5nZVdBVkVTdG9VU0ROAAAAAwAAAAZhbW91bnQAAAAHYXNzZXRJZAAAAAZjYWxsZXIDCQAAAAAAAAIFAAAAB2Fzc2V0SWQFAAAABVdBVkVTCQAETAAAAAIJAQAAAA5TY3JpcHRU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FAAAAA25pbAkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAAADieWRw==", "height": 2209889, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3kKQa3X1twvpZtjrLc1EEWkcsLerQHrLjsoL8Ss65LQj Next: none Diff:
OldNewDifferences
77
88 let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100)
99
10-let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
10+let USDN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'
1111
1212 let WAVES = base58''
1313
1515
1616 let loanFeePercent = 1
1717
18+@Callable(i)
1819 func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
19- then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN)]
20+ then [ScriptTransfer(Address(caller), fraction(amount, (USDNtoWAVESrate - 1), 100), USDN), IntegerEntry("WAVEStoUSDN", amount)]
2021 else throw("Unexpected Token")
2122
2223
24+
25+@Callable(i)
2326 func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
24- then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES)]
27+ then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), unit), IntegerEntry("USDNtoWAVES", amount)]
2528 else throw("Unexpected Token")
2629
2730
31+
32+@Callable(i)
2833 func trade (borrower,amount,assetId) = {
2934 let loanAmount = if ((assetId == USDN))
3035 then amount
3136 else throw("Unexpected payment asset")
32- let startBalanceWAVES = assetBalance(this, WAVES)
33- if ((startBalanceWAVES == startBalanceWAVES))
37+ let startBalanceWAVES = wavesBalance(this).regular
38+ let r1 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, USDN, borrower], nil)
39+ if ((r1 == r1))
3440 then {
35- let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
36- if ((r1 == r1))
37- then {
38- let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
39- if ((diffWAVES == diffWAVES))
40- then {
41- let r2 = exchangeWAVEStoUSDN(amount, WAVES, borrower)
42- if ((r2 == r2))
43- then {
44- let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
45- let profit = (assetBalance(this, USDN) - debt)
46-[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)]
47- }
48- else throw("Strict value is not equal to itself.")
49- }
50- else throw("Strict value is not equal to itself.")
51- }
41+ let diffWAVES = wavesBalance(this).regular
42+ let diffWAVES2 = (diffWAVES - startBalanceWAVES)
43+ let r2 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, WAVES, borrower], nil)
44+ if ((r2 == r2))
45+ then [IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", diffWAVES), IntegerEntry("loanAmount", loanAmount), ScriptTransfer(Address(borrower), amount, USDN)]
5246 else throw("Strict value is not equal to itself.")
5347 }
5448 else throw("Strict value is not equal to itself.")
5549 }
5650
5751
52+
5853 @Callable(i)
5954 func flashloan (amount,borr) = {
6055 let startBalance = assetBalance(this, USDN)
61- if ((startBalance == startBalance))
56+ let borrower = borr
57+ let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil)
58+ if ((test == test))
6259 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.")
60+ let balanceDiff = assetBalance(this, USDN)
61+ let balanceDiff2 = (balanceDiff - startBalance)
62+ let profit = fraction(amount, loanFeePercent, 100)
63+ if ((profit > balanceDiff2))
64+ then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
65+ else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", balanceDiff2), StringEntry("this", toString(this)), ScriptTransfer(Address(fromBase58String(borr)), profit, USDN)]
7466 }
7567 else throw("Strict value is not equal to itself.")
7668 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let exchangeRate = 10
55
66 let exchangeRateDiffPercent = 10
77
88 let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100)
99
10-let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
10+let USDN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'
1111
1212 let WAVES = base58''
1313
1414 let USDNtoWAVESRate = 10
1515
1616 let loanFeePercent = 1
1717
18+@Callable(i)
1819 func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
19- then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN)]
20+ then [ScriptTransfer(Address(caller), fraction(amount, (USDNtoWAVESrate - 1), 100), USDN), IntegerEntry("WAVEStoUSDN", amount)]
2021 else throw("Unexpected Token")
2122
2223
24+
25+@Callable(i)
2326 func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
24- then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES)]
27+ then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), unit), IntegerEntry("USDNtoWAVES", amount)]
2528 else throw("Unexpected Token")
2629
2730
31+
32+@Callable(i)
2833 func trade (borrower,amount,assetId) = {
2934 let loanAmount = if ((assetId == USDN))
3035 then amount
3136 else throw("Unexpected payment asset")
32- let startBalanceWAVES = assetBalance(this, WAVES)
33- if ((startBalanceWAVES == startBalanceWAVES))
37+ let startBalanceWAVES = wavesBalance(this).regular
38+ let r1 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, USDN, borrower], nil)
39+ if ((r1 == r1))
3440 then {
35- let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
36- if ((r1 == r1))
37- then {
38- let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
39- if ((diffWAVES == diffWAVES))
40- then {
41- let r2 = exchangeWAVEStoUSDN(amount, WAVES, borrower)
42- if ((r2 == r2))
43- then {
44- let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
45- let profit = (assetBalance(this, USDN) - debt)
46-[ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)]
47- }
48- else throw("Strict value is not equal to itself.")
49- }
50- else throw("Strict value is not equal to itself.")
51- }
41+ let diffWAVES = wavesBalance(this).regular
42+ let diffWAVES2 = (diffWAVES - startBalanceWAVES)
43+ let r2 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, WAVES, borrower], nil)
44+ if ((r2 == r2))
45+ then [IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", diffWAVES), IntegerEntry("loanAmount", loanAmount), ScriptTransfer(Address(borrower), amount, USDN)]
5246 else throw("Strict value is not equal to itself.")
5347 }
5448 else throw("Strict value is not equal to itself.")
5549 }
5650
5751
52+
5853 @Callable(i)
5954 func flashloan (amount,borr) = {
6055 let startBalance = assetBalance(this, USDN)
61- if ((startBalance == startBalance))
56+ let borrower = borr
57+ let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil)
58+ if ((test == test))
6259 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.")
60+ let balanceDiff = assetBalance(this, USDN)
61+ let balanceDiff2 = (balanceDiff - startBalance)
62+ let profit = fraction(amount, loanFeePercent, 100)
63+ if ((profit > balanceDiff2))
64+ then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
65+ else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", balanceDiff2), StringEntry("this", toString(this)), ScriptTransfer(Address(fromBase58String(borr)), profit, USDN)]
7466 }
7567 else throw("Strict value is not equal to itself.")
7668 }
7769
7870

github/deemru/w8io/026f985 
26.99 ms