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