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