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