#0
nonstandard
0.00004000 BSV
Q!lKQ§Ê JÒæe»ºê®°f×,U»ÓmãÎóh?Q®M{"__cls":"class PositionSC {\r\n constructor(owner, numberOfShares = 0, dealId = '', facilityId = '', fundId = '') {\r\n this._owners = [owner];\r\n this.numberOfShares = numberOfShares;\r\n this.dealId = dealId\r\n this.facilityId = facilityId;\r\n this.fundId = fundId;\r\n }\r\n\r\n split(newNumberOfShares) {\r\n if (newNumberOfShares === this.numberOfShares) {\r\n return this;\r\n }\r\n if (newNumberOfShares < this.numberOfShares) {\r\n this.numberOfShares -= newNumberOfShares;\r\n return new PositionSC(this._owners[0], newNumberOfShares, this.dealId, this.facilityId, this.fundId);\r\n }\r\n throw new Error(`Cannot split current transaction`);\r\n }\r\n\r\n merge(...positions) {\r\n try {\r\n if (positions.length === 0) return this;\r\n let sendNumberOfShares = this.numberOfShares;\r\n this.numberOfShares = 0;\r\n for (let i = 0; i < positions.length; i += 1) {\r\n if (positions[i].dealId !== this.dealId || positions[i].facilityId !== this.facilityId || positions[i].fundId !== this.fundId) {\r\n throw new Error(`Unable to merge, positions don't originate from the same facility or don't belong to the same fund`);\r\n }\r\n sendNumberOfShares += positions[i].numberOfShares;\r\n positions[i].numberOfShares = 0;\r\n }\r\n return new PositionSC(this._owners[0], sendNumberOfShares, this.dealId, this.facilityId, this.fundId);\r\n } catch (err) {\r\n throw new Error(`Unable to merge positions`);\r\n }\r\n }\r\n\r\n send(to, fundId, numberOfShares) {\r\n if (this.numberOfShares < numberOfShares) throw new Error(`Insufficient funds`);\r\n this.numberOfShares = this.numberOfShares - numberOfShares;\r\n return new PositionSC(to, numberOfShares, this.dealId, this.facilityId, fundId);\r\n }\r\n}","__index":{"obj":0},"__func":"constructor","__args":["026c924b51a7caa04ad294e6659ebbbaeaaeb066d72c55bbd31c6de3cef30c683f",300,"c85121858896c60eaef03058c759ecc8022a2bb0d8251d2e8ac4884d45e8d8ca:0","e3f0fc5e00017ef20adbef2f27825582f3a70ea402ce003038c213784449f072:0","a32291fe648c03742af58c59c82fbd9575d22876a33c3baf858dbb02e454b060:0"]}u
https://whatsonchain.com/tx/10c15841a1c3273afd3dbb32e7ce86aa2a556c4a85cfeb9758820ed998c94bdd