tx · Cn5Vz8MkuM4fVutgyYi8guu2yAYMoDSgMCZex1Csy8yh

3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8:  -0.00300000 Waves

2023.01.16 23:34 [2407981] smart account 3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8 > SELF 0.00000000 Waves

{ "type": 13, "id": "Cn5Vz8MkuM4fVutgyYi8guu2yAYMoDSgMCZex1Csy8yh", "fee": 300000, "feeAssetId": null, "timestamp": 1673901264386, "version": 2, "chainId": 84, "sender": "3N1XAEyg1TQGa5FCEerrRhLGi5KyVq26Xm8", "senderPublicKey": "ATuPi6fn8277fNiCoRgPTav9QG15CJoW95GEGcDmfYt8", "proofs": [ "SgGLMjDSiVw5rNA6wEMTdwarubAg2raidckNbzM3E9r8TF7vk6UNQPSrvzMXFm6DGurZ9atpx8SJmxDxvT2VFGz" ], "script": "base64:BgILCAISABIDCgEIEgAUAAV3Y2RJZAIsNVdFNkhCVnNtQWJhcFRtVEtwbXlXbVVSNjdmYzE2eWJGck5qeHptREJ0UGEAC3djZERlY2ltYWxzAAIBE3RvdGFsU2hhcmVCeVVzZXJLRVkBBW93bmVyCQC5CQIJAMwIAgIGc2hhcmVzCQDMCAIFBW93bmVyBQNuaWwCAV8BFHRvdGFsU2hhcmVCeVVzZXJSRUFEAQVvd25lcgkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzCQETdG90YWxTaGFyZUJ5VXNlcktFWQEFBW93bmVyAAAAEnRvdGFsSXNzdWVkV0NEX0tFWQIQdG90YWxfaXNzdWVkX1dDRAETdG90YWxJc3N1ZWRXQ0RfUkVBRAAJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUSdG90YWxJc3N1ZWRXQ0RfS0VZAAAADnRvdGFsU2hhcmVzS0VZAgx0b3RhbF9zaGFyZXMBD3RvdGFsU2hhcmVzUkVBRAAJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUOdG90YWxTaGFyZXNLRVkAAA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ogCQCkAwEJAQdnZXRUTURVAADm0O2m", "height": 2407981, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3K9Li9Aa78jsBpLA96h865KrXmT6S8wSvRK8J95qezgZ Next: 9KdqPcwAza4QYSE1EYk4xvA1XXvfT7jxiyHANixsGPGV Diff:
OldNewDifferences
5656 func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ())
5757
5858
59+func getTMDU () = {
60+ let diff = (totalCollateralREAD() - totalSharesREAD())
61+ if ((diff > 0))
62+ then TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ())
63+ else 0
64+ }
65+
66+
5967 func getUserTMDI (owner) = fraction(getTMDI(), userShareFraction(owner), 100000000)
68+
69+
70+func getUserTMDU (owner) = fraction(getTMDU(), userShareFraction(owner), 100000000)
6071
6172
6273 @Callable(i)
8394
8495
8596 @Callable(i)
86-func test_ii (issued_wcd,A) = throw(("Result: " + toString(computeTMDI(issued_wcd, A))))
97+func test_ii () = throw(("Result: " + toString(getTMDU())))
8798
8899
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
4848 func TMDIRmultiply (amount,issued_wcd,A) = fraction(amount, pow(10, 0, computeLogTMDIR(issued_wcd, A), 8, 8, HALFUP), 100000000)
4949
5050
5151 func computeTMDI (issued_wcd,A) = if ((issued_wcd > 10000000))
5252 then TMDIRmultiply(issued_wcd, issued_wcd, A)
5353 else 10000000
5454
5555
5656 func getTMDI () = computeTMDI(totalIssuedWCD_READ(), paramA_READ())
5757
5858
59+func getTMDU () = {
60+ let diff = (totalCollateralREAD() - totalSharesREAD())
61+ if ((diff > 0))
62+ then TMDIRmultiply((diff * 10), totalIssuedWCD_READ(), paramA_READ())
63+ else 0
64+ }
65+
66+
5967 func getUserTMDI (owner) = fraction(getTMDI(), userShareFraction(owner), 100000000)
68+
69+
70+func getUserTMDU (owner) = fraction(getTMDU(), userShareFraction(owner), 100000000)
6071
6172
6273 @Callable(i)
6374 func deposit_share () = {
6475 let pmt = if ((size(i.payments) == 1))
6576 then i.payments[0]
6677 else throw("Attached payment is required")
6778 if (isDefined(pmt.assetId))
6879 then throw("Only WAVES is allowed.")
6980 else {
7081 let account = toString(i.caller)
7182 let totalShareByUser = totalShareByUserREAD(account)
7283 let totalShares = totalSharesREAD()
7384 let totalCollateral = totalCollateralREAD()
7485 [IntegerEntry(totalShareByUserKEY(account), (totalShareByUser + pmt.amount)), IntegerEntry(totalSharesKEY, (totalShares + pmt.amount)), IntegerEntry(totalCollateralKEY, (totalCollateral + pmt.amount))]
7586 }
7687 }
7788
7889
7990
8091 @Callable(i)
8192 func test (account) = throw(("Result: " + toString(getUserTMDI(account))))
8293
8394
8495
8596 @Callable(i)
86-func test_ii (issued_wcd,A) = throw(("Result: " + toString(computeTMDI(issued_wcd, A))))
97+func test_ii () = throw(("Result: " + toString(getTMDU())))
8798
8899

github/deemru/w8io/169f3d6 
30.94 ms