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