tx · mvBeaTcVMZgX6bMcNUspWUWGPuG2YgeKrdGoGYsLbGe

3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8:  -0.00400000 Waves

2023.01.22 16:54 [2416247] smart account 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8 > SELF 0.00000000 Waves

{ "type": 13, "id": "mvBeaTcVMZgX6bMcNUspWUWGPuG2YgeKrdGoGYsLbGe", "fee": 400000, "feeAssetId": null, "timestamp": 1674395683925, "version": 2, "chainId": 84, "sender": "3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8", "senderPublicKey": "ATuPi6fn8277fNiCoRgPTav9QG15CJoW95GEGcDmfYt8", "proofs": [ "2R1yVss8XXXmsSB4YBJw9G8QjW4Q4qVh4RPy7M2qfLMkvZBvJPvHZyN6grM463YckYfurHDKLYSv9LdB96u3xK5Z" ], "script": "base64:BgIPCAISABIAEgMKAQgSABIAGQAFd2NkSWQCLDVXRTZIQlZzbUFiYXBUbVRLcG15V21VUjY3ZmMxNnliRnJOanh6bURCdFBhAAt3Y2REZWNpbWFscwACARN0b3RhbFNoYXJlQnlVc2VyS0VZAQVvd25lcgkAuQkCCQDMCAICBnNoYXJlcwkAzAgCBQVvd25lcgUDbmlsAgFfARR0b3RhbFNoYXJlQnlVc2VyUkVBRAEFb3duZXIJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwkBE3RvdGFsU2hhcmVCeVVzZXJLRVkBBQVvd25lcgAAABJ0b3RhbElzc3VlZFdDRF9LRVkCEHRvdGFsX2lzc3VlZF9XQ0QBE3RvdGFsSXNzdWVkV0NEX1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFEnRvdGFsSXNzdWVkV0NEX0tFWQAAAA50b3RhbFNoYXJlc0tFWQIMdG90YWxfc2hhcmVzAQ90b3RhbFNoYXJlc1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFDnRvdGFsU2hhcmVzS0VZAAAAEnRvd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ACAgOmDsd4WBA90b3RhbENvbGxhdGVyYWwJARN0b3RhbENvbGxhdGVyYWxSRUFEAAQMdG90YWxfaXNzdWVkCQETdG90YWxJc3N1ZWRXQ0RfUkVBRAAJAMwIAgkBDEludGVnZXJFbnRyeQIFEnRvdGFsQ29sbGF0ZXJhbEtFWQkAZAIFD3RvdGFsQ29sbGF0ZXJhbAgFA3BtdAZhbW91bnQJAMwIAgkBDEludGVnZXJFbnRyeQIFEnRvdGFsSXNzdWVkV0NEX0tFWQkAZAIFDHRvdGFsX2lzc3VlZAUQd2NkX2lzc3VlX2Ftb3VudAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQERQGV4dHJOYXRpdmUoMTA2MikBBQdhY2NvdW50BRB3Y2RfaXNzdWVfYW1vdW50CQDZBAEFBXdjZElkBQNuaWwBaQESdGVzdF9nZXRfdXNlcl90bWR1AQdhY2NvdW50CQACAQkArAICAghSZXN1bHQ6IAkApAMBCQEPZ2V0VXNlclRNRFVfV0NEAQUHYWNjb3VudAFpAQ10ZXN0X2dldF90bWR1AAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBB2dldFRNRFUAAWkBDXRlc3RfZ2V0X3RtZGkACQACAQkArAICAghSZXN1bHQ6IAkApAMBCQEHZ2V0VE1ESQAA+qgWZw==", "height": 2416247, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6B8yquQo5zKWp4TxiBXMmMUNszj1kwqXtNnd5NxF5xxf Next: CuuvyDUBVWrFjNi6QpNg5BYQ6Xgkot66vAjiLjxqrjtr Diff:
OldNewDifferences
6363 func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ())
6464
6565
66+func getBaseTMDU () = {
67+ let diff = (totalCollateralREAD() - totalSharesREAD())
68+ TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ())
69+ }
70+
71+
6672 func getTMDU () = {
6773 let diff = (totalCollateralREAD() - totalSharesREAD())
6874 if ((diff > 0))
6975 then {
70- let max_theorical_unlockable_waves = TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ())
71- if ((diff > max_theorical_unlockable_waves))
72- then max_theorical_unlockable_waves
73- else max_theorical_unlockable_waves
76+ let max_base_unlockable_waves = getBaseTMDU()
77+ if ((diff > max_base_unlockable_waves))
78+ then max_base_unlockable_waves
79+ else diff
7480 }
7581 else 0
7682 }
127133
128134
129135 @Callable(i)
130-func test (account) = throw(("Result: " + toString(getUserTMDU_WCD(account))))
136+func test_get_user_tmdu (account) = throw(("Result: " + toString(getUserTMDU_WCD(account))))
131137
132138
133139
134140 @Callable(i)
135-func test_ii () = throw(("Result: " + toString(getTMDU())))
141+func test_get_tmdu () = throw(("Result: " + toString(getTMDU())))
142+
143+
144+
145+@Callable(i)
146+func test_get_tmdi () = throw(("Result: " + toString(getTMDI())))
136147
137148
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let wcdId = "5WE6HBVsmAbapTmTKpmyWmUR67fc16ybFrNjxzmDBtPa"
55
66 let wcdDecimals = 2
77
88 func totalShareByUserKEY (owner) = makeString(["shares", owner], "_")
99
1010
1111 func totalShareByUserREAD (owner) = valueOrElse(getInteger(this, totalShareByUserKEY(owner)), 0)
1212
1313
1414 let totalIssuedWCD_KEY = "total_issued_WCD"
1515
1616 func totalIssuedWCD_READ () = valueOrElse(getInteger(this, totalIssuedWCD_KEY), 0)
1717
1818
1919 let totalSharesKEY = "total_shares"
2020
2121 func totalSharesREAD () = valueOrElse(getInteger(this, totalSharesKEY), 0)
2222
2323
2424 let totalCollateralKEY = "total_collateral"
2525
2626 func totalCollateralREAD () = valueOrElse(getInteger(this, totalCollateralKEY), 0)
2727
2828
2929 let INITIAL_PRICE = 240000000
3030
3131 let wavesReferencePrice_KEY = "waves_reference_price"
3232
3333 func wavesReferencePrice_READ () = valueOrElse(getInteger(this, wavesReferencePrice_KEY), INITIAL_PRICE)
3434
3535
3636 func userShareFraction (owner) = {
3737 let totalShares = totalSharesREAD()
3838 if ((totalShares > 0))
3939 then {
4040 let totalUserShare = totalShareByUserREAD(owner)
4141 fraction(100000000, totalUserShare, totalShares)
4242 }
4343 else 0
4444 }
4545
4646
4747 let paramA_KEY = "A"
4848
4949 func paramA_READ () = valueOrElse(getInteger(this, "A"), 100)
5050
5151
5252 func computeLogTMDIR (issued_wcd,A) = (500000000 - (log(issued_wcd, wcdDecimals, 10, 0, 6, HALFUP) * A))
5353
5454
5555 func TMDIRmultiply (amount,issued_wcd,A) = fraction(amount, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000)
5656
5757
5858 func computeTMDI (issued_wcd,A) = if ((issued_wcd > 10000000))
5959 then TMDIRmultiply(issued_wcd, issued_wcd, A)
6060 else 10000000
6161
6262
6363 func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ())
6464
6565
66+func getBaseTMDU () = {
67+ let diff = (totalCollateralREAD() - totalSharesREAD())
68+ TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ())
69+ }
70+
71+
6672 func getTMDU () = {
6773 let diff = (totalCollateralREAD() - totalSharesREAD())
6874 if ((diff > 0))
6975 then {
70- let max_theorical_unlockable_waves = TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ())
71- if ((diff > max_theorical_unlockable_waves))
72- then max_theorical_unlockable_waves
73- else max_theorical_unlockable_waves
76+ let max_base_unlockable_waves = getBaseTMDU()
77+ if ((diff > max_base_unlockable_waves))
78+ then max_base_unlockable_waves
79+ else diff
7480 }
7581 else 0
7682 }
7783
7884
7985 func getUserTMDI_WAVES (owner) = (1000000 * fraction(getTMDI(), userShareFraction(owner), wavesReferencePrice_READ()))
8086
8187
8288 func getUserTMDU (owner) = fraction(getTMDU(), userShareFraction(owner), 100000000)
8389
8490
8591 func getUserTMDU_WCD (owner) = fraction(fraction(getTMDU(), userShareFraction(owner), 100000000), wavesReferencePrice_READ(), 100000000)
8692
8793
8894 @Callable(i)
8995 func deposit_share () = {
9096 let pmt = if ((size(i.payments) == 1))
9197 then i.payments[0]
9298 else throw("Attached payment is required")
9399 if (isDefined(pmt.assetId))
94100 then throw("Only WAVES is allowed.")
95101 else {
96102 let account = toString(i.caller)
97103 let totalShareByUser = totalShareByUserREAD(account)
98104 let totalShares = totalSharesREAD()
99105 let totalCollateral = totalCollateralREAD()
100106 [IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount)), IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount))]
101107 }
102108 }
103109
104110
105111
106112 @Callable(i)
107113 func issue () = {
108114 let pmt = if ((size(i.payments) == 1))
109115 then i.payments[0]
110116 else throw("Attached payment is required")
111117 if (isDefined(pmt.assetId))
112118 then throw("Only WAVES is allowed.")
113119 else {
114120 let account = toString(i.caller)
115121 let max_waves = getUserTMDI_WAVES(account)
116122 if ((pmt.amount > max_waves))
117123 then throw((((("User lock limit is " + toString(max_waves)) + " WAVES. Sent ") + toString(pmt.amount)) + " WAVES."))
118124 else {
119125 let wcd_issue_amount = fraction(pmt.amount, wavesReferencePrice_READ(), 100000000000000)
120126 let totalCollateral = totalCollateralREAD()
121127 let total_issued = totalIssuedWCD_READ()
122128 [IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount)), IntegerEntry(totalIssuedWCD_KEY, (total_issued + wcd_issue_amount)), ScriptTransfer(addressFromStringValue(account), wcd_issue_amount, fromBase58String(wcdId))]
123129 }
124130 }
125131 }
126132
127133
128134
129135 @Callable(i)
130-func test (account) = throw(("Result: " + toString(getUserTMDU_WCD(account))))
136+func test_get_user_tmdu (account) = throw(("Result: " + toString(getUserTMDU_WCD(account))))
131137
132138
133139
134140 @Callable(i)
135-func test_ii () = throw(("Result: " + toString(getTMDU())))
141+func test_get_tmdu () = throw(("Result: " + toString(getTMDU())))
142+
143+
144+
145+@Callable(i)
146+func test_get_tmdi () = throw(("Result: " + toString(getTMDI())))
136147
137148

github/deemru/w8io/169f3d6 
106.12 ms