tx · 2LGqgBzdBPdaEPYXnUq5JEExyVHPNeSELsZfUcfw2jKH 3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG: -0.00300000 Waves 2023.09.01 02:32 [2735524] smart account 3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG > SELF 0.00000000 Waves
{ "type": 13, "id": "2LGqgBzdBPdaEPYXnUq5JEExyVHPNeSELsZfUcfw2jKH", "fee": 300000, "feeAssetId": null, "timestamp": 1693524801319, "version": 2, "chainId": 84, "sender": "3N93XuDT7GvzMZdp8WGTbqYxiGY9JQmiWAG", "senderPublicKey": "3MV6QZNSjqH7Ctc3BGRQJJyZ3DJgCJ6Tqn7LXRgneZ5B", "proofs": [ "2MdK61quJPj7hJEPwJtCBJhfGQKLYaPDAQGXkoCaGkrWHvX2zc4cWBymcSH7KnCqJ1x2Xi1UAZKnpEZ5Hj6kptte" ], "script": "base64:BgISCAISBAoCCAESABIGCgQIAQgICQAKbGltaXRSYXRpbwCgjQYAA2ZlZQBkAAZzY2FsZTUAoI0GAAxmZWVDb2xsZWN0b3ICIzNOMkZ1em9NMXg4aEpxU0RVVmlYdXZhdE5wOWlwN0dyS29CAQpnZXRBc3NldElkAQNhc3QEByRtYXRjaDAFA2FzdAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFwBQckbWF0Y2gwBQNhc3QFBHVuaXQBDmdldEFzc2V0U3RyaW5nAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAWIFByRtYXRjaDAJANgEAQUBYgIFV0FWRVMBDWdldEFzc2V0Qnl0ZXMBB2Fzc2V0SWQDCQAAAgUHYXNzZXRJZAIFV0FWRVMFBHVuaXQJANkEAQUHYXNzZXRJZAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAFiBQckbWF0Y2gwCQDwBwI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BQdhc3NldElkBQZhbW91bnQFA25pbAMJAAACBQhjYWxsYmFjawUIY2FsbGJhY2sECWZlZUFtb3VudAkAawMFBmFtb3VudAUDZmVlBQZzY2FsZTUEDWFtb3VudFRvUmVwYXkJAGQCBQZhbW91bnQFCWZlZUFtb3VudAQKbmV3QmFsYW5jZQkBCmdldEJhbGFuY2UBCQENZ2V0QXNzZXRCeXRlcwEFB2Fzc2V0SWQDCQAAAgUKbmV3QmFsYW5jZQUKbmV3QmFsYW5jZQMJAGcCBQpuZXdCYWxhbmNlBQ5jdXJyZW50QmFsYW5jZQkAAgEJAKwCAgkArAICCQCsAgICEGN1cnJlbnRCYWxhbmNlOiAJAKQDAQUOY3VycmVudEJhbGFuY2UCDiwgbmV3QmFsYW5jZTogCQCkAwEFCm5ld0JhbGFuY2UJAAIBCQCsAgIJAKwCAgkArAICAihSZWplY3RlZCBkdWUgdG8gbG93IHJlcGF5IGFtb3VudC4gTmVlZDogCQCkAwEFDWFtb3VudFRvUmVwYXkCDCwgcHJvdmlkZWQ6IAkApAMBCQBlAgUKbmV3QmFsYW5jZQUOY3VycmVudEJhbGFuY2UJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AN6warg==", "height": 2735524, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7g8g5Kyyr8gX82DkmyE1UM6ehMCZufG2L4ErHeVjcjSi Next: G9A3gkA3wMSCCBEdF7Jf8qAvUZLXxetvdAcQfrr9gTw Diff:
Old | New | Differences | |
---|---|---|---|
97 | 97 | let newBalance = getBalance(getAssetBytes(assetId)) | |
98 | 98 | if ((newBalance == newBalance)) | |
99 | 99 | then if ((newBalance >= currentBalance)) | |
100 | - | then | |
100 | + | then throw(((("currentBalance: " + toString(currentBalance)) + ", newBalance: ") + toString(newBalance))) | |
101 | 101 | else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", provided: ") + toString((newBalance - currentBalance)))) | |
102 | 102 | else throw("Strict value is not equal to itself.") | |
103 | 103 | } |
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 [IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + assetId), amount), ScriptTransfer(i.originCaller, amount, getAssetBytes(assetId))] | |
57 | 57 | else throw(((("Requested amount " + toString(amount)) + " is bigger than limit: ") + toString(limit))) | |
58 | 58 | } | |
59 | 59 | else throw("Strict value is not equal to itself.") | |
60 | 60 | } | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | ||
64 | 64 | @Callable(i) | |
65 | 65 | func repay () = { | |
66 | 66 | let amount = value(i.payments[0].amount) | |
67 | 67 | let assetId = i.payments[0].assetId | |
68 | 68 | let borrowed = tryGetInteger(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), this) | |
69 | 69 | if ((borrowed > 0)) | |
70 | 70 | then { | |
71 | 71 | let toRepayAmount = min([amount, borrowed]) | |
72 | 72 | let toReturnAmount = (amount - toRepayAmount) | |
73 | 73 | let returnTransfer = if ((toReturnAmount > 0)) | |
74 | 74 | then ScriptTransfer(i.originCaller, toReturnAmount, assetId) | |
75 | 75 | else unit | |
76 | 76 | [IntegerEntry(((("borrowed_" + toString(i.originCaller)) + "_") + getAssetString(assetId)), (borrowed - toRepayAmount))] | |
77 | 77 | } | |
78 | 78 | else throw("You shouldn't repay") | |
79 | 79 | } | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | ||
83 | 83 | @Callable(i) | |
84 | 84 | func flash (assetId,amount,callbackAddress,callBackFunction) = { | |
85 | 85 | let callbackAdr = Address(fromBase58String(callbackAddress)) | |
86 | 86 | let currentBalance = getBalance(getAssetBytes(assetId)) | |
87 | 87 | if ((currentBalance == currentBalance)) | |
88 | 88 | then { | |
89 | 89 | let borrow = invoke(this, "borrow", [assetId, amount], nil) | |
90 | 90 | if ((borrow == borrow)) | |
91 | 91 | then { | |
92 | 92 | let callback = invoke(Address(fromBase58String(callbackAddress)), callBackFunction, nil, [AttachedPayment(getAssetBytes(assetId), amount)]) | |
93 | 93 | if ((callback == callback)) | |
94 | 94 | then { | |
95 | 95 | let feeAmount = fraction(amount, fee, scale5) | |
96 | 96 | let amountToRepay = (amount + feeAmount) | |
97 | 97 | let newBalance = getBalance(getAssetBytes(assetId)) | |
98 | 98 | if ((newBalance == newBalance)) | |
99 | 99 | then if ((newBalance >= currentBalance)) | |
100 | - | then | |
100 | + | then throw(((("currentBalance: " + toString(currentBalance)) + ", newBalance: ") + toString(newBalance))) | |
101 | 101 | else throw(((("Rejected due to low repay amount. Need: " + toString(amountToRepay)) + ", provided: ") + toString((newBalance - currentBalance)))) | |
102 | 102 | else throw("Strict value is not equal to itself.") | |
103 | 103 | } | |
104 | 104 | else throw("Strict value is not equal to itself.") | |
105 | 105 | } | |
106 | 106 | else throw("Strict value is not equal to itself.") | |
107 | 107 | } | |
108 | 108 | else throw("Strict value is not equal to itself.") | |
109 | 109 | } | |
110 | 110 | ||
111 | 111 |
github/deemru/w8io/026f985 45.72 ms ◑