tx · Gf5VaWnfJee47U2EpZqByWN1vkzMbUNexKjZ6T4n7kzL

3N1EmStFtB5dXZbZ8RHjeryGdWHTcFsVtYE:  -0.00200000 Waves

2022.11.13 01:49 [2314549] smart account 3N1EmStFtB5dXZbZ8RHjeryGdWHTcFsVtYE > SELF 0.00000000 Waves

{ "type": 13, "id": "Gf5VaWnfJee47U2EpZqByWN1vkzMbUNexKjZ6T4n7kzL", "fee": 200000, "feeAssetId": null, "timestamp": 1668293383642, "version": 1, "sender": "3N1EmStFtB5dXZbZ8RHjeryGdWHTcFsVtYE", "senderPublicKey": "5VUgXzkrEkNf3JYsycwQ74BUdcbcpxoWr1bcFq9sK7Zv", "proofs": [ "3wVtdFJtedsb2jHkzARvfBWq1Bv48E5gRBwa7so6wzzCJZHDguDt7p9udwE1oDeLZB7quHp19bMtzQVCtG2JPwj8" ], "script": "base64:BgIHCAISAwoBCAkAAVMCAl9fAANERUMAwIQ9AAZ1c2RuSWQJANkEAQkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzAgtjZmdfX3VzZG5JZAIsSGV6c2RRdVJEdHprc0FZVXk5N2dmaEt5N1oxTlcydVhZU0hBM2JncWVuTloBDGdldEludE9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQdhZGRyZXNzBQNrZXkJAKwCAgkArAICCQCsAgIJAKUIAQUHYWRkcmVzcwIBLgUDa2V5Ag8gaXMgbm90IGRlZmluZWQBBmdldFN0cgMHYWRkcmVzcwNrZXkHZGVmYXVsdAkBC3ZhbHVlT3JFbHNlAgkAnQgCBQdhZGRyZXNzBQNrZXkFB2RlZmF1bHQBCmtleVRlYW1DYXABCHRlYW1Db2RlCQC5CQIJAMwIAgIYJXMlc19fdGVhbUNhcGl0YWxpemF0aW9uCQDMCAIFCHRlYW1Db2RlBQNuaWwFAVMBCmtleVRlYW1Ua24BCHRlYW1Db2RlCQC5CQIJAMwIAgIQJXMlc19fdGVhbV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1DYXAFA0RFQwUHdGVhbVRrbgUDREVDBA50ZWFtVGtuRm9yVXNlcgkAawMFBnBtdEFtdAUDREVDBQVwcmljZQkAzAgCCQEMSW50ZWdlckVudHJ5AgkBCmtleVRlYW1DYXABBQh0ZWFtQ29kZQkAZAIFB3RlYW1DYXAFBnBtdEFtdAkAzAgCCQEMSW50ZWdlckVudHJ5AgkBCmtleVRlYW1Ua24BBQh0ZWFtQ29kZQkAZAIFB3RlYW1Ua24FDnRlYW1Ua25Gb3JVc2VyCQDMCAIJAQ51cGRhdGVVc2VyVGVhbQMJAQtrZXlVc2VyVGVhbQIFBHVzZXIFCHRlYW1Db2RlBQ50ZWFtVGtuRm9yVXNlcgUGcG10QW10BQNuaWwACUlF8w==", "chainId": 84, "height": 2314549, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let S = "__"
5+
6+let DEC = 1000000
7+
8+let usdnId = fromBase58String(valueOrElse(getString(this, "cfg__usdnId"), "HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ"))
9+
10+func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((toString(address) + ".") + key) + " is not defined"))
11+
12+
13+func getStr (address,key,default) = valueOrElse(getString(address, key), default)
14+
15+
16+func keyTeamCap (teamCode) = makeString(["%s%s__teamCapitalization", teamCode], S)
17+
18+
19+func keyTeamTkn (teamCode) = makeString(["%s%s__teamTokens", teamCode], S)
20+
21+
22+func keyUserTeam (user,teamCode) = makeString(["%s%s%s__userTeam", user, teamCode], S)
23+
24+
25+func updateUserTeam (key,teamTknDiff,investDiff) = {
26+ let data = split(getStr(this, key, "%d%d__0__0"), S)
27+ let teamTknAmtNew = toString((parseIntValue(data[1]) + teamTknDiff))
28+ let investUsdnNew = toString((parseIntValue(data[2]) + investDiff))
29+ StringEntry(key, makeString(["%d%d", teamTknAmtNew, investUsdnNew], S))
30+ }
31+
32+
33+@Callable(i)
34+func buyTeam (teamCode) = {
35+ let user = toString(i.caller)
36+ let pmt = i.payments[0]
37+ let pmtAmt = pmt.amount
38+ let pmtAssetId = pmt.assetId
39+ if ((size(i.payments) != 1))
40+ then throw("1 payment is expected")
41+ else if ((pmtAssetId != usdnId))
42+ then throw("invalid payment asset id")
43+ else {
44+ let teamCap = getIntOrFail(this, keyTeamCap(teamCode))
45+ let teamTkn = getIntOrFail(this, keyTeamTkn(teamCode))
46+ let price = if ((teamTkn != 0))
47+ then fraction(teamCap, DEC, teamTkn)
48+ else DEC
49+ let teamTknForUser = fraction(pmtAmt, DEC, price)
50+[IntegerEntry(keyTeamCap(teamCode), (teamCap + pmtAmt)), IntegerEntry(keyTeamTkn(teamCode), (teamTkn + teamTknForUser)), updateUserTeam(keyUserTeam(user, teamCode), teamTknForUser, pmtAmt)]
51+ }
52+ }
53+
54+

github/deemru/w8io/026f985 
21.69 ms