tx · 2f5rrpzXBFCh2nCnNnQGkjYSicPyUA1vPHpcS6r16gWS

3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG:  -0.00300000 Waves

2023.09.01 02:16 [2735501] smart account 3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG > SELF 0.00000000 Waves

{ "type": 13, "id": "2f5rrpzXBFCh2nCnNnQGkjYSicPyUA1vPHpcS6r16gWS", "fee": 300000, "feeAssetId": null, "timestamp": 1693523828867, "version": 2, "chainId": 84, "sender": "3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG", "senderPublicKey": "3MV6QZNSjqH7Ctc3BGRQJJyZ3DJgCJ6Tqn7LXRgneZ5B", "proofs": [ "LYM2V8Rx2EMVX4bNb4os4KSXV3KukqpbFrZ2Xuyp9MtV1La78N86S6RvzDGcsh7Avh8gbZzzVsQJd9GNhCU2P23" ], "script": "base64:BgISCAISBAoCCAESABIGCgQIAQgICQAKbGltaXRSYXRpbwCgjQYAA2ZlZQBkAAZzY2FsZTUAoI0GAAxmZWVDb2xsZWN0b3ICAAEKZ2V0QXNzZXRJZAEDYXN0BAckbWF0Y2gwBQNhc3QDCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQBcAUHJG1hdGNoMAUDYXN0BQR1bml0AQ5nZXRBc3NldFN0cmluZwEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDYBAEFAWICBVdBVkVTAQ1nZXRBc3NldEJ5dGVzAQdhc3NldElkAwkAAAIFB2Fzc2V0SWQCBVdBVkVTBQR1bml0CQDZBAEFB2Fzc2V0SWQBCmdldEJhbGFuY2UBB2Fzc2V0SWQEByRtYXRjaDAFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQBYgUHJG1hdGNoMAkA8AcCBQR0aGlzBQFiCAkA7wcBBQR0aGlzCWF2YWlsYWJs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hbW91bnQFA2ZlZQUGc2NhbGU1BA1hbW91bnRUb1JlcGF5CQBkAgUGYW1vdW50BQlmZWVBbW91bnQECm5ld0JhbGFuY2UJAQpnZXRCYWxhbmNlAQkBDWdldEFzc2V0Qnl0ZXMBBQdhc3NldElkAwkAAAIFCm5ld0JhbGFuY2UFCm5ld0JhbGFuY2UDCQBnAgUKbmV3QmFsYW5jZQUNYW1vdW50VG9SZXBheQkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQEHQWRkcmVzcwEJANkEAQUMZmVlQ29sbGVjdG9yBQlmZWVBbW91bnQJAQ1nZXRBc3NldEJ5dGVzAQUHYXNzZXRJZAUDbmlsCQACAQkArAICCQCsAgIJAKwCAgIoUmVqZWN0ZWQgZHVlIHRvIGxvdyByZXBheSBhbW91bnQuIE5lZWQ6IAkApAMBBQ1hbW91bnRUb1JlcGF5AgwsIHByb3ZpZGVkOiAJAKQDAQkAZQIFCm5ld0JhbGFuY2UFDmN1cnJlbnRCYWxhbmNlCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAK8CrtM=", "height": 2735501, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 5V6cDcYegLTCkEb3paZ8qocycrVxdr4MrzapLRuq8Jit Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let limitRatio = 100000
5+
6+let fee = 100
7+
8+let scale5 = 100000
9+
10+let feeCollector = ""
11+
12+func getAssetId (ast) = match ast {
13+ case p: ByteVector =>
14+ ast
15+ case _ =>
16+ unit
17+}
18+
19+
20+func getAssetString (assetId) = match assetId {
21+ case b: ByteVector =>
22+ toBase58String(b)
23+ case _ =>
24+ "WAVES"
25+}
26+
27+
28+func getAssetBytes (assetId) = if ((assetId == "WAVES"))
29+ then unit
30+ else fromBase58String(assetId)
31+
32+
33+func getBalance (assetId) = match assetId {
34+ case b: ByteVector =>
35+ assetBalance(this, b)
36+ case _ =>
37+ wavesBalance(this).available
38+}
39+
40+
41+func tryGetInteger (key,address) = match getInteger(address, key) {
42+ case b: Int =>
43+ b
44+ case _ =>
45+ 0
46+}
47+
48+
49+@Callable(i)
50+func borrow (assetId,amount) = {
51+ let currentBalance = getBalance(getAssetBytes(assetId))
52+ if ((currentBalance == currentBalance))
53+ then {
54+ let limit = fraction(currentBalance, limitRatio, scale5)
55+ if ((limit >= amount))
56+ then [IntegerEntry(((("borrowed_" + toString(i.caller)) + "_") + assetId), amount), ScriptTransfer(i.caller, amount, getAssetBytes(assetId))]
57+ else throw(((("Requested amount " + toString(amount)) + " is bigger than limit: ") + toString(limit)))
58+ }
59+ else throw("Strict value is not equal to itself.")
60+ }
61+
62+
63+
64+@Callable(i)
65+func repay () = {
66+ let amount = value(i.payments[0].amount)
67+ let assetId = i.payments[0].assetId
68+ let borrowed = tryGetInteger(((("borrowed_" + toString(i.caller)) + "_") + getAssetString(assetId)), this)
69+ if ((borrowed > 0))
70+ then {
71+ let toRepayAmount = min([amount, borrowed])
72+ let toReturnAmount = (amount - toRepayAmount)
73+ let returnTransfer = if ((toReturnAmount > 0))
74+ then ScriptTransfer(i.caller, toReturnAmount, assetId)
75+ else unit
76+[IntegerEntry(((("borrowed_" + toString(i.caller)) + "_") + getAssetString(assetId)), (borrowed - toRepayAmount))]
77+ }
78+ else throw("You shouldn't repay")
79+ }
80+
81+
82+
83+@Callable(i)
84+func flash (assetId,amount,callbackAddress,callBackFunction) = {
85+ let callbackAdr = Address(fromBase58String(callbackAddress))
86+ let currentBalance = getBalance(getAssetBytes(assetId))
87+ if ((currentBalance == currentBalance))
88+ then {
89+ let borrow = invoke(this, "borrow", [assetId, amount], nil)
90+ if ((borrow == borrow))
91+ then {
92+ let callback = invoke(Address(fromBase58String(callbackAddress)), callBackFunction, nil, [AttachedPayment(getAssetBytes(assetId), amount)])
93+ if ((callback == callback))
94+ then {
95+ let feeAmount = fraction(amount, fee, scale5)
96+ let amountToRepay = (amount + feeAmount)
97+ let newBalance = getBalance(getAssetBytes(assetId))
98+ if ((newBalance == newBalance))
99+ then if ((newBalance >= amountToRepay))
100+ then [ScriptTransfer(Address(fromBase58String(feeCollector)), feeAmount, getAssetBytes(assetId))]
101+ else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", provided: ") + toString((newBalance - currentBalance))))
102+ else throw("Strict value is not equal to itself.")
103+ }
104+ else throw("Strict value is not equal to itself.")
105+ }
106+ else throw("Strict value is not equal to itself.")
107+ }
108+ else throw("Strict value is not equal to itself.")
109+ }
110+
111+

github/deemru/w8io/169f3d6 
17.82 ms