tx · 2vbogszrDoHYHC39vvW4xNAcsT8pGsj7iuAJkjFTPV91

3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG:  -0.00300000 Waves

2023.09.01 02:22 [2735510] smart account 3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG > SELF 0.00000000 Waves

{ "type": 13, "id": "2vbogszrDoHYHC39vvW4xNAcsT8pGsj7iuAJkjFTPV91", "fee": 300000, "feeAssetId": null, "timestamp": 1693524153736, "version": 2, "chainId": 84, "sender": "3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG", "senderPublicKey": "3MV6QZNSjqH7Ctc3BGRQJJyZ3DJgCJ6Tqn7LXRgneZ5B", "proofs": [ "JRAYKg7Wa4ZWu9cSW6AW2UvZVpRuoiqWLSDkiNK5Qc52q7AnEHDYUisSQ6F3cug2txkcsoSbAUqVbpwM2hERu2u" ], "script": "base64:BgISCAISBAoCCAESABIGCgQIAQgICQAKbGltaXRSYXRpbwCgjQYAA2ZlZQBkAAZzY2FsZTUAoI0GAAxmZWVDb2xsZWN0b3ICIzNOMkZ1em9NMXg4aEpxU0RVVmlYdXZhdE5wOWlwN0dyS29CAQpnZXRBc3NldElkAQNhc3QEByRtYXRjaDAFA2FzdAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFwBQckbWF0Y2gwBQNhc3QFBHVuaXQBDmdldEFzc2V0U3RyaW5nAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAWIFByRtYXRjaDAJANgEAQUBYgIFV0FWRVMBDWdldEFzc2V0Qnl0ZXMBB2Fzc2V0SWQDCQAAAgUHYXNzZXRJZAIFV0FWRVMFBHVuaXQJANkEAQUHYXNzZXRJZAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDwBwIFBHR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c3NldElkBQZhbW91bnQFA25pbAMJAAACBQhjYWxsYmFjawUIY2FsbGJhY2sECWZlZUFtb3VudAkAawMFBmFtb3VudAUDZmVlBQZzY2FsZTUEDWFtb3VudFRvUmVwYXkJAGQCBQZhbW91bnQFCWZlZUFtb3VudAQKbmV3QmFsYW5jZQkBCmdldEJhbGFuY2UBCQENZ2V0QXNzZXRCeXRlcwEFB2Fzc2V0SWQDCQAAAgUKbmV3QmFsYW5jZQUKbmV3QmFsYW5jZQMJAGcCBQpuZXdCYWxhbmNlBQ1hbW91bnRUb1JlcGF5CQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMJAQdBZGRyZXNzAQkA2QQBBQxmZWVDb2xsZWN0b3IFCWZlZUFtb3VudAkBDWdldEFzc2V0Qnl0ZXMBBQdhc3NldElkBQNuaWwJAAIBCQCsAgIJAKwCAgkArAICAihSZWplY3RlZCBkdWUgdG8gbG93IHJlcGF5IGFtb3VudC4gTmVlZDogCQCkAwEFDWFtb3VudFRvUmVwYXkCDCwgcHJvdmlkZWQ6IAkApAMBCQBlAgUKbmV3QmFsYW5jZQUOY3VycmVudEJhbGFuY2UJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4ADmVXow==", "height": 2735510, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5V6cDcYegLTCkEb3paZ8qocycrVxdr4MrzapLRuq8Jit Next: 7g8g5Kyyr8gX82DkmyE1UM6ehMCZufG2L4ErHeVjcjSi Diff:
OldNewDifferences
5353 then {
5454 let limit = fraction(currentBalance, limitRatio, scale5)
5555 if ((limit >= amount))
56- then [IntegerEntry(((("borrowed_" + toString(i.caller)) + "_") + assetId), amount), ScriptTransfer(i.caller, amount, getAssetBytes(assetId))]
56+ then [IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + assetId), amount), ScriptTransfer(i.originCaller, amount, getAssetBytes(assetId))]
5757 else throw(((("Requested amount " + toString(amount)) + " is bigger than limit: ") + toString(limit)))
5858 }
5959 else throw("Strict value is not equal to itself.")
6565 func repay () = {
6666 let amount = value(i.payments[0].amount)
6767 let assetId = i.payments[0].assetId
68- let borrowed = tryGetInteger(((("borrowed_" + toString(i.caller)) + "_") + getAssetString(assetId)), this)
68+ let borrowed = tryGetInteger(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), this)
6969 if ((borrowed > 0))
7070 then {
7171 let toRepayAmount = min([amount, borrowed])
7272 let toReturnAmount = (amount - toRepayAmount)
7373 let returnTransfer = if ((toReturnAmount > 0))
74- then ScriptTransfer(i.caller, toReturnAmount, assetId)
74+ then ScriptTransfer(i.originCaller, toReturnAmount, assetId)
7575 else unit
76-[IntegerEntry(((("borrowed_" + toString(i.caller)) + "_") + getAssetString(assetId)), (borrowed - toRepayAmount))]
76+[IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), (borrowed - toRepayAmount))]
7777 }
7878 else throw("You shouldn't repay")
7979 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let limitRatio = 100000
55
66 let fee = 100
77
88 let scale5 = 100000
99
1010 let feeCollector = "3N2FuzoM1x8hJqSDUViXuvatNp9ip7GrKoB"
1111
1212 func getAssetId (ast) = match ast {
1313 case p: ByteVector =>
1414 ast
1515 case _ =>
1616 unit
1717 }
1818
1919
2020 func getAssetString (assetId) = match assetId {
2121 case b: ByteVector =>
2222 toBase58String(b)
2323 case _ =>
2424 "WAVES"
2525 }
2626
2727
2828 func getAssetBytes (assetId) = if ((assetId == "WAVES"))
2929 then unit
3030 else fromBase58String(assetId)
3131
3232
3333 func getBalance (assetId) = match assetId {
3434 case b: ByteVector =>
3535 assetBalance(this, b)
3636 case _ =>
3737 wavesBalance(this).available
3838 }
3939
4040
4141 func tryGetInteger (key,address) = match getInteger(address, key) {
4242 case b: Int =>
4343 b
4444 case _ =>
4545 0
4646 }
4747
4848
4949 @Callable(i)
5050 func borrow (assetId,amount) = {
5151 let currentBalance = getBalance(getAssetBytes(assetId))
5252 if ((currentBalance == currentBalance))
5353 then {
5454 let limit = fraction(currentBalance, limitRatio, scale5)
5555 if ((limit >= amount))
56- then [IntegerEntry(((("borrowed_" + toString(i.caller)) + "_") + assetId), amount), ScriptTransfer(i.caller, amount, getAssetBytes(assetId))]
56+ then [IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + assetId), amount), ScriptTransfer(i.originCaller, amount, getAssetBytes(assetId))]
5757 else throw(((("Requested amount " + toString(amount)) + " is bigger than limit: ") + toString(limit)))
5858 }
5959 else throw("Strict value is not equal to itself.")
6060 }
6161
6262
6363
6464 @Callable(i)
6565 func repay () = {
6666 let amount = value(i.payments[0].amount)
6767 let assetId = i.payments[0].assetId
68- let borrowed = tryGetInteger(((("borrowed_" + toString(i.caller)) + "_") + getAssetString(assetId)), this)
68+ let borrowed = tryGetInteger(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), this)
6969 if ((borrowed > 0))
7070 then {
7171 let toRepayAmount = min([amount, borrowed])
7272 let toReturnAmount = (amount - toRepayAmount)
7373 let returnTransfer = if ((toReturnAmount > 0))
74- then ScriptTransfer(i.caller, toReturnAmount, assetId)
74+ then ScriptTransfer(i.originCaller, toReturnAmount, assetId)
7575 else unit
76-[IntegerEntry(((("borrowed_" + toString(i.caller)) + "_") + getAssetString(assetId)), (borrowed - toRepayAmount))]
76+[IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), (borrowed - toRepayAmount))]
7777 }
7878 else throw("You shouldn't repay")
7979 }
8080
8181
8282
8383 @Callable(i)
8484 func flash (assetId,amount,callbackAddress,callBackFunction) = {
8585 let callbackAdr = Address(fromBase58String(callbackAddress))
8686 let currentBalance = getBalance(getAssetBytes(assetId))
8787 if ((currentBalance == currentBalance))
8888 then {
8989 let borrow = invoke(this, "borrow", [assetId, amount], nil)
9090 if ((borrow == borrow))
9191 then {
9292 let callback = invoke(Address(fromBase58String(callbackAddress)), callBackFunction, nil, [AttachedPayment(getAssetBytes(assetId), amount)])
9393 if ((callback == callback))
9494 then {
9595 let feeAmount = fraction(amount, fee, scale5)
9696 let amountToRepay = (amount + feeAmount)
9797 let newBalance = getBalance(getAssetBytes(assetId))
9898 if ((newBalance == newBalance))
9999 then if ((newBalance >= amountToRepay))
100100 then [ScriptTransfer(Address(fromBase58String(feeCollector)), feeAmount, getAssetBytes(assetId))]
101101 else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", provided: ") + toString((newBalance - currentBalance))))
102102 else throw("Strict value is not equal to itself.")
103103 }
104104 else throw("Strict value is not equal to itself.")
105105 }
106106 else throw("Strict value is not equal to itself.")
107107 }
108108 else throw("Strict value is not equal to itself.")
109109 }
110110
111111

github/deemru/w8io/026f985 
34.30 ms