tx · HC7vdMwYPGpjpHGvHud1bEPJnnkshrccyNfda7kfx1E3 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8: -0.01000000 Waves 2022.03.14 21:51 [1964015] smart account 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8 > SELF 0.00000000 Waves
{ "type": 13, "id": "HC7vdMwYPGpjpHGvHud1bEPJnnkshrccyNfda7kfx1E3", "fee": 1000000, "feeAssetId": null, "timestamp": 1647283927776, "version": 2, "chainId": 84, "sender": "3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8", "senderPublicKey": "7KdKmjfPuTXGRNZv4VEz9mZiC2qb9JPzuji5z6jszZyo", "proofs": [ "3u32XzTT24JNoCrnUYkHg2uyGuz8XePkZgRUXsL1kRbZ9Msi4kRt4HktLpoyzTmgXetVPoBtYMY3ChMbbdEU8S85" ], "script": "base64:AAIFAAAAAAAAAAgIAhIECgIBCAAAAAoAAAAADGV4Y2hhbmdlUmF0ZQAAAAAAAAAACgAAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAABQAAAAAD1VTRE50b1dBVkVTcmF0ZQkAAGsAAAADBQAAAAxleGNoYW5nZVJhdGUJAABlAAAAAgAAAAAAAAAAZAUAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAGQAAAAABFVTRE4BAAAAICJkPx6+YEbpEWoTE9ymM/4Wfgf5d+mz8hX8mUkqMAo3AAAAAAVXQVZFUwEAAAAEE6vZMwAAAAAPVVNETnRvV0FWRVNSYXRlAAAAAAAAAAAFAAAAAA5sb2FuRmVlUGVyY2VudAkAAGkAAAACAAAAAAAAAAAJAAAAAAAAAABkAQAAABNleGNoYW5nZVdBVkVTdG9VU0ROAAAAAwAAAAZhbW91bnQAAAAHYXNzZXRJZAAAAAZjYWxsZXIDCQAAAAAAAAIFAAAAB2Fzc2V0SWQFAAAABVdBVkVTCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2Zl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ABHRlc3QFAAAABHRlc3QEAAAAC2JhbGFuY2VEaWZmCQAAZQAAAAIJAAPwAAAAAgUAAAAEdGhpcwUAAAAEVVNETgUAAAAMc3RhcnRCYWxhbmNlBAAAAAZwcm9maXQJAABrAAAAAwUAAAAGYW1vdW50BQAAAA5sb2FuRmVlUGVyY2VudAAAAAAAAAAAZAMJAABmAAAAAgUAAAAGcHJvZml0BQAAAAtiYWxhbmNlRGlmZgkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAB5EZWJ0IG5vdCBwYWlkLCBiZWNhdXNlIGRpZmYgPSAJAAGkAAAAAQUAAAALYmFsYW5jZURpZmYCAAAAEi4gRXhwZWN0ZWQgZGlmZiA9IAkAAaQAAAABBQAAAAZwcm9maXQFAAAAA25pbAkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAFFc84c=", "height": 1964015, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DCEqFhc7FHgYtHouoTq1SG1y4KYuMyZXeUdVvRn8rBwZ Next: 7iCHc12dbSnEArBYcNy4xdJfS6N9CvK8YfuKMiwRY2NL Diff:
Old | New | Differences | |
---|---|---|---|
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | - | func flashloan (amount, | |
59 | + | func flashloan (amount,borr) = { | |
60 | 60 | let startBalance = assetBalance(this, USDN) | |
61 | 61 | if ((startBalance == startBalance)) | |
62 | 62 | then { | |
63 | - | let test = trade(borrower, amount, assetId) | |
63 | + | let borrower = borr | |
64 | + | let test = trade(fromBase58String(borr), amount, USDN) | |
64 | 65 | if ((test == test)) | |
65 | 66 | then { | |
66 | 67 | let balanceDiff = (assetBalance(this, USDN) - startBalance) |
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 = 20 | |
7 | 7 | ||
8 | 8 | let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100) | |
9 | 9 | ||
10 | 10 | let USDN = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC' | |
11 | 11 | ||
12 | 12 | let WAVES = base58'WAVES' | |
13 | 13 | ||
14 | 14 | let USDNtoWAVESRate = 5 | |
15 | 15 | ||
16 | 16 | let loanFeePercent = (9 / 100) | |
17 | 17 | ||
18 | 18 | func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES)) | |
19 | 19 | then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN)] | |
20 | 20 | else throw("Unexpected Token") | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN)) | |
24 | 24 | then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES)] | |
25 | 25 | else throw("Unexpected Token") | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func trade (borrower,amount,assetId) = { | |
29 | 29 | let loanAmount = if ((assetId == USDN)) | |
30 | 30 | then amount | |
31 | 31 | else throw("Unexpected payment asset") | |
32 | 32 | let startBalanceWAVES = assetBalance(this, WAVES) | |
33 | 33 | if ((startBalanceWAVES == startBalanceWAVES)) | |
34 | 34 | then { | |
35 | 35 | let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower) | |
36 | 36 | if ((r1 == r1)) | |
37 | 37 | then { | |
38 | 38 | let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES) | |
39 | 39 | if ((diffWAVES == diffWAVES)) | |
40 | 40 | then { | |
41 | 41 | let r2 = exchangeWAVEStoUSDN(amount, assetId, borrower) | |
42 | 42 | if ((r2 == r2)) | |
43 | 43 | then { | |
44 | 44 | let debt = fraction(loanAmount, (100 + loanFeePercent), 100) | |
45 | 45 | let profit = (assetBalance(this, USDN) - debt) | |
46 | 46 | [ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)] | |
47 | 47 | } | |
48 | 48 | else throw("Strict value is not equal to itself.") | |
49 | 49 | } | |
50 | 50 | else throw("Strict value is not equal to itself.") | |
51 | 51 | } | |
52 | 52 | else throw("Strict value is not equal to itself.") | |
53 | 53 | } | |
54 | 54 | else throw("Strict value is not equal to itself.") | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | - | func flashloan (amount, | |
59 | + | func flashloan (amount,borr) = { | |
60 | 60 | let startBalance = assetBalance(this, USDN) | |
61 | 61 | if ((startBalance == startBalance)) | |
62 | 62 | then { | |
63 | - | let test = trade(borrower, amount, assetId) | |
63 | + | let borrower = borr | |
64 | + | let test = trade(fromBase58String(borr), amount, USDN) | |
64 | 65 | if ((test == test)) | |
65 | 66 | then { | |
66 | 67 | let balanceDiff = (assetBalance(this, USDN) - startBalance) | |
67 | 68 | let profit = fraction(amount, loanFeePercent, 100) | |
68 | 69 | if ((profit > balanceDiff)) | |
69 | 70 | then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit))) | |
70 | 71 | else nil | |
71 | 72 | } | |
72 | 73 | else throw("Strict value is not equal to itself.") | |
73 | 74 | } | |
74 | 75 | else throw("Strict value is not equal to itself.") | |
75 | 76 | } | |
76 | 77 | ||
77 | 78 |
github/deemru/w8io/169f3d6 40.42 ms ◑