tx · ABqEYGbmUNvS8kZB9cxC4dRR1m4c4VbPf5NV9hpRvzBU 3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X: -0.04000000 Waves 2021.05.17 15:20 [1529662] smart account 3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X > SELF 0.00000000 Waves
{ "type": 13, "id": "ABqEYGbmUNvS8kZB9cxC4dRR1m4c4VbPf5NV9hpRvzBU", "fee": 4000000, "feeAssetId": null, "timestamp": 1621254018701, "version": 2, "chainId": 84, "sender": "3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X", "senderPublicKey": "7d8ot6oQCGQZb8ATJ6U8KciEiWMyGupkrdYRjcoRfNzs", "proofs": [ "YPNfc5gQBE3mdQMEwXiJifSfzrNuRqXobJuZtGUKGFEQV3RLX2M8q5ZRhvrNMzY5tY3eqWa3ZjM1jmqRnirhmH5" ], "script": "base64:AAIEAAAAAAAAACAIAhIECgIBCBIECgIBCBIECgIBCBIECgIBCBIECgIBCAAAAAMBAAAAEGdldERlcG9zaXRBbW91bnQAAAACAAAACXB1YmxpY0tleQAAAAVhc3NldAQAAAAHYmFsYW5jZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAhkZXBvc2l0XwUAAAAJcHVibGljS2V5AgAAAAFfBQAAAAVhc3NldAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAAdiYWxhbmNlAQAAAA9nZXRCb3Jyb3dBbW91bnQAAAACAAAACXB1YmxpY0tleQAAAAVhc3NldAQAAAAHYmFsYW5jZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAdib3Jyb3dfBQAAAAlwdWJsaWNLZXkCAAAAAV8FAAAABWFzc2V0AwkAAAEAAAACBQAAAAckbWF0Y2g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XwUAAAAFYXNzZXQJAABlAAAAAgUAAAAKY3VycmVudERlcAUAAAAGYW1vdW50BQAAAANuaWwJAAACAAAAAQIAAAATTm90aGluZyB0byB3aXRoZHJhdwAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgYGmhGPSw==", "height": 1529662, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CuzvUZ2bjQsCPr74YAzfdZav9BfoS27wrpUKKwjeEeDt Next: 7zMtizKKWVwmCzdhAoDQDZMLsQtpDkNqCJtBVHZKNYe2 Diff:
Old | New | Differences | |
---|---|---|---|
52 | 52 | else asset | |
53 | 53 | let depositAmount = getDepositAmount(publicKey, test) | |
54 | 54 | let newDepositAmount = (depositAmount + amount) | |
55 | - | [IntegerEntry(((("deposit_" + publicKey) + "_") + | |
55 | + | [IntegerEntry(((("deposit_" + publicKey) + "_") + test), newDepositAmount)] | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getDepositAmount (publicKey,asset) = { | |
5 | 5 | let balance = match getInteger(this, ((("deposit_" + publicKey) + "_") + asset)) { | |
6 | 6 | case a: Int => | |
7 | 7 | a | |
8 | 8 | case _ => | |
9 | 9 | 0 | |
10 | 10 | } | |
11 | 11 | balance | |
12 | 12 | } | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func getBorrowAmount (publicKey,asset) = { | |
16 | 16 | let balance = match getInteger(this, ((("borrow_" + publicKey) + "_") + asset)) { | |
17 | 17 | case a: Int => | |
18 | 18 | a | |
19 | 19 | case _ => | |
20 | 20 | 0 | |
21 | 21 | } | |
22 | 22 | balance | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getCollateral (publicKey,asset) = if ((asset == "")) | |
27 | 27 | then { | |
28 | 28 | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_Waves") + asset)) { | |
29 | 29 | case a: Int => | |
30 | 30 | a | |
31 | 31 | case _ => | |
32 | 32 | 0 | |
33 | 33 | } | |
34 | 34 | collateral | |
35 | 35 | } | |
36 | 36 | else { | |
37 | 37 | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_") + asset)) { | |
38 | 38 | case a: Int => | |
39 | 39 | a | |
40 | 40 | case _ => | |
41 | 41 | 0 | |
42 | 42 | } | |
43 | 43 | collateral | |
44 | 44 | } | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | @Callable(i) | |
48 | 48 | func deposit (amount,asset) = { | |
49 | 49 | let publicKey = toBase58String(i.callerPublicKey) | |
50 | 50 | let test = if ((asset == "")) | |
51 | 51 | then "WAVES" | |
52 | 52 | else asset | |
53 | 53 | let depositAmount = getDepositAmount(publicKey, test) | |
54 | 54 | let newDepositAmount = (depositAmount + amount) | |
55 | - | [IntegerEntry(((("deposit_" + publicKey) + "_") + | |
55 | + | [IntegerEntry(((("deposit_" + publicKey) + "_") + test), newDepositAmount)] | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | 60 | @Callable(i) | |
61 | 61 | func depositCollateral (amount,asset) = { | |
62 | 62 | let publicKey = toBase58String(i.callerPublicKey) | |
63 | 63 | let collateralAmount = getCollateral(publicKey, asset) | |
64 | 64 | let newCollateralAmount = (collateralAmount + amount) | |
65 | 65 | [IntegerEntry(((("collateral_" + publicKey) + "_") + asset), newCollateralAmount)] | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | 70 | @Callable(i) | |
71 | 71 | func borrow (amount,asset) = { | |
72 | 72 | let publicKey = toBase58String(i.callerPublicKey) | |
73 | 73 | let borrowAmount = getBorrowAmount(publicKey, asset) | |
74 | 74 | let collateral = getCollateral(publicKey, asset) | |
75 | 75 | let maxBorrowAmount = ((collateral * 70) / 100) | |
76 | 76 | let newBorrowAmount = (borrowAmount + amount) | |
77 | 77 | if ((collateral >= maxBorrowAmount)) | |
78 | 78 | then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), newBorrowAmount)] | |
79 | 79 | else throw("Not enough collateral") | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | 85 | func repay (amount,asset) = { | |
86 | 86 | let publicKey = toBase58String(i.callerPublicKey) | |
87 | 87 | let currentBorr = getBorrowAmount(publicKey, asset) | |
88 | 88 | if ((currentBorr > 0)) | |
89 | 89 | then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), (currentBorr - amount))] | |
90 | 90 | else throw("Nothing to repay") | |
91 | 91 | } | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | ||
95 | 95 | @Callable(i) | |
96 | 96 | func withdraw (amount,asset) = { | |
97 | 97 | let publicKey = toBase58String(i.callerPublicKey) | |
98 | 98 | let currentDep = getDepositAmount(publicKey, asset) | |
99 | 99 | if ((currentDep > 0)) | |
100 | 100 | then [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), (currentDep - amount))] | |
101 | 101 | else throw("Nothing to withdraw") | |
102 | 102 | } | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | @Verifier(tx) | |
106 | 106 | func verify () = match tx { | |
107 | 107 | case _: DataTransaction => | |
108 | 108 | true | |
109 | 109 | case _: SetScriptTransaction => | |
110 | 110 | true | |
111 | 111 | case _ => | |
112 | 112 | true | |
113 | 113 | } | |
114 | 114 |
github/deemru/w8io/169f3d6 35.48 ms ◑