tx · Ai1Z1acoXVR4XornNhK21iesFTvhL45ZZ7x4g3XADBY4

3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X:  -0.01000000 Waves

2021.05.17 13:30 [1529559] smart account 3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X > SELF 0.00000000 Waves

{ "type": 13, "id": "Ai1Z1acoXVR4XornNhK21iesFTvhL45ZZ7x4g3XADBY4", "fee": 1000000, "feeAssetId": null, "timestamp": 1621247449253, "version": 2, "chainId": 84, "sender": "3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X", "senderPublicKey": "7d8ot6oQCGQZb8ATJ6U8KciEiWMyGupkrdYRjcoRfNzs", "proofs": [ "pwKh1bYTz32gp9enhdF83szahJXvuUgVQwAhjVkV8mZHoQjaU8sVdJT4BPqy2irYE1hLQxBMNmcaMXgfywyuzxv" ], "script": "base64:AAIEAAAAAAAAACAIAhIECgIBCBIECgIBCBIECgIBCBIECgIBCBIECgIBCAAAAAMBAAAAEGdldERlcG9zaXRBbW91bnQAAAACAAAACXB1YmxpY0tleQAAAAVhc3NldAQAAAAHYmFsYW5jZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAhkZXBvc2l0XwUAAAAJcHVibGljS2V5AgAAAAFfBQAAAAVhc3NldAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAAdiYWxhbmNlAQAAAA9nZXRCb3Jyb3dBbW91bnQAAAACAAAACXB1YmxpY0tleQAAAAVhc3NldAQAAAAHYmFsYW5jZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAdib3Jyb3dfBQAAAAlwdWJsaWNLZXkCAAAAAV8FAAAABWFzc2V0AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQ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m9ycm93QW1vdW50AAAAAgUAAAAJcHVibGljS2V5BQAAAAVhc3NldAMJAABmAAAAAgUAAAALY3VycmVudEJvcnIAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAAB2JvcnJvd18FAAAACXB1YmxpY0tleQIAAAABXwUAAAAFYXNzZXQJAABlAAAAAgUAAAALY3VycmVudEJvcnIFAAAABmFtb3VudAUAAAADbmlsCQAAAgAAAAECAAAAEE5vdGhpbmcgdG8gcmVwYXkAAAABaQEAAAAId2l0aGRyYXcAAAACAAAABmFtb3VudAAAAAVhc3NldAQAAAAJcHVibGljS2V5CQACWAAAAAEIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQQAAAAKY3VycmVudERlcAkBAAAAEGdldERlcG9zaXRBbW91bnQAAAACBQAAAAlwdWJsaWNLZXkFAAAABWFzc2V0AwkAAGYAAAACBQAAAApjdXJyZW50RGVwAAAAAAAAAAAACQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAhkZXBvc2l0XwUAAAAJcHVibGljS2V5AgAAAAFfBQAAAAVhc3NldAkAAGUAAAACBQAAAApjdXJyZW50RGVwBQAAAAZhbW91bnQFAAAAA25pbAkAAAIAAAABAgAAABNOb3RoaW5nIHRvIHdpdGhkcmF3AAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBgYZTXkn", "height": 1529559, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 2YXY9UAUnnrrCQwPJ2ofvsH29zpgym639VhyBbEs5Mfr Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 4 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+func getDepositAmount (publicKey,asset) = {
5+ let balance = match getInteger(this, ((("deposit_" + publicKey) + "_") + asset)) {
6+ case a: Int =>
7+ a
8+ case _ =>
9+ 0
10+ }
11+ balance
12+ }
13+
14+
15+func getBorrowAmount (publicKey,asset) = {
16+ let balance = match getInteger(this, ((("borrow_" + publicKey) + "_") + asset)) {
17+ case a: Int =>
18+ a
19+ case _ =>
20+ 0
21+ }
22+ balance
23+ }
24+
25+
26+func getCollateral (publicKey,asset) = {
27+ let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_") + asset)) {
28+ case a: Int =>
29+ a
30+ case _ =>
31+ 0
32+ }
33+ collateral
34+ }
35+
36+
37+@Callable(i)
38+func deposit (amount,asset) = {
39+ let publicKey = toBase58String(i.callerPublicKey)
40+ let depositAmount = getDepositAmount(publicKey, asset)
41+ let newDepositAmount = (depositAmount + amount)
42+[IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)]
43+ }
44+
45+
46+
47+@Callable(i)
48+func depositCollateral (amount,asset) = {
49+ let publicKey = toBase58String(i.callerPublicKey)
50+ let collateralAmount = getCollateral(publicKey, asset)
51+ let newCollateralAmount = (collateralAmount + amount)
52+[IntegerEntry(((("collateral_" + publicKey) + "_") + asset), newCollateralAmount)]
53+ }
54+
55+
56+
57+@Callable(i)
58+func borrow (amount,asset) = {
59+ let publicKey = toBase58String(i.callerPublicKey)
60+ let borrowAmount = getBorrowAmount(publicKey, asset)
61+ let collateral = getCollateral(publicKey, asset)
62+ let maxBorrowAmount = ((collateral * 70) / 100)
63+ let newBorrowAmount = (borrowAmount + amount)
64+ if ((collateral >= maxBorrowAmount))
65+ then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), newBorrowAmount)]
66+ else throw("Not enough collateral")
67+ }
68+
69+
70+
71+@Callable(i)
72+func repay (amount,asset) = {
73+ let publicKey = toBase58String(i.callerPublicKey)
74+ let currentBorr = getBorrowAmount(publicKey, asset)
75+ if ((currentBorr > 0))
76+ then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), (currentBorr - amount))]
77+ else throw("Nothing to repay")
78+ }
79+
80+
81+
82+@Callable(i)
83+func withdraw (amount,asset) = {
84+ let publicKey = toBase58String(i.callerPublicKey)
85+ let currentDep = getDepositAmount(publicKey, asset)
86+ if ((currentDep > 0))
87+ then [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), (currentDep - amount))]
88+ else throw("Nothing to withdraw")
89+ }
90+
91+
92+@Verifier(tx)
93+func verify () = match tx {
94+ case _: DataTransaction =>
95+ true
96+ case _: SetScriptTransaction =>
97+ true
98+ case _ =>
99+ true
100+}
101+

github/deemru/w8io/169f3d6 
22.78 ms