tx · 13UsKqtm9NVMPFi6PZV15xmBWqiXupAZvP8RN6zxYkm6 3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG: -0.00300000 Waves 2023.09.01 03:00 [2735551] smart account 3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG > SELF 0.00000000 Waves
{ "type": 13, "id": "13UsKqtm9NVMPFi6PZV15xmBWqiXupAZvP8RN6zxYkm6", "fee": 300000, "feeAssetId": null, "timestamp": 1693526417996, "version": 2, "chainId": 84, "sender": "3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG", "senderPublicKey": "3MV6QZNSjqH7Ctc3BGRQJJyZ3DJgCJ6Tqn7LXRgneZ5B", "proofs": [ "59nWSoVvz9eP7342iHwiemBSuT4NmtEuMcZiX986vQPwYgKjSXdWyXQXq68dibvvzgnzJHgKit6wT3wxq6GQqQtp" ], "script": "base64:BgISCAISBAoCCAESABIGCgQIAQgICQAKbGltaXRSYXRpbwCgjQYAA2ZlZQBkAAZzY2FsZTUAoI0GAAxmZWVDb2xsZWN0b3ICIzNOMkZ1em9NMXg4aEpxU0RVVmlYdXZhdE5wOWlwN0dyS29CAQpnZXRBc3NldElkAQNhc3QEByRtYXRjaDAFA2FzdAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFwBQckbWF0Y2gwBQNhc3QFBHVuaXQBDmdldEFzc2V0U3RyaW5nAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAWIFByRtYXRjaDAJANgEAQUBYgIFV0FWRVMBDWdldEFzc2V0Qnl0ZXMBB2Fzc2V0SWQDCQAAAgUHYXNzZXRJZAIFV0FWRVMFBHVuaXQJANkEAQUHYXNzZXRJZAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDwBwIFBHRoaXMFA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acted Prev: CQFn5V94xYDrowXD5JErCRUD84EthGZiVt2JdYbEX7RF Next: HazBkLE9zJtULt88ocAAKeBpsS9KjP2P3xfBo9u3NH2o Diff:
Old | New | Differences | |
---|---|---|---|
105 | 105 | if ((newBalance == newBalance)) | |
106 | 106 | then if ((newBalance >= currentBalance)) | |
107 | 107 | then [ScriptTransfer(Address(fromBase58String(feeCollector)), feeAmount, getAssetBytes(assetId))] | |
108 | - | else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", | |
108 | + | else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", but received: ") + toString(((newBalance - currentBalance) + amount)))) | |
109 | 109 | else throw("Strict value is not equal to itself.") | |
110 | 110 | } | |
111 | 111 | else throw("Strict value is not equal to itself.") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let limitRatio = 100000 | |
5 | 5 | ||
6 | 6 | let fee = 100 | |
7 | 7 | ||
8 | 8 | let scale5 = 100000 | |
9 | 9 | ||
10 | 10 | let feeCollector = "3N2FuzoM1x8hJqSDUViXuvatNp9ip7GrKoB" | |
11 | 11 | ||
12 | 12 | func getAssetId (ast) = match ast { | |
13 | 13 | case p: ByteVector => | |
14 | 14 | ast | |
15 | 15 | case _ => | |
16 | 16 | unit | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getAssetString (assetId) = match assetId { | |
21 | 21 | case b: ByteVector => | |
22 | 22 | toBase58String(b) | |
23 | 23 | case _ => | |
24 | 24 | "WAVES" | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getAssetBytes (assetId) = if ((assetId == "WAVES")) | |
29 | 29 | then unit | |
30 | 30 | else fromBase58String(assetId) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func getBalance (assetId) = match assetId { | |
34 | 34 | case b: ByteVector => | |
35 | 35 | assetBalance(this, b) | |
36 | 36 | case _ => | |
37 | 37 | wavesBalance(this).available | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func tryGetInteger (key,address) = match getInteger(address, key) { | |
42 | 42 | case b: Int => | |
43 | 43 | b | |
44 | 44 | case _ => | |
45 | 45 | 0 | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | @Callable(i) | |
50 | 50 | func borrow (assetId,amount) = { | |
51 | 51 | let currentBalance = getBalance(getAssetBytes(assetId)) | |
52 | 52 | if ((currentBalance == currentBalance)) | |
53 | 53 | then { | |
54 | 54 | let limit = fraction(currentBalance, limitRatio, scale5) | |
55 | 55 | if ((limit >= amount)) | |
56 | 56 | then { | |
57 | 57 | let intEntry = IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + assetId), amount) | |
58 | 58 | let transfer = ScriptTransfer(i.originCaller, amount, getAssetBytes(assetId)) | |
59 | 59 | if ((i.caller == this)) | |
60 | 60 | then [intEntry] | |
61 | 61 | else [intEntry, transfer] | |
62 | 62 | } | |
63 | 63 | else throw(((("Requested amount " + toString(amount)) + " is bigger than limit: ") + toString(limit))) | |
64 | 64 | } | |
65 | 65 | else throw("Strict value is not equal to itself.") | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | 70 | @Callable(i) | |
71 | 71 | func repay () = { | |
72 | 72 | let amount = value(i.payments[0].amount) | |
73 | 73 | let assetId = i.payments[0].assetId | |
74 | 74 | let borrowed = tryGetInteger(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), this) | |
75 | 75 | if ((borrowed > 0)) | |
76 | 76 | then { | |
77 | 77 | let toRepayAmount = min([amount, borrowed]) | |
78 | 78 | let toReturnAmount = (amount - toRepayAmount) | |
79 | 79 | let intEntry = IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), (borrowed - toRepayAmount)) | |
80 | 80 | let transfer = ScriptTransfer(i.originCaller, toReturnAmount, assetId) | |
81 | 81 | if ((toReturnAmount > 0)) | |
82 | 82 | then [intEntry, transfer] | |
83 | 83 | else [intEntry] | |
84 | 84 | } | |
85 | 85 | else throw("You shouldn't repay") | |
86 | 86 | } | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | 90 | @Callable(i) | |
91 | 91 | func flash (assetId,amount,callbackAddress,callBackFunction) = { | |
92 | 92 | let callbackAdr = Address(fromBase58String(callbackAddress)) | |
93 | 93 | let currentBalance = getBalance(getAssetBytes(assetId)) | |
94 | 94 | if ((currentBalance == currentBalance)) | |
95 | 95 | then { | |
96 | 96 | let borrow = invoke(this, "borrow", [assetId, amount], nil) | |
97 | 97 | if ((borrow == borrow)) | |
98 | 98 | then { | |
99 | 99 | let callback = invoke(Address(fromBase58String(callbackAddress)), callBackFunction, nil, [AttachedPayment(getAssetBytes(assetId), amount)]) | |
100 | 100 | if ((callback == callback)) | |
101 | 101 | then { | |
102 | 102 | let feeAmount = fraction(amount, fee, scale5) | |
103 | 103 | let amountToRepay = (amount + feeAmount) | |
104 | 104 | let newBalance = getBalance(getAssetBytes(assetId)) | |
105 | 105 | if ((newBalance == newBalance)) | |
106 | 106 | then if ((newBalance >= currentBalance)) | |
107 | 107 | then [ScriptTransfer(Address(fromBase58String(feeCollector)), feeAmount, getAssetBytes(assetId))] | |
108 | - | else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", | |
108 | + | else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", but received: ") + toString(((newBalance - currentBalance) + amount)))) | |
109 | 109 | else throw("Strict value is not equal to itself.") | |
110 | 110 | } | |
111 | 111 | else throw("Strict value is not equal to itself.") | |
112 | 112 | } | |
113 | 113 | else throw("Strict value is not equal to itself.") | |
114 | 114 | } | |
115 | 115 | else throw("Strict value is not equal to itself.") | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 |
github/deemru/w8io/026f985 36.24 ms ◑