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