tx · 3NwPdgvxBCoh5krNCScVtwijAi1Rr9TLLZhvxD96UNyK

3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8:  -0.00200000 Waves

2023.01.16 23:14 [2407961] smart account 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8 > SELF 0.00000000 Waves

{ "type": 13, "id": "3NwPdgvxBCoh5krNCScVtwijAi1Rr9TLLZhvxD96UNyK", "fee": 200000, "feeAssetId": null, "timestamp": 1673900062556, "version": 2, "chainId": 84, "sender": "3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8", "senderPublicKey": "ATuPi6fn8277fNiCoRgPTav9QG15CJoW95GEGcDmfYt8", "proofs": [ "HPfi6ok6wJFd1RwQDeUGMWPXYvfocHYHBckXzGtHPe3Pexpvs8ohFWou8gDFpF1Ca8pT2WAZZfTFcp7JNG2WX1Y" ], "script": "base64:BgIJCAISABIDCgEIEgAFd2NkSWQCLDVXRTZIQlZzbUFiYXBUbVRLcG15V21VUjY3ZmMxNnliRnJOanh6bURCdFBhAAt3Y2REZWNpbWFscwACARN0b3RhbFNoYXJlQnlVc2VyS0VZAQVvd25lcgkAuQkCCQDMCAICBnNoYXJlcwkAzAgCBQVvd25lcgUDbmlsAgFfARR0b3RhbFNoYXJlQnlVc2VyUkVBRAEFb3duZXIJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwkBE3RvdGFsU2hhcmVCeVVzZXJLRVkBBQVvd25lcgAAABJ0b3RhbElzc3VlZFdDRF9LRVkCEHRvdGFsX2lzc3VlZF9XQ0QBE3RvdGFsSXNzdWVkV0NEX1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFEnRvdGFsSXNzdWVkV0NEX0tFWQAAAA50b3RhbFNoYXJlc0tFWQIMdG90YWxfc2hhcmVzAQ90b3RhbFNoYXJlc1JFQUQACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFDnRvdGFsU2hhcmVzS0VZAAAAEnRvdGFsQ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AAQkAkQMCCAUBaQhwYXltZW50cwAACQACAQIcQXR0YWNoZWQgcGF5bWVudCBpcyByZXF1aXJlZAMJAQlpc0RlZmluZWQBCAUDcG10B2Fzc2V0SWQJAAIBAhZPbmx5IFdBVkVTIGlzIGFsbG93ZWQuBAdhY2NvdW50CQClCAEIBQFpBmNhbGxlcgQQdG90YWxTaGFyZUJ5VXNlcgkBFHRvdGFsU2hhcmVCeVVzZXJSRUFEAQUHYWNjb3VudAQLdG90YWxTaGFyZXMJAQ90b3RhbFNoYXJlc1JFQUQABA90b3RhbENvbGxhdGVyYWwJARN0b3RhbENvbGxhdGVyYWxSRUFEAAkAzAgCCQEMSW50ZWdlckVudHJ5AgkBE3RvdGFsU2hhcmVCeVVzZXJLRVkBBQdhY2NvdW50CQBkAgUQdG90YWxTaGFyZUJ5VXNlcggFA3BtdAZhbW91bnQJAMwIAgkBDEludGVnZXJFbnRyeQIFDnRvdGFsU2hhcmVzS0VZCQBkAgULdG90YWxTaGFyZXMIBQNwbXQGYW1vdW50CQDMCAIJAQxJbnRlZ2VyRW50cnkCBRJ0b3RhbENvbGxhdGVyYWxLRVkJAGQCBQ90b3RhbENvbGxhdGVyYWwIBQNwbXQGYW1vdW50BQNuaWwBaQEEdGVzdAEHYWNjb3VudAkAAgEJAKwCAgIIUmVzdWx0OiAJAKQDAQkBC2dldFVzZXJUTURJAQUHYWNjb3VudACy8dVX", "height": 2407961, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FBVd4PENSumhkVFNBJeFef4YhihRZbYyfiERu7Qc9cSg Next: 3K9Li9Aa78jsBpLA96h865KrXmT6S8wSvRK8J95qezgZ Diff:
OldNewDifferences
4545 func computeLogTMDIR (issued_wcd,A) = (500000000 - (log(issued_wcd, wcdDecimals, 10, 0, 6, HALFUP) * A))
4646
4747
48+func TMDIRmultiply (amount,issued_wcd,A) = fraction(amount, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000)
49+
50+
4851 func computeTMDI (issued_wcd,A) = if ((issued_wcd > 10000000))
49- then fraction(issued_wcd, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000)
52+ then TMDIRmultiply(issued_wcd, issued_wcd, A)
5053 else 10000000
5154
5255
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 func userShareFraction (owner) = {
3030 let totalShares = totalSharesREAD()
3131 if ((totalShares > 0))
3232 then {
3333 let totalUserShare = totalShareByUserREAD(owner)
3434 fraction(100000000, totalUserShare, totalShares)
3535 }
3636 else 0
3737 }
3838
3939
4040 let paramA_KEY = "A"
4141
4242 func paramA_READ () = valueOrElse(getInteger(this, "A"), 100)
4343
4444
4545 func computeLogTMDIR (issued_wcd,A) = (500000000 - (log(issued_wcd, wcdDecimals, 10, 0, 6, HALFUP) * A))
4646
4747
48+func TMDIRmultiply (amount,issued_wcd,A) = fraction(amount, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000)
49+
50+
4851 func computeTMDI (issued_wcd,A) = if ((issued_wcd > 10000000))
49- then fraction(issued_wcd, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000)
52+ then TMDIRmultiply(issued_wcd, issued_wcd, A)
5053 else 10000000
5154
5255
5356 func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ())
5457
5558
5659 func getUserTMDI (owner) = fraction(getTMDI(), userShareFraction(owner), 100000000)
5760
5861
5962 @Callable(i)
6063 func deposit_share () = {
6164 let pmt = if ((size(i.payments) == 1))
6265 then i.payments[0]
6366 else throw("Attached payment is required")
6467 if (isDefined(pmt.assetId))
6568 then throw("Only WAVES is allowed.")
6669 else {
6770 let account = toString(i.caller)
6871 let totalShareByUser = totalShareByUserREAD(account)
6972 let totalShares = totalSharesREAD()
7073 let totalCollateral = totalCollateralREAD()
7174 [IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount)), IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount))]
7275 }
7376 }
7477
7578
7679
7780 @Callable(i)
7881 func test (account) = throw(("Result: " + toString(getUserTMDI(account))))
7982
8083

github/deemru/w8io/169f3d6 
56.92 ms