tx · Fz8orZu4Bnqo6Z1Voxj3ju312cuDY9Pb6MR13QNJAJaa 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8: -0.01000000 Waves 2022.04.13 12:23 [2006613] smart account 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8 > SELF 0.00000000 Waves
{ "type": 13, "id": "Fz8orZu4Bnqo6Z1Voxj3ju312cuDY9Pb6MR13QNJAJaa", "fee": 1000000, "feeAssetId": null, "timestamp": 1649841839154, "version": 2, "chainId": 84, "sender": "3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8", "senderPublicKey": "7KdKmjfPuTXGRNZv4VEz9mZiC2qb9JPzuji5z6jszZyo", "proofs": [ "2bkxgzhrfWtkhEvMLhXGa2sc1mUJCusHE5UCZGCDNSpRn7oHCd7Gy3sHP98CnM1bA42Rnnxvgr8gGT2PLfj8AoGH" ], "script": "base64:AAIFAAAAAAAAAB0IAhIFCgMBAgISBQoDAQICEgUKAwIBAhIECgIBCAAAAAcAAAAADGV4Y2hhbmdlUmF0ZQAAAAAAAAAACgAAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAAoAAAAAD1VTRE50b1dBVkVTcmF0ZQkAAGsAAAADBQAAAAxleGNoYW5nZVJhdGUJAABlAAAAAgAAAAAAAAAAZAUAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAGQAAAAABFVTRE4BAAAAIA/yHBKs5MQ8muxGGqslqLDsugcrRsxtiHLwteKSSQG0AAAAAAVXQVZFUwEAAAAAAAAAAA9VU0ROdG9XQVZFU1JhdGUAAAAAAAAAAAoAAAAADmxvYW5GZWVQZXJjZW50AAAAAAAAAAABAAAABAAAAAFpAQAAABNleGNoYW5nZVdBVkVTdG9VU0ROAAAAAwAAAAZhbW91bnQAAAAHYXNzZXRJZAAAAAZjYWxsZXIDCQAAAAAAAAIFAAAAB2Fzc2V0SWQFAAAABVdBVkVTCQAETAAAAAIJAQAAA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WZmCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAABHRoaXMJAAQlAAAAAQUAAAAEdGhpcwUAAAADbmlsCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAAAKg0Db", "height": 2006613, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9CULrVNaApft9aEMKJCMT312sJB42UHUtsRXXBtfavBf Next: BMo9driGxPRQjQc2nUha9Daa1njQ9tsvj7r3tujwB8Fb Diff:
Old | New | Differences | |
---|---|---|---|
56 | 56 | @Callable(i) | |
57 | 57 | func flashloan (amount,borr) = { | |
58 | 58 | let startBalance = assetBalance(this, USDN) | |
59 | - | [IntegerEntry("startBalance", startBalance)] | |
59 | + | let borrower = borr | |
60 | + | let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil) | |
61 | + | if ((test == test)) | |
62 | + | then { | |
63 | + | let balanceDiff = (assetBalance(this, USDN) - startBalance) | |
64 | + | let profit = fraction(amount, loanFeePercent, 100) | |
65 | + | if ((profit > balanceDiff)) | |
66 | + | then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit))) | |
67 | + | else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", balanceDiff), StringEntry("this", toString(this))] | |
68 | + | } | |
69 | + | else throw("Strict value is not equal to itself.") | |
60 | 70 | } | |
61 | 71 | ||
62 | 72 |
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), (amount / USDNtoWAVESrate), 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 = assetBalance(this, WAVES) | |
38 | 38 | let r1 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, USDN, borrower], nil) | |
39 | 39 | if ((r1 == r1)) | |
40 | 40 | then { | |
41 | 41 | let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES) | |
42 | 42 | let r2 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, WAVES, borrower], nil) | |
43 | 43 | if ((r2 == r2)) | |
44 | 44 | then { | |
45 | 45 | let debt = fraction(loanAmount, loanFeePercent, 100) | |
46 | 46 | let profit = (assetBalance(this, USDN) - debt) | |
47 | 47 | [StringEntry("profit", toString(profit)), IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", diffWAVES), IntegerEntry("debt", debt), IntegerEntry("loanAmount", loanAmount), ScriptTransfer(Address(borrower), profit, USDN)] | |
48 | 48 | } | |
49 | 49 | else throw("Strict value is not equal to itself.") | |
50 | 50 | } | |
51 | 51 | else throw("Strict value is not equal to itself.") | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | ||
56 | 56 | @Callable(i) | |
57 | 57 | func flashloan (amount,borr) = { | |
58 | 58 | let startBalance = assetBalance(this, USDN) | |
59 | - | [IntegerEntry("startBalance", startBalance)] | |
59 | + | let borrower = borr | |
60 | + | let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil) | |
61 | + | if ((test == test)) | |
62 | + | then { | |
63 | + | let balanceDiff = (assetBalance(this, USDN) - startBalance) | |
64 | + | let profit = fraction(amount, loanFeePercent, 100) | |
65 | + | if ((profit > balanceDiff)) | |
66 | + | then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit))) | |
67 | + | else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", balanceDiff), StringEntry("this", toString(this))] | |
68 | + | } | |
69 | + | else throw("Strict value is not equal to itself.") | |
60 | 70 | } | |
61 | 71 | ||
62 | 72 |
github/deemru/w8io/026f985 26.23 ms ◑