tx · 3agbDC377kX4quSvwhKBdkGyNhmoELSL3e5RKm5SXGcd 3N3PoX8z2Mvu5YbaqZmtyF3dRFjqvhRkB3M: -0.01400000 Waves 2022.03.10 17:16 [1957954] smart account 3N3PoX8z2Mvu5YbaqZmtyF3dRFjqvhRkB3M > SELF 0.00000000 Waves
{ "type": 13, "id": "3agbDC377kX4quSvwhKBdkGyNhmoELSL3e5RKm5SXGcd", "fee": 1400000, "feeAssetId": null, "timestamp": 1646921769962, "version": 2, "chainId": 84, "sender": "3N3PoX8z2Mvu5YbaqZmtyF3dRFjqvhRkB3M", "senderPublicKey": "FWZMxrtn6KRrWMPXmQPqDg5eRzwB2YvHhMjMJpwnLmBi", "proofs": [ "2QYQTLTXyVJX2RLLcburNmNNvfDpu7MbngNjE1bLmToqYtTbAe8pTe8DvB7X4oiRQAD5WPoLaNYjxC8vK8rSVLJu" ], "script": "base64:AAIFAAAAAAAAACIIAhIJCgcBAQEBAQgBEgASBAoCCAgSBAoCCAgSAwoBCBIAAAAALwEAAAAPZ2V0U3RyaW5nT3JGYWlsAAAAAQAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABCIAAAABBQAAAANrZXkJAAEsAAAAAgkAASwAAAACAgAAAA9tYW5kYXRvcnkgdGhpcy4FAAAAA2tleQIAAAAPIGlzIG5vdCBkZWZpbmVkAAAAAANTRVACAAAAAl9fAAAAAAhCVUZTQ0FMRQkAATYAAAABAA3gtrOnZAAAAQAAAB1jb252ZXJ0UHJpY2VBc3NldEludG9JZG9Bc3NldAAAAAUAAAAQcHJpY2VBc3NldEFtb3VudAAAAA5wcmljZUFzc2V0TVVMVAAAAAVwcmljZQAAAAlwcmljZU1VTFQAAAAMaWRvQXNzZXRNVUxUBAAAAA9iUHJpY2VBc3NldE1VTFQJAAE2AAAAAQUAAAAOcHJpY2VBc3NldE1VTFQEAAAADWJJZG9Bc3NldE1VTFQJAAE2AAAAAQUAAAAMaWRvQXNzZXRNVUxUBAA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AAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAPdGFyZ2V0UHVibGljS2V5BAAAAAckbWF0Y2gwCQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAADCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGVWZWN0b3IEAAAAAnBrBQAAAAckbWF0Y2gwBQAAAAJwawMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAD3RhcmdldFB1YmxpY0tleXyBoDE=", "height": 1957954, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CBTYBsa7RBN6d8kZrKtgcqSsEcjCAjy6Zm6vxikQEo8b Next: 6yAo28f4tA5JpJof7PCMZ2ipYSe24GhZLhVwkZnvPN9k Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
5 | + | ||
6 | + | ||
4 | 7 | let SEP = "__" | |
5 | 8 | ||
6 | - | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (("mandatory this." + key) + " is not defined")) | |
9 | + | let BUFSCALE = toBigInt(1000000000000000000) | |
10 | + | ||
11 | + | func convertPriceAssetIntoIdoAsset (priceAssetAmount,priceAssetMULT,price,priceMULT,idoAssetMULT) = { | |
12 | + | let bPriceAssetMULT = toBigInt(priceAssetMULT) | |
13 | + | let bIdoAssetMULT = toBigInt(idoAssetMULT) | |
14 | + | let bPriceAssetBUF = fraction(toBigInt(priceAssetAmount), BUFSCALE, bPriceAssetMULT) | |
15 | + | let bAmountAssetBUF = fraction(bPriceAssetBUF, toBigInt(priceMULT), toBigInt(price)) | |
16 | + | toInt(fraction(bAmountAssetBUF, toBigInt(idoAssetMULT), BUFSCALE)) | |
17 | + | } | |
7 | 18 | ||
8 | 19 | ||
9 | - | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
20 | + | let IdxCfgIdoStart = 1 | |
21 | + | ||
22 | + | let IdxCfgIdoDuration = 2 | |
23 | + | ||
24 | + | let IdxCfgClaimStart = 3 | |
25 | + | ||
26 | + | let IdxCfgClaimDuration = 4 | |
27 | + | ||
28 | + | let IdxCfgPrice = 5 | |
29 | + | ||
30 | + | let IdxCfgPriceMult = 6 | |
31 | + | ||
32 | + | let IdxCfgIdoAssetId = 7 | |
33 | + | ||
34 | + | let IdxCfgIdoAssetMult = 8 | |
35 | + | ||
36 | + | let IdxCfgPriceAssetId = 9 | |
37 | + | ||
38 | + | let IdxCfgPriceAssetMult = 10 | |
39 | + | ||
40 | + | let IdxCfgMinInvestAmount = 11 | |
41 | + | ||
42 | + | func fromatConfigS (idoStart,idoDuration,claimStart,claimDuration,price,priceMult,idoAssetId58,idoAssetMult,priceAssetId58,priceAssetMult,minInvestAmount,totalIdoAssetToSell) = makeString(["%d%d%d%d%d%d%s%d%s%d%d%d", idoStart, idoDuration, claimStart, claimDuration, price, priceMult, idoAssetId58, idoAssetMult, priceAssetId58, priceAssetMult, minInvestAmount, totalIdoAssetToSell], SEP) | |
10 | 43 | ||
11 | 44 | ||
12 | - | let IdxFactoryCfgStakingDapp = 1 | |
13 | - | ||
14 | - | let IdxFactoryCfgBoostingDapp = 2 | |
15 | - | ||
16 | - | let IdxFactoryCfgIdoDapp = 3 | |
17 | - | ||
18 | - | let IdxFactoryCfgTeamDapp = 4 | |
19 | - | ||
20 | - | let IdxFactoryCfgEmissionDapp = 5 | |
21 | - | ||
22 | - | let IdxFactoryCfgRestDapp = 6 | |
23 | - | ||
24 | - | let IdxFactoryCfgSlippageDapp = 7 | |
25 | - | ||
26 | - | let IdxFactoryCfgGwxRewardDapp = 10 | |
27 | - | ||
28 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
45 | + | func fromatConfig (idoStart,idoDuration,claimStart,claimDuration,price,priceMult,idoAssetId58,idoAssetMult,priceAssetId58,priceAssetMult,minInvestAmount,totalIdoAssetToSell) = fromatConfigS(toString(idoStart), toString(idoDuration), toString(claimStart), toString(claimDuration), toString(price), toString(priceMult), idoAssetId58, toString(idoAssetMult), priceAssetId58, toString(priceAssetMult), toString(minInvestAmount), toString(totalIdoAssetToSell)) | |
29 | 46 | ||
30 | 47 | ||
31 | - | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
48 | + | let IdxInvTotalAmount = 1 | |
49 | + | ||
50 | + | let IdxInvRemainingAmount = 2 | |
51 | + | ||
52 | + | let IdxInvClaimedPriceAssetAmount = 3 | |
53 | + | ||
54 | + | let IdxInvClaimedIdoAssetAmount = 4 | |
55 | + | ||
56 | + | let IdxInvLastClaimedHeight = 5 | |
57 | + | ||
58 | + | func formatInvestorS (totalAmount,remainingAmount,claimedPriceAssetAmount,claimedIdoAssetAmount,lastClaimedHeight) = makeString(["%d%d%d%d%d", totalAmount, remainingAmount, claimedPriceAssetAmount, claimedIdoAssetAmount, lastClaimedHeight], SEP) | |
32 | 59 | ||
33 | 60 | ||
34 | - | func | |
61 | + | func formatInvestor (totalAmount,remainingAmount,claimedPriceAssetAmount,claimedIdoAssetAmount,lastClaimedHeight) = formatInvestorS(toString(totalAmount), toString(remainingAmount), toString(claimedPriceAssetAmount), toString(claimedIdoAssetAmount), toString(lastClaimedHeight)) | |
35 | 62 | ||
36 | 63 | ||
37 | - | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
38 | - | ||
39 | - | ||
40 | - | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
41 | - | ||
42 | - | ||
43 | - | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress())) | |
44 | - | ||
45 | - | ||
46 | - | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
47 | - | ||
48 | - | ||
49 | - | func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP) | |
50 | - | ||
51 | - | ||
52 | - | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
53 | - | ||
54 | - | ||
55 | - | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
56 | - | ||
57 | - | ||
58 | - | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
59 | - | ||
60 | - | ||
61 | - | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) | |
64 | + | func formatHistoryRecord (priceAssetAmount,idoAssetAmount) = makeString(["%d%d%d%d", toString(height), toString(lastBlock.timestamp), toString(priceAssetAmount), toString(idoAssetAmount)], SEP) | |
62 | 65 | ||
63 | 66 | ||
64 | 67 | func keyConfig () = "%s__config" | |
65 | 68 | ||
66 | 69 | ||
67 | - | func | |
70 | + | func keyInvestor (userAddress) = ("%s__" + userAddress) | |
68 | 71 | ||
69 | 72 | ||
70 | - | func | |
73 | + | func keyTotals () = "%s__totals" | |
71 | 74 | ||
72 | 75 | ||
73 | - | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
74 | - | ||
75 | - | ||
76 | - | func keyRatePerBlockStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlock__start", toString(timestamp), toString(block)], SEP) | |
77 | - | ||
78 | - | ||
79 | - | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
80 | - | ||
81 | - | ||
82 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
83 | - | ||
84 | - | ||
85 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
76 | + | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
86 | 77 | ||
87 | 78 | ||
88 | 79 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
89 | 80 | ||
90 | 81 | ||
91 | 82 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
83 | + | ||
84 | + | ||
85 | + | func readConfigArray () = split(getStringOrFail(keyConfig()), SEP) | |
86 | + | ||
87 | + | ||
88 | + | func readTotalsArrayOrDefaultByCustomKey (customKey) = split(valueOrElse(getString(customKey), formatInvestorS("0", "0", "0", "0", "0")), SEP) | |
89 | + | ||
90 | + | ||
91 | + | func readTotalsArrayOrDefault () = readTotalsArrayOrDefaultByCustomKey(keyTotals()) | |
92 | + | ||
93 | + | ||
94 | + | func readInvestorArrayOrDefault (userAddress) = readTotalsArrayOrDefaultByCustomKey(keyInvestor(userAddress)) | |
95 | + | ||
96 | + | ||
97 | + | func readInvestorArrayOrFail (userAddress) = split(getStringOrFail(keyInvestor(userAddress)), SEP) | |
98 | + | ||
99 | + | ||
100 | + | let IdxDiffTotalIncrement = 0 | |
101 | + | ||
102 | + | let IdxDiffRemainingPriceAmountIncrement = 1 | |
103 | + | ||
104 | + | let IdxDiffClaimedPriceAmountIncrement = 2 | |
105 | + | ||
106 | + | let IdxDiffClaimedIdoAssetAmountIncrement = 3 | |
107 | + | ||
108 | + | func TotalsEntry (key,origArray,incrementDiff,newLastClaimedHeight) = { | |
109 | + | let totalAmount = parseIntValue(origArray[IdxInvTotalAmount]) | |
110 | + | let remainingAmount = parseIntValue(origArray[IdxInvRemainingAmount]) | |
111 | + | let claimedPriceAssetAmount = parseIntValue(origArray[IdxInvClaimedPriceAssetAmount]) | |
112 | + | let claimedIdoAssetAmount = parseIntValue(origArray[IdxInvClaimedIdoAssetAmount]) | |
113 | + | let lastClaimedHeight = parseIntValue(origArray[IdxInvLastClaimedHeight]) | |
114 | + | let newTotalAmount = (totalAmount + incrementDiff[IdxDiffTotalIncrement]) | |
115 | + | let newRemainingAmount = (remainingAmount + incrementDiff[IdxDiffRemainingPriceAmountIncrement]) | |
116 | + | let newClaimedPriceAssetAmount = (claimedPriceAssetAmount + incrementDiff[IdxDiffClaimedPriceAmountIncrement]) | |
117 | + | let newClaimedIdoAssetAmount = (claimedIdoAssetAmount + incrementDiff[IdxDiffClaimedIdoAssetAmountIncrement]) | |
118 | + | if ((0 > newRemainingAmount)) | |
119 | + | then throw("invalid math") | |
120 | + | else StringEntry(key, formatInvestor(newTotalAmount, newRemainingAmount, newClaimedPriceAssetAmount, newClaimedIdoAssetAmount, newLastClaimedHeight)) | |
121 | + | } | |
122 | + | ||
123 | + | ||
124 | + | func InvestOperationHistoryEntry (userAddress,priceAssetAmount,idoAssetAmount,txId) = StringEntry(keyOperationHistoryRecord("invest", userAddress, toBase58String(txId)), formatHistoryRecord(priceAssetAmount, idoAssetAmount)) | |
125 | + | ||
126 | + | ||
127 | + | func ClaimOperationHistoryEntry (userAddress,priceAssetAmount,idoAssetAmount,txId) = StringEntry(keyOperationHistoryRecord("claim", userAddress, toBase58String(txId)), formatHistoryRecord(priceAssetAmount, idoAssetAmount)) | |
128 | + | ||
129 | + | ||
130 | + | func internalClaim (claimedAssetId58,userAddress,txId) = { | |
131 | + | let cfgArray = readConfigArray() | |
132 | + | let claimStart = parseIntValue(cfgArray[IdxCfgClaimStart]) | |
133 | + | let claimDuration = parseIntValue(cfgArray[IdxCfgClaimDuration]) | |
134 | + | let claimEnd = (claimStart + claimDuration) | |
135 | + | let price = parseIntValue(cfgArray[IdxCfgPrice]) | |
136 | + | let priceMult = parseIntValue(cfgArray[IdxCfgPriceMult]) | |
137 | + | let idoAssetId58 = cfgArray[IdxCfgIdoAssetId] | |
138 | + | let idoAssetId = fromBase58String(idoAssetId58) | |
139 | + | let idoAssetMult = parseIntValue(cfgArray[IdxCfgIdoAssetMult]) | |
140 | + | let priceAssetId58 = cfgArray[IdxCfgPriceAssetId] | |
141 | + | let priceAssetId = fromBase58String(priceAssetId58) | |
142 | + | let priceAssetMult = parseIntValue(cfgArray[IdxCfgPriceAssetMult]) | |
143 | + | let userAddress58 = toString(userAddress) | |
144 | + | let origInvestArray = readInvestorArrayOrFail(userAddress58) | |
145 | + | let investTotalAmount = parseIntValue(origInvestArray[IdxInvTotalAmount]) | |
146 | + | let investLastClaimedHeightTMP = parseIntValue(origInvestArray[IdxInvLastClaimedHeight]) | |
147 | + | let investLastClaimedHeight = if ((claimStart >= investLastClaimedHeightTMP)) | |
148 | + | then claimStart | |
149 | + | else investLastClaimedHeightTMP | |
150 | + | let newClaimPeriodHeight = if ((height > claimEnd)) | |
151 | + | then claimEnd | |
152 | + | else if ((claimStart > height)) | |
153 | + | then claimStart | |
154 | + | else height | |
155 | + | let claimingBlocks = (newClaimPeriodHeight - investLastClaimedHeight) | |
156 | + | let claimingPriceAssetAmount = fraction(investTotalAmount, claimingBlocks, claimDuration) | |
157 | + | let claimingIdoAssetAmount = convertPriceAssetIntoIdoAsset(claimingPriceAssetAmount, priceAssetMult, price, priceMult, idoAssetMult) | |
158 | + | if ((claimedAssetId58 == priceAssetId58)) | |
159 | + | then $Tuple6([0, -(claimingPriceAssetAmount), claimingPriceAssetAmount, 0], claimingPriceAssetAmount, priceAssetId, origInvestArray, newClaimPeriodHeight, [claimingPriceAssetAmount, claimingIdoAssetAmount]) | |
160 | + | else if ((claimedAssetId58 == idoAssetId58)) | |
161 | + | then $Tuple6([0, -(claimingPriceAssetAmount), 0, claimingIdoAssetAmount], claimingIdoAssetAmount, idoAssetId, origInvestArray, newClaimPeriodHeight, [claimingPriceAssetAmount, claimingIdoAssetAmount]) | |
162 | + | else throw(("unsupported assetId: " + claimedAssetId58)) | |
163 | + | } | |
92 | 164 | ||
93 | 165 | ||
94 | 166 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
129 | 201 | ||
130 | 202 | ||
131 | 203 | @Callable(i) | |
132 | - | func constructor (factoryAddress,ratePerBlockMax,ratePerBlock,emissionStartBlock,emissionDuration,emissionStartTimestamp,wxAssetIdStr) = { | |
133 | - | let checkCaller = mustManager(i) | |
134 | - | if ((checkCaller == checkCaller)) | |
135 | - | then [IntegerEntry(keyRatePerBlockMaxStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlockMax), IntegerEntry(keyRatePerBlockMaxCurrent(), ratePerBlockMax), IntegerEntry(keyRatePerBlockStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlock), IntegerEntry(keyRatePerBlockCurrent(), ratePerBlock), IntegerEntry(keyEmissionStartBlock(), emissionStartBlock), IntegerEntry(keyEmissionDurationInBlocks(), emissionDuration), IntegerEntry(keyEmissionEndBlock(), (emissionStartBlock + emissionDuration)), StringEntry(keyFactoryAddress(), factoryAddress), StringEntry(keyConfig(), ("%s__" + wxAssetIdStr))] | |
136 | - | else throw("Strict value is not equal to itself.") | |
204 | + | func constructor (idoStart,idoDuration,claimStart,claimDuration,price,priceAssetId58,minInvestAmount) = { | |
205 | + | let priceMult = ((100 * 1000) * 1000) | |
206 | + | let idoEnd = (idoStart + idoDuration) | |
207 | + | if (isDefined(getString(keyConfig()))) | |
208 | + | then throw("already initialized") | |
209 | + | else if (("3PMEHLx1j6zerarZTYfsGqDeeZqQoMpxq5S" != toString(i.caller))) | |
210 | + | then throw("not authorized") | |
211 | + | else if ((size(i.payments) != 1)) | |
212 | + | then throw("exactly 1 payment must be attached") | |
213 | + | else if ((idoEnd >= claimStart)) | |
214 | + | then throw("claimStart must be greater than idoEnd") | |
215 | + | else { | |
216 | + | let pmt = value(i.payments[0]) | |
217 | + | let idoAssetId = value(pmt.assetId) | |
218 | + | let idoAssetInfo = valueOrErrorMessage(assetInfo(idoAssetId), "fail to load ido asset info") | |
219 | + | let idoAssetId58 = toBase58String(idoAssetId) | |
220 | + | let idoAssetMult = pow(10, 0, idoAssetInfo.decimals, 0, 0, DOWN) | |
221 | + | let priceAssetId = fromBase58String(priceAssetId58) | |
222 | + | let priceAssetInfo = valueOrErrorMessage(assetInfo(priceAssetId), "fail to load price asset info") | |
223 | + | let priceAssetMult = pow(10, 0, priceAssetInfo.decimals, 0, 0, DOWN) | |
224 | + | let origTotalsArray = readTotalsArrayOrDefault() | |
225 | + | let totalsDiff = [0, 0, 0, 0] | |
226 | + | [StringEntry(keyConfig(), fromatConfig(idoStart, idoDuration, claimStart, claimDuration, price, priceMult, idoAssetId58, idoAssetMult, priceAssetId58, priceAssetMult, minInvestAmount, pmt.amount)), TotalsEntry(keyTotals(), origTotalsArray, totalsDiff, claimStart)] | |
227 | + | } | |
137 | 228 | } | |
138 | 229 | ||
139 | 230 | ||
140 | 231 | ||
141 | 232 | @Callable(i) | |
142 | - | func emit (amount) = if ((0 >= amount)) | |
143 | - | then $Tuple2(nil, nil) | |
144 | - | else { | |
145 | - | let factoryContract = readFactoryAddressOrFail() | |
146 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
147 | - | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
148 | - | let gwxRewardsContract = getGwxRewardAddressOrFail(factoryCfg) | |
149 | - | let caller = i.caller | |
150 | - | if (if ((caller != stakingContract)) | |
151 | - | then (caller != gwxRewardsContract) | |
152 | - | else false) | |
153 | - | then throw("permissions denied") | |
154 | - | else { | |
155 | - | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
156 | - | let wxAssetId = fromBase58String(wxAssetIdStr) | |
157 | - | $Tuple2([ScriptTransfer(caller, amount, wxAssetId)], [wxAssetId]) | |
158 | - | } | |
159 | - | } | |
233 | + | func invest () = { | |
234 | + | let cfgArray = readConfigArray() | |
235 | + | let idoStart = parseIntValue(cfgArray[IdxCfgIdoStart]) | |
236 | + | let idoDuration = parseIntValue(cfgArray[IdxCfgIdoDuration]) | |
237 | + | let idoEnd = (idoStart + idoDuration) | |
238 | + | let claimStart = parseIntValue(cfgArray[IdxCfgClaimStart]) | |
239 | + | let claimDuration = parseIntValue(cfgArray[IdxCfgClaimDuration]) | |
240 | + | let price = parseIntValue(cfgArray[IdxCfgPrice]) | |
241 | + | let priceMult = parseIntValue(cfgArray[IdxCfgPriceMult]) | |
242 | + | let idoAssetId58 = cfgArray[IdxCfgIdoAssetId] | |
243 | + | let idoAssetId = fromBase58String(idoAssetId58) | |
244 | + | let idoAssetMult = parseIntValue(cfgArray[IdxCfgIdoAssetMult]) | |
245 | + | let priceAssetId58 = cfgArray[IdxCfgPriceAssetId] | |
246 | + | let priceAssetId = fromBase58String(priceAssetId58) | |
247 | + | let priceAssetMult = parseIntValue(cfgArray[IdxCfgPriceAssetMult]) | |
248 | + | let minIvestAmount = parseIntValue(cfgArray[IdxCfgMinInvestAmount]) | |
249 | + | let userAddress = toString(i.caller) | |
250 | + | if ((idoStart > height)) | |
251 | + | then throw("ido has not been started yet") | |
252 | + | else if ((height > idoEnd)) | |
253 | + | then throw("ido has been already ended") | |
254 | + | else if ((size(i.payments) != 1)) | |
255 | + | then throw("exactly 1 payment is expected") | |
256 | + | else { | |
257 | + | let pmt = value(i.payments[0]) | |
258 | + | let pmtAssetId = value(pmt.assetId) | |
259 | + | let pmtAmount = pmt.amount | |
260 | + | if ((pmtAssetId != priceAssetId)) | |
261 | + | then throw((("invalid payment asset id: " + toBase58String(pmtAssetId)) + " is expected")) | |
262 | + | else { | |
263 | + | let origInvestorArray = readInvestorArrayOrDefault(userAddress) | |
264 | + | let origTotalsArray = readTotalsArrayOrDefault() | |
265 | + | let newPriceTotalAmount = (parseIntValue(origTotalsArray[IdxInvTotalAmount]) + pmtAmount) | |
266 | + | let requiredIdoAssetAmount = (newPriceTotalAmount * 100) | |
267 | + | if ((requiredIdoAssetAmount > assetBalance(this, idoAssetId))) | |
268 | + | then throw("IDO asset has been - sold consider to use smaller payment") | |
269 | + | else { | |
270 | + | let totalsDiff = [pmtAmount, pmtAmount, 0, 0] | |
271 | + | [TotalsEntry(keyInvestor(userAddress), origInvestorArray, totalsDiff, claimStart), TotalsEntry(keyTotals(), origTotalsArray, totalsDiff, claimStart), InvestOperationHistoryEntry(userAddress, pmtAmount, 0, i.transactionId)] | |
272 | + | } | |
273 | + | } | |
274 | + | } | |
275 | + | } | |
160 | 276 | ||
161 | 277 | ||
162 | 278 | ||
163 | 279 | @Callable(i) | |
164 | - | func burn () = { | |
165 | - | let factoryContract = readFactoryAddressOrFail() | |
166 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
167 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
168 | - | if ((size(i.payments) != 1)) | |
169 | - | then throw("exact one payment is allowed") | |
280 | + | func claim (claimedAssetId58,userAddress58) = { | |
281 | + | let callerAddress58 = toString(i.caller) | |
282 | + | if ((userAddress58 != callerAddress58)) | |
283 | + | then throw("not authorized") | |
170 | 284 | else { | |
171 | - | let | |
172 | - | let | |
173 | - | let | |
174 | - | let | |
175 | - | | |
176 | - | | |
177 | - | | |
178 | - | | |
179 | - | | |
285 | + | let claimResultTuple = internalClaim(claimedAssetId58, i.caller, i.transactionId) | |
286 | + | let totalsDiff = claimResultTuple._1 | |
287 | + | let outAmount = claimResultTuple._2 | |
288 | + | let outAssetId = claimResultTuple._3 | |
289 | + | let origInvestArray = claimResultTuple._4 | |
290 | + | let newClaimPeriodHeight = claimResultTuple._5 | |
291 | + | let claimedPriceAmountFromDiff = totalsDiff[IdxDiffClaimedPriceAmountIncrement] | |
292 | + | let claimedIdoAssetAmountFromDiff = totalsDiff[IdxDiffClaimedIdoAssetAmountIncrement] | |
293 | + | $Tuple2([ScriptTransfer(i.caller, outAmount, outAssetId), TotalsEntry(keyInvestor(userAddress58), origInvestArray, totalsDiff, newClaimPeriodHeight), TotalsEntry(keyTotals(), readTotalsArrayOrDefault(), totalsDiff, newClaimPeriodHeight), ClaimOperationHistoryEntry(userAddress58, claimedPriceAmountFromDiff, claimedIdoAssetAmountFromDiff, i.transactionId)], unit) | |
180 | 294 | } | |
295 | + | } | |
296 | + | ||
297 | + | ||
298 | + | ||
299 | + | @Callable(i) | |
300 | + | func claimREADONLY (claimedAssetId58,userAddress58) = { | |
301 | + | let claimResultTuple = internalClaim(claimedAssetId58, addressFromStringValue(userAddress58), fromBase58String("")) | |
302 | + | let totalsDiff = claimResultTuple._1 | |
303 | + | let outAmount = claimResultTuple._2 | |
304 | + | let outAssetId = claimResultTuple._3 | |
305 | + | let origInvestArray = claimResultTuple._4 | |
306 | + | let newClaimPeriodHeight = claimResultTuple._5 | |
307 | + | let availableToClaimArray = claimResultTuple._6 | |
308 | + | let availablePriceAmountToClaim = availableToClaimArray[0] | |
309 | + | let availableIdoAmountToClaim = availableToClaimArray[1] | |
310 | + | $Tuple2(nil, makeString(["%s%d%d", userAddress58, toString(availablePriceAmountToClaim), toString(availableIdoAmountToClaim)], SEP)) | |
181 | 311 | } | |
182 | 312 | ||
183 | 313 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
5 | + | ||
6 | + | ||
4 | 7 | let SEP = "__" | |
5 | 8 | ||
6 | - | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (("mandatory this." + key) + " is not defined")) | |
9 | + | let BUFSCALE = toBigInt(1000000000000000000) | |
10 | + | ||
11 | + | func convertPriceAssetIntoIdoAsset (priceAssetAmount,priceAssetMULT,price,priceMULT,idoAssetMULT) = { | |
12 | + | let bPriceAssetMULT = toBigInt(priceAssetMULT) | |
13 | + | let bIdoAssetMULT = toBigInt(idoAssetMULT) | |
14 | + | let bPriceAssetBUF = fraction(toBigInt(priceAssetAmount), BUFSCALE, bPriceAssetMULT) | |
15 | + | let bAmountAssetBUF = fraction(bPriceAssetBUF, toBigInt(priceMULT), toBigInt(price)) | |
16 | + | toInt(fraction(bAmountAssetBUF, toBigInt(idoAssetMULT), BUFSCALE)) | |
17 | + | } | |
7 | 18 | ||
8 | 19 | ||
9 | - | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
20 | + | let IdxCfgIdoStart = 1 | |
21 | + | ||
22 | + | let IdxCfgIdoDuration = 2 | |
23 | + | ||
24 | + | let IdxCfgClaimStart = 3 | |
25 | + | ||
26 | + | let IdxCfgClaimDuration = 4 | |
27 | + | ||
28 | + | let IdxCfgPrice = 5 | |
29 | + | ||
30 | + | let IdxCfgPriceMult = 6 | |
31 | + | ||
32 | + | let IdxCfgIdoAssetId = 7 | |
33 | + | ||
34 | + | let IdxCfgIdoAssetMult = 8 | |
35 | + | ||
36 | + | let IdxCfgPriceAssetId = 9 | |
37 | + | ||
38 | + | let IdxCfgPriceAssetMult = 10 | |
39 | + | ||
40 | + | let IdxCfgMinInvestAmount = 11 | |
41 | + | ||
42 | + | func fromatConfigS (idoStart,idoDuration,claimStart,claimDuration,price,priceMult,idoAssetId58,idoAssetMult,priceAssetId58,priceAssetMult,minInvestAmount,totalIdoAssetToSell) = makeString(["%d%d%d%d%d%d%s%d%s%d%d%d", idoStart, idoDuration, claimStart, claimDuration, price, priceMult, idoAssetId58, idoAssetMult, priceAssetId58, priceAssetMult, minInvestAmount, totalIdoAssetToSell], SEP) | |
10 | 43 | ||
11 | 44 | ||
12 | - | let IdxFactoryCfgStakingDapp = 1 | |
13 | - | ||
14 | - | let IdxFactoryCfgBoostingDapp = 2 | |
15 | - | ||
16 | - | let IdxFactoryCfgIdoDapp = 3 | |
17 | - | ||
18 | - | let IdxFactoryCfgTeamDapp = 4 | |
19 | - | ||
20 | - | let IdxFactoryCfgEmissionDapp = 5 | |
21 | - | ||
22 | - | let IdxFactoryCfgRestDapp = 6 | |
23 | - | ||
24 | - | let IdxFactoryCfgSlippageDapp = 7 | |
25 | - | ||
26 | - | let IdxFactoryCfgGwxRewardDapp = 10 | |
27 | - | ||
28 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
45 | + | func fromatConfig (idoStart,idoDuration,claimStart,claimDuration,price,priceMult,idoAssetId58,idoAssetMult,priceAssetId58,priceAssetMult,minInvestAmount,totalIdoAssetToSell) = fromatConfigS(toString(idoStart), toString(idoDuration), toString(claimStart), toString(claimDuration), toString(price), toString(priceMult), idoAssetId58, toString(idoAssetMult), priceAssetId58, toString(priceAssetMult), toString(minInvestAmount), toString(totalIdoAssetToSell)) | |
29 | 46 | ||
30 | 47 | ||
31 | - | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
48 | + | let IdxInvTotalAmount = 1 | |
49 | + | ||
50 | + | let IdxInvRemainingAmount = 2 | |
51 | + | ||
52 | + | let IdxInvClaimedPriceAssetAmount = 3 | |
53 | + | ||
54 | + | let IdxInvClaimedIdoAssetAmount = 4 | |
55 | + | ||
56 | + | let IdxInvLastClaimedHeight = 5 | |
57 | + | ||
58 | + | func formatInvestorS (totalAmount,remainingAmount,claimedPriceAssetAmount,claimedIdoAssetAmount,lastClaimedHeight) = makeString(["%d%d%d%d%d", totalAmount, remainingAmount, claimedPriceAssetAmount, claimedIdoAssetAmount, lastClaimedHeight], SEP) | |
32 | 59 | ||
33 | 60 | ||
34 | - | func | |
61 | + | func formatInvestor (totalAmount,remainingAmount,claimedPriceAssetAmount,claimedIdoAssetAmount,lastClaimedHeight) = formatInvestorS(toString(totalAmount), toString(remainingAmount), toString(claimedPriceAssetAmount), toString(claimedIdoAssetAmount), toString(lastClaimedHeight)) | |
35 | 62 | ||
36 | 63 | ||
37 | - | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
38 | - | ||
39 | - | ||
40 | - | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
41 | - | ||
42 | - | ||
43 | - | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress())) | |
44 | - | ||
45 | - | ||
46 | - | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
47 | - | ||
48 | - | ||
49 | - | func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP) | |
50 | - | ||
51 | - | ||
52 | - | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
53 | - | ||
54 | - | ||
55 | - | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
56 | - | ||
57 | - | ||
58 | - | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
59 | - | ||
60 | - | ||
61 | - | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) | |
64 | + | func formatHistoryRecord (priceAssetAmount,idoAssetAmount) = makeString(["%d%d%d%d", toString(height), toString(lastBlock.timestamp), toString(priceAssetAmount), toString(idoAssetAmount)], SEP) | |
62 | 65 | ||
63 | 66 | ||
64 | 67 | func keyConfig () = "%s__config" | |
65 | 68 | ||
66 | 69 | ||
67 | - | func | |
70 | + | func keyInvestor (userAddress) = ("%s__" + userAddress) | |
68 | 71 | ||
69 | 72 | ||
70 | - | func | |
73 | + | func keyTotals () = "%s__totals" | |
71 | 74 | ||
72 | 75 | ||
73 | - | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
74 | - | ||
75 | - | ||
76 | - | func keyRatePerBlockStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlock__start", toString(timestamp), toString(block)], SEP) | |
77 | - | ||
78 | - | ||
79 | - | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
80 | - | ||
81 | - | ||
82 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
83 | - | ||
84 | - | ||
85 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
76 | + | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
86 | 77 | ||
87 | 78 | ||
88 | 79 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
89 | 80 | ||
90 | 81 | ||
91 | 82 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
83 | + | ||
84 | + | ||
85 | + | func readConfigArray () = split(getStringOrFail(keyConfig()), SEP) | |
86 | + | ||
87 | + | ||
88 | + | func readTotalsArrayOrDefaultByCustomKey (customKey) = split(valueOrElse(getString(customKey), formatInvestorS("0", "0", "0", "0", "0")), SEP) | |
89 | + | ||
90 | + | ||
91 | + | func readTotalsArrayOrDefault () = readTotalsArrayOrDefaultByCustomKey(keyTotals()) | |
92 | + | ||
93 | + | ||
94 | + | func readInvestorArrayOrDefault (userAddress) = readTotalsArrayOrDefaultByCustomKey(keyInvestor(userAddress)) | |
95 | + | ||
96 | + | ||
97 | + | func readInvestorArrayOrFail (userAddress) = split(getStringOrFail(keyInvestor(userAddress)), SEP) | |
98 | + | ||
99 | + | ||
100 | + | let IdxDiffTotalIncrement = 0 | |
101 | + | ||
102 | + | let IdxDiffRemainingPriceAmountIncrement = 1 | |
103 | + | ||
104 | + | let IdxDiffClaimedPriceAmountIncrement = 2 | |
105 | + | ||
106 | + | let IdxDiffClaimedIdoAssetAmountIncrement = 3 | |
107 | + | ||
108 | + | func TotalsEntry (key,origArray,incrementDiff,newLastClaimedHeight) = { | |
109 | + | let totalAmount = parseIntValue(origArray[IdxInvTotalAmount]) | |
110 | + | let remainingAmount = parseIntValue(origArray[IdxInvRemainingAmount]) | |
111 | + | let claimedPriceAssetAmount = parseIntValue(origArray[IdxInvClaimedPriceAssetAmount]) | |
112 | + | let claimedIdoAssetAmount = parseIntValue(origArray[IdxInvClaimedIdoAssetAmount]) | |
113 | + | let lastClaimedHeight = parseIntValue(origArray[IdxInvLastClaimedHeight]) | |
114 | + | let newTotalAmount = (totalAmount + incrementDiff[IdxDiffTotalIncrement]) | |
115 | + | let newRemainingAmount = (remainingAmount + incrementDiff[IdxDiffRemainingPriceAmountIncrement]) | |
116 | + | let newClaimedPriceAssetAmount = (claimedPriceAssetAmount + incrementDiff[IdxDiffClaimedPriceAmountIncrement]) | |
117 | + | let newClaimedIdoAssetAmount = (claimedIdoAssetAmount + incrementDiff[IdxDiffClaimedIdoAssetAmountIncrement]) | |
118 | + | if ((0 > newRemainingAmount)) | |
119 | + | then throw("invalid math") | |
120 | + | else StringEntry(key, formatInvestor(newTotalAmount, newRemainingAmount, newClaimedPriceAssetAmount, newClaimedIdoAssetAmount, newLastClaimedHeight)) | |
121 | + | } | |
122 | + | ||
123 | + | ||
124 | + | func InvestOperationHistoryEntry (userAddress,priceAssetAmount,idoAssetAmount,txId) = StringEntry(keyOperationHistoryRecord("invest", userAddress, toBase58String(txId)), formatHistoryRecord(priceAssetAmount, idoAssetAmount)) | |
125 | + | ||
126 | + | ||
127 | + | func ClaimOperationHistoryEntry (userAddress,priceAssetAmount,idoAssetAmount,txId) = StringEntry(keyOperationHistoryRecord("claim", userAddress, toBase58String(txId)), formatHistoryRecord(priceAssetAmount, idoAssetAmount)) | |
128 | + | ||
129 | + | ||
130 | + | func internalClaim (claimedAssetId58,userAddress,txId) = { | |
131 | + | let cfgArray = readConfigArray() | |
132 | + | let claimStart = parseIntValue(cfgArray[IdxCfgClaimStart]) | |
133 | + | let claimDuration = parseIntValue(cfgArray[IdxCfgClaimDuration]) | |
134 | + | let claimEnd = (claimStart + claimDuration) | |
135 | + | let price = parseIntValue(cfgArray[IdxCfgPrice]) | |
136 | + | let priceMult = parseIntValue(cfgArray[IdxCfgPriceMult]) | |
137 | + | let idoAssetId58 = cfgArray[IdxCfgIdoAssetId] | |
138 | + | let idoAssetId = fromBase58String(idoAssetId58) | |
139 | + | let idoAssetMult = parseIntValue(cfgArray[IdxCfgIdoAssetMult]) | |
140 | + | let priceAssetId58 = cfgArray[IdxCfgPriceAssetId] | |
141 | + | let priceAssetId = fromBase58String(priceAssetId58) | |
142 | + | let priceAssetMult = parseIntValue(cfgArray[IdxCfgPriceAssetMult]) | |
143 | + | let userAddress58 = toString(userAddress) | |
144 | + | let origInvestArray = readInvestorArrayOrFail(userAddress58) | |
145 | + | let investTotalAmount = parseIntValue(origInvestArray[IdxInvTotalAmount]) | |
146 | + | let investLastClaimedHeightTMP = parseIntValue(origInvestArray[IdxInvLastClaimedHeight]) | |
147 | + | let investLastClaimedHeight = if ((claimStart >= investLastClaimedHeightTMP)) | |
148 | + | then claimStart | |
149 | + | else investLastClaimedHeightTMP | |
150 | + | let newClaimPeriodHeight = if ((height > claimEnd)) | |
151 | + | then claimEnd | |
152 | + | else if ((claimStart > height)) | |
153 | + | then claimStart | |
154 | + | else height | |
155 | + | let claimingBlocks = (newClaimPeriodHeight - investLastClaimedHeight) | |
156 | + | let claimingPriceAssetAmount = fraction(investTotalAmount, claimingBlocks, claimDuration) | |
157 | + | let claimingIdoAssetAmount = convertPriceAssetIntoIdoAsset(claimingPriceAssetAmount, priceAssetMult, price, priceMult, idoAssetMult) | |
158 | + | if ((claimedAssetId58 == priceAssetId58)) | |
159 | + | then $Tuple6([0, -(claimingPriceAssetAmount), claimingPriceAssetAmount, 0], claimingPriceAssetAmount, priceAssetId, origInvestArray, newClaimPeriodHeight, [claimingPriceAssetAmount, claimingIdoAssetAmount]) | |
160 | + | else if ((claimedAssetId58 == idoAssetId58)) | |
161 | + | then $Tuple6([0, -(claimingPriceAssetAmount), 0, claimingIdoAssetAmount], claimingIdoAssetAmount, idoAssetId, origInvestArray, newClaimPeriodHeight, [claimingPriceAssetAmount, claimingIdoAssetAmount]) | |
162 | + | else throw(("unsupported assetId: " + claimedAssetId58)) | |
163 | + | } | |
92 | 164 | ||
93 | 165 | ||
94 | 166 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
95 | 167 | case s: String => | |
96 | 168 | fromBase58String(s) | |
97 | 169 | case _: Unit => | |
98 | 170 | unit | |
99 | 171 | case _ => | |
100 | 172 | throw("Match error") | |
101 | 173 | } | |
102 | 174 | ||
103 | 175 | ||
104 | 176 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
105 | 177 | case s: String => | |
106 | 178 | fromBase58String(s) | |
107 | 179 | case _: Unit => | |
108 | 180 | unit | |
109 | 181 | case _ => | |
110 | 182 | throw("Match error") | |
111 | 183 | } | |
112 | 184 | ||
113 | 185 | ||
114 | 186 | func mustManager (i) = { | |
115 | 187 | let pd = throw("Permission denied") | |
116 | 188 | match managerPublicKeyOrUnit() { | |
117 | 189 | case pk: ByteVector => | |
118 | 190 | if ((i.callerPublicKey == pk)) | |
119 | 191 | then true | |
120 | 192 | else pd | |
121 | 193 | case _: Unit => | |
122 | 194 | if ((i.caller == this)) | |
123 | 195 | then true | |
124 | 196 | else pd | |
125 | 197 | case _ => | |
126 | 198 | throw("Match error") | |
127 | 199 | } | |
128 | 200 | } | |
129 | 201 | ||
130 | 202 | ||
131 | 203 | @Callable(i) | |
132 | - | func constructor (factoryAddress,ratePerBlockMax,ratePerBlock,emissionStartBlock,emissionDuration,emissionStartTimestamp,wxAssetIdStr) = { | |
133 | - | let checkCaller = mustManager(i) | |
134 | - | if ((checkCaller == checkCaller)) | |
135 | - | then [IntegerEntry(keyRatePerBlockMaxStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlockMax), IntegerEntry(keyRatePerBlockMaxCurrent(), ratePerBlockMax), IntegerEntry(keyRatePerBlockStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlock), IntegerEntry(keyRatePerBlockCurrent(), ratePerBlock), IntegerEntry(keyEmissionStartBlock(), emissionStartBlock), IntegerEntry(keyEmissionDurationInBlocks(), emissionDuration), IntegerEntry(keyEmissionEndBlock(), (emissionStartBlock + emissionDuration)), StringEntry(keyFactoryAddress(), factoryAddress), StringEntry(keyConfig(), ("%s__" + wxAssetIdStr))] | |
136 | - | else throw("Strict value is not equal to itself.") | |
204 | + | func constructor (idoStart,idoDuration,claimStart,claimDuration,price,priceAssetId58,minInvestAmount) = { | |
205 | + | let priceMult = ((100 * 1000) * 1000) | |
206 | + | let idoEnd = (idoStart + idoDuration) | |
207 | + | if (isDefined(getString(keyConfig()))) | |
208 | + | then throw("already initialized") | |
209 | + | else if (("3PMEHLx1j6zerarZTYfsGqDeeZqQoMpxq5S" != toString(i.caller))) | |
210 | + | then throw("not authorized") | |
211 | + | else if ((size(i.payments) != 1)) | |
212 | + | then throw("exactly 1 payment must be attached") | |
213 | + | else if ((idoEnd >= claimStart)) | |
214 | + | then throw("claimStart must be greater than idoEnd") | |
215 | + | else { | |
216 | + | let pmt = value(i.payments[0]) | |
217 | + | let idoAssetId = value(pmt.assetId) | |
218 | + | let idoAssetInfo = valueOrErrorMessage(assetInfo(idoAssetId), "fail to load ido asset info") | |
219 | + | let idoAssetId58 = toBase58String(idoAssetId) | |
220 | + | let idoAssetMult = pow(10, 0, idoAssetInfo.decimals, 0, 0, DOWN) | |
221 | + | let priceAssetId = fromBase58String(priceAssetId58) | |
222 | + | let priceAssetInfo = valueOrErrorMessage(assetInfo(priceAssetId), "fail to load price asset info") | |
223 | + | let priceAssetMult = pow(10, 0, priceAssetInfo.decimals, 0, 0, DOWN) | |
224 | + | let origTotalsArray = readTotalsArrayOrDefault() | |
225 | + | let totalsDiff = [0, 0, 0, 0] | |
226 | + | [StringEntry(keyConfig(), fromatConfig(idoStart, idoDuration, claimStart, claimDuration, price, priceMult, idoAssetId58, idoAssetMult, priceAssetId58, priceAssetMult, minInvestAmount, pmt.amount)), TotalsEntry(keyTotals(), origTotalsArray, totalsDiff, claimStart)] | |
227 | + | } | |
137 | 228 | } | |
138 | 229 | ||
139 | 230 | ||
140 | 231 | ||
141 | 232 | @Callable(i) | |
142 | - | func emit (amount) = if ((0 >= amount)) | |
143 | - | then $Tuple2(nil, nil) | |
144 | - | else { | |
145 | - | let factoryContract = readFactoryAddressOrFail() | |
146 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
147 | - | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
148 | - | let gwxRewardsContract = getGwxRewardAddressOrFail(factoryCfg) | |
149 | - | let caller = i.caller | |
150 | - | if (if ((caller != stakingContract)) | |
151 | - | then (caller != gwxRewardsContract) | |
152 | - | else false) | |
153 | - | then throw("permissions denied") | |
154 | - | else { | |
155 | - | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
156 | - | let wxAssetId = fromBase58String(wxAssetIdStr) | |
157 | - | $Tuple2([ScriptTransfer(caller, amount, wxAssetId)], [wxAssetId]) | |
158 | - | } | |
159 | - | } | |
233 | + | func invest () = { | |
234 | + | let cfgArray = readConfigArray() | |
235 | + | let idoStart = parseIntValue(cfgArray[IdxCfgIdoStart]) | |
236 | + | let idoDuration = parseIntValue(cfgArray[IdxCfgIdoDuration]) | |
237 | + | let idoEnd = (idoStart + idoDuration) | |
238 | + | let claimStart = parseIntValue(cfgArray[IdxCfgClaimStart]) | |
239 | + | let claimDuration = parseIntValue(cfgArray[IdxCfgClaimDuration]) | |
240 | + | let price = parseIntValue(cfgArray[IdxCfgPrice]) | |
241 | + | let priceMult = parseIntValue(cfgArray[IdxCfgPriceMult]) | |
242 | + | let idoAssetId58 = cfgArray[IdxCfgIdoAssetId] | |
243 | + | let idoAssetId = fromBase58String(idoAssetId58) | |
244 | + | let idoAssetMult = parseIntValue(cfgArray[IdxCfgIdoAssetMult]) | |
245 | + | let priceAssetId58 = cfgArray[IdxCfgPriceAssetId] | |
246 | + | let priceAssetId = fromBase58String(priceAssetId58) | |
247 | + | let priceAssetMult = parseIntValue(cfgArray[IdxCfgPriceAssetMult]) | |
248 | + | let minIvestAmount = parseIntValue(cfgArray[IdxCfgMinInvestAmount]) | |
249 | + | let userAddress = toString(i.caller) | |
250 | + | if ((idoStart > height)) | |
251 | + | then throw("ido has not been started yet") | |
252 | + | else if ((height > idoEnd)) | |
253 | + | then throw("ido has been already ended") | |
254 | + | else if ((size(i.payments) != 1)) | |
255 | + | then throw("exactly 1 payment is expected") | |
256 | + | else { | |
257 | + | let pmt = value(i.payments[0]) | |
258 | + | let pmtAssetId = value(pmt.assetId) | |
259 | + | let pmtAmount = pmt.amount | |
260 | + | if ((pmtAssetId != priceAssetId)) | |
261 | + | then throw((("invalid payment asset id: " + toBase58String(pmtAssetId)) + " is expected")) | |
262 | + | else { | |
263 | + | let origInvestorArray = readInvestorArrayOrDefault(userAddress) | |
264 | + | let origTotalsArray = readTotalsArrayOrDefault() | |
265 | + | let newPriceTotalAmount = (parseIntValue(origTotalsArray[IdxInvTotalAmount]) + pmtAmount) | |
266 | + | let requiredIdoAssetAmount = (newPriceTotalAmount * 100) | |
267 | + | if ((requiredIdoAssetAmount > assetBalance(this, idoAssetId))) | |
268 | + | then throw("IDO asset has been - sold consider to use smaller payment") | |
269 | + | else { | |
270 | + | let totalsDiff = [pmtAmount, pmtAmount, 0, 0] | |
271 | + | [TotalsEntry(keyInvestor(userAddress), origInvestorArray, totalsDiff, claimStart), TotalsEntry(keyTotals(), origTotalsArray, totalsDiff, claimStart), InvestOperationHistoryEntry(userAddress, pmtAmount, 0, i.transactionId)] | |
272 | + | } | |
273 | + | } | |
274 | + | } | |
275 | + | } | |
160 | 276 | ||
161 | 277 | ||
162 | 278 | ||
163 | 279 | @Callable(i) | |
164 | - | func burn () = { | |
165 | - | let factoryContract = readFactoryAddressOrFail() | |
166 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
167 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
168 | - | if ((size(i.payments) != 1)) | |
169 | - | then throw("exact one payment is allowed") | |
280 | + | func claim (claimedAssetId58,userAddress58) = { | |
281 | + | let callerAddress58 = toString(i.caller) | |
282 | + | if ((userAddress58 != callerAddress58)) | |
283 | + | then throw("not authorized") | |
170 | 284 | else { | |
171 | - | let | |
172 | - | let | |
173 | - | let | |
174 | - | let | |
175 | - | | |
176 | - | | |
177 | - | | |
178 | - | | |
179 | - | | |
285 | + | let claimResultTuple = internalClaim(claimedAssetId58, i.caller, i.transactionId) | |
286 | + | let totalsDiff = claimResultTuple._1 | |
287 | + | let outAmount = claimResultTuple._2 | |
288 | + | let outAssetId = claimResultTuple._3 | |
289 | + | let origInvestArray = claimResultTuple._4 | |
290 | + | let newClaimPeriodHeight = claimResultTuple._5 | |
291 | + | let claimedPriceAmountFromDiff = totalsDiff[IdxDiffClaimedPriceAmountIncrement] | |
292 | + | let claimedIdoAssetAmountFromDiff = totalsDiff[IdxDiffClaimedIdoAssetAmountIncrement] | |
293 | + | $Tuple2([ScriptTransfer(i.caller, outAmount, outAssetId), TotalsEntry(keyInvestor(userAddress58), origInvestArray, totalsDiff, newClaimPeriodHeight), TotalsEntry(keyTotals(), readTotalsArrayOrDefault(), totalsDiff, newClaimPeriodHeight), ClaimOperationHistoryEntry(userAddress58, claimedPriceAmountFromDiff, claimedIdoAssetAmountFromDiff, i.transactionId)], unit) | |
180 | 294 | } | |
295 | + | } | |
296 | + | ||
297 | + | ||
298 | + | ||
299 | + | @Callable(i) | |
300 | + | func claimREADONLY (claimedAssetId58,userAddress58) = { | |
301 | + | let claimResultTuple = internalClaim(claimedAssetId58, addressFromStringValue(userAddress58), fromBase58String("")) | |
302 | + | let totalsDiff = claimResultTuple._1 | |
303 | + | let outAmount = claimResultTuple._2 | |
304 | + | let outAssetId = claimResultTuple._3 | |
305 | + | let origInvestArray = claimResultTuple._4 | |
306 | + | let newClaimPeriodHeight = claimResultTuple._5 | |
307 | + | let availableToClaimArray = claimResultTuple._6 | |
308 | + | let availablePriceAmountToClaim = availableToClaimArray[0] | |
309 | + | let availableIdoAmountToClaim = availableToClaimArray[1] | |
310 | + | $Tuple2(nil, makeString(["%s%d%d", userAddress58, toString(availablePriceAmountToClaim), toString(availableIdoAmountToClaim)], SEP)) | |
181 | 311 | } | |
182 | 312 | ||
183 | 313 | ||
184 | 314 | ||
185 | 315 | @Callable(i) | |
186 | 316 | func setManager (pendingManagerPublicKey) = { | |
187 | 317 | let checkCaller = mustManager(i) | |
188 | 318 | if ((checkCaller == checkCaller)) | |
189 | 319 | then { | |
190 | 320 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
191 | 321 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
192 | 322 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
193 | 323 | else throw("Strict value is not equal to itself.") | |
194 | 324 | } | |
195 | 325 | else throw("Strict value is not equal to itself.") | |
196 | 326 | } | |
197 | 327 | ||
198 | 328 | ||
199 | 329 | ||
200 | 330 | @Callable(i) | |
201 | 331 | func confirmManager () = { | |
202 | 332 | let pm = pendingManagerPublicKeyOrUnit() | |
203 | 333 | let hasPM = if (isDefined(pm)) | |
204 | 334 | then true | |
205 | 335 | else throw("No pending manager") | |
206 | 336 | if ((hasPM == hasPM)) | |
207 | 337 | then { | |
208 | 338 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
209 | 339 | then true | |
210 | 340 | else throw("You are not pending manager") | |
211 | 341 | if ((checkPM == checkPM)) | |
212 | 342 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
213 | 343 | else throw("Strict value is not equal to itself.") | |
214 | 344 | } | |
215 | 345 | else throw("Strict value is not equal to itself.") | |
216 | 346 | } | |
217 | 347 | ||
218 | 348 | ||
219 | 349 | @Verifier(tx) | |
220 | 350 | func verify () = { | |
221 | 351 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
222 | 352 | case pk: ByteVector => | |
223 | 353 | pk | |
224 | 354 | case _: Unit => | |
225 | 355 | tx.senderPublicKey | |
226 | 356 | case _ => | |
227 | 357 | throw("Match error") | |
228 | 358 | } | |
229 | 359 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
230 | 360 | } | |
231 | 361 |
github/deemru/w8io/026f985 53.98 ms ◑