tx · 5XeBKemPvDAdfiCJjyNoP1to3Stpj5DA5wW7jK92Jsx1

3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8:  -0.01000000 Waves

2022.04.13 14:20 [2006731] smart account 3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8 > SELF 0.00000000 Waves

{ "type": 13, "id": "5XeBKemPvDAdfiCJjyNoP1to3Stpj5DA5wW7jK92Jsx1", "fee": 1000000, "feeAssetId": null, "timestamp": 1649848840396, "version": 2, "chainId": 84, "sender": "3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8", "senderPublicKey": "7KdKmjfPuTXGRNZv4VEz9mZiC2qb9JPzuji5z6jszZyo", "proofs": [ "2PmWk4sQvcjg2iq3eDkdvCpEUHU7AxADPSwiJ1CZDpzbVqP1dfSQ5q8JnEGDB6eCTnwbgqmaYPPWjmLWBaX3DRxu" ], "script": "base64:AAIFAAAAAAAAAB0IAhIFCgMBAgISBQoDAQICEgUKAwIBAhIECgIBCAAAAAcAAAAADGV4Y2hhbmdlUmF0ZQAAAAAAAAAACgAAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAAoAAAAAD1VTRE50b1dBVkVTcmF0ZQkAAGsAAAADBQAAAAxleGNoYW5nZVJhdGUJAABlAAAAAgAAAAAAAAAAZAUAAAAXZXhjaGFuZ2VSYXRlRGlmZlBlcmNlbnQAAAAAAAAAAGQAAAAABFVTRE4BAAAAIA/yHBKs5MQ8muxGGqslqLDsugcrRsxtiHLwteKSSQG0AAAAAAVXQVZFUwEAAAAAAAAAAA9VU0ROdG9XQVZFU1JhdGUAAAAAAAAAAAoAAAAADmxvYW5GZWVQZXJjZW50AAAAAAAAAAABAAAABAAAAAFpAQAAABNleGNoYW5nZVdBVkVTdG9VU0ROAAAAAwAAAAZhbW91bnQAAAAHYXNzZXRJZAAAAAZjYWxsZXIDCQAAAAAAAAIFAAAAB2Fzc2V0SWQFAAAABVdBVkVTCQAETAAAAAIJAQAAA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ationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DDECCHeatAWqxdAohS3v1W65o8Ah4X1mZZeASxPmuEv1 Next: DMrDvCrNv4WoYPPfXorzrmiqfRbeNHXWdFo2FuotTVs1 Diff:
OldNewDifferences
5656 let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil)
5757 if ((test == test))
5858 then {
59- let balanceDiff = assetBalance(this, USDN)
59+ let balanceDiff = (assetBalance(this, USDN) - startBalance)
6060 let profit = fraction(amount, loanFeePercent, 100)
6161 if ((profit > balanceDiff))
6262 then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let exchangeRate = 10
55
66 let exchangeRateDiffPercent = 10
77
88 let USDNtoWAVESrate = fraction(exchangeRate, (100 - exchangeRateDiffPercent), 100)
99
1010 let USDN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'
1111
1212 let WAVES = base58''
1313
1414 let USDNtoWAVESRate = 10
1515
1616 let loanFeePercent = 1
1717
1818 @Callable(i)
1919 func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
2020 then [ScriptTransfer(Address(caller), fraction(amount, (USDNtoWAVESrate - 1), 100), USDN), IntegerEntry("WAVEStoUSDN", amount)]
2121 else throw("Unexpected Token")
2222
2323
2424
2525 @Callable(i)
2626 func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
2727 then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), unit), IntegerEntry("USDNtoWAVES", amount)]
2828 else throw("Unexpected Token")
2929
3030
3131
3232 @Callable(i)
3333 func trade (borrower,amount,assetId) = {
3434 let loanAmount = if ((assetId == USDN))
3535 then amount
3636 else throw("Unexpected payment asset")
3737 let startBalanceWAVES = wavesBalance(this).regular
3838 let r1 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, USDN, borrower], nil)
3939 if ((r1 == r1))
4040 then {
4141 let diffWAVES = (wavesBalance(this).regular - startBalanceWAVES)
4242 let r2 = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, WAVES, borrower], nil)
4343 if ((r2 == r2))
4444 then [IntegerEntry("STARTBALANCEWAVES", startBalanceWAVES), IntegerEntry("diffWAVES", diffWAVES), IntegerEntry("loanAmount", loanAmount), ScriptTransfer(Address(borrower), amount, USDN)]
4545 else throw("Strict value is not equal to itself.")
4646 }
4747 else throw("Strict value is not equal to itself.")
4848 }
4949
5050
5151
5252 @Callable(i)
5353 func flashloan (amount,borr) = {
5454 let startBalance = assetBalance(this, USDN)
5555 let borrower = borr
5656 let test = reentrantInvoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], nil)
5757 if ((test == test))
5858 then {
59- let balanceDiff = assetBalance(this, USDN)
59+ let balanceDiff = (assetBalance(this, USDN) - startBalance)
6060 let profit = fraction(amount, loanFeePercent, 100)
6161 if ((profit > balanceDiff))
6262 then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
6363 else [IntegerEntry("startBalance", startBalance), IntegerEntry("balanceDiff", balanceDiff), StringEntry("this", toString(this)), ScriptTransfer(Address(fromBase58String(borr)), profit, USDN)]
6464 }
6565 else throw("Strict value is not equal to itself.")
6666 }
6767
6868

github/deemru/w8io/026f985 
34.76 ms