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+mz8hX8mUkqMAo3AAAAAAVXQVZFUwEAAAAAAAAAAA9VU0ROdG9XQVZFU1JhdGUAAAAAAAAAAAoAAAAADmxvYW5GZWVQZXJjZW50AAAAAAAAAAABAAAABAAAAAFpAQAAABNleGNoYW5nZVdBVkVTdG9VU0ROAAAAAwAAAAZhbW91bnQAAAAHYXNzZXRJZAAAAAZjYWxsZXIDCQAAAAAAAAIFAAAAB2Fzc2V0SWQFAAAABVdBVkVTCQAETAAAAAIJAQAAAA5TY3J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AAAAAAAAAAZAMJAABmAAAAAgUAAAAGcHJvZml0BQAAAAtiYWxhbmNlRGlmZgkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAB5EZWJ0IG5vdCBwYWlkLCBiZWNhdXNlIGRpZmYgPSAJAAGkAAAAAQUAAAALYmFsYW5jZURpZmYCAAAAEi4gRXhwZWN0ZWQgZGlmZiA9IAkAAaQAAAABBQAAAAZwcm9maXQJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgIAAAAEdGVzdAIAAAAEdGVzdAUAAAADbmlsCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAAA9m8yQQ==", "height": 1983722, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2xG2imNGJjRJQiu8dATfAixAqMsGWVRTFohwkEkt756X Next: 3aPKHCqnt7yAuukSK1wabvrXBGKqyaXYMmmTdDjV41gs Diff:
OldNewDifferences
1515
1616 let loanFeePercent = 1
1717
18+@Callable(i)
1819 func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
1920 then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN), IntegerEntry("WAVEStoUSDN", amount)]
2021 else throw("Unexpected Token")
2122
2223
24+
25+@Callable(i)
2326 func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
2427 then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES), IntegerEntry("USDNtoWAVES", amount)]
2528 else throw("Unexpected Token")
29+
2630
2731
2832 @Callable(i)
3337 let startBalanceWAVES = assetBalance(this, WAVES)
3438 if ((startBalanceWAVES == startBalanceWAVES))
3539 then {
36- let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
40+ let r1 = invoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, assetId, borrower], [AttachedPayment(USDN, loanAmount)])
3741 if ((r1 == r1))
3842 then {
3943 let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
4044 if ((diffWAVES == diffWAVES))
4145 then {
42- let r2 = exchangeWAVEStoUSDN(amount, WAVES, borrower)
46+ let r2 = invoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, assetId, borrower], [AttachedPayment(WAVES, diffWAVES)])
4347 if ((r2 == r2))
4448 then {
4549 let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
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'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC'
1111
1212 let WAVES = base58''
1313
1414 let USDNtoWAVESRate = 10
1515
1616 let loanFeePercent = 1
1717
18+@Callable(i)
1819 func exchangeWAVEStoUSDN (amount,assetId,caller) = if ((assetId == WAVES))
1920 then [ScriptTransfer(Address(caller), (amount / USDNtoWAVESrate), USDN), IntegerEntry("WAVEStoUSDN", amount)]
2021 else throw("Unexpected Token")
2122
2223
24+
25+@Callable(i)
2326 func exchangeUSDNtoWAVES (amount,assetId,caller) = if ((assetId == USDN))
2427 then [ScriptTransfer(Address(caller), (amount * USDNtoWAVESRate), WAVES), IntegerEntry("USDNtoWAVES", amount)]
2528 else throw("Unexpected Token")
29+
2630
2731
2832 @Callable(i)
2933 func trade (borrower,amount,assetId) = {
3034 let loanAmount = if ((assetId == USDN))
3135 then amount
3236 else throw("Unexpected payment asset")
3337 let startBalanceWAVES = assetBalance(this, WAVES)
3438 if ((startBalanceWAVES == startBalanceWAVES))
3539 then {
36- let r1 = exchangeUSDNtoWAVES(amount, assetId, borrower)
40+ let r1 = invoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeUSDNtoWAVES", [amount, assetId, borrower], [AttachedPayment(USDN, loanAmount)])
3741 if ((r1 == r1))
3842 then {
3943 let diffWAVES = (assetBalance(this, WAVES) - startBalanceWAVES)
4044 if ((diffWAVES == diffWAVES))
4145 then {
42- let r2 = exchangeWAVEStoUSDN(amount, WAVES, borrower)
46+ let r2 = invoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "exchangeWAVEStoUSDN", [amount, assetId, borrower], [AttachedPayment(WAVES, diffWAVES)])
4347 if ((r2 == r2))
4448 then {
4549 let debt = fraction(loanAmount, (100 + loanFeePercent), 100)
4650 let profit = (assetBalance(this, USDN) - debt)
4751 [StringEntry("trade", ((toString(debt) + " ") + toString(profit))), ScriptTransfer(Address(borrower), profit, USDN), ScriptTransfer(this, debt, USDN)]
4852 }
4953 else throw("Strict value is not equal to itself.")
5054 }
5155 else throw("Strict value is not equal to itself.")
5256 }
5357 else throw("Strict value is not equal to itself.")
5458 }
5559 else throw("Strict value is not equal to itself.")
5660 }
5761
5862
5963
6064 @Callable(i)
6165 func flashloan (amount,borr) = {
6266 let startBalance = assetBalance(this, USDN)
6367 if ((startBalance == startBalance))
6468 then {
6569 let borrower = borr
6670 let test = invoke(Address(base58'3Mw2biLQi5ygMk7zexboNGrnMYuaSfrziY8'), "trade", [fromBase58String(borr), amount, USDN], [AttachedPayment(unit, 900000)])
6771 if ((test == test))
6872 then {
6973 let balanceDiff = ((assetBalance(this, USDN) + 100000) - startBalance)
7074 let profit = fraction(amount, loanFeePercent, 100)
7175 if ((profit > balanceDiff))
7276 then throw(((("Debt not paid, because diff = " + toString(balanceDiff)) + ". Expected diff = ") + toString(profit)))
7377 else [StringEntry("test", "test")]
7478 }
7579 else throw("Strict value is not equal to itself.")
7680 }
7781 else throw("Strict value is not equal to itself.")
7882 }
7983
8084

github/deemru/w8io/026f985 
27.48 ms