tx · 2YXY9UAUnnrrCQwPJ2ofvsH29zpgym639VhyBbEs5Mfr 3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X: -0.04000000 Waves 2021.05.17 14:50 [1529639] smart account 3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X > SELF 0.00000000 Waves
{ "type": 13, "id": "2YXY9UAUnnrrCQwPJ2ofvsH29zpgym639VhyBbEs5Mfr", "fee": 4000000, "feeAssetId": null, "timestamp": 1621252315717, "version": 2, "chainId": 84, "sender": "3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X", "senderPublicKey": "7d8ot6oQCGQZb8ATJ6U8KciEiWMyGupkrdYRjcoRfNzs", "proofs": [ "LcPYapZwHCsNXmwfmUS8XXU6X7z2VgDoQuogLS7rKHWuG6cQaQsuBLE2YQWyRY46HMmXX8dn8ZaXxbMwyoa8Yfh" ], "script": "base64:AAIEAAAAAAAAACAIAhIECgIBCBIECgIBCBIECgIBCBIECgIBCBIECgIBCAAAAAMBAAAAEGdldERlcG9zaXRBbW91bnQAAAACAAAACXB1YmxpY0tleQAAAAVhc3NldAQAAAAHYmFsYW5jZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAhkZXBvc2l0XwUAAAAJcHVibGljS2V5AgAAAAFfBQAAAAVhc3NldAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAAdiYWxhbmNlAQAAAA9nZXRCb3Jyb3dBbW91bnQAAAACAAAACXB1YmxpY0tleQAAAAVhc3NldAQAAAAHYmFsYW5jZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAdib3Jyb3dfBQAAAAlwdWJsaWNLZXkCAAAAAV8FAAAABWFzc2V0AwkAAAEAAAACBQAAAAckbWF0Y2gwAg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UAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24GBjxYlg8=", "height": 1529639, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ai1Z1acoXVR4XornNhK21iesFTvhL45ZZ7x4g3XADBY4 Next: FwmruPTPKcouQSgY1iKbefQphmcAYAzgCKXpeXoSV4Uj Diff:
Old | New | Differences | |
---|---|---|---|
39 | 39 | let publicKey = toBase58String(i.callerPublicKey) | |
40 | 40 | let depositAmount = getDepositAmount(publicKey, asset) | |
41 | 41 | let newDepositAmount = (depositAmount + amount) | |
42 | - | [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
42 | + | if ((asset == "")) | |
43 | + | then [IntegerEntry((("deposit_" + publicKey) + "_WAVES"), newDepositAmount)] | |
44 | + | else [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
43 | 45 | } | |
44 | 46 | ||
45 | 47 |
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) = { | |
27 | 27 | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_") + asset)) { | |
28 | 28 | case a: Int => | |
29 | 29 | a | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | collateral | |
34 | 34 | } | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | @Callable(i) | |
38 | 38 | func deposit (amount,asset) = { | |
39 | 39 | let publicKey = toBase58String(i.callerPublicKey) | |
40 | 40 | let depositAmount = getDepositAmount(publicKey, asset) | |
41 | 41 | let newDepositAmount = (depositAmount + amount) | |
42 | - | [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
42 | + | if ((asset == "")) | |
43 | + | then [IntegerEntry((("deposit_" + publicKey) + "_WAVES"), newDepositAmount)] | |
44 | + | else [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
43 | 45 | } | |
44 | 46 | ||
45 | 47 | ||
46 | 48 | ||
47 | 49 | @Callable(i) | |
48 | 50 | func depositCollateral (amount,asset) = { | |
49 | 51 | let publicKey = toBase58String(i.callerPublicKey) | |
50 | 52 | let collateralAmount = getCollateral(publicKey, asset) | |
51 | 53 | let newCollateralAmount = (collateralAmount + amount) | |
52 | 54 | [IntegerEntry(((("collateral_" + publicKey) + "_") + asset), newCollateralAmount)] | |
53 | 55 | } | |
54 | 56 | ||
55 | 57 | ||
56 | 58 | ||
57 | 59 | @Callable(i) | |
58 | 60 | func borrow (amount,asset) = { | |
59 | 61 | let publicKey = toBase58String(i.callerPublicKey) | |
60 | 62 | let borrowAmount = getBorrowAmount(publicKey, asset) | |
61 | 63 | let collateral = getCollateral(publicKey, asset) | |
62 | 64 | let maxBorrowAmount = ((collateral * 70) / 100) | |
63 | 65 | let newBorrowAmount = (borrowAmount + amount) | |
64 | 66 | if ((collateral >= maxBorrowAmount)) | |
65 | 67 | then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), newBorrowAmount)] | |
66 | 68 | else throw("Not enough collateral") | |
67 | 69 | } | |
68 | 70 | ||
69 | 71 | ||
70 | 72 | ||
71 | 73 | @Callable(i) | |
72 | 74 | func repay (amount,asset) = { | |
73 | 75 | let publicKey = toBase58String(i.callerPublicKey) | |
74 | 76 | let currentBorr = getBorrowAmount(publicKey, asset) | |
75 | 77 | if ((currentBorr > 0)) | |
76 | 78 | then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), (currentBorr - amount))] | |
77 | 79 | else throw("Nothing to repay") | |
78 | 80 | } | |
79 | 81 | ||
80 | 82 | ||
81 | 83 | ||
82 | 84 | @Callable(i) | |
83 | 85 | func withdraw (amount,asset) = { | |
84 | 86 | let publicKey = toBase58String(i.callerPublicKey) | |
85 | 87 | let currentDep = getDepositAmount(publicKey, asset) | |
86 | 88 | if ((currentDep > 0)) | |
87 | 89 | then [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), (currentDep - amount))] | |
88 | 90 | else throw("Nothing to withdraw") | |
89 | 91 | } | |
90 | 92 | ||
91 | 93 | ||
92 | 94 | @Verifier(tx) | |
93 | 95 | func verify () = match tx { | |
94 | 96 | case _: DataTransaction => | |
95 | 97 | true | |
96 | 98 | case _: SetScriptTransaction => | |
97 | 99 | true | |
98 | 100 | case _ => | |
99 | 101 | true | |
100 | 102 | } | |
101 | 103 |
github/deemru/w8io/169f3d6 25.79 ms ◑