tx · EfNTyBtjsEPCR86WDGUuj2dnN2tnJoWxxatJxdFqtsgY 3Mwx228RAk1rkDAtxyd5Zp8XVGJsbcvpewR: -0.02900000 Waves 2023.02.21 12:08 [2459211] smart account 3Mwx228RAk1rkDAtxyd5Zp8XVGJsbcvpewR > SELF 0.00000000 Waves
{ "type": 13, "id": "EfNTyBtjsEPCR86WDGUuj2dnN2tnJoWxxatJxdFqtsgY", "fee": 2900000, "feeAssetId": null, "timestamp": 1676970499747, "version": 1, "sender": "3Mwx228RAk1rkDAtxyd5Zp8XVGJsbcvpewR", "senderPublicKey": "7LtLPpYjVJQYuVoHoauJnaQAAE8Qs8cC681mnvgDK21m", "proofs": [ "5yps8xxrhsf3qpX27es6xnudi4VRom6FHFUwmia3sUpADfxGucKE9ULgXpA47ch8SWSqeqE1GABwYpGiPjsenafr" ], "script": "base64:AAIFAAAAAAAAADQIAhIDCgEIEgkKBwgICAgBCAgSAwoBARIAEgASBQoDCAgIEgQKAggBEgMKAQgSAwoBCBIAAAAAOQAAAAADU0VQAgAAAAJfXwAAAAAFRU1QVFkCAAAAAAEAAAAPZ2V0U3RyaW5nT3JGYWlsAAAAAQAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkJAAEsAAAAAgIAAAAVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQAAAANrZXkBAAAAEGdldEJvb2xlYW5PckZhaWwAAAABAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEGwAAAAIFAAAABHRoaXMFAAAAA2tleQkAASwAAAACAgAAABVObyBkYXRhIGZvciB0aGlzLmtleT0FAAAAA2tleQEAAAATa2V5TWFuYWdlclB1YmxpY0tleQAAAAAJAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAABBtYW5hZ2VyUHVibGljS2V5BQAAAANuaWwFAAAAA1NFUAEAAAAaa2V5UGVuZGluZ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AAtNYXRjaCBlcnJvcgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAD3RhcmdldFB1YmxpY0tleUBN2RE=", "chainId": 84, "height": 2459211, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 31aNxzknW7jaKp5938ehXQzxeBsRVJYBH8aq1MoZBdPV Next: 2jSMTBy7nJ32kEs27D9iwF9WGD5PNuUjVafVzL7gGcAG Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let SCALE8 = 8 | |
5 | - | ||
6 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | - | let SCALE18 = 18 | |
9 | - | ||
10 | - | let MULT18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | 4 | let SEP = "__" | |
13 | 5 | ||
14 | - | let | |
6 | + | let EMPTY = "" | |
15 | 7 | ||
16 | - | let zeroBigInt = toBigInt(0) | |
17 | - | ||
18 | - | let idxPoolAddress = 1 | |
19 | - | ||
20 | - | let idxPoolStatus = 2 | |
21 | - | ||
22 | - | let idxPoolLPAssetId = 3 | |
23 | - | ||
24 | - | let idxAmtAssetId = 4 | |
25 | - | ||
26 | - | let idxPriceAssetId = 5 | |
27 | - | ||
28 | - | let idxAmtAssetDcm = 6 | |
29 | - | ||
30 | - | let idxPriceAssetDcm = 7 | |
31 | - | ||
32 | - | let idxIAmtAssetId = 8 | |
33 | - | ||
34 | - | let idxIPriceAssetId = 9 | |
35 | - | ||
36 | - | let idxLPAssetDcm = 10 | |
37 | - | ||
38 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
8 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
39 | 9 | ||
40 | 10 | ||
41 | - | func | |
11 | + | func getBooleanOrFail (key) = valueOrErrorMessage(getBoolean(this, key), ("No data for this.key=" + key)) | |
42 | 12 | ||
43 | 13 | ||
44 | - | func | |
14 | + | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
45 | 15 | ||
46 | 16 | ||
47 | - | func | |
17 | + | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
48 | 18 | ||
49 | 19 | ||
50 | - | func asAnyList (val) = match val { | |
51 | - | case valAnyLyst: List[Any] => | |
52 | - | valAnyLyst | |
53 | - | case _ => | |
54 | - | throw("fail to cast into List[Any]") | |
55 | - | } | |
20 | + | func failExecuteGet (msg,baseAssetStr,userAddressStr,getTxIdStr) = throw(((((((msg + ": baseAssetStr=") + baseAssetStr) + " userAddressStr=") + userAddressStr) + " getTxIdStr=") + getTxIdStr)) | |
56 | 21 | ||
57 | 22 | ||
58 | - | func asInt (val) = match val { | |
59 | - | case valInt: Int => | |
60 | - | valInt | |
61 | - | case _ => | |
62 | - | throw("fail to cast into Int") | |
63 | - | } | |
23 | + | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], SEP) | |
64 | 24 | ||
65 | 25 | ||
66 | - | func asString (val) = match val { | |
67 | - | case valStr: String => | |
68 | - | valStr | |
69 | - | case _ => | |
70 | - | throw("fail to cast into String") | |
71 | - | } | |
26 | + | func keyAssetCfg (baseAssetStr) = ("%s%s%s__config__asset__" + baseAssetStr) | |
72 | 27 | ||
73 | 28 | ||
74 | - | func | |
29 | + | func keyProxyAddress (assetId) = makeString(["%s%s", "proxyAddress", assetId], SEP) | |
75 | 30 | ||
76 | 31 | ||
77 | - | func | |
32 | + | func keyBalance (assetId) = makeString(["%s%s", "balance", assetId], SEP) | |
78 | 33 | ||
79 | 34 | ||
80 | - | func | |
35 | + | func keyNextInternalAssetId () = "%s__nextInternalAssetId" | |
81 | 36 | ||
82 | 37 | ||
83 | - | let IdxFactoryCfgStakingDapp = 1 | |
84 | - | ||
85 | - | let IdxFactoryCfgBoostingDapp = 2 | |
86 | - | ||
87 | - | let IdxFactoryCfgIdoDapp = 3 | |
88 | - | ||
89 | - | let IdxFactoryCfgTeamDapp = 4 | |
90 | - | ||
91 | - | let IdxFactoryCfgEmissionDapp = 5 | |
92 | - | ||
93 | - | let IdxFactoryCfgRestDapp = 6 | |
94 | - | ||
95 | - | let IdxFactoryCfgSlippageDapp = 7 | |
96 | - | ||
97 | - | let IdxFactoryCfgGwxRewardDapp = 8 | |
98 | - | ||
99 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
38 | + | func keyPriceLast (internalBasetAssetStr) = ("%s%s%d__price__last__" + internalBasetAssetStr) | |
100 | 39 | ||
101 | 40 | ||
102 | - | func | |
41 | + | func keyTopUpLastHeight (internalBasetAssetStr,sender) = makeString(["%s%s%s%d%s__topup__last__height", internalBasetAssetStr, sender], SEP) | |
103 | 42 | ||
104 | 43 | ||
105 | - | func | |
44 | + | func keyPriceHistory (internalBasetAssetStr,h,timestamp) = makeString(["%s%s%d%d%d__price__history", internalBasetAssetStr, toString(h), toString(timestamp)], SEP) | |
106 | 45 | ||
107 | 46 | ||
108 | - | func | |
47 | + | func keyTotalLocked (internalBasetAssetStr) = ("%s%s%d__total__locked__" + internalBasetAssetStr) | |
109 | 48 | ||
110 | 49 | ||
111 | - | func | |
50 | + | func keyTotalLockedByUser (internalBaseAssetStr,userAddressStr) = makeString(["%s%s%d%s__total__locked", internalBaseAssetStr, userAddressStr], SEP) | |
112 | 51 | ||
113 | 52 | ||
114 | - | func | |
53 | + | func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset)) | |
115 | 54 | ||
116 | 55 | ||
117 | - | func | |
56 | + | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
118 | 57 | ||
119 | 58 | ||
120 | - | func | |
59 | + | func keyMappingsShare2baseAssetId (shareAssetStr) = ("%s%s%s__mappings__share2baseAssetId__" + shareAssetStr) | |
121 | 60 | ||
122 | 61 | ||
123 | - | func | |
62 | + | func keyMappingsBaseAsset2shareId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2shareId__" + baseAssetStr) | |
124 | 63 | ||
125 | 64 | ||
126 | - | func | |
65 | + | func keyShutdownPutOperation (internalBaseAssetStr) = ("%s%s%d__shutdown__put__" + internalBaseAssetStr) | |
127 | 66 | ||
128 | 67 | ||
129 | - | func | |
68 | + | func keyShutdownManager (internalBaseAssetStr) = ("%s%s%d__shutdown__manager__" + internalBaseAssetStr) | |
130 | 69 | ||
131 | 70 | ||
132 | - | func | |
71 | + | func assetsStoreContract () = addressFromStringValue(value(getString(keyAssetsStoreContract()))) | |
133 | 72 | ||
134 | 73 | ||
135 | - | func keyBoostCfg () = "%s__config" | |
74 | + | let IdxCfgShareAssetId = 1 | |
75 | + | ||
76 | + | let IdxCfgInternalBaseAsset = 2 | |
77 | + | ||
78 | + | let IdxCfgDecimalsMultBothAssets = 3 | |
79 | + | ||
80 | + | let IdxCfgDecimalsMultPrice = 4 | |
81 | + | ||
82 | + | let IdxCfgGetDelayBlocks = 5 | |
83 | + | ||
84 | + | func dataAssetCfg (shareAssetStr,internalBaseAssetStr,decimalsMultBothAssets,decimalsMultPrice,getDelayInBlocks) = makeString(["%s%d%d%d%d", shareAssetStr, internalBaseAssetStr, toString(decimalsMultBothAssets), toString(decimalsMultPrice), toString(getDelayInBlocks)], SEP) | |
136 | 85 | ||
137 | 86 | ||
138 | - | func keyBoostingLockParamTotalAmount () = "%s%s__stats__activeTotalLocked" | |
87 | + | let IdxTotalLockedShare = 1 | |
88 | + | ||
89 | + | let IdxTotalLockedBase = 2 | |
90 | + | ||
91 | + | func dataTotalLocked (shareAssetAmount,baseAssetAmount) = makeString(["%d%d", toString(shareAssetAmount), toString(baseAssetAmount)], SEP) | |
139 | 92 | ||
140 | 93 | ||
141 | - | func keyBoostingStatsLocksDurationSumInBlocks () = "%s%s__stats__locksDurationSumInBlocks" | |
142 | - | ||
143 | - | ||
144 | - | func keyBoostingStatsLocksCount () = "%s%s__stats__locksCount" | |
145 | - | ||
146 | - | ||
147 | - | func keyBoostingStatsUsersCount () = "%s%s__stats__activeUsersCount" | |
148 | - | ||
149 | - | ||
150 | - | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", userAddress], SEP) | |
151 | - | ||
152 | - | ||
153 | - | func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP) | |
154 | - | ||
155 | - | ||
156 | - | func keyLockParamUserAmount (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "amount"], SEP) | |
157 | - | ||
158 | - | ||
159 | - | func keyLockParamStartBlock (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "start"], SEP) | |
160 | - | ||
161 | - | ||
162 | - | func keyLockParamDuration (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "duration"], SEP) | |
163 | - | ||
164 | - | ||
165 | - | func keyLockParamK (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "k"], SEP) | |
166 | - | ||
167 | - | ||
168 | - | func keyLockParamB (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "b"], SEP) | |
169 | - | ||
170 | - | ||
171 | - | func keyLockParamByPeriodK (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "k", period], SEP) | |
172 | - | ||
173 | - | ||
174 | - | func keyLockParamByPeriodB (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "b", period], SEP) | |
175 | - | ||
176 | - | ||
177 | - | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastInt", userNum], SEP) | |
178 | - | ||
179 | - | ||
180 | - | func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", userNum], SEP) | |
181 | - | ||
182 | - | ||
183 | - | func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total" | |
184 | - | ||
185 | - | ||
186 | - | func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", userNum], SEP) | |
187 | - | ||
188 | - | ||
189 | - | func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", userNum], SEP) | |
190 | - | ||
191 | - | ||
192 | - | func keyTotalCachedGwx () = "%s%s__gwxCached__total" | |
193 | - | ||
194 | - | ||
195 | - | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
196 | - | ||
197 | - | ||
198 | - | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
199 | - | ||
200 | - | ||
201 | - | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
202 | - | ||
203 | - | ||
204 | - | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) | |
205 | - | ||
206 | - | ||
207 | - | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) | |
208 | - | ||
209 | - | ||
210 | - | func readStaked (stakingDapp,key) = valueOrElse(getInteger(stakingDapp, key), 0) | |
211 | - | ||
212 | - | ||
213 | - | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
214 | - | ||
215 | - | ||
216 | - | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
217 | - | ||
218 | - | ||
219 | - | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
220 | - | ||
221 | - | ||
222 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
223 | - | ||
224 | - | ||
225 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
226 | - | ||
227 | - | ||
228 | - | func keyAddonAddr () = "%s__addonAddr" | |
229 | - | ||
230 | - | ||
231 | - | let factoryDapp = readFactoryAddressOrFail() | |
232 | - | ||
233 | - | let factoryCfg = readFactoryCfgOrFail(factoryDapp) | |
234 | - | ||
235 | - | let emissionDapp = getEmissionAddressOrFail(factoryCfg) | |
236 | - | ||
237 | - | let stakingDapp = getStakingAddressOrFail(factoryCfg) | |
238 | - | ||
239 | - | let gwxRewardDapp = getGwxRewardAddressOrFail(factoryCfg) | |
240 | - | ||
241 | - | let boostingDapp = getBoostingAddressOrFail(factoryCfg) | |
242 | - | ||
243 | - | func getPoolInFee (poolAddress) = { | |
244 | - | let @ = invoke(factoryDapp, "getInFeeREADONLY", [toString(poolAddress)], nil) | |
245 | - | if ($isInstanceOf(@, "Int")) | |
246 | - | then @ | |
247 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
94 | + | func readTotalLocked (key) = { | |
95 | + | let totalLockedArray = split(valueOrElse(getString(this, key), dataTotalLocked(0, 0)), SEP) | |
96 | + | [-1, parseIntValue(totalLockedArray[IdxTotalLockedShare]), parseIntValue(totalLockedArray[IdxTotalLockedBase])] | |
248 | 97 | } | |
249 | 98 | ||
250 | 99 | ||
251 | - | func getPoolOutFee (poolAddress) = { | |
252 | - | let @ = invoke(factoryDapp, "getOutFeeREADONLY", [toString(poolAddress)], nil) | |
253 | - | if ($isInstanceOf(@, "Int")) | |
254 | - | then @ | |
255 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
100 | + | func keyOperation (operationType,internalBaseAssetStr,userAddress,txId) = makeString(["%s%d%s%s", operationType, internalBaseAssetStr, userAddress, txId], SEP) | |
101 | + | ||
102 | + | ||
103 | + | let IdxOperStatus = 1 | |
104 | + | ||
105 | + | let IdxOperInAmount = 2 | |
106 | + | ||
107 | + | let IdxOperPrice = 3 | |
108 | + | ||
109 | + | let IdxOperOutAmount = 4 | |
110 | + | ||
111 | + | let IdxOperStartHeight = 5 | |
112 | + | ||
113 | + | let IdxOperStartTimestamp = 6 | |
114 | + | ||
115 | + | let IdxOperEndHeight = 7 | |
116 | + | ||
117 | + | let IdxOperEndTimestamp = 8 | |
118 | + | ||
119 | + | func privateDataOperationAllStrings (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = makeString(["%s%d%d%d%d%d%d%d", status, inAssetAmount, price, outAssetAmount, startHeight, startTimestamp, endHeight, endTimestamp], SEP) | |
120 | + | ||
121 | + | ||
122 | + | func dataOperation (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = privateDataOperationAllStrings(status, toString(inAssetAmount), toString(price), toString(outAssetAmount), toString(startHeight), toString(startTimestamp), toString(endHeight), toString(endTimestamp)) | |
123 | + | ||
124 | + | ||
125 | + | func dataOperationExecutionUpdate (currOperArray,newStatus,newEndTimestamp) = privateDataOperationAllStrings(newStatus, currOperArray[IdxOperInAmount], currOperArray[IdxOperPrice], currOperArray[IdxOperOutAmount], currOperArray[IdxOperStartHeight], currOperArray[IdxOperStartTimestamp], currOperArray[IdxOperEndHeight], toString(newEndTimestamp)) | |
126 | + | ||
127 | + | ||
128 | + | func readAssetCfgOrFail (baseAssetStr) = { | |
129 | + | let key = keyAssetCfg(baseAssetStr) | |
130 | + | split(getStringOrFail(key), SEP) | |
256 | 131 | } | |
257 | 132 | ||
258 | 133 | ||
259 | - | func internalCurrentRewardRate (lpAssetId) = { | |
260 | - | let poolAddressStr = getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAssetId)) | |
261 | - | let poolWeightMult = MULT8 | |
262 | - | let poolWeight = getIntegerValue(factoryDapp, keyFactoryPoolWeight(poolAddressStr)) | |
263 | - | let wxEmissionPerBlock = getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) | |
264 | - | let wxEmissionPerBlockMax = getIntOrFail(emissionDapp, keyEmissionRatePerBlockMaxCurrent()) | |
265 | - | let boostMaxCoeff = 3 | |
266 | - | let poolWxEmissionPerBlock = (fraction(wxEmissionPerBlock, poolWeight, poolWeightMult) / boostMaxCoeff) | |
267 | - | let poolWxEmissionPerBlockMax = fraction(wxEmissionPerBlockMax, poolWeight, poolWeightMult) | |
268 | - | let maxFactor = (boostMaxCoeff * MULT8) | |
269 | - | let totalLpStaked = getIntOrZero(stakingDapp, keyStakedTotal(lpAssetId)) | |
270 | - | [poolWxEmissionPerBlock, maxFactor, totalLpStaked] | |
134 | + | func incrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
135 | + | let dataArray = readTotalLocked(key) | |
136 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] + shareAssetAmount), (dataArray[IdxTotalLockedBase] + baseAssetAmount))) | |
271 | 137 | } | |
272 | 138 | ||
273 | 139 | ||
274 | - | func calcGwxAmountStartREADONLY (lockAmount,lockDuration,maxLockDuration) = { | |
275 | - | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
276 | - | let gWxAmountStart = fraction(lockAmount, coeffX8, MULT8) | |
277 | - | [gWxAmountStart] | |
140 | + | func decrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
141 | + | let dataArray = readTotalLocked(key) | |
142 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] - shareAssetAmount), (dataArray[IdxTotalLockedBase] - baseAssetAmount))) | |
278 | 143 | } | |
279 | - | ||
280 | - | ||
281 | - | func getKey (addr,key,type) = if ((type == "string")) | |
282 | - | then getStringValue(addr, key) | |
283 | - | else if ((type == "integer")) | |
284 | - | then toString(getIntegerValue(addr, key)) | |
285 | - | else if ((type == "boolean")) | |
286 | - | then toString(getBooleanValue(addr, key)) | |
287 | - | else throw("unknown type. expected string/integer/boolean") | |
288 | 144 | ||
289 | 145 | ||
290 | 146 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
307 | 163 | } | |
308 | 164 | ||
309 | 165 | ||
166 | + | func balanceOrZero (assetId) = valueOrElse(getInteger(keyBalance(assetId)), 0) | |
167 | + | ||
168 | + | ||
169 | + | func calcPrice (internalBaseAssetStr,baseAssetId,topUpBaseAmount,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = { | |
170 | + | let totalLockedArray = readTotalLocked(keyTotalLocked(internalBaseAssetStr)) | |
171 | + | let totalLockedBaseAmount = totalLockedArray[IdxTotalLockedBase] | |
172 | + | let baseAssetBalance = balanceOrZero(toBase58String(baseAssetId)) | |
173 | + | let baseAssetBalanceConsideringLock = (baseAssetBalance + topUpBaseAmount) | |
174 | + | if ((0 > baseAssetBalanceConsideringLock)) | |
175 | + | then throw(((("baseAssetBalanceConsideringLock < 0: baseAssetBalance=" + toString(baseAssetBalance)) + " baseAssetBalanceConsideringLock=") + toString(baseAssetBalanceConsideringLock))) | |
176 | + | else { | |
177 | + | let shareEmission = value(assetInfo(shareAssetId)).quantity | |
178 | + | let price = if ((shareEmission == 0)) | |
179 | + | then (1 * decimalsMultPrice) | |
180 | + | else fraction(baseAssetBalanceConsideringLock, decimalsMultPrice, shareEmission) | |
181 | + | $Tuple5(price, baseAssetBalance, totalLockedBaseAmount, baseAssetBalanceConsideringLock, shareEmission) | |
182 | + | } | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func getPrice (internalBaseAssetStr,baseAssetId,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = { | |
187 | + | let totalLockedArray = readTotalLocked(keyTotalLocked(internalBaseAssetStr)) | |
188 | + | let totalLockedBaseAmount = totalLockedArray[IdxTotalLockedBase] | |
189 | + | let baseAssetBalance = balanceOrZero(toBase58String(baseAssetId)) | |
190 | + | let baseAssetBalanceConsideringLock = baseAssetBalance | |
191 | + | let shareEmission = value(assetInfo(shareAssetId)).quantity | |
192 | + | let price = value(getInteger(keyPriceLast(internalBaseAssetStr))) | |
193 | + | $Tuple5(price, baseAssetBalance, totalLockedBaseAmount, baseAssetBalanceConsideringLock, shareEmission) | |
194 | + | } | |
195 | + | ||
196 | + | ||
197 | + | func privateCurrentSysParamsREST (baseAssetStr) = { | |
198 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
199 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
200 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
201 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
202 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
203 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
204 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
205 | + | let sysState = getPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
206 | + | let topUpLastHeight = match getInteger(keyTopUpLastHeight(internalBaseAssetStr, getStringValue(keyProxyAddress(baseAssetStr)))) { | |
207 | + | case h: Int => | |
208 | + | value(h) | |
209 | + | case _: Unit => | |
210 | + | getIntegerValue(keyTopUpLastHeight(internalBaseAssetStr, toString(addressFromPublicKey(fromBase58String(getStringValue(keyManagerPublicKey())))))) | |
211 | + | case _ => | |
212 | + | throw("undefined behaviour in privateCurrentSysParamsREST match") | |
213 | + | } | |
214 | + | $Tuple8(IntegerEntry("price", sysState._1), IntegerEntry("decimalsMultPrice", decimalsMultPrice), IntegerEntry("baseAssetBalance", sysState._2), IntegerEntry("totalLockedBaseAmount", sysState._3), IntegerEntry("baseAssetBalanceConsideringLock", sysState._4), IntegerEntry("shareEmission", sysState._5), IntegerEntry("baseAssetDecimals", value(assetInfo(baseAssetId)).decimals), IntegerEntry("lastTopUpTimestamp", value(blockInfoByHeight(topUpLastHeight)).timestamp)) | |
215 | + | } | |
216 | + | ||
217 | + | ||
310 | 218 | func mustManager (i) = { | |
311 | - | let pd = throw(" | |
219 | + | let pd = throw("permission denied") | |
312 | 220 | match managerPublicKeyOrUnit() { | |
313 | 221 | case pk: ByteVector => | |
314 | 222 | if ((i.callerPublicKey == pk)) | |
324 | 232 | } | |
325 | 233 | ||
326 | 234 | ||
235 | + | func mustProxyAddress (i,assetId) = { | |
236 | + | let isProxy = (toString(i.caller) == valueOrElse(getString(keyProxyAddress(assetId)), EMPTY)) | |
237 | + | if (isProxy) | |
238 | + | then true | |
239 | + | else { | |
240 | + | let checkCaller = mustManager(i) | |
241 | + | if ((checkCaller == checkCaller)) | |
242 | + | then true | |
243 | + | else throw("Strict value is not equal to itself.") | |
244 | + | } | |
245 | + | } | |
246 | + | ||
247 | + | ||
327 | 248 | @Callable(i) | |
328 | - | func constructor ( | |
249 | + | func constructor (assetsStoreContract) = { | |
329 | 250 | let checkCaller = mustManager(i) | |
330 | 251 | if ((checkCaller == checkCaller)) | |
331 | - | then [StringEntry( | |
252 | + | then [StringEntry(keyAssetsStoreContract(), assetsStoreContract)] | |
332 | 253 | else throw("Strict value is not equal to itself.") | |
333 | 254 | } | |
334 | 255 | ||
335 | 256 | ||
336 | 257 | ||
337 | 258 | @Callable(i) | |
338 | - | func currentRewardRateREADONLY (lpAssetId) = { | |
339 | - | let rewardData = internalCurrentRewardRate(lpAssetId) | |
340 | - | let wxEmissionPerBlock = rewardData[0] | |
341 | - | let maxFactor = rewardData[1] | |
342 | - | let totalLpStaked = rewardData[2] | |
343 | - | $Tuple2(nil, makeString(["%d%d%d", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked)], SEP)) | |
259 | + | func adminRegisterAsset (baseAssetStr,shareAssetName,shareAssetDescr,shareAssetLogo,getDelayinBlocks,shutdownManagerAddress,proxyAddress) = { | |
260 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
261 | + | let decimals = value(assetInfo(baseAssetId)).decimals | |
262 | + | let check = mustManager(i) | |
263 | + | if ((check == check)) | |
264 | + | then if ((toString(addressFromStringValue(shutdownManagerAddress)) != shutdownManagerAddress)) | |
265 | + | then throw("invalid shutdownManagerAddress") | |
266 | + | else if ((0 > getDelayinBlocks)) | |
267 | + | then throw(("invalid getDelayinBlocks=" + toString(getDelayinBlocks))) | |
268 | + | else { | |
269 | + | let shareAssetIssueAction = Issue(shareAssetName, shareAssetDescr, 1, decimals, true) | |
270 | + | let shareAssetId = calculateAssetId(shareAssetIssueAction) | |
271 | + | let shareAssetStr = toBase58String(shareAssetId) | |
272 | + | let decimalsMultPrice = ((100 * 1000) * 1000) | |
273 | + | let decimalsMultBothAssets = pow(10, 0, decimals, 0, 0, DOWN) | |
274 | + | let startPrice = (1 * decimalsMultPrice) | |
275 | + | let internalBaseAssettId = valueOrElse(getInteger(this, keyNextInternalAssetId()), 0) | |
276 | + | let internalBaseAssetStr = toString(internalBaseAssettId) | |
277 | + | let createOrUpdate = invoke(assetsStoreContract(), "createOrUpdate", [shareAssetStr, shareAssetLogo, false], nil) | |
278 | + | if ((createOrUpdate == createOrUpdate)) | |
279 | + | then { | |
280 | + | let addLabel = invoke(assetsStoreContract(), "addLabel", [shareAssetStr, "STAKING_LP"], nil) | |
281 | + | if ((addLabel == addLabel)) | |
282 | + | then [StringEntry(keyAssetCfg(baseAssetStr), dataAssetCfg(shareAssetStr, internalBaseAssetStr, decimalsMultBothAssets, decimalsMultPrice, getDelayinBlocks)), StringEntry(keyMappingsInternal2baseAssetId(internalBaseAssettId), baseAssetStr), StringEntry(keyMappingsBaseAsset2internalId(baseAssetStr), internalBaseAssetStr), StringEntry(keyMappingsShare2baseAssetId(shareAssetStr), baseAssetStr), StringEntry(keyMappingsBaseAsset2shareId(baseAssetStr), shareAssetStr), BooleanEntry(keyShutdownPutOperation(internalBaseAssetStr), false), StringEntry(keyShutdownManager(internalBaseAssetStr), shutdownManagerAddress), IntegerEntry(keyNextInternalAssetId(), (internalBaseAssettId + 1)), IntegerEntry(keyPriceLast(internalBaseAssetStr), startPrice), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), startPrice), shareAssetIssueAction, Burn(shareAssetId, 1), StringEntry(keyProxyAddress(baseAssetStr), proxyAddress)] | |
283 | + | else throw("Strict value is not equal to itself.") | |
284 | + | } | |
285 | + | else throw("Strict value is not equal to itself.") | |
286 | + | } | |
287 | + | else throw("Strict value is not equal to itself.") | |
344 | 288 | } | |
345 | 289 | ||
346 | 290 | ||
347 | 291 | ||
348 | 292 | @Callable(i) | |
349 | - | func currentUserRewardRateREADONLY (lpAssetId,userAddress) = { | |
350 | - | let rewardData = internalCurrentRewardRate(lpAssetId) | |
351 | - | let wxEmissionPerBlock = rewardData[0] | |
352 | - | let maxFactor = rewardData[1] | |
353 | - | let totalLpStaked = rewardData[2] | |
354 | - | let lpStakedByUser = getIntOrZero(stakingDapp, keyStakedByUser(userAddress, lpAssetId)) | |
355 | - | let userClaimInfo = split(asString(invoke(stakingDapp, "claimWxREADONLY", [lpAssetId, userAddress], nil)), SEP) | |
356 | - | let minRewardPart = valueOrErrorMessage(parseInt(userClaimInfo[5]), "couldn't parse minRewardPart") | |
357 | - | let boostRewardPart = valueOrErrorMessage(parseInt(userClaimInfo[6]), "couldn't parse boostRewardPart") | |
358 | - | let debug = userClaimInfo[7] | |
359 | - | let boostingPower = if ((boostRewardPart == 0)) | |
360 | - | then (1 * MULT8) | |
361 | - | else fraction((minRewardPart + boostRewardPart), MULT8, minRewardPart) | |
362 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%s", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked), toString(lpStakedByUser), toString(boostingPower), debug], SEP)) | |
293 | + | func shutdownPut (internalBaseAssetId) = { | |
294 | + | let internalBaseAssetIdStr = toString(internalBaseAssetId) | |
295 | + | let baseAssetIdStr = getStringOrFail(keyMappingsInternal2baseAssetId(internalBaseAssetId)) | |
296 | + | let shutdownManagerAddress = getStringOrFail(keyShutdownManager(internalBaseAssetIdStr)) | |
297 | + | if ((1 > size(baseAssetIdStr))) | |
298 | + | then throw("invalid internalBaseAssetId") | |
299 | + | else if ((toString(i.caller) != shutdownManagerAddress)) | |
300 | + | then throw("access denied") | |
301 | + | else [BooleanEntry(keyShutdownPutOperation(toString(internalBaseAssetId)), true)] | |
363 | 302 | } | |
364 | 303 | ||
365 | 304 | ||
366 | 305 | ||
367 | 306 | @Callable(i) | |
368 | - | func calcBoostBulkInternalREADONLY (currentIter,deltaWxAmountBulk,deltaLockPeriodInBlocksBulk,deltaLpAmountBulk,lpAssetIdOptBulk,userAddressOpt,resAcc) = if ((currentIter == size(deltaWxAmountBulk))) | |
369 | - | then $Tuple2(nil, resAcc) | |
370 | - | else { | |
371 | - | let deltaWxAmount = deltaWxAmountBulk[currentIter] | |
372 | - | let deltaLockPeriodInBlocks = deltaLockPeriodInBlocksBulk[currentIter] | |
373 | - | let deltaLpAmount = deltaLpAmountBulk[currentIter] | |
374 | - | let lpAssetIdOpt = lpAssetIdOptBulk[currentIter] | |
375 | - | let info = { | |
376 | - | let @ = invoke(this, "calcBoostREADONLY", [deltaWxAmount, deltaLockPeriodInBlocks, deltaLpAmount, lpAssetIdOpt, userAddressOpt], nil) | |
377 | - | if ($isInstanceOf(@, "String")) | |
378 | - | then @ | |
379 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
380 | - | } | |
381 | - | let res = (resAcc :+ info) | |
382 | - | let inv = { | |
383 | - | let @ = invoke(this, "calcBoostBulkInternalREADONLY", [(currentIter + 1), deltaWxAmountBulk, deltaLockPeriodInBlocksBulk, deltaLpAmountBulk, lpAssetIdOptBulk, userAddressOpt, res], nil) | |
384 | - | if ($isInstanceOf(@, "List[Any]")) | |
385 | - | then @ | |
386 | - | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
387 | - | } | |
388 | - | if ((inv == inv)) | |
389 | - | then $Tuple2(nil, inv) | |
390 | - | else throw("Strict value is not equal to itself.") | |
391 | - | } | |
392 | - | ||
393 | - | ||
394 | - | ||
395 | - | @Callable(i) | |
396 | - | func calcBoostBulkREADONLY (deltaWxAmount,deltaLockPeriodInBlocks,deltaLpAmount,lpAssetIdOpt,userAddressOpt) = { | |
397 | - | let res = invoke(this, "calcBoostBulkInternalREADONLY", [0, deltaWxAmount, deltaLockPeriodInBlocks, deltaLpAmount, lpAssetIdOpt, userAddressOpt, nil], nil) | |
398 | - | $Tuple2(nil, res) | |
399 | - | } | |
400 | - | ||
401 | - | ||
402 | - | ||
403 | - | @Callable(i) | |
404 | - | func calcBoostREADONLY (deltaWxAmount,deltaLockPeriodInBlocks,deltaLpAmount,lpAssetIdOpt,userAddressOpt) = { | |
405 | - | let mathDapp = gwxRewardDapp | |
406 | - | let EMPTYSTR = "empty" | |
407 | - | let maxLockDurationInBlocks = parseIntValue(split(getStringByAddressOrFail(boostingDapp, keyBoostCfg()), SEP)[4]) | |
408 | - | let lpAssetIdStr = if ((lpAssetIdOpt == "")) | |
409 | - | then EMPTYSTR | |
410 | - | else lpAssetIdOpt | |
411 | - | let userAddressStr = if ((userAddressOpt == "")) | |
412 | - | then EMPTYSTR | |
413 | - | else userAddressOpt | |
414 | - | let userNumStr = valueOrElse(getString(boostingDapp, keyUser2NumMapping(userAddressOpt)), EMPTYSTR) | |
415 | - | let userAmount = valueOrElse(getInteger(boostingDapp, keyLockParamUserAmount(userNumStr)), 0) | |
416 | - | let lockStart = valueOrElse(getInteger(boostingDapp, keyLockParamStartBlock(userNumStr)), height) | |
417 | - | let lockDuration = valueOrElse(getInteger(boostingDapp, keyLockParamDuration(userNumStr)), 0) | |
418 | - | let lockEnd = (lockStart + lockDuration) | |
419 | - | let remainingDuration = max([(lockEnd - height), 0]) | |
420 | - | let userAmountNew = (userAmount + deltaWxAmount) | |
421 | - | let lockDurationNew = min([(remainingDuration + deltaLockPeriodInBlocks), maxLockDurationInBlocks]) | |
422 | - | let userCurrgWxAmount = asInt(asAnyList(invoke(boostingDapp, "gwxUserInfoREADONLY", [userAddressStr], nil))[0]) | |
423 | - | let gWxAmountStartNew = calcGwxAmountStartREADONLY(userAmountNew, lockDurationNew, maxLockDurationInBlocks)[0] | |
424 | - | let gWxParamsResultList = asAnyList(invoke(mathDapp, "calcGwxParamsREADONLY", [gWxAmountStartNew, height, lockDurationNew], nil)) | |
425 | - | let gWxAmountDiff = (gWxAmountStartNew - userCurrgWxAmount) | |
426 | - | let k = asInt(gWxParamsResultList[0]) | |
427 | - | let b = asInt(gWxParamsResultList[1]) | |
428 | - | let period = toString(asInt(gWxParamsResultList[2])) | |
429 | - | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
430 | - | let userMaxBoostIntNew = ((gWxAmountStartNew * lockDurationNew) / 2) | |
431 | - | let totalMaxBoostInt = getIntOrZero(boostingDapp, totalMaxBoostIntegralKEY) | |
432 | - | let totalCachedGwx = { | |
433 | - | let @ = invoke(boostingDapp, "getTotalCachedGwxREADONLY", nil, nil) | |
434 | - | if ($isInstanceOf(@, "Int")) | |
435 | - | then @ | |
436 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
437 | - | } | |
438 | - | let MULT3 = 1000 | |
439 | - | let wxEmissionPerBlockX3 = (getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) * MULT3) | |
440 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
441 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
442 | - | let stakedByUser = readStaked(stakingDapp, stakedByUserKEY) | |
443 | - | let stakedTotal = readStaked(stakingDapp, stakedTotalKEY) | |
444 | - | let stakedByUserNew = (stakedByUser + deltaLpAmount) | |
445 | - | let stakedTotalNew = (stakedTotal + deltaLpAmount) | |
446 | - | let poolWeight = if ((lpAssetIdStr != EMPTYSTR)) | |
447 | - | then { | |
448 | - | let poolAddressStr = valueOrErrorMessage(getString(factoryDapp, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
449 | - | getIntegerValue(factoryDapp, keyFactoryPoolWeight(poolAddressStr)) | |
450 | - | } | |
451 | - | else 0 | |
452 | - | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * 3)) | |
453 | - | let wxPerLpX3 = if ((stakedTotalNew != 0)) | |
454 | - | then fraction(poolWxEmissionPerBlockX3, MULT8, stakedTotalNew) | |
455 | - | else 0 | |
456 | - | let userWxPerBlockX3 = fraction(wxPerLpX3, stakedByUserNew, MULT8) | |
457 | - | let boostEmissionPerBlockX3 = (poolWxEmissionPerBlockX3 * 2) | |
458 | - | let tmpUserBoostPerBlockX3 = fraction(gWxAmountStartNew, boostEmissionPerBlockX3, (totalCachedGwx + gWxAmountDiff)) | |
459 | - | let userBoostPerBlockX3 = min([tmpUserBoostPerBlockX3, (userWxPerBlockX3 * 2)]) | |
460 | - | let boostCoeff = if ((userWxPerBlockX3 == 0)) | |
461 | - | then (1 * MULT8) | |
462 | - | else fraction((userBoostPerBlockX3 + userWxPerBlockX3), MULT8, userWxPerBlockX3) | |
463 | - | $Tuple2(nil, makeString(["%d%d%s", toString(gWxAmountStartNew), toString(boostCoeff), "d"], SEP)) | |
464 | - | } | |
465 | - | ||
466 | - | ||
467 | - | ||
468 | - | @Callable(i) | |
469 | - | func wxEmissionStatsREADONLY () = { | |
470 | - | let ONEMULT = toString(MULT8) | |
471 | - | let ONE = "1" | |
472 | - | let wxEmissionPerBlock = getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) | |
473 | - | let emissionStartBlock = getIntOrFail(emissionDapp, keyEmissionStartBlock()) | |
474 | - | let passedBlocks = if ((emissionStartBlock > height)) | |
475 | - | then 0 | |
476 | - | else (height - emissionStartBlock) | |
477 | - | let teamEmDuration = (1440 * 365) | |
478 | - | let teamEmMax = (201000000 * MULT8) | |
479 | - | let teamEm = if ((passedBlocks > teamEmDuration)) | |
480 | - | then teamEmMax | |
481 | - | else fraction(teamEmMax, passedBlocks, teamEmDuration) | |
482 | - | let totalWxReleased = ((wxEmissionPerBlock * passedBlocks) + teamEm) | |
483 | - | let totalWxLocked = getIntOrZero(boostingDapp, keyBoostingLockParamTotalAmount()) | |
484 | - | let locksDurationSumInBlocks = getIntOrZero(boostingDapp, keyBoostingStatsLocksDurationSumInBlocks()) | |
485 | - | let locksCount = getIntOrZero(boostingDapp, keyBoostingStatsLocksCount()) | |
486 | - | $Tuple2(nil, makeString(["%d%d%d%d", toString(totalWxReleased), toString(totalWxLocked), toString(locksDurationSumInBlocks), toString(locksCount)], SEP)) | |
487 | - | } | |
488 | - | ||
489 | - | ||
490 | - | ||
491 | - | @Callable(i) | |
492 | - | func poolStatsREADONLY (lpAsset) = { | |
493 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) | |
494 | - | let status = { | |
495 | - | let @ = invoke(factoryDapp, "getPoolStatusREADONLY", [toString(poolAddress)], nil) | |
496 | - | if ($isInstanceOf(@, "Int")) | |
497 | - | then @ | |
498 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
499 | - | } | |
500 | - | let tpl = "%d%d%d%d%d%d%d%d%d%s" | |
501 | - | if ((status == 4)) | |
502 | - | then $Tuple2(nil, makeString([tpl, toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(false)], SEP)) | |
307 | + | func put () = { | |
308 | + | let pmt = value(i.payments[0]) | |
309 | + | let baseAssetId = value(pmt.assetId) | |
310 | + | let baseAssetStr = toBase58String(baseAssetId) | |
311 | + | let userAddressStr = toString(i.caller) | |
312 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
313 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
314 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
315 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
316 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
317 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
318 | + | let isPutBlocked = getBooleanOrFail(keyShutdownPutOperation(internalBaseAssetStr)) | |
319 | + | if (isPutBlocked) | |
320 | + | then throw("put operation is blocked") | |
503 | 321 | else { | |
504 | - | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) | |
505 | - | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) | |
506 | - | let amtAssetId = asString(cfg[idxAmtAssetId]) | |
507 | - | let priceAssetId = asString(cfg[idxPriceAssetId]) | |
508 | - | let iAmtAssetId = asString(cfg[idxIAmtAssetId]) | |
509 | - | let iPriceAssetId = asString(cfg[idxIPriceAssetId]) | |
510 | - | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) | |
511 | - | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) | |
512 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
513 | - | let accAmtAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amtAssetId], nil)) | |
514 | - | let accPriceAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [priceAssetId], nil)) | |
515 | - | let pricesList = if ((poolLPBalance == 0)) | |
516 | - | then [toString(zeroBigInt), toString(zeroBigInt), toString(zeroBigInt)] | |
517 | - | else asAnyList(invoke(poolAddress, "calcPricesWrapperREADONLY", [accAmtAssetBalance, accPriceAssetBalance, poolLPBalance], nil)) | |
518 | - | let curPrice = 0 | |
519 | - | let lpAmtAssetShare = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [pricesList[1], MULT8], nil)) | |
520 | - | let lpPriceAssetShare = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [pricesList[2], MULT8], nil)) | |
521 | - | let poolWeight = getIntegerValue(factoryDapp, keyFactoryPoolWeight(toString(poolAddress))) | |
522 | - | let inFee = getPoolInFee(poolAddress) | |
523 | - | let outFee = getPoolOutFee(poolAddress) | |
524 | - | let poolOneTokenOperationsDisabled = { | |
525 | - | let @ = invoke(factoryDapp, "isPoolOneTokenOperationsDisabledREADONLY", [toString(poolAddress)], nil) | |
526 | - | if ($isInstanceOf(@, "Boolean")) | |
527 | - | then @ | |
528 | - | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
529 | - | } | |
530 | - | let poolOneTokenOperationsEnabled = !(poolOneTokenOperationsDisabled) | |
531 | - | $Tuple2(nil, makeString([tpl, toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight), toString(inFee), toString(outFee), toString(poolOneTokenOperationsEnabled)], SEP)) | |
322 | + | let newBalance = (balanceOrZero(baseAssetStr) + pmt.amount) | |
323 | + | let price = getPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
324 | + | let shareAssetAmount = fraction(pmt.amount, decimalsMultPrice, price, CEILING) | |
325 | + | [Reissue(shareAssetId, shareAssetAmount, true), ScriptTransfer(i.caller, shareAssetAmount, shareAssetId), StringEntry(keyOperation("P", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)), dataOperation("FINISHED", pmt.amount, price, shareAssetAmount, height, lastBlock.timestamp, height, lastBlock.timestamp)), ScriptTransfer(addressFromStringValue(value(getString(keyProxyAddress(baseAssetStr)))), pmt.amount, baseAssetId), IntegerEntry(keyBalance(baseAssetStr), newBalance)] | |
532 | 326 | } | |
533 | 327 | } | |
534 | 328 | ||
535 | 329 | ||
536 | 330 | ||
537 | 331 | @Callable(i) | |
538 | - | func poolEvaluatePutByAmountAssetREADONLY (lpAsset,inAmAssetAmt) = { | |
539 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) | |
540 | - | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) | |
541 | - | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) | |
542 | - | let amAssetIdStr = asString(cfg[idxAmtAssetId]) | |
543 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
544 | - | let prAssetIdStr = asString(cfg[idxPriceAssetId]) | |
545 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
546 | - | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) | |
547 | - | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) | |
548 | - | let poolStatus = asString(cfg[idxPoolStatus]) | |
549 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
550 | - | let accAmtAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amAssetIdStr], nil)) | |
551 | - | let accPriceAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [prAssetIdStr], nil)) | |
552 | - | let amtAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [accAmtAssetBalance, amtAssetDcm], nil))) | |
553 | - | let priceAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [accPriceAssetBalance, priceAssetDcm], nil))) | |
554 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
555 | - | then zeroBigInt | |
556 | - | else parseBigIntValue(asString(invoke(poolAddress, "calcPriceBigIntWrapperREADONLY", [toString(priceAssetAmtX18), toString(amtAssetAmtX18)], nil))) | |
557 | - | let curPrice = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(curPriceX18), MULT8], nil)) | |
558 | - | let inAmAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [inAmAssetAmt, amtAssetDcm], nil))) | |
559 | - | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, MULT18) | |
560 | - | let inPrAssetAmt = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(inPrAssetAmtX18), priceAssetDcm], nil)) | |
561 | - | let res = invoke(poolAddress, "estimatePutOperationWrapperREADONLY", ["", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false], nil) | |
562 | - | let $t02384624210 = match res { | |
563 | - | case _ => | |
564 | - | if (if (if ($isInstanceOf($match0._1, "Int")) | |
565 | - | then if ($isInstanceOf($match0._3, "Int")) | |
566 | - | then if ($isInstanceOf($match0._4, "Int")) | |
567 | - | then if ($isInstanceOf($match0._5, "Int")) | |
568 | - | then $isInstanceOf($match0._6, "Int") | |
569 | - | else false | |
570 | - | else false | |
571 | - | else false | |
572 | - | else false) | |
573 | - | then (size($match0) == 13) | |
574 | - | else false) | |
575 | - | then { | |
576 | - | let calcLpAmt = $match0._1 | |
577 | - | let curPriceCalc = $match0._3 | |
578 | - | let amBalance = $match0._4 | |
579 | - | let prBalance = $match0._5 | |
580 | - | let lpEmission = $match0._6 | |
581 | - | $Tuple5(calcLpAmt, curPriceCalc, amBalance, prBalance, lpEmission) | |
582 | - | } | |
583 | - | else throw("Couldn't cast types") | |
584 | - | } | |
585 | - | let calcLpAmt = $t02384624210._1 | |
586 | - | let curPriceCalc = $t02384624210._2 | |
587 | - | let amBalance = $t02384624210._3 | |
588 | - | let prBalance = $t02384624210._4 | |
589 | - | let lpEmission = $t02384624210._5 | |
590 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(curPrice), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
332 | + | func submitGetRequest () = { | |
333 | + | let pmt = value(i.payments[0]) | |
334 | + | let shareAssetId = value(pmt.assetId) | |
335 | + | let shareAssetStr = toBase58String(shareAssetId) | |
336 | + | let callerPubStr = toBase58String(i.callerPublicKey) | |
337 | + | let userAddress = i.caller | |
338 | + | let userAddressStr = toString(userAddress) | |
339 | + | let shareAssetAmount = pmt.amount | |
340 | + | let baseAssetStr = getStringOrFail(keyMappingsShare2baseAssetId(shareAssetStr)) | |
341 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
342 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
343 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
344 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
345 | + | let getDelayBlocks = parseIntValue(cfgArray[IdxCfgGetDelayBlocks]) | |
346 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
347 | + | let price = getPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
348 | + | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
349 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
350 | + | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
351 | + | [Burn(shareAssetId, shareAssetAmount), StringEntry(operationKey, operationData), incrementTotalLocked(keyTotalLocked(internalBaseAssetStr), shareAssetAmount, baseAssetAmount), incrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), shareAssetAmount, baseAssetAmount), IntegerEntry(keyBalance(baseAssetStr), (balanceOrZero(baseAssetStr) - baseAssetAmount))] | |
591 | 352 | } | |
592 | 353 | ||
593 | 354 | ||
594 | 355 | ||
595 | 356 | @Callable(i) | |
596 | - | func poolEvaluatePutByPriceAssetREADONLY (lpAsset,inPrAssetAmt) = { | |
597 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) | |
598 | - | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) | |
599 | - | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) | |
600 | - | let amAssetIdStr = asString(cfg[idxAmtAssetId]) | |
601 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
602 | - | let prAssetIdStr = asString(cfg[idxPriceAssetId]) | |
603 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
604 | - | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) | |
605 | - | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) | |
606 | - | let poolStatus = asString(cfg[idxPoolStatus]) | |
607 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
608 | - | let amBalanceRaw = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amAssetIdStr], nil)) | |
609 | - | let prBalanceRaw = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [prAssetIdStr], nil)) | |
610 | - | let amBalanceRawX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [amBalanceRaw, amtAssetDcm], nil))) | |
611 | - | let prBalanceRawX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [prBalanceRaw, priceAssetDcm], nil))) | |
612 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
613 | - | then zeroBigInt | |
614 | - | else parseBigIntValue(asString(invoke(poolAddress, "calcPriceBigIntWrapperREADONLY", [toString(prBalanceRawX18), toString(amBalanceRawX18)], nil))) | |
615 | - | let curPrice = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(curPriceX18), MULT8], nil)) | |
616 | - | let inPrAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [inPrAssetAmt, priceAssetDcm], nil))) | |
617 | - | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, MULT18, curPriceX18) | |
618 | - | let inAmAssetAmt = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(inAmAssetAmtX18), amtAssetDcm], nil)) | |
619 | - | let res = invoke(poolAddress, "estimatePutOperationWrapperREADONLY", ["", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false], nil) | |
620 | - | let $t02684227206 = match res { | |
621 | - | case _ => | |
622 | - | if (if (if ($isInstanceOf($match0._1, "Int")) | |
623 | - | then if ($isInstanceOf($match0._3, "Int")) | |
624 | - | then if ($isInstanceOf($match0._4, "Int")) | |
625 | - | then if ($isInstanceOf($match0._5, "Int")) | |
626 | - | then $isInstanceOf($match0._6, "Int") | |
627 | - | else false | |
628 | - | else false | |
629 | - | else false | |
630 | - | else false) | |
631 | - | then (size($match0) == 13) | |
632 | - | else false) | |
633 | - | then { | |
634 | - | let calcLpAmt = $match0._1 | |
635 | - | let curPriceCalc = $match0._3 | |
636 | - | let amBalance = $match0._4 | |
637 | - | let prBalance = $match0._5 | |
638 | - | let lpEmission = $match0._6 | |
639 | - | $Tuple5(calcLpAmt, curPriceCalc, amBalance, prBalance, lpEmission) | |
640 | - | } | |
641 | - | else throw("Couldn't cast types") | |
642 | - | } | |
643 | - | let calcLpAmt = $t02684227206._1 | |
644 | - | let curPriceCalc = $t02684227206._2 | |
645 | - | let amBalance = $t02684227206._3 | |
646 | - | let prBalance = $t02684227206._4 | |
647 | - | let lpEmission = $t02684227206._5 | |
648 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(curPrice), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
357 | + | func executeGetRequest (baseAssetStr,userAddressStr,getTxIdStr) = { | |
358 | + | let userAddress = addressFromStringValue(userAddressStr) | |
359 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
360 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
361 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
362 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
363 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
364 | + | let operationArray = split(getStringOrFail(operationKey), SEP) | |
365 | + | let status = operationArray[IdxOperStatus] | |
366 | + | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
367 | + | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
368 | + | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
369 | + | if ((status != "PENDING")) | |
370 | + | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
371 | + | else if ((endHeight > height)) | |
372 | + | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
373 | + | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount)] | |
649 | 374 | } | |
650 | 375 | ||
651 | 376 | ||
652 | 377 | ||
653 | 378 | @Callable(i) | |
654 | - | func poolEvaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
655 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(paymentLpAssetId))) | |
656 | - | let res = invoke(poolAddress, "estimateGetOperationWrapperREADONLY", ["", paymentLpAssetId, paymentLpAmt, toString(poolAddress)], nil) | |
657 | - | let $t02793028360 = match res { | |
658 | - | case _ => | |
659 | - | if (if (if ($isInstanceOf($match0._1, "Int")) | |
660 | - | then if ($isInstanceOf($match0._2, "Int")) | |
661 | - | then if ($isInstanceOf($match0._5, "Int")) | |
662 | - | then if ($isInstanceOf($match0._6, "Int")) | |
663 | - | then if ($isInstanceOf($match0._7, "Int")) | |
664 | - | then if ($isInstanceOf($match0._8, "String")) | |
665 | - | then $isInstanceOf($match0._9, "String") | |
666 | - | else false | |
667 | - | else false | |
668 | - | else false | |
669 | - | else false | |
670 | - | else false | |
671 | - | else false) | |
672 | - | then (size($match0) == 10) | |
673 | - | else false) | |
674 | - | then { | |
675 | - | let outAmAmt = $match0._1 | |
676 | - | let outPrAmt = $match0._2 | |
677 | - | let amBalance = $match0._5 | |
678 | - | let prBalance = $match0._6 | |
679 | - | let lpEmission = $match0._7 | |
680 | - | let curPrice = $match0._8 | |
681 | - | let poolStatus = $match0._9 | |
682 | - | $Tuple7(outAmAmt, outPrAmt, amBalance, prBalance, lpEmission, curPrice, poolStatus) | |
379 | + | func topUpBalance (baseAssetStr,delta) = { | |
380 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
381 | + | let pmt = value(i.payments[0]) | |
382 | + | let pmtAssetId = value(pmt.assetId) | |
383 | + | let pmtAssetStr = toBase58String(pmtAssetId) | |
384 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
385 | + | let decimalsMultBothAssets = parseIntValue(assetCfgArray[IdxCfgDecimalsMultBothAssets]) | |
386 | + | let decimalsMultPrice = parseIntValue(assetCfgArray[IdxCfgDecimalsMultPrice]) | |
387 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
388 | + | let topUpLastHeightKEY = keyTopUpLastHeight(internalBaseAssetStr, toString(i.caller)) | |
389 | + | let topUpLastHeight = valueOrElse(getInteger(this, topUpLastHeightKEY), 0) | |
390 | + | let checks = [mustProxyAddress(i, baseAssetStr), if ((topUpLastHeight != height)) | |
391 | + | then true | |
392 | + | else throw("only one topUp per block is allowed"), if ((delta > 0)) | |
393 | + | then true | |
394 | + | else throw("only positive delta is allowed")] | |
395 | + | if ((checks == checks)) | |
396 | + | then if ((baseAssetStr != pmtAssetStr)) | |
397 | + | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
398 | + | else if ((size(i.payments) > 1)) | |
399 | + | then throw("only one payment can be attached") | |
400 | + | else { | |
401 | + | let price = calcPrice(internalBaseAssetStr, pmtAssetId, delta, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
402 | + | [IntegerEntry(keyPriceLast(internalBaseAssetStr), price), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), price), IntegerEntry(topUpLastHeightKEY, height), IntegerEntry(keyBalance(pmtAssetStr), (balanceOrZero(pmtAssetStr) + delta))] | |
683 | 403 | } | |
684 | - | else throw("Couldn't cast types") | |
685 | - | } | |
686 | - | let outAmAmt = $t02793028360._1 | |
687 | - | let outPrAmt = $t02793028360._2 | |
688 | - | let amBalance = $t02793028360._3 | |
689 | - | let prBalance = $t02793028360._4 | |
690 | - | let lpEmission = $t02793028360._5 | |
691 | - | let curPrice = $t02793028360._6 | |
692 | - | let poolStatus = $t02793028360._7 | |
693 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), curPrice, poolStatus], SEP)) | |
694 | - | } | |
695 | - | ||
696 | - | ||
697 | - | ||
698 | - | @Callable(i) | |
699 | - | func gwxUserInfoREADONLY (userAddress) = { | |
700 | - | let gwxUserInfoLIST = asAnyList(invoke(boostingDapp, "gwxUserInfoREADONLY", [userAddress], nil)) | |
701 | - | let gwxAmount = asInt(gwxUserInfoLIST[0]) | |
702 | - | $Tuple2(nil, makeString(["%d", toString(gwxAmount)], SEP)) | |
703 | - | } | |
704 | - | ||
705 | - | ||
706 | - | ||
707 | - | @Callable(i) | |
708 | - | func unstakeAndGetOneTknV2 (poolAddress,unstakeAmount,outAssetId,minOutAmount) = { | |
709 | - | let inv = invoke(addressFromStringValue(poolAddress), "unstakeAndGetOneTknV2", [unstakeAmount, outAssetId, minOutAmount], nil) | |
710 | - | if ((inv == inv)) | |
711 | - | then $Tuple2(nil, unit) | |
712 | 404 | else throw("Strict value is not equal to itself.") | |
713 | 405 | } | |
714 | 406 | ||
715 | 407 | ||
716 | 408 | ||
717 | 409 | @Callable(i) | |
718 | - | func getKeysBulkInternal (currentIter,keys,resAcc) = if ((currentIter == size(keys))) | |
719 | - | then $Tuple2(nil, resAcc) | |
720 | - | else { | |
721 | - | let k = split(keys[currentIter], "++") | |
722 | - | let addr = addressFromStringValue(k[0]) | |
723 | - | let key = k[1] | |
724 | - | let type = k[2] | |
725 | - | let val = getKey(addr, key, type) | |
726 | - | let res = (resAcc :+ val) | |
727 | - | let inv = invoke(this, "getKeysBulkInternal", [(currentIter + 1), keys, res], nil) | |
728 | - | if ((inv == inv)) | |
729 | - | then $Tuple2(nil, inv) | |
730 | - | else throw("Strict value is not equal to itself.") | |
731 | - | } | |
732 | - | ||
733 | - | ||
734 | - | ||
735 | - | @Callable(i) | |
736 | - | func getKeysBulk (keys) = { | |
737 | - | let res = invoke(this, "getKeysBulkInternal", [0, keys, nil], nil) | |
738 | - | $Tuple2(nil, res) | |
410 | + | func currentSysParamsREST (baseAssetStr) = { | |
411 | + | let sysStateTuple = privateCurrentSysParamsREST(baseAssetStr) | |
412 | + | let price = sysStateTuple._1.value | |
413 | + | let decimalsMultPrice = sysStateTuple._2.value | |
414 | + | let baseAssetBalance = sysStateTuple._3.value | |
415 | + | let totalLockedBaseAmount = sysStateTuple._4.value | |
416 | + | let baseAssetBalanceConsideringLock = sysStateTuple._5.value | |
417 | + | let shareEmission = sysStateTuple._6.value | |
418 | + | let restData = makeString(["startCurrentSysParamsREST", toString(price), toString(decimalsMultPrice), toString(baseAssetBalance), toString(totalLockedBaseAmount), toString(baseAssetBalanceConsideringLock), toString(shareEmission), "endCurrentSysParamsREST"], SEP) | |
419 | + | throw(restData) | |
739 | 420 | } | |
740 | 421 | ||
741 | 422 | ||
760 | 441 | let pm = pendingManagerPublicKeyOrUnit() | |
761 | 442 | let hasPM = if (isDefined(pm)) | |
762 | 443 | then true | |
763 | - | else throw(" | |
444 | + | else throw("no pending manager") | |
764 | 445 | if ((hasPM == hasPM)) | |
765 | 446 | then { | |
766 | 447 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
767 | 448 | then true | |
768 | - | else throw(" | |
449 | + | else throw("you are not pending manager") | |
769 | 450 | if ((checkPM == checkPM)) | |
770 | 451 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
771 | 452 | else throw("Strict value is not equal to itself.") |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let SCALE8 = 8 | |
5 | - | ||
6 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | - | let SCALE18 = 18 | |
9 | - | ||
10 | - | let MULT18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | 4 | let SEP = "__" | |
13 | 5 | ||
14 | - | let | |
6 | + | let EMPTY = "" | |
15 | 7 | ||
16 | - | let zeroBigInt = toBigInt(0) | |
17 | - | ||
18 | - | let idxPoolAddress = 1 | |
19 | - | ||
20 | - | let idxPoolStatus = 2 | |
21 | - | ||
22 | - | let idxPoolLPAssetId = 3 | |
23 | - | ||
24 | - | let idxAmtAssetId = 4 | |
25 | - | ||
26 | - | let idxPriceAssetId = 5 | |
27 | - | ||
28 | - | let idxAmtAssetDcm = 6 | |
29 | - | ||
30 | - | let idxPriceAssetDcm = 7 | |
31 | - | ||
32 | - | let idxIAmtAssetId = 8 | |
33 | - | ||
34 | - | let idxIPriceAssetId = 9 | |
35 | - | ||
36 | - | let idxLPAssetDcm = 10 | |
37 | - | ||
38 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
8 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
39 | 9 | ||
40 | 10 | ||
41 | - | func | |
11 | + | func getBooleanOrFail (key) = valueOrErrorMessage(getBoolean(this, key), ("No data for this.key=" + key)) | |
42 | 12 | ||
43 | 13 | ||
44 | - | func | |
14 | + | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
45 | 15 | ||
46 | 16 | ||
47 | - | func | |
17 | + | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
48 | 18 | ||
49 | 19 | ||
50 | - | func asAnyList (val) = match val { | |
51 | - | case valAnyLyst: List[Any] => | |
52 | - | valAnyLyst | |
53 | - | case _ => | |
54 | - | throw("fail to cast into List[Any]") | |
55 | - | } | |
20 | + | func failExecuteGet (msg,baseAssetStr,userAddressStr,getTxIdStr) = throw(((((((msg + ": baseAssetStr=") + baseAssetStr) + " userAddressStr=") + userAddressStr) + " getTxIdStr=") + getTxIdStr)) | |
56 | 21 | ||
57 | 22 | ||
58 | - | func asInt (val) = match val { | |
59 | - | case valInt: Int => | |
60 | - | valInt | |
61 | - | case _ => | |
62 | - | throw("fail to cast into Int") | |
63 | - | } | |
23 | + | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], SEP) | |
64 | 24 | ||
65 | 25 | ||
66 | - | func asString (val) = match val { | |
67 | - | case valStr: String => | |
68 | - | valStr | |
69 | - | case _ => | |
70 | - | throw("fail to cast into String") | |
71 | - | } | |
26 | + | func keyAssetCfg (baseAssetStr) = ("%s%s%s__config__asset__" + baseAssetStr) | |
72 | 27 | ||
73 | 28 | ||
74 | - | func | |
29 | + | func keyProxyAddress (assetId) = makeString(["%s%s", "proxyAddress", assetId], SEP) | |
75 | 30 | ||
76 | 31 | ||
77 | - | func | |
32 | + | func keyBalance (assetId) = makeString(["%s%s", "balance", assetId], SEP) | |
78 | 33 | ||
79 | 34 | ||
80 | - | func | |
35 | + | func keyNextInternalAssetId () = "%s__nextInternalAssetId" | |
81 | 36 | ||
82 | 37 | ||
83 | - | let IdxFactoryCfgStakingDapp = 1 | |
84 | - | ||
85 | - | let IdxFactoryCfgBoostingDapp = 2 | |
86 | - | ||
87 | - | let IdxFactoryCfgIdoDapp = 3 | |
88 | - | ||
89 | - | let IdxFactoryCfgTeamDapp = 4 | |
90 | - | ||
91 | - | let IdxFactoryCfgEmissionDapp = 5 | |
92 | - | ||
93 | - | let IdxFactoryCfgRestDapp = 6 | |
94 | - | ||
95 | - | let IdxFactoryCfgSlippageDapp = 7 | |
96 | - | ||
97 | - | let IdxFactoryCfgGwxRewardDapp = 8 | |
98 | - | ||
99 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
38 | + | func keyPriceLast (internalBasetAssetStr) = ("%s%s%d__price__last__" + internalBasetAssetStr) | |
100 | 39 | ||
101 | 40 | ||
102 | - | func | |
41 | + | func keyTopUpLastHeight (internalBasetAssetStr,sender) = makeString(["%s%s%s%d%s__topup__last__height", internalBasetAssetStr, sender], SEP) | |
103 | 42 | ||
104 | 43 | ||
105 | - | func | |
44 | + | func keyPriceHistory (internalBasetAssetStr,h,timestamp) = makeString(["%s%s%d%d%d__price__history", internalBasetAssetStr, toString(h), toString(timestamp)], SEP) | |
106 | 45 | ||
107 | 46 | ||
108 | - | func | |
47 | + | func keyTotalLocked (internalBasetAssetStr) = ("%s%s%d__total__locked__" + internalBasetAssetStr) | |
109 | 48 | ||
110 | 49 | ||
111 | - | func | |
50 | + | func keyTotalLockedByUser (internalBaseAssetStr,userAddressStr) = makeString(["%s%s%d%s__total__locked", internalBaseAssetStr, userAddressStr], SEP) | |
112 | 51 | ||
113 | 52 | ||
114 | - | func | |
53 | + | func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset)) | |
115 | 54 | ||
116 | 55 | ||
117 | - | func | |
56 | + | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
118 | 57 | ||
119 | 58 | ||
120 | - | func | |
59 | + | func keyMappingsShare2baseAssetId (shareAssetStr) = ("%s%s%s__mappings__share2baseAssetId__" + shareAssetStr) | |
121 | 60 | ||
122 | 61 | ||
123 | - | func | |
62 | + | func keyMappingsBaseAsset2shareId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2shareId__" + baseAssetStr) | |
124 | 63 | ||
125 | 64 | ||
126 | - | func | |
65 | + | func keyShutdownPutOperation (internalBaseAssetStr) = ("%s%s%d__shutdown__put__" + internalBaseAssetStr) | |
127 | 66 | ||
128 | 67 | ||
129 | - | func | |
68 | + | func keyShutdownManager (internalBaseAssetStr) = ("%s%s%d__shutdown__manager__" + internalBaseAssetStr) | |
130 | 69 | ||
131 | 70 | ||
132 | - | func | |
71 | + | func assetsStoreContract () = addressFromStringValue(value(getString(keyAssetsStoreContract()))) | |
133 | 72 | ||
134 | 73 | ||
135 | - | func keyBoostCfg () = "%s__config" | |
74 | + | let IdxCfgShareAssetId = 1 | |
75 | + | ||
76 | + | let IdxCfgInternalBaseAsset = 2 | |
77 | + | ||
78 | + | let IdxCfgDecimalsMultBothAssets = 3 | |
79 | + | ||
80 | + | let IdxCfgDecimalsMultPrice = 4 | |
81 | + | ||
82 | + | let IdxCfgGetDelayBlocks = 5 | |
83 | + | ||
84 | + | func dataAssetCfg (shareAssetStr,internalBaseAssetStr,decimalsMultBothAssets,decimalsMultPrice,getDelayInBlocks) = makeString(["%s%d%d%d%d", shareAssetStr, internalBaseAssetStr, toString(decimalsMultBothAssets), toString(decimalsMultPrice), toString(getDelayInBlocks)], SEP) | |
136 | 85 | ||
137 | 86 | ||
138 | - | func keyBoostingLockParamTotalAmount () = "%s%s__stats__activeTotalLocked" | |
87 | + | let IdxTotalLockedShare = 1 | |
88 | + | ||
89 | + | let IdxTotalLockedBase = 2 | |
90 | + | ||
91 | + | func dataTotalLocked (shareAssetAmount,baseAssetAmount) = makeString(["%d%d", toString(shareAssetAmount), toString(baseAssetAmount)], SEP) | |
139 | 92 | ||
140 | 93 | ||
141 | - | func keyBoostingStatsLocksDurationSumInBlocks () = "%s%s__stats__locksDurationSumInBlocks" | |
142 | - | ||
143 | - | ||
144 | - | func keyBoostingStatsLocksCount () = "%s%s__stats__locksCount" | |
145 | - | ||
146 | - | ||
147 | - | func keyBoostingStatsUsersCount () = "%s%s__stats__activeUsersCount" | |
148 | - | ||
149 | - | ||
150 | - | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", userAddress], SEP) | |
151 | - | ||
152 | - | ||
153 | - | func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP) | |
154 | - | ||
155 | - | ||
156 | - | func keyLockParamUserAmount (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "amount"], SEP) | |
157 | - | ||
158 | - | ||
159 | - | func keyLockParamStartBlock (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "start"], SEP) | |
160 | - | ||
161 | - | ||
162 | - | func keyLockParamDuration (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "duration"], SEP) | |
163 | - | ||
164 | - | ||
165 | - | func keyLockParamK (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "k"], SEP) | |
166 | - | ||
167 | - | ||
168 | - | func keyLockParamB (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "b"], SEP) | |
169 | - | ||
170 | - | ||
171 | - | func keyLockParamByPeriodK (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "k", period], SEP) | |
172 | - | ||
173 | - | ||
174 | - | func keyLockParamByPeriodB (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "b", period], SEP) | |
175 | - | ||
176 | - | ||
177 | - | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastInt", userNum], SEP) | |
178 | - | ||
179 | - | ||
180 | - | func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", userNum], SEP) | |
181 | - | ||
182 | - | ||
183 | - | func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total" | |
184 | - | ||
185 | - | ||
186 | - | func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", userNum], SEP) | |
187 | - | ||
188 | - | ||
189 | - | func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", userNum], SEP) | |
190 | - | ||
191 | - | ||
192 | - | func keyTotalCachedGwx () = "%s%s__gwxCached__total" | |
193 | - | ||
194 | - | ||
195 | - | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
196 | - | ||
197 | - | ||
198 | - | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
199 | - | ||
200 | - | ||
201 | - | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
202 | - | ||
203 | - | ||
204 | - | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) | |
205 | - | ||
206 | - | ||
207 | - | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) | |
208 | - | ||
209 | - | ||
210 | - | func readStaked (stakingDapp,key) = valueOrElse(getInteger(stakingDapp, key), 0) | |
211 | - | ||
212 | - | ||
213 | - | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
214 | - | ||
215 | - | ||
216 | - | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
217 | - | ||
218 | - | ||
219 | - | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
220 | - | ||
221 | - | ||
222 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
223 | - | ||
224 | - | ||
225 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
226 | - | ||
227 | - | ||
228 | - | func keyAddonAddr () = "%s__addonAddr" | |
229 | - | ||
230 | - | ||
231 | - | let factoryDapp = readFactoryAddressOrFail() | |
232 | - | ||
233 | - | let factoryCfg = readFactoryCfgOrFail(factoryDapp) | |
234 | - | ||
235 | - | let emissionDapp = getEmissionAddressOrFail(factoryCfg) | |
236 | - | ||
237 | - | let stakingDapp = getStakingAddressOrFail(factoryCfg) | |
238 | - | ||
239 | - | let gwxRewardDapp = getGwxRewardAddressOrFail(factoryCfg) | |
240 | - | ||
241 | - | let boostingDapp = getBoostingAddressOrFail(factoryCfg) | |
242 | - | ||
243 | - | func getPoolInFee (poolAddress) = { | |
244 | - | let @ = invoke(factoryDapp, "getInFeeREADONLY", [toString(poolAddress)], nil) | |
245 | - | if ($isInstanceOf(@, "Int")) | |
246 | - | then @ | |
247 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
94 | + | func readTotalLocked (key) = { | |
95 | + | let totalLockedArray = split(valueOrElse(getString(this, key), dataTotalLocked(0, 0)), SEP) | |
96 | + | [-1, parseIntValue(totalLockedArray[IdxTotalLockedShare]), parseIntValue(totalLockedArray[IdxTotalLockedBase])] | |
248 | 97 | } | |
249 | 98 | ||
250 | 99 | ||
251 | - | func getPoolOutFee (poolAddress) = { | |
252 | - | let @ = invoke(factoryDapp, "getOutFeeREADONLY", [toString(poolAddress)], nil) | |
253 | - | if ($isInstanceOf(@, "Int")) | |
254 | - | then @ | |
255 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
100 | + | func keyOperation (operationType,internalBaseAssetStr,userAddress,txId) = makeString(["%s%d%s%s", operationType, internalBaseAssetStr, userAddress, txId], SEP) | |
101 | + | ||
102 | + | ||
103 | + | let IdxOperStatus = 1 | |
104 | + | ||
105 | + | let IdxOperInAmount = 2 | |
106 | + | ||
107 | + | let IdxOperPrice = 3 | |
108 | + | ||
109 | + | let IdxOperOutAmount = 4 | |
110 | + | ||
111 | + | let IdxOperStartHeight = 5 | |
112 | + | ||
113 | + | let IdxOperStartTimestamp = 6 | |
114 | + | ||
115 | + | let IdxOperEndHeight = 7 | |
116 | + | ||
117 | + | let IdxOperEndTimestamp = 8 | |
118 | + | ||
119 | + | func privateDataOperationAllStrings (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = makeString(["%s%d%d%d%d%d%d%d", status, inAssetAmount, price, outAssetAmount, startHeight, startTimestamp, endHeight, endTimestamp], SEP) | |
120 | + | ||
121 | + | ||
122 | + | func dataOperation (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = privateDataOperationAllStrings(status, toString(inAssetAmount), toString(price), toString(outAssetAmount), toString(startHeight), toString(startTimestamp), toString(endHeight), toString(endTimestamp)) | |
123 | + | ||
124 | + | ||
125 | + | func dataOperationExecutionUpdate (currOperArray,newStatus,newEndTimestamp) = privateDataOperationAllStrings(newStatus, currOperArray[IdxOperInAmount], currOperArray[IdxOperPrice], currOperArray[IdxOperOutAmount], currOperArray[IdxOperStartHeight], currOperArray[IdxOperStartTimestamp], currOperArray[IdxOperEndHeight], toString(newEndTimestamp)) | |
126 | + | ||
127 | + | ||
128 | + | func readAssetCfgOrFail (baseAssetStr) = { | |
129 | + | let key = keyAssetCfg(baseAssetStr) | |
130 | + | split(getStringOrFail(key), SEP) | |
256 | 131 | } | |
257 | 132 | ||
258 | 133 | ||
259 | - | func internalCurrentRewardRate (lpAssetId) = { | |
260 | - | let poolAddressStr = getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAssetId)) | |
261 | - | let poolWeightMult = MULT8 | |
262 | - | let poolWeight = getIntegerValue(factoryDapp, keyFactoryPoolWeight(poolAddressStr)) | |
263 | - | let wxEmissionPerBlock = getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) | |
264 | - | let wxEmissionPerBlockMax = getIntOrFail(emissionDapp, keyEmissionRatePerBlockMaxCurrent()) | |
265 | - | let boostMaxCoeff = 3 | |
266 | - | let poolWxEmissionPerBlock = (fraction(wxEmissionPerBlock, poolWeight, poolWeightMult) / boostMaxCoeff) | |
267 | - | let poolWxEmissionPerBlockMax = fraction(wxEmissionPerBlockMax, poolWeight, poolWeightMult) | |
268 | - | let maxFactor = (boostMaxCoeff * MULT8) | |
269 | - | let totalLpStaked = getIntOrZero(stakingDapp, keyStakedTotal(lpAssetId)) | |
270 | - | [poolWxEmissionPerBlock, maxFactor, totalLpStaked] | |
134 | + | func incrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
135 | + | let dataArray = readTotalLocked(key) | |
136 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] + shareAssetAmount), (dataArray[IdxTotalLockedBase] + baseAssetAmount))) | |
271 | 137 | } | |
272 | 138 | ||
273 | 139 | ||
274 | - | func calcGwxAmountStartREADONLY (lockAmount,lockDuration,maxLockDuration) = { | |
275 | - | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
276 | - | let gWxAmountStart = fraction(lockAmount, coeffX8, MULT8) | |
277 | - | [gWxAmountStart] | |
140 | + | func decrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
141 | + | let dataArray = readTotalLocked(key) | |
142 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] - shareAssetAmount), (dataArray[IdxTotalLockedBase] - baseAssetAmount))) | |
278 | 143 | } | |
279 | - | ||
280 | - | ||
281 | - | func getKey (addr,key,type) = if ((type == "string")) | |
282 | - | then getStringValue(addr, key) | |
283 | - | else if ((type == "integer")) | |
284 | - | then toString(getIntegerValue(addr, key)) | |
285 | - | else if ((type == "boolean")) | |
286 | - | then toString(getBooleanValue(addr, key)) | |
287 | - | else throw("unknown type. expected string/integer/boolean") | |
288 | 144 | ||
289 | 145 | ||
290 | 146 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
291 | 147 | case s: String => | |
292 | 148 | fromBase58String(s) | |
293 | 149 | case _: Unit => | |
294 | 150 | unit | |
295 | 151 | case _ => | |
296 | 152 | throw("Match error") | |
297 | 153 | } | |
298 | 154 | ||
299 | 155 | ||
300 | 156 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
301 | 157 | case s: String => | |
302 | 158 | fromBase58String(s) | |
303 | 159 | case _: Unit => | |
304 | 160 | unit | |
305 | 161 | case _ => | |
306 | 162 | throw("Match error") | |
307 | 163 | } | |
308 | 164 | ||
309 | 165 | ||
166 | + | func balanceOrZero (assetId) = valueOrElse(getInteger(keyBalance(assetId)), 0) | |
167 | + | ||
168 | + | ||
169 | + | func calcPrice (internalBaseAssetStr,baseAssetId,topUpBaseAmount,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = { | |
170 | + | let totalLockedArray = readTotalLocked(keyTotalLocked(internalBaseAssetStr)) | |
171 | + | let totalLockedBaseAmount = totalLockedArray[IdxTotalLockedBase] | |
172 | + | let baseAssetBalance = balanceOrZero(toBase58String(baseAssetId)) | |
173 | + | let baseAssetBalanceConsideringLock = (baseAssetBalance + topUpBaseAmount) | |
174 | + | if ((0 > baseAssetBalanceConsideringLock)) | |
175 | + | then throw(((("baseAssetBalanceConsideringLock < 0: baseAssetBalance=" + toString(baseAssetBalance)) + " baseAssetBalanceConsideringLock=") + toString(baseAssetBalanceConsideringLock))) | |
176 | + | else { | |
177 | + | let shareEmission = value(assetInfo(shareAssetId)).quantity | |
178 | + | let price = if ((shareEmission == 0)) | |
179 | + | then (1 * decimalsMultPrice) | |
180 | + | else fraction(baseAssetBalanceConsideringLock, decimalsMultPrice, shareEmission) | |
181 | + | $Tuple5(price, baseAssetBalance, totalLockedBaseAmount, baseAssetBalanceConsideringLock, shareEmission) | |
182 | + | } | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func getPrice (internalBaseAssetStr,baseAssetId,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = { | |
187 | + | let totalLockedArray = readTotalLocked(keyTotalLocked(internalBaseAssetStr)) | |
188 | + | let totalLockedBaseAmount = totalLockedArray[IdxTotalLockedBase] | |
189 | + | let baseAssetBalance = balanceOrZero(toBase58String(baseAssetId)) | |
190 | + | let baseAssetBalanceConsideringLock = baseAssetBalance | |
191 | + | let shareEmission = value(assetInfo(shareAssetId)).quantity | |
192 | + | let price = value(getInteger(keyPriceLast(internalBaseAssetStr))) | |
193 | + | $Tuple5(price, baseAssetBalance, totalLockedBaseAmount, baseAssetBalanceConsideringLock, shareEmission) | |
194 | + | } | |
195 | + | ||
196 | + | ||
197 | + | func privateCurrentSysParamsREST (baseAssetStr) = { | |
198 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
199 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
200 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
201 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
202 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
203 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
204 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
205 | + | let sysState = getPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
206 | + | let topUpLastHeight = match getInteger(keyTopUpLastHeight(internalBaseAssetStr, getStringValue(keyProxyAddress(baseAssetStr)))) { | |
207 | + | case h: Int => | |
208 | + | value(h) | |
209 | + | case _: Unit => | |
210 | + | getIntegerValue(keyTopUpLastHeight(internalBaseAssetStr, toString(addressFromPublicKey(fromBase58String(getStringValue(keyManagerPublicKey())))))) | |
211 | + | case _ => | |
212 | + | throw("undefined behaviour in privateCurrentSysParamsREST match") | |
213 | + | } | |
214 | + | $Tuple8(IntegerEntry("price", sysState._1), IntegerEntry("decimalsMultPrice", decimalsMultPrice), IntegerEntry("baseAssetBalance", sysState._2), IntegerEntry("totalLockedBaseAmount", sysState._3), IntegerEntry("baseAssetBalanceConsideringLock", sysState._4), IntegerEntry("shareEmission", sysState._5), IntegerEntry("baseAssetDecimals", value(assetInfo(baseAssetId)).decimals), IntegerEntry("lastTopUpTimestamp", value(blockInfoByHeight(topUpLastHeight)).timestamp)) | |
215 | + | } | |
216 | + | ||
217 | + | ||
310 | 218 | func mustManager (i) = { | |
311 | - | let pd = throw(" | |
219 | + | let pd = throw("permission denied") | |
312 | 220 | match managerPublicKeyOrUnit() { | |
313 | 221 | case pk: ByteVector => | |
314 | 222 | if ((i.callerPublicKey == pk)) | |
315 | 223 | then true | |
316 | 224 | else pd | |
317 | 225 | case _: Unit => | |
318 | 226 | if ((i.caller == this)) | |
319 | 227 | then true | |
320 | 228 | else pd | |
321 | 229 | case _ => | |
322 | 230 | throw("Match error") | |
323 | 231 | } | |
324 | 232 | } | |
325 | 233 | ||
326 | 234 | ||
235 | + | func mustProxyAddress (i,assetId) = { | |
236 | + | let isProxy = (toString(i.caller) == valueOrElse(getString(keyProxyAddress(assetId)), EMPTY)) | |
237 | + | if (isProxy) | |
238 | + | then true | |
239 | + | else { | |
240 | + | let checkCaller = mustManager(i) | |
241 | + | if ((checkCaller == checkCaller)) | |
242 | + | then true | |
243 | + | else throw("Strict value is not equal to itself.") | |
244 | + | } | |
245 | + | } | |
246 | + | ||
247 | + | ||
327 | 248 | @Callable(i) | |
328 | - | func constructor ( | |
249 | + | func constructor (assetsStoreContract) = { | |
329 | 250 | let checkCaller = mustManager(i) | |
330 | 251 | if ((checkCaller == checkCaller)) | |
331 | - | then [StringEntry( | |
252 | + | then [StringEntry(keyAssetsStoreContract(), assetsStoreContract)] | |
332 | 253 | else throw("Strict value is not equal to itself.") | |
333 | 254 | } | |
334 | 255 | ||
335 | 256 | ||
336 | 257 | ||
337 | 258 | @Callable(i) | |
338 | - | func currentRewardRateREADONLY (lpAssetId) = { | |
339 | - | let rewardData = internalCurrentRewardRate(lpAssetId) | |
340 | - | let wxEmissionPerBlock = rewardData[0] | |
341 | - | let maxFactor = rewardData[1] | |
342 | - | let totalLpStaked = rewardData[2] | |
343 | - | $Tuple2(nil, makeString(["%d%d%d", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked)], SEP)) | |
259 | + | func adminRegisterAsset (baseAssetStr,shareAssetName,shareAssetDescr,shareAssetLogo,getDelayinBlocks,shutdownManagerAddress,proxyAddress) = { | |
260 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
261 | + | let decimals = value(assetInfo(baseAssetId)).decimals | |
262 | + | let check = mustManager(i) | |
263 | + | if ((check == check)) | |
264 | + | then if ((toString(addressFromStringValue(shutdownManagerAddress)) != shutdownManagerAddress)) | |
265 | + | then throw("invalid shutdownManagerAddress") | |
266 | + | else if ((0 > getDelayinBlocks)) | |
267 | + | then throw(("invalid getDelayinBlocks=" + toString(getDelayinBlocks))) | |
268 | + | else { | |
269 | + | let shareAssetIssueAction = Issue(shareAssetName, shareAssetDescr, 1, decimals, true) | |
270 | + | let shareAssetId = calculateAssetId(shareAssetIssueAction) | |
271 | + | let shareAssetStr = toBase58String(shareAssetId) | |
272 | + | let decimalsMultPrice = ((100 * 1000) * 1000) | |
273 | + | let decimalsMultBothAssets = pow(10, 0, decimals, 0, 0, DOWN) | |
274 | + | let startPrice = (1 * decimalsMultPrice) | |
275 | + | let internalBaseAssettId = valueOrElse(getInteger(this, keyNextInternalAssetId()), 0) | |
276 | + | let internalBaseAssetStr = toString(internalBaseAssettId) | |
277 | + | let createOrUpdate = invoke(assetsStoreContract(), "createOrUpdate", [shareAssetStr, shareAssetLogo, false], nil) | |
278 | + | if ((createOrUpdate == createOrUpdate)) | |
279 | + | then { | |
280 | + | let addLabel = invoke(assetsStoreContract(), "addLabel", [shareAssetStr, "STAKING_LP"], nil) | |
281 | + | if ((addLabel == addLabel)) | |
282 | + | then [StringEntry(keyAssetCfg(baseAssetStr), dataAssetCfg(shareAssetStr, internalBaseAssetStr, decimalsMultBothAssets, decimalsMultPrice, getDelayinBlocks)), StringEntry(keyMappingsInternal2baseAssetId(internalBaseAssettId), baseAssetStr), StringEntry(keyMappingsBaseAsset2internalId(baseAssetStr), internalBaseAssetStr), StringEntry(keyMappingsShare2baseAssetId(shareAssetStr), baseAssetStr), StringEntry(keyMappingsBaseAsset2shareId(baseAssetStr), shareAssetStr), BooleanEntry(keyShutdownPutOperation(internalBaseAssetStr), false), StringEntry(keyShutdownManager(internalBaseAssetStr), shutdownManagerAddress), IntegerEntry(keyNextInternalAssetId(), (internalBaseAssettId + 1)), IntegerEntry(keyPriceLast(internalBaseAssetStr), startPrice), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), startPrice), shareAssetIssueAction, Burn(shareAssetId, 1), StringEntry(keyProxyAddress(baseAssetStr), proxyAddress)] | |
283 | + | else throw("Strict value is not equal to itself.") | |
284 | + | } | |
285 | + | else throw("Strict value is not equal to itself.") | |
286 | + | } | |
287 | + | else throw("Strict value is not equal to itself.") | |
344 | 288 | } | |
345 | 289 | ||
346 | 290 | ||
347 | 291 | ||
348 | 292 | @Callable(i) | |
349 | - | func currentUserRewardRateREADONLY (lpAssetId,userAddress) = { | |
350 | - | let rewardData = internalCurrentRewardRate(lpAssetId) | |
351 | - | let wxEmissionPerBlock = rewardData[0] | |
352 | - | let maxFactor = rewardData[1] | |
353 | - | let totalLpStaked = rewardData[2] | |
354 | - | let lpStakedByUser = getIntOrZero(stakingDapp, keyStakedByUser(userAddress, lpAssetId)) | |
355 | - | let userClaimInfo = split(asString(invoke(stakingDapp, "claimWxREADONLY", [lpAssetId, userAddress], nil)), SEP) | |
356 | - | let minRewardPart = valueOrErrorMessage(parseInt(userClaimInfo[5]), "couldn't parse minRewardPart") | |
357 | - | let boostRewardPart = valueOrErrorMessage(parseInt(userClaimInfo[6]), "couldn't parse boostRewardPart") | |
358 | - | let debug = userClaimInfo[7] | |
359 | - | let boostingPower = if ((boostRewardPart == 0)) | |
360 | - | then (1 * MULT8) | |
361 | - | else fraction((minRewardPart + boostRewardPart), MULT8, minRewardPart) | |
362 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%s", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked), toString(lpStakedByUser), toString(boostingPower), debug], SEP)) | |
293 | + | func shutdownPut (internalBaseAssetId) = { | |
294 | + | let internalBaseAssetIdStr = toString(internalBaseAssetId) | |
295 | + | let baseAssetIdStr = getStringOrFail(keyMappingsInternal2baseAssetId(internalBaseAssetId)) | |
296 | + | let shutdownManagerAddress = getStringOrFail(keyShutdownManager(internalBaseAssetIdStr)) | |
297 | + | if ((1 > size(baseAssetIdStr))) | |
298 | + | then throw("invalid internalBaseAssetId") | |
299 | + | else if ((toString(i.caller) != shutdownManagerAddress)) | |
300 | + | then throw("access denied") | |
301 | + | else [BooleanEntry(keyShutdownPutOperation(toString(internalBaseAssetId)), true)] | |
363 | 302 | } | |
364 | 303 | ||
365 | 304 | ||
366 | 305 | ||
367 | 306 | @Callable(i) | |
368 | - | func calcBoostBulkInternalREADONLY (currentIter,deltaWxAmountBulk,deltaLockPeriodInBlocksBulk,deltaLpAmountBulk,lpAssetIdOptBulk,userAddressOpt,resAcc) = if ((currentIter == size(deltaWxAmountBulk))) | |
369 | - | then $Tuple2(nil, resAcc) | |
370 | - | else { | |
371 | - | let deltaWxAmount = deltaWxAmountBulk[currentIter] | |
372 | - | let deltaLockPeriodInBlocks = deltaLockPeriodInBlocksBulk[currentIter] | |
373 | - | let deltaLpAmount = deltaLpAmountBulk[currentIter] | |
374 | - | let lpAssetIdOpt = lpAssetIdOptBulk[currentIter] | |
375 | - | let info = { | |
376 | - | let @ = invoke(this, "calcBoostREADONLY", [deltaWxAmount, deltaLockPeriodInBlocks, deltaLpAmount, lpAssetIdOpt, userAddressOpt], nil) | |
377 | - | if ($isInstanceOf(@, "String")) | |
378 | - | then @ | |
379 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
380 | - | } | |
381 | - | let res = (resAcc :+ info) | |
382 | - | let inv = { | |
383 | - | let @ = invoke(this, "calcBoostBulkInternalREADONLY", [(currentIter + 1), deltaWxAmountBulk, deltaLockPeriodInBlocksBulk, deltaLpAmountBulk, lpAssetIdOptBulk, userAddressOpt, res], nil) | |
384 | - | if ($isInstanceOf(@, "List[Any]")) | |
385 | - | then @ | |
386 | - | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
387 | - | } | |
388 | - | if ((inv == inv)) | |
389 | - | then $Tuple2(nil, inv) | |
390 | - | else throw("Strict value is not equal to itself.") | |
391 | - | } | |
392 | - | ||
393 | - | ||
394 | - | ||
395 | - | @Callable(i) | |
396 | - | func calcBoostBulkREADONLY (deltaWxAmount,deltaLockPeriodInBlocks,deltaLpAmount,lpAssetIdOpt,userAddressOpt) = { | |
397 | - | let res = invoke(this, "calcBoostBulkInternalREADONLY", [0, deltaWxAmount, deltaLockPeriodInBlocks, deltaLpAmount, lpAssetIdOpt, userAddressOpt, nil], nil) | |
398 | - | $Tuple2(nil, res) | |
399 | - | } | |
400 | - | ||
401 | - | ||
402 | - | ||
403 | - | @Callable(i) | |
404 | - | func calcBoostREADONLY (deltaWxAmount,deltaLockPeriodInBlocks,deltaLpAmount,lpAssetIdOpt,userAddressOpt) = { | |
405 | - | let mathDapp = gwxRewardDapp | |
406 | - | let EMPTYSTR = "empty" | |
407 | - | let maxLockDurationInBlocks = parseIntValue(split(getStringByAddressOrFail(boostingDapp, keyBoostCfg()), SEP)[4]) | |
408 | - | let lpAssetIdStr = if ((lpAssetIdOpt == "")) | |
409 | - | then EMPTYSTR | |
410 | - | else lpAssetIdOpt | |
411 | - | let userAddressStr = if ((userAddressOpt == "")) | |
412 | - | then EMPTYSTR | |
413 | - | else userAddressOpt | |
414 | - | let userNumStr = valueOrElse(getString(boostingDapp, keyUser2NumMapping(userAddressOpt)), EMPTYSTR) | |
415 | - | let userAmount = valueOrElse(getInteger(boostingDapp, keyLockParamUserAmount(userNumStr)), 0) | |
416 | - | let lockStart = valueOrElse(getInteger(boostingDapp, keyLockParamStartBlock(userNumStr)), height) | |
417 | - | let lockDuration = valueOrElse(getInteger(boostingDapp, keyLockParamDuration(userNumStr)), 0) | |
418 | - | let lockEnd = (lockStart + lockDuration) | |
419 | - | let remainingDuration = max([(lockEnd - height), 0]) | |
420 | - | let userAmountNew = (userAmount + deltaWxAmount) | |
421 | - | let lockDurationNew = min([(remainingDuration + deltaLockPeriodInBlocks), maxLockDurationInBlocks]) | |
422 | - | let userCurrgWxAmount = asInt(asAnyList(invoke(boostingDapp, "gwxUserInfoREADONLY", [userAddressStr], nil))[0]) | |
423 | - | let gWxAmountStartNew = calcGwxAmountStartREADONLY(userAmountNew, lockDurationNew, maxLockDurationInBlocks)[0] | |
424 | - | let gWxParamsResultList = asAnyList(invoke(mathDapp, "calcGwxParamsREADONLY", [gWxAmountStartNew, height, lockDurationNew], nil)) | |
425 | - | let gWxAmountDiff = (gWxAmountStartNew - userCurrgWxAmount) | |
426 | - | let k = asInt(gWxParamsResultList[0]) | |
427 | - | let b = asInt(gWxParamsResultList[1]) | |
428 | - | let period = toString(asInt(gWxParamsResultList[2])) | |
429 | - | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
430 | - | let userMaxBoostIntNew = ((gWxAmountStartNew * lockDurationNew) / 2) | |
431 | - | let totalMaxBoostInt = getIntOrZero(boostingDapp, totalMaxBoostIntegralKEY) | |
432 | - | let totalCachedGwx = { | |
433 | - | let @ = invoke(boostingDapp, "getTotalCachedGwxREADONLY", nil, nil) | |
434 | - | if ($isInstanceOf(@, "Int")) | |
435 | - | then @ | |
436 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
437 | - | } | |
438 | - | let MULT3 = 1000 | |
439 | - | let wxEmissionPerBlockX3 = (getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) * MULT3) | |
440 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
441 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
442 | - | let stakedByUser = readStaked(stakingDapp, stakedByUserKEY) | |
443 | - | let stakedTotal = readStaked(stakingDapp, stakedTotalKEY) | |
444 | - | let stakedByUserNew = (stakedByUser + deltaLpAmount) | |
445 | - | let stakedTotalNew = (stakedTotal + deltaLpAmount) | |
446 | - | let poolWeight = if ((lpAssetIdStr != EMPTYSTR)) | |
447 | - | then { | |
448 | - | let poolAddressStr = valueOrErrorMessage(getString(factoryDapp, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
449 | - | getIntegerValue(factoryDapp, keyFactoryPoolWeight(poolAddressStr)) | |
450 | - | } | |
451 | - | else 0 | |
452 | - | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * 3)) | |
453 | - | let wxPerLpX3 = if ((stakedTotalNew != 0)) | |
454 | - | then fraction(poolWxEmissionPerBlockX3, MULT8, stakedTotalNew) | |
455 | - | else 0 | |
456 | - | let userWxPerBlockX3 = fraction(wxPerLpX3, stakedByUserNew, MULT8) | |
457 | - | let boostEmissionPerBlockX3 = (poolWxEmissionPerBlockX3 * 2) | |
458 | - | let tmpUserBoostPerBlockX3 = fraction(gWxAmountStartNew, boostEmissionPerBlockX3, (totalCachedGwx + gWxAmountDiff)) | |
459 | - | let userBoostPerBlockX3 = min([tmpUserBoostPerBlockX3, (userWxPerBlockX3 * 2)]) | |
460 | - | let boostCoeff = if ((userWxPerBlockX3 == 0)) | |
461 | - | then (1 * MULT8) | |
462 | - | else fraction((userBoostPerBlockX3 + userWxPerBlockX3), MULT8, userWxPerBlockX3) | |
463 | - | $Tuple2(nil, makeString(["%d%d%s", toString(gWxAmountStartNew), toString(boostCoeff), "d"], SEP)) | |
464 | - | } | |
465 | - | ||
466 | - | ||
467 | - | ||
468 | - | @Callable(i) | |
469 | - | func wxEmissionStatsREADONLY () = { | |
470 | - | let ONEMULT = toString(MULT8) | |
471 | - | let ONE = "1" | |
472 | - | let wxEmissionPerBlock = getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) | |
473 | - | let emissionStartBlock = getIntOrFail(emissionDapp, keyEmissionStartBlock()) | |
474 | - | let passedBlocks = if ((emissionStartBlock > height)) | |
475 | - | then 0 | |
476 | - | else (height - emissionStartBlock) | |
477 | - | let teamEmDuration = (1440 * 365) | |
478 | - | let teamEmMax = (201000000 * MULT8) | |
479 | - | let teamEm = if ((passedBlocks > teamEmDuration)) | |
480 | - | then teamEmMax | |
481 | - | else fraction(teamEmMax, passedBlocks, teamEmDuration) | |
482 | - | let totalWxReleased = ((wxEmissionPerBlock * passedBlocks) + teamEm) | |
483 | - | let totalWxLocked = getIntOrZero(boostingDapp, keyBoostingLockParamTotalAmount()) | |
484 | - | let locksDurationSumInBlocks = getIntOrZero(boostingDapp, keyBoostingStatsLocksDurationSumInBlocks()) | |
485 | - | let locksCount = getIntOrZero(boostingDapp, keyBoostingStatsLocksCount()) | |
486 | - | $Tuple2(nil, makeString(["%d%d%d%d", toString(totalWxReleased), toString(totalWxLocked), toString(locksDurationSumInBlocks), toString(locksCount)], SEP)) | |
487 | - | } | |
488 | - | ||
489 | - | ||
490 | - | ||
491 | - | @Callable(i) | |
492 | - | func poolStatsREADONLY (lpAsset) = { | |
493 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) | |
494 | - | let status = { | |
495 | - | let @ = invoke(factoryDapp, "getPoolStatusREADONLY", [toString(poolAddress)], nil) | |
496 | - | if ($isInstanceOf(@, "Int")) | |
497 | - | then @ | |
498 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
499 | - | } | |
500 | - | let tpl = "%d%d%d%d%d%d%d%d%d%s" | |
501 | - | if ((status == 4)) | |
502 | - | then $Tuple2(nil, makeString([tpl, toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(0), toString(false)], SEP)) | |
307 | + | func put () = { | |
308 | + | let pmt = value(i.payments[0]) | |
309 | + | let baseAssetId = value(pmt.assetId) | |
310 | + | let baseAssetStr = toBase58String(baseAssetId) | |
311 | + | let userAddressStr = toString(i.caller) | |
312 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
313 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
314 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
315 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
316 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
317 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
318 | + | let isPutBlocked = getBooleanOrFail(keyShutdownPutOperation(internalBaseAssetStr)) | |
319 | + | if (isPutBlocked) | |
320 | + | then throw("put operation is blocked") | |
503 | 321 | else { | |
504 | - | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) | |
505 | - | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) | |
506 | - | let amtAssetId = asString(cfg[idxAmtAssetId]) | |
507 | - | let priceAssetId = asString(cfg[idxPriceAssetId]) | |
508 | - | let iAmtAssetId = asString(cfg[idxIAmtAssetId]) | |
509 | - | let iPriceAssetId = asString(cfg[idxIPriceAssetId]) | |
510 | - | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) | |
511 | - | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) | |
512 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
513 | - | let accAmtAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amtAssetId], nil)) | |
514 | - | let accPriceAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [priceAssetId], nil)) | |
515 | - | let pricesList = if ((poolLPBalance == 0)) | |
516 | - | then [toString(zeroBigInt), toString(zeroBigInt), toString(zeroBigInt)] | |
517 | - | else asAnyList(invoke(poolAddress, "calcPricesWrapperREADONLY", [accAmtAssetBalance, accPriceAssetBalance, poolLPBalance], nil)) | |
518 | - | let curPrice = 0 | |
519 | - | let lpAmtAssetShare = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [pricesList[1], MULT8], nil)) | |
520 | - | let lpPriceAssetShare = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [pricesList[2], MULT8], nil)) | |
521 | - | let poolWeight = getIntegerValue(factoryDapp, keyFactoryPoolWeight(toString(poolAddress))) | |
522 | - | let inFee = getPoolInFee(poolAddress) | |
523 | - | let outFee = getPoolOutFee(poolAddress) | |
524 | - | let poolOneTokenOperationsDisabled = { | |
525 | - | let @ = invoke(factoryDapp, "isPoolOneTokenOperationsDisabledREADONLY", [toString(poolAddress)], nil) | |
526 | - | if ($isInstanceOf(@, "Boolean")) | |
527 | - | then @ | |
528 | - | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
529 | - | } | |
530 | - | let poolOneTokenOperationsEnabled = !(poolOneTokenOperationsDisabled) | |
531 | - | $Tuple2(nil, makeString([tpl, toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight), toString(inFee), toString(outFee), toString(poolOneTokenOperationsEnabled)], SEP)) | |
322 | + | let newBalance = (balanceOrZero(baseAssetStr) + pmt.amount) | |
323 | + | let price = getPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
324 | + | let shareAssetAmount = fraction(pmt.amount, decimalsMultPrice, price, CEILING) | |
325 | + | [Reissue(shareAssetId, shareAssetAmount, true), ScriptTransfer(i.caller, shareAssetAmount, shareAssetId), StringEntry(keyOperation("P", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)), dataOperation("FINISHED", pmt.amount, price, shareAssetAmount, height, lastBlock.timestamp, height, lastBlock.timestamp)), ScriptTransfer(addressFromStringValue(value(getString(keyProxyAddress(baseAssetStr)))), pmt.amount, baseAssetId), IntegerEntry(keyBalance(baseAssetStr), newBalance)] | |
532 | 326 | } | |
533 | 327 | } | |
534 | 328 | ||
535 | 329 | ||
536 | 330 | ||
537 | 331 | @Callable(i) | |
538 | - | func poolEvaluatePutByAmountAssetREADONLY (lpAsset,inAmAssetAmt) = { | |
539 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) | |
540 | - | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) | |
541 | - | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) | |
542 | - | let amAssetIdStr = asString(cfg[idxAmtAssetId]) | |
543 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
544 | - | let prAssetIdStr = asString(cfg[idxPriceAssetId]) | |
545 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
546 | - | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) | |
547 | - | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) | |
548 | - | let poolStatus = asString(cfg[idxPoolStatus]) | |
549 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
550 | - | let accAmtAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amAssetIdStr], nil)) | |
551 | - | let accPriceAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [prAssetIdStr], nil)) | |
552 | - | let amtAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [accAmtAssetBalance, amtAssetDcm], nil))) | |
553 | - | let priceAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [accPriceAssetBalance, priceAssetDcm], nil))) | |
554 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
555 | - | then zeroBigInt | |
556 | - | else parseBigIntValue(asString(invoke(poolAddress, "calcPriceBigIntWrapperREADONLY", [toString(priceAssetAmtX18), toString(amtAssetAmtX18)], nil))) | |
557 | - | let curPrice = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(curPriceX18), MULT8], nil)) | |
558 | - | let inAmAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [inAmAssetAmt, amtAssetDcm], nil))) | |
559 | - | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, MULT18) | |
560 | - | let inPrAssetAmt = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(inPrAssetAmtX18), priceAssetDcm], nil)) | |
561 | - | let res = invoke(poolAddress, "estimatePutOperationWrapperREADONLY", ["", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false], nil) | |
562 | - | let $t02384624210 = match res { | |
563 | - | case _ => | |
564 | - | if (if (if ($isInstanceOf($match0._1, "Int")) | |
565 | - | then if ($isInstanceOf($match0._3, "Int")) | |
566 | - | then if ($isInstanceOf($match0._4, "Int")) | |
567 | - | then if ($isInstanceOf($match0._5, "Int")) | |
568 | - | then $isInstanceOf($match0._6, "Int") | |
569 | - | else false | |
570 | - | else false | |
571 | - | else false | |
572 | - | else false) | |
573 | - | then (size($match0) == 13) | |
574 | - | else false) | |
575 | - | then { | |
576 | - | let calcLpAmt = $match0._1 | |
577 | - | let curPriceCalc = $match0._3 | |
578 | - | let amBalance = $match0._4 | |
579 | - | let prBalance = $match0._5 | |
580 | - | let lpEmission = $match0._6 | |
581 | - | $Tuple5(calcLpAmt, curPriceCalc, amBalance, prBalance, lpEmission) | |
582 | - | } | |
583 | - | else throw("Couldn't cast types") | |
584 | - | } | |
585 | - | let calcLpAmt = $t02384624210._1 | |
586 | - | let curPriceCalc = $t02384624210._2 | |
587 | - | let amBalance = $t02384624210._3 | |
588 | - | let prBalance = $t02384624210._4 | |
589 | - | let lpEmission = $t02384624210._5 | |
590 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(curPrice), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
332 | + | func submitGetRequest () = { | |
333 | + | let pmt = value(i.payments[0]) | |
334 | + | let shareAssetId = value(pmt.assetId) | |
335 | + | let shareAssetStr = toBase58String(shareAssetId) | |
336 | + | let callerPubStr = toBase58String(i.callerPublicKey) | |
337 | + | let userAddress = i.caller | |
338 | + | let userAddressStr = toString(userAddress) | |
339 | + | let shareAssetAmount = pmt.amount | |
340 | + | let baseAssetStr = getStringOrFail(keyMappingsShare2baseAssetId(shareAssetStr)) | |
341 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
342 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
343 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
344 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
345 | + | let getDelayBlocks = parseIntValue(cfgArray[IdxCfgGetDelayBlocks]) | |
346 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
347 | + | let price = getPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
348 | + | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
349 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
350 | + | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
351 | + | [Burn(shareAssetId, shareAssetAmount), StringEntry(operationKey, operationData), incrementTotalLocked(keyTotalLocked(internalBaseAssetStr), shareAssetAmount, baseAssetAmount), incrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), shareAssetAmount, baseAssetAmount), IntegerEntry(keyBalance(baseAssetStr), (balanceOrZero(baseAssetStr) - baseAssetAmount))] | |
591 | 352 | } | |
592 | 353 | ||
593 | 354 | ||
594 | 355 | ||
595 | 356 | @Callable(i) | |
596 | - | func poolEvaluatePutByPriceAssetREADONLY (lpAsset,inPrAssetAmt) = { | |
597 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) | |
598 | - | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) | |
599 | - | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) | |
600 | - | let amAssetIdStr = asString(cfg[idxAmtAssetId]) | |
601 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
602 | - | let prAssetIdStr = asString(cfg[idxPriceAssetId]) | |
603 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
604 | - | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) | |
605 | - | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) | |
606 | - | let poolStatus = asString(cfg[idxPoolStatus]) | |
607 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
608 | - | let amBalanceRaw = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amAssetIdStr], nil)) | |
609 | - | let prBalanceRaw = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [prAssetIdStr], nil)) | |
610 | - | let amBalanceRawX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [amBalanceRaw, amtAssetDcm], nil))) | |
611 | - | let prBalanceRawX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [prBalanceRaw, priceAssetDcm], nil))) | |
612 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
613 | - | then zeroBigInt | |
614 | - | else parseBigIntValue(asString(invoke(poolAddress, "calcPriceBigIntWrapperREADONLY", [toString(prBalanceRawX18), toString(amBalanceRawX18)], nil))) | |
615 | - | let curPrice = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(curPriceX18), MULT8], nil)) | |
616 | - | let inPrAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [inPrAssetAmt, priceAssetDcm], nil))) | |
617 | - | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, MULT18, curPriceX18) | |
618 | - | let inAmAssetAmt = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(inAmAssetAmtX18), amtAssetDcm], nil)) | |
619 | - | let res = invoke(poolAddress, "estimatePutOperationWrapperREADONLY", ["", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false], nil) | |
620 | - | let $t02684227206 = match res { | |
621 | - | case _ => | |
622 | - | if (if (if ($isInstanceOf($match0._1, "Int")) | |
623 | - | then if ($isInstanceOf($match0._3, "Int")) | |
624 | - | then if ($isInstanceOf($match0._4, "Int")) | |
625 | - | then if ($isInstanceOf($match0._5, "Int")) | |
626 | - | then $isInstanceOf($match0._6, "Int") | |
627 | - | else false | |
628 | - | else false | |
629 | - | else false | |
630 | - | else false) | |
631 | - | then (size($match0) == 13) | |
632 | - | else false) | |
633 | - | then { | |
634 | - | let calcLpAmt = $match0._1 | |
635 | - | let curPriceCalc = $match0._3 | |
636 | - | let amBalance = $match0._4 | |
637 | - | let prBalance = $match0._5 | |
638 | - | let lpEmission = $match0._6 | |
639 | - | $Tuple5(calcLpAmt, curPriceCalc, amBalance, prBalance, lpEmission) | |
640 | - | } | |
641 | - | else throw("Couldn't cast types") | |
642 | - | } | |
643 | - | let calcLpAmt = $t02684227206._1 | |
644 | - | let curPriceCalc = $t02684227206._2 | |
645 | - | let amBalance = $t02684227206._3 | |
646 | - | let prBalance = $t02684227206._4 | |
647 | - | let lpEmission = $t02684227206._5 | |
648 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(curPrice), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
357 | + | func executeGetRequest (baseAssetStr,userAddressStr,getTxIdStr) = { | |
358 | + | let userAddress = addressFromStringValue(userAddressStr) | |
359 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
360 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
361 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
362 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
363 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
364 | + | let operationArray = split(getStringOrFail(operationKey), SEP) | |
365 | + | let status = operationArray[IdxOperStatus] | |
366 | + | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
367 | + | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
368 | + | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
369 | + | if ((status != "PENDING")) | |
370 | + | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
371 | + | else if ((endHeight > height)) | |
372 | + | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
373 | + | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount)] | |
649 | 374 | } | |
650 | 375 | ||
651 | 376 | ||
652 | 377 | ||
653 | 378 | @Callable(i) | |
654 | - | func poolEvaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
655 | - | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(paymentLpAssetId))) | |
656 | - | let res = invoke(poolAddress, "estimateGetOperationWrapperREADONLY", ["", paymentLpAssetId, paymentLpAmt, toString(poolAddress)], nil) | |
657 | - | let $t02793028360 = match res { | |
658 | - | case _ => | |
659 | - | if (if (if ($isInstanceOf($match0._1, "Int")) | |
660 | - | then if ($isInstanceOf($match0._2, "Int")) | |
661 | - | then if ($isInstanceOf($match0._5, "Int")) | |
662 | - | then if ($isInstanceOf($match0._6, "Int")) | |
663 | - | then if ($isInstanceOf($match0._7, "Int")) | |
664 | - | then if ($isInstanceOf($match0._8, "String")) | |
665 | - | then $isInstanceOf($match0._9, "String") | |
666 | - | else false | |
667 | - | else false | |
668 | - | else false | |
669 | - | else false | |
670 | - | else false | |
671 | - | else false) | |
672 | - | then (size($match0) == 10) | |
673 | - | else false) | |
674 | - | then { | |
675 | - | let outAmAmt = $match0._1 | |
676 | - | let outPrAmt = $match0._2 | |
677 | - | let amBalance = $match0._5 | |
678 | - | let prBalance = $match0._6 | |
679 | - | let lpEmission = $match0._7 | |
680 | - | let curPrice = $match0._8 | |
681 | - | let poolStatus = $match0._9 | |
682 | - | $Tuple7(outAmAmt, outPrAmt, amBalance, prBalance, lpEmission, curPrice, poolStatus) | |
379 | + | func topUpBalance (baseAssetStr,delta) = { | |
380 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
381 | + | let pmt = value(i.payments[0]) | |
382 | + | let pmtAssetId = value(pmt.assetId) | |
383 | + | let pmtAssetStr = toBase58String(pmtAssetId) | |
384 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
385 | + | let decimalsMultBothAssets = parseIntValue(assetCfgArray[IdxCfgDecimalsMultBothAssets]) | |
386 | + | let decimalsMultPrice = parseIntValue(assetCfgArray[IdxCfgDecimalsMultPrice]) | |
387 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
388 | + | let topUpLastHeightKEY = keyTopUpLastHeight(internalBaseAssetStr, toString(i.caller)) | |
389 | + | let topUpLastHeight = valueOrElse(getInteger(this, topUpLastHeightKEY), 0) | |
390 | + | let checks = [mustProxyAddress(i, baseAssetStr), if ((topUpLastHeight != height)) | |
391 | + | then true | |
392 | + | else throw("only one topUp per block is allowed"), if ((delta > 0)) | |
393 | + | then true | |
394 | + | else throw("only positive delta is allowed")] | |
395 | + | if ((checks == checks)) | |
396 | + | then if ((baseAssetStr != pmtAssetStr)) | |
397 | + | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
398 | + | else if ((size(i.payments) > 1)) | |
399 | + | then throw("only one payment can be attached") | |
400 | + | else { | |
401 | + | let price = calcPrice(internalBaseAssetStr, pmtAssetId, delta, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
402 | + | [IntegerEntry(keyPriceLast(internalBaseAssetStr), price), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), price), IntegerEntry(topUpLastHeightKEY, height), IntegerEntry(keyBalance(pmtAssetStr), (balanceOrZero(pmtAssetStr) + delta))] | |
683 | 403 | } | |
684 | - | else throw("Couldn't cast types") | |
685 | - | } | |
686 | - | let outAmAmt = $t02793028360._1 | |
687 | - | let outPrAmt = $t02793028360._2 | |
688 | - | let amBalance = $t02793028360._3 | |
689 | - | let prBalance = $t02793028360._4 | |
690 | - | let lpEmission = $t02793028360._5 | |
691 | - | let curPrice = $t02793028360._6 | |
692 | - | let poolStatus = $t02793028360._7 | |
693 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), curPrice, poolStatus], SEP)) | |
694 | - | } | |
695 | - | ||
696 | - | ||
697 | - | ||
698 | - | @Callable(i) | |
699 | - | func gwxUserInfoREADONLY (userAddress) = { | |
700 | - | let gwxUserInfoLIST = asAnyList(invoke(boostingDapp, "gwxUserInfoREADONLY", [userAddress], nil)) | |
701 | - | let gwxAmount = asInt(gwxUserInfoLIST[0]) | |
702 | - | $Tuple2(nil, makeString(["%d", toString(gwxAmount)], SEP)) | |
703 | - | } | |
704 | - | ||
705 | - | ||
706 | - | ||
707 | - | @Callable(i) | |
708 | - | func unstakeAndGetOneTknV2 (poolAddress,unstakeAmount,outAssetId,minOutAmount) = { | |
709 | - | let inv = invoke(addressFromStringValue(poolAddress), "unstakeAndGetOneTknV2", [unstakeAmount, outAssetId, minOutAmount], nil) | |
710 | - | if ((inv == inv)) | |
711 | - | then $Tuple2(nil, unit) | |
712 | 404 | else throw("Strict value is not equal to itself.") | |
713 | 405 | } | |
714 | 406 | ||
715 | 407 | ||
716 | 408 | ||
717 | 409 | @Callable(i) | |
718 | - | func getKeysBulkInternal (currentIter,keys,resAcc) = if ((currentIter == size(keys))) | |
719 | - | then $Tuple2(nil, resAcc) | |
720 | - | else { | |
721 | - | let k = split(keys[currentIter], "++") | |
722 | - | let addr = addressFromStringValue(k[0]) | |
723 | - | let key = k[1] | |
724 | - | let type = k[2] | |
725 | - | let val = getKey(addr, key, type) | |
726 | - | let res = (resAcc :+ val) | |
727 | - | let inv = invoke(this, "getKeysBulkInternal", [(currentIter + 1), keys, res], nil) | |
728 | - | if ((inv == inv)) | |
729 | - | then $Tuple2(nil, inv) | |
730 | - | else throw("Strict value is not equal to itself.") | |
731 | - | } | |
732 | - | ||
733 | - | ||
734 | - | ||
735 | - | @Callable(i) | |
736 | - | func getKeysBulk (keys) = { | |
737 | - | let res = invoke(this, "getKeysBulkInternal", [0, keys, nil], nil) | |
738 | - | $Tuple2(nil, res) | |
410 | + | func currentSysParamsREST (baseAssetStr) = { | |
411 | + | let sysStateTuple = privateCurrentSysParamsREST(baseAssetStr) | |
412 | + | let price = sysStateTuple._1.value | |
413 | + | let decimalsMultPrice = sysStateTuple._2.value | |
414 | + | let baseAssetBalance = sysStateTuple._3.value | |
415 | + | let totalLockedBaseAmount = sysStateTuple._4.value | |
416 | + | let baseAssetBalanceConsideringLock = sysStateTuple._5.value | |
417 | + | let shareEmission = sysStateTuple._6.value | |
418 | + | let restData = makeString(["startCurrentSysParamsREST", toString(price), toString(decimalsMultPrice), toString(baseAssetBalance), toString(totalLockedBaseAmount), toString(baseAssetBalanceConsideringLock), toString(shareEmission), "endCurrentSysParamsREST"], SEP) | |
419 | + | throw(restData) | |
739 | 420 | } | |
740 | 421 | ||
741 | 422 | ||
742 | 423 | ||
743 | 424 | @Callable(i) | |
744 | 425 | func setManager (pendingManagerPublicKey) = { | |
745 | 426 | let checkCaller = mustManager(i) | |
746 | 427 | if ((checkCaller == checkCaller)) | |
747 | 428 | then { | |
748 | 429 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
749 | 430 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
750 | 431 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
751 | 432 | else throw("Strict value is not equal to itself.") | |
752 | 433 | } | |
753 | 434 | else throw("Strict value is not equal to itself.") | |
754 | 435 | } | |
755 | 436 | ||
756 | 437 | ||
757 | 438 | ||
758 | 439 | @Callable(i) | |
759 | 440 | func confirmManager () = { | |
760 | 441 | let pm = pendingManagerPublicKeyOrUnit() | |
761 | 442 | let hasPM = if (isDefined(pm)) | |
762 | 443 | then true | |
763 | - | else throw(" | |
444 | + | else throw("no pending manager") | |
764 | 445 | if ((hasPM == hasPM)) | |
765 | 446 | then { | |
766 | 447 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
767 | 448 | then true | |
768 | - | else throw(" | |
449 | + | else throw("you are not pending manager") | |
769 | 450 | if ((checkPM == checkPM)) | |
770 | 451 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
771 | 452 | else throw("Strict value is not equal to itself.") | |
772 | 453 | } | |
773 | 454 | else throw("Strict value is not equal to itself.") | |
774 | 455 | } | |
775 | 456 | ||
776 | 457 | ||
777 | 458 | @Verifier(tx) | |
778 | 459 | func verify () = { | |
779 | 460 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
780 | 461 | case pk: ByteVector => | |
781 | 462 | pk | |
782 | 463 | case _: Unit => | |
783 | 464 | tx.senderPublicKey | |
784 | 465 | case _ => | |
785 | 466 | throw("Match error") | |
786 | 467 | } | |
787 | 468 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
788 | 469 | } | |
789 | 470 |
github/deemru/w8io/026f985 122.37 ms ◑