#0
nonstandard
0.00004000 BSV
Q!ƹȤ|jY{3`aS¹Y¸>çâ,$¸QaQ®M;{"__cls":"class PositionSC {\n constructor(owner, numberOfShares = 0, dealId = '', facilityId = '', fundId = '') {\n this._owners = [owner];\n this.numberOfShares = numberOfShares;\n this.dealId = dealId\n this.facilityId = facilityId;\n this.fundId = fundId;\n }\n\n split(newNumberOfShares) {\n if (newNumberOfShares === this.numberOfShares) {\n return this;\n }\n if (newNumberOfShares < this.numberOfShares) {\n this.numberOfShares -= newNumberOfShares;\n return new PositionSC(this._owners[0], newNumberOfShares, this.dealId, this.facilityId, this.fundId);\n }\n throw new Error(`Cannot split current transaction`);\n }\n\n merge(...positions) {\n try {\n if (positions.length === 0) return this;\n let sendNumberOfShares = this.numberOfShares;\n this.numberOfShares = 0;\n for (let i = 0; i < positions.length; i += 1) {\n if (positions[i].dealId !== this.dealId || positions[i].facilityId !== this.facilityId || positions[i].fundId !== this.fundId) {\n throw new Error(`Unable to merge, positions don't originate from the same facility or don't belong to the same fund`);\n }\n sendNumberOfShares += positions[i].numberOfShares;\n positions[i].numberOfShares = 0;\n }\n return new PositionSC(this._owners[0], sendNumberOfShares, this.dealId, this.facilityId, this.fundId);\n } catch (err) {\n throw new Error(`Unable to merge positions`);\n }\n }\n\n send(to, fundId, numberOfShares) {\n if (this.numberOfShares < numberOfShares) throw new Error(`Insufficient funds`);\n this.numberOfShares = this.numberOfShares - numberOfShares;\n return new PositionSC(to, numberOfShares, this.dealId, this.facilityId, fundId);\n }\n}","__index":{"obj":0},"__func":"constructor","__args":["03c6b9c8a47c0c6a17597b33608a6102ad53b9590b1e18b83e98e7e22c24b85161",100,"78c0c4953c9efc56aed757ea0ba644d21fd731018bf71c7b5c9e75db215423b2:0","62b73c373d5543e2ba0fe24b53a3e920d8c1ae134c030f5de186c207aa23d3da:0","84a40f59478f97102c93a05120ed8ac6163e15901a16a3567f13f344c9f7f18f:0"]}u
https://whatsonchain.com/tx/9268ea122c3831e3af1b37cbd639e0d80c31445e7ca698ba81e33d981ad366e4