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