tx · DMrDvCrNv4WoYPPfXorzrmiqfRbeNHXWdFo2FuotTVs1 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8: -0.01000000 Waves 2022.04.13 14:25 [2006736] smart account 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8 > SELF 0.00000000 Waves
{ "type": 13, "id": "DMrDvCrNv4WoYPPfXorzrmiqfRbeNHXWdFo2FuotTVs1", "fee": 1000000, "feeAssetId": null, "timestamp": 1649849170659, "version": 2, "chainId": 84, "sender": "3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8", "senderPublicKey": "7KdKmjfPuTXGRNZv4VEz9mZiC2qb9JPzuji5z6jszZyo", "proofs": [ "55YynfYiQ5C3magXMqdsJDddLAumbJr6mwamA4YUTbxxMhv2Ha5oEHoK1dXq4XS4oMBQCtF73TqNRUujs1Kfyc8b" ], "script": "base64:AAIFAAAAAAAAAB0IAhIFCgMBAgISBQoDAQICEgUKAwIBAhIECgIBCAAAAAcAAAAADGV4Y2hhbmdlUmF0ZQAAAAAAAAAACgAAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAAoAAAAAD1VTRE50b1dBVkVTcmF0ZQkAAGsAAAADBQAAAAxleGNoYW5nZVJhdGUJAABlAAAAAgAAAAAAAAAAZAUAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAGQAAAAABFVTRE4BAAAAIA/yHBKs5MQ8muxGGqslqLDsugcrRsxtiHLwteKSSQG0AAAAAAVXQVZFUwEAAAAAAAAAAA9VU0ROdG9XQVZFU1JhdGUAAAAAAAAAAAoAAAAADmxvYW5GZWVQZXJjZW50AAAAAAAAAAABAAAABAAAAAFpAQAAABNleGNoYW5nZVdBVkVTdG9VU0ROAAAAAwAAAAZhbW91bnQAAAAHYXNzZXRJZAAAAAZjYWxsZXIDCQAAAAAAAAIFAAAAB2Fzc2V0SWQFAAAABVdBVkVTCQAETAAAAAIJAQAAAA5TY3JpcH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AAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAPpDuwU=", "height": 2006736, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5XeBKemPvDAdfiCJjyNoP1to3Stpj5DA5wW7jK92Jsx1 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
38 | 38 | let r1 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, USDN, borrower], nil) | |
39 | 39 | if ((r1 == r1)) | |
40 | 40 | then { | |
41 | - | let diffWAVES = (wavesBalance(this).regular - startBalanceWAVES) | |
41 | + | let diffWAVES = wavesBalance(this).regular | |
42 | + | let diffWAVES2 = (diffWAVES - startBalanceWAVES) | |
42 | 43 | let r2 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, WAVES, borrower], nil) | |
43 | 44 | if ((r2 == r2)) | |
44 | - | then [IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", | |
45 | + | then [IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", diffWAVES2), IntegerEntry("loanAmount", loanAmount), ScriptTransfer(Address(borrower), amount, USDN)] | |
45 | 46 | else throw("Strict value is not equal to itself.") | |
46 | 47 | } | |
47 | 48 | else throw("Strict value is not equal to itself.") | |
56 | 57 | let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil) | |
57 | 58 | if ((test == test)) | |
58 | 59 | then { | |
59 | - | let balanceDiff = (assetBalance(this, USDN) - startBalance) | |
60 | + | let balanceDiff = assetBalance(this, USDN) | |
61 | + | let balanceDiff2 = (balanceDiff - startBalance) | |
60 | 62 | let profit = fraction(amount, loanFeePercent, 100) | |
61 | - | if ((profit > | |
63 | + | if ((profit > balanceDiff2)) | |
62 | 64 | then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit))) | |
63 | - | else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", | |
65 | + | else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", balanceDiff2), StringEntry("this", toString(this)), ScriptTransfer(Address(fromBase58String(borr)), profit, USDN)] | |
64 | 66 | } | |
65 | 67 | else throw("Strict value is not equal to itself.") | |
66 | 68 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let exchangeRate = 10 | |
5 | 5 | ||
6 | 6 | let exchangeRateDiffPercent = 10 | |
7 | 7 | ||
8 | 8 | let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100) | |
9 | 9 | ||
10 | 10 | let USDN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
11 | 11 | ||
12 | 12 | let WAVES = base58'' | |
13 | 13 | ||
14 | 14 | let USDNtoWAVESRate = 10 | |
15 | 15 | ||
16 | 16 | let loanFeePercent = 1 | |
17 | 17 | ||
18 | 18 | @Callable(i) | |
19 | 19 | func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES)) | |
20 | 20 | then [ScriptTransfer(Address(caller), fraction(amount, (USDNtoWAVESrate - 1), 100), USDN), IntegerEntry("WAVEStoUSDN", amount)] | |
21 | 21 | else throw("Unexpected Token") | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | ||
25 | 25 | @Callable(i) | |
26 | 26 | func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN)) | |
27 | 27 | then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), unit), IntegerEntry("USDNtoWAVES", amount)] | |
28 | 28 | else throw("Unexpected Token") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | ||
32 | 32 | @Callable(i) | |
33 | 33 | func trade (borrower,amount,assetId) = { | |
34 | 34 | let loanAmount = if ((assetId == USDN)) | |
35 | 35 | then amount | |
36 | 36 | else throw("Unexpected payment asset") | |
37 | 37 | let startBalanceWAVES = wavesBalance(this).regular | |
38 | 38 | let r1 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, USDN, borrower], nil) | |
39 | 39 | if ((r1 == r1)) | |
40 | 40 | then { | |
41 | - | let diffWAVES = (wavesBalance(this).regular - startBalanceWAVES) | |
41 | + | let diffWAVES = wavesBalance(this).regular | |
42 | + | let diffWAVES2 = (diffWAVES - startBalanceWAVES) | |
42 | 43 | let r2 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, WAVES, borrower], nil) | |
43 | 44 | if ((r2 == r2)) | |
44 | - | then [IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", | |
45 | + | then [IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", diffWAVES2), IntegerEntry("loanAmount", loanAmount), ScriptTransfer(Address(borrower), amount, USDN)] | |
45 | 46 | else throw("Strict value is not equal to itself.") | |
46 | 47 | } | |
47 | 48 | else throw("Strict value is not equal to itself.") | |
48 | 49 | } | |
49 | 50 | ||
50 | 51 | ||
51 | 52 | ||
52 | 53 | @Callable(i) | |
53 | 54 | func flashloan (amount,borr) = { | |
54 | 55 | let startBalance = assetBalance(this, USDN) | |
55 | 56 | let borrower = borr | |
56 | 57 | let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil) | |
57 | 58 | if ((test == test)) | |
58 | 59 | then { | |
59 | - | let balanceDiff = (assetBalance(this, USDN) - startBalance) | |
60 | + | let balanceDiff = assetBalance(this, USDN) | |
61 | + | let balanceDiff2 = (balanceDiff - startBalance) | |
60 | 62 | let profit = fraction(amount, loanFeePercent, 100) | |
61 | - | if ((profit > | |
63 | + | if ((profit > balanceDiff2)) | |
62 | 64 | then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit))) | |
63 | - | else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", | |
65 | + | else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", balanceDiff2), StringEntry("this", toString(this)), ScriptTransfer(Address(fromBase58String(borr)), profit, USDN)] | |
64 | 66 | } | |
65 | 67 | else throw("Strict value is not equal to itself.") | |
66 | 68 | } | |
67 | 69 | ||
68 | 70 |
github/deemru/w8io/026f985 39.68 ms ◑