#0
nonstandard
0.00004000 BSV
Q!«ÿÅ_-§ó*(íbÙ°*ùPj¬ïªì
@Q®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":["03ab96ffc55f0b2da7f32a28ed0662ad01d980b0812af991506aacefaa01ec0d40",500,"160fa34d24dc32a3a40754f8ee50126e1d4551cc09babeade59f5d3e43db39e6:0","b25679fd69b09249ffa4bc29ca7662c9164cae770e2253393995f8a6ff7e2feb:0","073d6a02cf42061d45d3c562af338842d205ce0028805770f0744a86b20c698e:0"]}u
https://whatsonchain.com/tx/9a0f3d9e52b320e2a80b3ccee3fcbcc8116f83c449c27519005aac51cdb12303