tx · BFad4bNkU8LuDxhX2nX4dbjPRAYW8RB1Uoj625j7Busp 3N8LCS3KtW9515VfPp4VaeNaWvZUMHcEK9B: -0.01400000 Waves 2021.10.27 19:34 [1764949] smart account 3N8LCS3KtW9515VfPp4VaeNaWvZUMHcEK9B > SELF 0.00000000 Waves
{ "type": 13, "id": "BFad4bNkU8LuDxhX2nX4dbjPRAYW8RB1Uoj625j7Busp", "fee": 1400000, "feeAssetId": null, "timestamp": 1635352550082, "version": 1, "sender": "3N8LCS3KtW9515VfPp4VaeNaWvZUMHcEK9B", "senderPublicKey": "9cVoX1wWBuTSgXtAXVP4SgmHbvySujpvVgY5WtJ1e9nW", "proofs": [ "3RUKTC5jgjfo3KwiNG8KTD9oSgALGKnnUE8MaDgig2kK8NLi2BhzFZytqLcWWHcjDTAbzmJ5hVNR31GKriYmwxBy" ], "script": "base64:AAIFAAAAAAAAABAIAhIAEgASAwoBARIDCgEBAAAAFAAAAAAHYmFsYW5jZQkBAAAAB0FkZHJlc3MAAAABAQAAABoBVAFWHrpP6BOYBOAT8NlRIH0npFLJg78ScQAAAAARU1dPUGdvdmVybmFuY2VBZHIJAQAAAAV2YWx1ZQAAAAEJAAQmAAAAAQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2JhbGFuY2UCAAAAD1NXT1BfZ292ZXJuYW5jZQIAAAAVRW1wdHkgU1dPUF9nb3Zlcm5hbmNlAAAAABdkZWZpaGVscGVyTWFuYWdlclB1YktleQkAAlkAAAABCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAAB2JhbGFuY2UCAAAAGWRlZmloZWxwZXJfbWFuYWdlcl9QdWJLZXkCAAAAI0VtcHR5IGtleSBkZWZpaGVscGVyX21hbmFnZXJfUHViS2V5AAAAAAxhZG1pblB1YktleTEBAAAAIJI0rvSL2N+4Jd3ss8OgEArwbahdnCXQKg1y+jLzTuJDAAAAAAxhZG1pblB1YktleTIBAAAAIJI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AAAAQFAAAAEVNXT1Bnb3Zlcm5hbmNlQWRyAgAAAAx3aXRoZHJhd1NXT1AJAARMAAAAAgUAAAANYW10VG9XaXRoZHJhdwUAAAADbmlsBQAAAANuaWwDCQAAAAAAAAIFAAAAAXoFAAAAAXoJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA1hbXRUb1dpdGhkcmF3BQAAAARTV09QBQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAALecxBE=", "chainId": 84, "height": 1764949, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let balance = Address(base58'3Mp39cqVsfFiuWFD9wHLtFzN2KcAeTsYehv') | |
5 | + | ||
6 | + | let SWOPgovernanceAdr = value(addressFromString(valueOrErrorMessage(getString(balance, "SWOP_governance"), "Empty SWOP_governance"))) | |
7 | + | ||
8 | + | let defihelperManagerPubKey = fromBase58String(valueOrElse(getString(balance, "defihelper_manager_PubKey"), "Empty key defihelper_manager_PubKey")) | |
9 | + | ||
10 | + | let adminPubKey1 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
11 | + | ||
12 | + | let adminPubKey2 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
13 | + | ||
14 | + | let adminPubKey3 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
15 | + | ||
16 | + | let keyOwner = "owner" | |
17 | + | ||
18 | + | let keyIsProtocolActive = "isProtocolActive" | |
19 | + | ||
20 | + | let owner = addressFromString(valueOrErrorMessage(getString(this, keyOwner), "Empty keyOwner")) | |
21 | + | ||
22 | + | let ownerStr = valueOrErrorMessage(getString(this, keyOwner), "Empty keyOwner") | |
23 | + | ||
24 | + | let isProtocolActive = valueOrErrorMessage(getBoolean(balance, keyIsProtocolActive), "Empty key isProtocolActive") | |
25 | + | ||
26 | + | let keyLastInterest = "last_interest" | |
27 | + | ||
28 | + | let keyUserSWOPLocked = "_SWOP_amount" | |
29 | + | ||
30 | + | let keyUserLastInterest = "_last_interest" | |
31 | + | ||
32 | + | let SWOP = base58'Ccgesc9iWMSg1f8CqFP5nZwgF6xsGirReDhpvNp1JAWW' | |
33 | + | ||
34 | + | let scaleValue = 100000000 | |
35 | + | ||
36 | + | func getLastInterestInfo () = { | |
37 | + | let lastInterest = valueOrElse(getInteger(SWOPgovernanceAdr, keyLastInterest), 0) | |
38 | + | lastInterest | |
39 | + | } | |
40 | + | ||
41 | + | ||
42 | + | func getUserSWOPLocked (user) = valueOrElse(getInteger(SWOPgovernanceAdr, (toString(user) + keyUserSWOPLocked)), 0) | |
43 | + | ||
44 | + | ||
45 | + | func getUserInterestInfo (user,lastInterest) = { | |
46 | + | let userSWOPAmount = getUserSWOPLocked(user) | |
47 | + | let userLastInterest = getInteger(SWOPgovernanceAdr, (toString(user) + keyUserLastInterest)) | |
48 | + | let userLastInterestValue = match userLastInterest { | |
49 | + | case userLastInterest: Int => | |
50 | + | userLastInterest | |
51 | + | case _ => | |
52 | + | lastInterest | |
53 | + | } | |
54 | + | $Tuple2(userLastInterestValue, userSWOPAmount) | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | func claimCalc (caller) = { | |
59 | + | let lastInterest = getLastInterestInfo() | |
60 | + | let uifo = getUserInterestInfo(caller, lastInterest) | |
61 | + | let userLastInterest = uifo._1 | |
62 | + | let userSWOPLocked = uifo._2 | |
63 | + | let claimAmount = fraction(userSWOPLocked, (lastInterest - userLastInterest), scaleValue) | |
64 | + | let userNewInterest = lastInterest | |
65 | + | $Tuple2(userNewInterest, claimAmount) | |
66 | + | } | |
67 | + | ||
68 | + | ||
69 | + | @Callable(i) | |
70 | + | func init () = if (isDefined(getString(this, keyOwner))) | |
71 | + | then throw("Automate already initialized") | |
72 | + | else if ((size(i.payments) == 0)) | |
73 | + | then [StringEntry(keyOwner, toString(i.caller))] | |
74 | + | else if ((size(i.payments) == 1)) | |
75 | + | then { | |
76 | + | let $t027642839 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
77 | + | let pmtAmount = $t027642839._1 | |
78 | + | let pmtAssetId = $t027642839._2 | |
79 | + | if ((pmtAssetId != SWOP)) | |
80 | + | then throw("Only SWOP payment available in init()") | |
81 | + | else { | |
82 | + | let z = invoke(SWOPgovernanceAdr, "lockSWOP", nil, [AttachedPayment(SWOP, pmtAmount)]) | |
83 | + | if ((z == z)) | |
84 | + | then [StringEntry(keyOwner, toString(i.caller))] | |
85 | + | else throw("Strict value is not equal to itself.") | |
86 | + | } | |
87 | + | } | |
88 | + | else throw("Incorrect paynemt. You should attach SWOP or empty payment") | |
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | @Callable(i) | |
93 | + | func governanceLockSWOP () = { | |
94 | + | let $t032533328 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
95 | + | let pmtAmount = $t032533328._1 | |
96 | + | let pmtAssetId = $t032533328._2 | |
97 | + | if ((pmtAssetId != SWOP)) | |
98 | + | then throw("Only SWOP payment available in governanceLockSWOP()") | |
99 | + | else { | |
100 | + | let z = invoke(SWOPgovernanceAdr, "lockSWOP", nil, [AttachedPayment(SWOP, pmtAmount)]) | |
101 | + | if ((z == z)) | |
102 | + | then nil | |
103 | + | else throw("Strict value is not equal to itself.") | |
104 | + | } | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | @Callable(i) | |
110 | + | func governanceClaimAndStake (minSWOPreward) = if (if ((i.caller != owner)) | |
111 | + | then (i.callerPublicKey != defihelperManagerPubKey) | |
112 | + | else false) | |
113 | + | then throw("Only owner or admin can call this function") | |
114 | + | else { | |
115 | + | let claimAmount = claimCalc(this)._2 | |
116 | + | if ((minSWOPreward > claimAmount)) | |
117 | + | then throw("Amount to claim is less than minSWOPreward") | |
118 | + | else { | |
119 | + | let isFeeExtract = if ((i.caller == owner)) | |
120 | + | then false | |
121 | + | else true | |
122 | + | let z = invoke(SWOPgovernanceAdr, "claimAndStakeSWOP", nil, nil) | |
123 | + | if ((z == z)) | |
124 | + | then { | |
125 | + | let y = invoke(balance, "extractFee", [ownerStr, isFeeExtract], nil) | |
126 | + | if ((y == y)) | |
127 | + | then nil | |
128 | + | else throw("Strict value is not equal to itself.") | |
129 | + | } | |
130 | + | else throw("Strict value is not equal to itself.") | |
131 | + | } | |
132 | + | } | |
133 | + | ||
134 | + | ||
135 | + | ||
136 | + | @Callable(i) | |
137 | + | func governanceWithdraw (amtToWithdraw) = if ((i.caller != owner)) | |
138 | + | then throw("Only owner can call this function") | |
139 | + | else { | |
140 | + | let z = invoke(SWOPgovernanceAdr, "withdrawSWOP", [amtToWithdraw], nil) | |
141 | + | if ((z == z)) | |
142 | + | then [ScriptTransfer(i.caller, amtToWithdraw, SWOP)] | |
143 | + | else throw("Strict value is not equal to itself.") | |
144 | + | } | |
145 | + | ||
146 | + |
github/deemru/w8io/169f3d6 16.98 ms ◑