datai-sdk 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/v1/activePositions/ActivePositionsResult.ts +76 -0
- package/API/v1/activePositions/OptionPosition.ts +78 -0
- package/API/v1/activePositions/Prediction.ts +82 -0
- package/API/v1/activePositions/TokenBalance.ts +6 -6
- package/API/v1/activePositions/activePositions.ts +7 -1
- package/API/v1/index.ts +2 -0
- package/API/v1/proto/activePositions/activePositions/ActivePositionsResultPb.ts +38 -1
- package/API/v1/proto/activePositions/activePositions/OptionPositionPb.ts +182 -0
- package/API/v1/proto/activePositions/activePositions/OptionSide.ts +10 -0
- package/API/v1/proto/activePositions/activePositions/OptionStyle.ts +10 -0
- package/API/v1/proto/activePositions/activePositions/OptionType.ts +10 -0
- package/API/v1/proto/activePositions/activePositions/PredictionPositionPb.ts +191 -0
- package/package.json +1 -1
|
@@ -5,6 +5,8 @@ import { TokenBalancePb } from '../proto/activePositions/activePositions/TokenBa
|
|
|
5
5
|
import { TokenBalance } from './TokenBalance'
|
|
6
6
|
import { NftItem } from './NftItem'
|
|
7
7
|
import { PerpPosition, PerpSide } from './PerpPosition'
|
|
8
|
+
import { OptionPosition } from './OptionPosition'
|
|
9
|
+
import { Prediction } from './Prediction'
|
|
8
10
|
|
|
9
11
|
export class ActivePositionsResult extends ActivePositionsResultPb {
|
|
10
12
|
tokenBalance(tokenBalances: Array<TokenBalancePb>, index: i32): TokenBalance {
|
|
@@ -362,4 +364,78 @@ export class ActivePositionsResult extends ActivePositionsResultPb {
|
|
|
362
364
|
get hasPerp(): bool {
|
|
363
365
|
return this.perpPosition !== null
|
|
364
366
|
}
|
|
367
|
+
|
|
368
|
+
// ==========================================================================
|
|
369
|
+
// OPTION POSITION METHODS
|
|
370
|
+
// ==========================================================================
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Set options position data (buyer/long or seller/short).
|
|
374
|
+
*
|
|
375
|
+
* @param option - An OptionPosition with scalar fields + token legs set
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* const opt = new OptionPosition()
|
|
380
|
+
* opt.optionType = OptionType.OPTION_TYPE_CALL
|
|
381
|
+
* opt.style = OptionStyle.OPTION_STYLE_EUROPEAN
|
|
382
|
+
* opt.side = OptionSide.OPTION_SIDE_SELLER
|
|
383
|
+
* opt.setUnderlying(weth, underlyingAmount)
|
|
384
|
+
* opt.setStrike(usdc, strikeNotional)
|
|
385
|
+
* opt.addCollateral(weth, collateralAmount)
|
|
386
|
+
* output.setOptionPosition(opt)
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
setOptionPosition(option: OptionPosition): void {
|
|
390
|
+
this.optionPosition = option
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Get options position (typed)
|
|
395
|
+
*
|
|
396
|
+
* @returns OptionPosition or null if no option position set
|
|
397
|
+
*/
|
|
398
|
+
getOption(): OptionPosition | null {
|
|
399
|
+
if (this.optionPosition === null) {
|
|
400
|
+
return null
|
|
401
|
+
}
|
|
402
|
+
return changetype<OptionPosition>(this.optionPosition)
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Check if an options position exists
|
|
407
|
+
*/
|
|
408
|
+
get hasOption(): bool {
|
|
409
|
+
return this.optionPosition !== null
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// ==========================================================================
|
|
413
|
+
// PREDICTION-MARKET METHODS
|
|
414
|
+
// ==========================================================================
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Add a prediction-market position (a user may hold several).
|
|
418
|
+
*
|
|
419
|
+
* @param prediction - A Prediction with its fields set
|
|
420
|
+
*/
|
|
421
|
+
addPrediction(prediction: Prediction): void {
|
|
422
|
+
this.predictions.push(prediction)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Get count of prediction positions
|
|
427
|
+
*/
|
|
428
|
+
get predictionCount(): i32 {
|
|
429
|
+
return this.predictions.length
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Get a prediction position by index (typed)
|
|
434
|
+
*/
|
|
435
|
+
getPrediction(index: i32): Prediction | null {
|
|
436
|
+
if (index < 0 || index >= this.predictions.length) {
|
|
437
|
+
return null
|
|
438
|
+
}
|
|
439
|
+
return changetype<Prediction>(this.predictions[index])
|
|
440
|
+
}
|
|
365
441
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Address, BigInt, BigDecimal } from '@graphprotocol/graph-ts'
|
|
2
|
+
import { Protobuf } from 'as-proto/assembly'
|
|
3
|
+
import { OptionPositionPb } from '../proto/activePositions/activePositions/OptionPositionPb'
|
|
4
|
+
import { BigDecimalPb } from '../bigDecimal/BigDecimalPb'
|
|
5
|
+
import { TokenBalance } from './TokenBalance'
|
|
6
|
+
|
|
7
|
+
// Re-export enums for convenience
|
|
8
|
+
export { OptionType } from '../proto/activePositions/activePositions/OptionType'
|
|
9
|
+
export { OptionStyle } from '../proto/activePositions/activePositions/OptionStyle'
|
|
10
|
+
export { OptionSide } from '../proto/activePositions/activePositions/OptionSide'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* OptionPosition - wrapper for options positions (long/buyer or short/seller).
|
|
14
|
+
*
|
|
15
|
+
* Canonical host shape: Type=PUT|CALL, Side=short|long, StrikePrice={Value,
|
|
16
|
+
* QuoteToken:{addr:wei}}, UnderlyingToken/CollateralTokens/SpreadHedgeTokens as
|
|
17
|
+
* {addr:wei} maps. Token amounts are wei; strikePriceValue is a decimal ratio.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const opt = new OptionPosition()
|
|
22
|
+
* opt.optionType = OptionType.OPTION_TYPE_PUT
|
|
23
|
+
* opt.style = OptionStyle.OPTION_STYLE_EUROPEAN
|
|
24
|
+
* opt.side = OptionSide.OPTION_SIDE_SELLER
|
|
25
|
+
* opt.isAutoExercise = true
|
|
26
|
+
* opt.exerciseStartAt = 1625011200
|
|
27
|
+
* opt.exerciseEndAt = 1625011200
|
|
28
|
+
* opt.expiryAt = 1625011200
|
|
29
|
+
* opt.strikePriceValue = BigDecimal.fromString("0.98")
|
|
30
|
+
* opt.setStrike(usdc, strikeNotionalWei) // StrikePrice.QuoteToken
|
|
31
|
+
* opt.setUnderlying(aUSDC, underlyingWei)
|
|
32
|
+
* opt.addCollateral(weth, collateralWei) // short only
|
|
33
|
+
* opt.addSpreadHedge(weth, hedgeWei) // short only
|
|
34
|
+
* output.setOptionPosition(opt)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export class OptionPosition extends OptionPositionPb {
|
|
38
|
+
/** Strike price ratio (quote per underlying) — a decimal, NOT a token amount. */
|
|
39
|
+
get strikePriceValue(): BigDecimal {
|
|
40
|
+
if (this.strikePriceValueBytes.length == 0) return BigDecimal.zero()
|
|
41
|
+
return Protobuf.decode<BigDecimal>(this.strikePriceValueBytes, BigDecimalPb.decode)
|
|
42
|
+
}
|
|
43
|
+
set strikePriceValue(value: BigDecimal) {
|
|
44
|
+
this.strikePriceValueBytes = Protobuf.encode(value, BigDecimalPb.encode)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Set the underlying token leg (address + amount in wei). */
|
|
48
|
+
setUnderlying(tokenAddress: Address, amount: BigInt): void {
|
|
49
|
+
const tb = new TokenBalance()
|
|
50
|
+
tb.tokenAddress = tokenAddress
|
|
51
|
+
tb.balance = amount
|
|
52
|
+
this.underlyingToken = tb
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Set the strike QuoteToken leg (address + notional amount in wei). */
|
|
56
|
+
setStrike(tokenAddress: Address, amount: BigInt): void {
|
|
57
|
+
const tb = new TokenBalance()
|
|
58
|
+
tb.tokenAddress = tokenAddress
|
|
59
|
+
tb.balance = amount
|
|
60
|
+
this.strikeToken = tb
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Add a collateral token entry (short positions only). */
|
|
64
|
+
addCollateral(tokenAddress: Address, amount: BigInt): void {
|
|
65
|
+
const tb = new TokenBalance()
|
|
66
|
+
tb.tokenAddress = tokenAddress
|
|
67
|
+
tb.balance = amount
|
|
68
|
+
this.collateralTokens.push(tb)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Add a spread-hedge token entry (short positions only). */
|
|
72
|
+
addSpreadHedge(tokenAddress: Address, amount: BigInt): void {
|
|
73
|
+
const tb = new TokenBalance()
|
|
74
|
+
tb.tokenAddress = tokenAddress
|
|
75
|
+
tb.balance = amount
|
|
76
|
+
this.spreadHedgeTokens.push(tb)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Address, BigInt, BigDecimal, Bytes } from '@graphprotocol/graph-ts'
|
|
2
|
+
import { Protobuf } from 'as-proto/assembly'
|
|
3
|
+
import { PredictionPositionPb } from '../proto/activePositions/activePositions/PredictionPositionPb'
|
|
4
|
+
import { BigDecimalPb } from '../bigDecimal/BigDecimalPb'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Prediction - wrapper for a prediction-market position (e.g. Polymarket CTF).
|
|
8
|
+
*
|
|
9
|
+
* shares / maxPayout are wei (raw). payoutPerShare / currentPrice are decimal
|
|
10
|
+
* ratios (0..1) in collateral units. Scalar fields (outcomeIndex,
|
|
11
|
+
* collateralDecimals, status, expiryAt, negativeRisk, market* strings) are set
|
|
12
|
+
* directly on the object.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const p = new Prediction()
|
|
17
|
+
* p.conditionId = conditionIdBytes
|
|
18
|
+
* p.positionId = positionIdBytes
|
|
19
|
+
* p.outcomeIndex = 1
|
|
20
|
+
* p.shares = sharesWei
|
|
21
|
+
* p.collateralTokenAddress = pUSD
|
|
22
|
+
* p.collateralDecimals = 6
|
|
23
|
+
* p.maxPayout = sharesWei
|
|
24
|
+
* p.status = "active"
|
|
25
|
+
* p.currentPrice = BigDecimal.fromString("0.475")
|
|
26
|
+
* p.negativeRisk = false
|
|
27
|
+
* p.marketTitle = "..."
|
|
28
|
+
* output.addPrediction(p)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class Prediction extends PredictionPositionPb {
|
|
32
|
+
get conditionId(): Bytes {
|
|
33
|
+
return changetype<Bytes>(this.conditionIdBytes)
|
|
34
|
+
}
|
|
35
|
+
set conditionId(value: Bytes) {
|
|
36
|
+
this.conditionIdBytes = value
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get positionId(): Bytes {
|
|
40
|
+
return changetype<Bytes>(this.positionIdBytes)
|
|
41
|
+
}
|
|
42
|
+
set positionId(value: Bytes) {
|
|
43
|
+
this.positionIdBytes = value
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get shares(): BigInt {
|
|
47
|
+
return changetype<BigInt>(this.sharesBytes)
|
|
48
|
+
}
|
|
49
|
+
set shares(value: BigInt) {
|
|
50
|
+
this.sharesBytes = changetype<Uint8Array>(value)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get collateralTokenAddress(): Address {
|
|
54
|
+
return changetype<Address>(this.collateralTokenAddressBytes)
|
|
55
|
+
}
|
|
56
|
+
set collateralTokenAddress(value: Address) {
|
|
57
|
+
this.collateralTokenAddressBytes = value
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get maxPayout(): BigInt {
|
|
61
|
+
return changetype<BigInt>(this.maxPayoutBytes)
|
|
62
|
+
}
|
|
63
|
+
set maxPayout(value: BigInt) {
|
|
64
|
+
this.maxPayoutBytes = changetype<Uint8Array>(value)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get payoutPerShare(): BigDecimal {
|
|
68
|
+
if (this.payoutPerShareBytes.length == 0) return BigDecimal.zero()
|
|
69
|
+
return Protobuf.decode<BigDecimal>(this.payoutPerShareBytes, BigDecimalPb.decode)
|
|
70
|
+
}
|
|
71
|
+
set payoutPerShare(value: BigDecimal) {
|
|
72
|
+
this.payoutPerShareBytes = Protobuf.encode(value, BigDecimalPb.encode)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get currentPrice(): BigDecimal {
|
|
76
|
+
if (this.currentPriceBytes.length == 0) return BigDecimal.zero()
|
|
77
|
+
return Protobuf.decode<BigDecimal>(this.currentPriceBytes, BigDecimalPb.decode)
|
|
78
|
+
}
|
|
79
|
+
set currentPrice(value: BigDecimal) {
|
|
80
|
+
this.currentPriceBytes = Protobuf.encode(value, BigDecimalPb.encode)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -46,11 +46,11 @@ export class TokenBalance extends TokenBalancePb {
|
|
|
46
46
|
}
|
|
47
47
|
return changetype<BigInt>(this.claimableAmountBytes)
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
// AssemblyScript cannot narrow `BigInt | null` → `BigInt` inside an `if` branch,
|
|
50
|
+
// and cannot implicitly widen `BigInt` → `Uint8Array` even though graph-ts BigInt
|
|
51
|
+
// extends Uint8Array. Accept non-null BigInt and use changetype explicitly.
|
|
52
|
+
// To clear the field, assign `new Uint8Array(0)` to `claimableAmountBytes` directly.
|
|
53
|
+
set claimableAmount(value: BigInt) {
|
|
54
|
+
this.claimableAmountBytes = changetype<Uint8Array>(value)
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -33,7 +33,13 @@ export namespace activePositions {
|
|
|
33
33
|
|
|
34
34
|
// NEW: Check for perpetual position
|
|
35
35
|
isActive = isActive || result.perpPosition !== null
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
// NEW: Check for options position
|
|
38
|
+
isActive = isActive || result.optionPosition !== null
|
|
39
|
+
|
|
40
|
+
// NEW: Check for prediction-market positions
|
|
41
|
+
isActive = isActive || result.predictions.length > 0
|
|
42
|
+
|
|
37
43
|
isActive = isActive && !forceInactive
|
|
38
44
|
|
|
39
45
|
const resultMsg = Protobuf.encode(
|
package/API/v1/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from './activePositions/activePositions'
|
|
|
2
2
|
export * from './activePositions/ActivePositionsResult'
|
|
3
3
|
export * from './activePositions/NftItem'
|
|
4
4
|
export * from './activePositions/PerpPosition'
|
|
5
|
+
export * from './activePositions/OptionPosition'
|
|
6
|
+
export * from './activePositions/Prediction'
|
|
5
7
|
export * from './store/store'
|
|
6
8
|
export * from './log/log'
|
|
7
9
|
export * from './ethereum/ethereum'
|
|
@@ -8,6 +8,8 @@ import { TokenBalancePb } from "./TokenBalancePb";
|
|
|
8
8
|
import { Timestamp } from "../../google/protobuf/Timestamp";
|
|
9
9
|
import { NftItemPb } from "./NftItemPb";
|
|
10
10
|
import { PerpPositionPb } from "./PerpPositionPb";
|
|
11
|
+
import { OptionPositionPb } from "./OptionPositionPb";
|
|
12
|
+
import { PredictionPositionPb } from "./PredictionPositionPb";
|
|
11
13
|
|
|
12
14
|
export class ActivePositionsResultPb {
|
|
13
15
|
static encode(message: ActivePositionsResultPb, writer: Writer): void {
|
|
@@ -69,6 +71,22 @@ export class ActivePositionsResultPb {
|
|
|
69
71
|
PerpPositionPb.encode(perpPosition, writer);
|
|
70
72
|
writer.ldelim();
|
|
71
73
|
}
|
|
74
|
+
|
|
75
|
+
const optionPosition = message.optionPosition;
|
|
76
|
+
if (optionPosition !== null) {
|
|
77
|
+
writer.uint32(74);
|
|
78
|
+
writer.fork();
|
|
79
|
+
OptionPositionPb.encode(optionPosition, writer);
|
|
80
|
+
writer.ldelim();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const predictions = message.predictions;
|
|
84
|
+
for (let i: i32 = 0; i < predictions.length; ++i) {
|
|
85
|
+
writer.uint32(82);
|
|
86
|
+
writer.fork();
|
|
87
|
+
PredictionPositionPb.encode(predictions[i], writer);
|
|
88
|
+
writer.ldelim();
|
|
89
|
+
}
|
|
72
90
|
}
|
|
73
91
|
|
|
74
92
|
static decode(reader: Reader, length: i32): ActivePositionsResultPb {
|
|
@@ -119,6 +137,19 @@ export class ActivePositionsResultPb {
|
|
|
119
137
|
message.perpPosition = PerpPositionPb.decode(reader, reader.uint32());
|
|
120
138
|
break;
|
|
121
139
|
|
|
140
|
+
case 9:
|
|
141
|
+
message.optionPosition = OptionPositionPb.decode(
|
|
142
|
+
reader,
|
|
143
|
+
reader.uint32()
|
|
144
|
+
);
|
|
145
|
+
break;
|
|
146
|
+
|
|
147
|
+
case 10:
|
|
148
|
+
message.predictions.push(
|
|
149
|
+
PredictionPositionPb.decode(reader, reader.uint32())
|
|
150
|
+
);
|
|
151
|
+
break;
|
|
152
|
+
|
|
122
153
|
default:
|
|
123
154
|
reader.skipType(tag & 7);
|
|
124
155
|
break;
|
|
@@ -136,6 +167,8 @@ export class ActivePositionsResultPb {
|
|
|
136
167
|
poolAddressBytes: Uint8Array;
|
|
137
168
|
supplyNfts: Array<NftItemPb>;
|
|
138
169
|
perpPosition: PerpPositionPb | null;
|
|
170
|
+
optionPosition: OptionPositionPb | null;
|
|
171
|
+
predictions: Array<PredictionPositionPb>;
|
|
139
172
|
|
|
140
173
|
constructor(
|
|
141
174
|
supplyTokens: Array<TokenBalancePb> = [],
|
|
@@ -145,7 +178,9 @@ export class ActivePositionsResultPb {
|
|
|
145
178
|
unlockTimestamp: Timestamp | null = null,
|
|
146
179
|
poolAddressBytes: Uint8Array = new Uint8Array(0),
|
|
147
180
|
supplyNfts: Array<NftItemPb> = [],
|
|
148
|
-
perpPosition: PerpPositionPb | null = null
|
|
181
|
+
perpPosition: PerpPositionPb | null = null,
|
|
182
|
+
optionPosition: OptionPositionPb | null = null,
|
|
183
|
+
predictions: Array<PredictionPositionPb> = []
|
|
149
184
|
) {
|
|
150
185
|
this.supplyTokens = supplyTokens;
|
|
151
186
|
this.borrowTokens = borrowTokens;
|
|
@@ -155,5 +190,7 @@ export class ActivePositionsResultPb {
|
|
|
155
190
|
this.poolAddressBytes = poolAddressBytes;
|
|
156
191
|
this.supplyNfts = supplyNfts;
|
|
157
192
|
this.perpPosition = perpPosition;
|
|
193
|
+
this.optionPosition = optionPosition;
|
|
194
|
+
this.predictions = predictions;
|
|
158
195
|
}
|
|
159
196
|
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Code generated by protoc-gen-as. DO NOT EDIT.
|
|
2
|
+
// Versions:
|
|
3
|
+
// protoc-gen-as v1.3.0
|
|
4
|
+
// protoc v6.33.4
|
|
5
|
+
|
|
6
|
+
import { Writer, Reader } from "as-proto/assembly";
|
|
7
|
+
import { OptionType } from "./OptionType";
|
|
8
|
+
import { OptionStyle } from "./OptionStyle";
|
|
9
|
+
import { OptionSide } from "./OptionSide";
|
|
10
|
+
import { TokenBalancePb } from "./TokenBalancePb";
|
|
11
|
+
|
|
12
|
+
export class OptionPositionPb {
|
|
13
|
+
static encode(message: OptionPositionPb, writer: Writer): void {
|
|
14
|
+
writer.uint32(8);
|
|
15
|
+
writer.int32(message.optionType);
|
|
16
|
+
|
|
17
|
+
writer.uint32(16);
|
|
18
|
+
writer.int32(message.style);
|
|
19
|
+
|
|
20
|
+
writer.uint32(24);
|
|
21
|
+
writer.int32(message.side);
|
|
22
|
+
|
|
23
|
+
writer.uint32(32);
|
|
24
|
+
writer.bool(message.isAutoExercise);
|
|
25
|
+
|
|
26
|
+
writer.uint32(40);
|
|
27
|
+
writer.int64(message.exerciseStartAt);
|
|
28
|
+
|
|
29
|
+
writer.uint32(48);
|
|
30
|
+
writer.int64(message.exerciseEndAt);
|
|
31
|
+
|
|
32
|
+
writer.uint32(56);
|
|
33
|
+
writer.int64(message.expiryAt);
|
|
34
|
+
|
|
35
|
+
const underlyingToken = message.underlyingToken;
|
|
36
|
+
if (underlyingToken !== null) {
|
|
37
|
+
writer.uint32(66);
|
|
38
|
+
writer.fork();
|
|
39
|
+
TokenBalancePb.encode(underlyingToken, writer);
|
|
40
|
+
writer.ldelim();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const strikeToken = message.strikeToken;
|
|
44
|
+
if (strikeToken !== null) {
|
|
45
|
+
writer.uint32(74);
|
|
46
|
+
writer.fork();
|
|
47
|
+
TokenBalancePb.encode(strikeToken, writer);
|
|
48
|
+
writer.ldelim();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const collateralTokens = message.collateralTokens;
|
|
52
|
+
for (let i: i32 = 0; i < collateralTokens.length; ++i) {
|
|
53
|
+
writer.uint32(82);
|
|
54
|
+
writer.fork();
|
|
55
|
+
TokenBalancePb.encode(collateralTokens[i], writer);
|
|
56
|
+
writer.ldelim();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
writer.uint32(90);
|
|
60
|
+
writer.bytes(message.strikePriceValueBytes);
|
|
61
|
+
|
|
62
|
+
const spreadHedgeTokens = message.spreadHedgeTokens;
|
|
63
|
+
for (let i: i32 = 0; i < spreadHedgeTokens.length; ++i) {
|
|
64
|
+
writer.uint32(98);
|
|
65
|
+
writer.fork();
|
|
66
|
+
TokenBalancePb.encode(spreadHedgeTokens[i], writer);
|
|
67
|
+
writer.ldelim();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static decode(reader: Reader, length: i32): OptionPositionPb {
|
|
72
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length;
|
|
73
|
+
const message = new OptionPositionPb();
|
|
74
|
+
|
|
75
|
+
while (reader.ptr < end) {
|
|
76
|
+
const tag = reader.uint32();
|
|
77
|
+
switch (tag >>> 3) {
|
|
78
|
+
case 1:
|
|
79
|
+
message.optionType = reader.int32();
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case 2:
|
|
83
|
+
message.style = reader.int32();
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 3:
|
|
87
|
+
message.side = reader.int32();
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case 4:
|
|
91
|
+
message.isAutoExercise = reader.bool();
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case 5:
|
|
95
|
+
message.exerciseStartAt = reader.int64();
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 6:
|
|
99
|
+
message.exerciseEndAt = reader.int64();
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case 7:
|
|
103
|
+
message.expiryAt = reader.int64();
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case 8:
|
|
107
|
+
message.underlyingToken = TokenBalancePb.decode(
|
|
108
|
+
reader,
|
|
109
|
+
reader.uint32()
|
|
110
|
+
);
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case 9:
|
|
114
|
+
message.strikeToken = TokenBalancePb.decode(reader, reader.uint32());
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
case 10:
|
|
118
|
+
message.collateralTokens.push(
|
|
119
|
+
TokenBalancePb.decode(reader, reader.uint32())
|
|
120
|
+
);
|
|
121
|
+
break;
|
|
122
|
+
|
|
123
|
+
case 11:
|
|
124
|
+
message.strikePriceValueBytes = reader.bytes();
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 12:
|
|
128
|
+
message.spreadHedgeTokens.push(
|
|
129
|
+
TokenBalancePb.decode(reader, reader.uint32())
|
|
130
|
+
);
|
|
131
|
+
break;
|
|
132
|
+
|
|
133
|
+
default:
|
|
134
|
+
reader.skipType(tag & 7);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return message;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
optionType: OptionType;
|
|
143
|
+
style: OptionStyle;
|
|
144
|
+
side: OptionSide;
|
|
145
|
+
isAutoExercise: bool;
|
|
146
|
+
exerciseStartAt: i64;
|
|
147
|
+
exerciseEndAt: i64;
|
|
148
|
+
expiryAt: i64;
|
|
149
|
+
underlyingToken: TokenBalancePb | null;
|
|
150
|
+
strikeToken: TokenBalancePb | null;
|
|
151
|
+
collateralTokens: Array<TokenBalancePb>;
|
|
152
|
+
strikePriceValueBytes: Uint8Array;
|
|
153
|
+
spreadHedgeTokens: Array<TokenBalancePb>;
|
|
154
|
+
|
|
155
|
+
constructor(
|
|
156
|
+
optionType: OptionType = 0,
|
|
157
|
+
style: OptionStyle = 0,
|
|
158
|
+
side: OptionSide = 0,
|
|
159
|
+
isAutoExercise: bool = false,
|
|
160
|
+
exerciseStartAt: i64 = 0,
|
|
161
|
+
exerciseEndAt: i64 = 0,
|
|
162
|
+
expiryAt: i64 = 0,
|
|
163
|
+
underlyingToken: TokenBalancePb | null = null,
|
|
164
|
+
strikeToken: TokenBalancePb | null = null,
|
|
165
|
+
collateralTokens: Array<TokenBalancePb> = [],
|
|
166
|
+
strikePriceValueBytes: Uint8Array = new Uint8Array(0),
|
|
167
|
+
spreadHedgeTokens: Array<TokenBalancePb> = []
|
|
168
|
+
) {
|
|
169
|
+
this.optionType = optionType;
|
|
170
|
+
this.style = style;
|
|
171
|
+
this.side = side;
|
|
172
|
+
this.isAutoExercise = isAutoExercise;
|
|
173
|
+
this.exerciseStartAt = exerciseStartAt;
|
|
174
|
+
this.exerciseEndAt = exerciseEndAt;
|
|
175
|
+
this.expiryAt = expiryAt;
|
|
176
|
+
this.underlyingToken = underlyingToken;
|
|
177
|
+
this.strikeToken = strikeToken;
|
|
178
|
+
this.collateralTokens = collateralTokens;
|
|
179
|
+
this.strikePriceValueBytes = strikePriceValueBytes;
|
|
180
|
+
this.spreadHedgeTokens = spreadHedgeTokens;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Code generated by protoc-gen-as. DO NOT EDIT.
|
|
2
|
+
// Versions:
|
|
3
|
+
// protoc-gen-as v1.3.0
|
|
4
|
+
// protoc v6.33.4
|
|
5
|
+
|
|
6
|
+
import { Writer, Reader } from "as-proto/assembly";
|
|
7
|
+
|
|
8
|
+
export class PredictionPositionPb {
|
|
9
|
+
static encode(message: PredictionPositionPb, writer: Writer): void {
|
|
10
|
+
writer.uint32(10);
|
|
11
|
+
writer.bytes(message.conditionIdBytes);
|
|
12
|
+
|
|
13
|
+
writer.uint32(18);
|
|
14
|
+
writer.bytes(message.positionIdBytes);
|
|
15
|
+
|
|
16
|
+
writer.uint32(24);
|
|
17
|
+
writer.int32(message.outcomeIndex);
|
|
18
|
+
|
|
19
|
+
writer.uint32(34);
|
|
20
|
+
writer.bytes(message.sharesBytes);
|
|
21
|
+
|
|
22
|
+
writer.uint32(42);
|
|
23
|
+
writer.bytes(message.collateralTokenAddressBytes);
|
|
24
|
+
|
|
25
|
+
writer.uint32(48);
|
|
26
|
+
writer.int32(message.collateralDecimals);
|
|
27
|
+
|
|
28
|
+
writer.uint32(58);
|
|
29
|
+
writer.bytes(message.maxPayoutBytes);
|
|
30
|
+
|
|
31
|
+
writer.uint32(66);
|
|
32
|
+
writer.string(message.status);
|
|
33
|
+
|
|
34
|
+
writer.uint32(74);
|
|
35
|
+
writer.bytes(message.payoutPerShareBytes);
|
|
36
|
+
|
|
37
|
+
writer.uint32(80);
|
|
38
|
+
writer.int64(message.expiryAt);
|
|
39
|
+
|
|
40
|
+
writer.uint32(88);
|
|
41
|
+
writer.bool(message.negativeRisk);
|
|
42
|
+
|
|
43
|
+
writer.uint32(98);
|
|
44
|
+
writer.bytes(message.currentPriceBytes);
|
|
45
|
+
|
|
46
|
+
writer.uint32(106);
|
|
47
|
+
writer.string(message.marketTitle);
|
|
48
|
+
|
|
49
|
+
writer.uint32(114);
|
|
50
|
+
writer.string(message.outcome);
|
|
51
|
+
|
|
52
|
+
writer.uint32(122);
|
|
53
|
+
writer.string(message.marketSlug);
|
|
54
|
+
|
|
55
|
+
writer.uint32(130);
|
|
56
|
+
writer.string(message.marketUrl);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static decode(reader: Reader, length: i32): PredictionPositionPb {
|
|
60
|
+
const end: usize = length < 0 ? reader.end : reader.ptr + length;
|
|
61
|
+
const message = new PredictionPositionPb();
|
|
62
|
+
|
|
63
|
+
while (reader.ptr < end) {
|
|
64
|
+
const tag = reader.uint32();
|
|
65
|
+
switch (tag >>> 3) {
|
|
66
|
+
case 1:
|
|
67
|
+
message.conditionIdBytes = reader.bytes();
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
case 2:
|
|
71
|
+
message.positionIdBytes = reader.bytes();
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
case 3:
|
|
75
|
+
message.outcomeIndex = reader.int32();
|
|
76
|
+
break;
|
|
77
|
+
|
|
78
|
+
case 4:
|
|
79
|
+
message.sharesBytes = reader.bytes();
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case 5:
|
|
83
|
+
message.collateralTokenAddressBytes = reader.bytes();
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 6:
|
|
87
|
+
message.collateralDecimals = reader.int32();
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case 7:
|
|
91
|
+
message.maxPayoutBytes = reader.bytes();
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case 8:
|
|
95
|
+
message.status = reader.string();
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 9:
|
|
99
|
+
message.payoutPerShareBytes = reader.bytes();
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case 10:
|
|
103
|
+
message.expiryAt = reader.int64();
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case 11:
|
|
107
|
+
message.negativeRisk = reader.bool();
|
|
108
|
+
break;
|
|
109
|
+
|
|
110
|
+
case 12:
|
|
111
|
+
message.currentPriceBytes = reader.bytes();
|
|
112
|
+
break;
|
|
113
|
+
|
|
114
|
+
case 13:
|
|
115
|
+
message.marketTitle = reader.string();
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
case 14:
|
|
119
|
+
message.outcome = reader.string();
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case 15:
|
|
123
|
+
message.marketSlug = reader.string();
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case 16:
|
|
127
|
+
message.marketUrl = reader.string();
|
|
128
|
+
break;
|
|
129
|
+
|
|
130
|
+
default:
|
|
131
|
+
reader.skipType(tag & 7);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return message;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
conditionIdBytes: Uint8Array;
|
|
140
|
+
positionIdBytes: Uint8Array;
|
|
141
|
+
outcomeIndex: i32;
|
|
142
|
+
sharesBytes: Uint8Array;
|
|
143
|
+
collateralTokenAddressBytes: Uint8Array;
|
|
144
|
+
collateralDecimals: i32;
|
|
145
|
+
maxPayoutBytes: Uint8Array;
|
|
146
|
+
status: string;
|
|
147
|
+
payoutPerShareBytes: Uint8Array;
|
|
148
|
+
expiryAt: i64;
|
|
149
|
+
negativeRisk: bool;
|
|
150
|
+
currentPriceBytes: Uint8Array;
|
|
151
|
+
marketTitle: string;
|
|
152
|
+
outcome: string;
|
|
153
|
+
marketSlug: string;
|
|
154
|
+
marketUrl: string;
|
|
155
|
+
|
|
156
|
+
constructor(
|
|
157
|
+
conditionIdBytes: Uint8Array = new Uint8Array(0),
|
|
158
|
+
positionIdBytes: Uint8Array = new Uint8Array(0),
|
|
159
|
+
outcomeIndex: i32 = 0,
|
|
160
|
+
sharesBytes: Uint8Array = new Uint8Array(0),
|
|
161
|
+
collateralTokenAddressBytes: Uint8Array = new Uint8Array(0),
|
|
162
|
+
collateralDecimals: i32 = 0,
|
|
163
|
+
maxPayoutBytes: Uint8Array = new Uint8Array(0),
|
|
164
|
+
status: string = "",
|
|
165
|
+
payoutPerShareBytes: Uint8Array = new Uint8Array(0),
|
|
166
|
+
expiryAt: i64 = 0,
|
|
167
|
+
negativeRisk: bool = false,
|
|
168
|
+
currentPriceBytes: Uint8Array = new Uint8Array(0),
|
|
169
|
+
marketTitle: string = "",
|
|
170
|
+
outcome: string = "",
|
|
171
|
+
marketSlug: string = "",
|
|
172
|
+
marketUrl: string = ""
|
|
173
|
+
) {
|
|
174
|
+
this.conditionIdBytes = conditionIdBytes;
|
|
175
|
+
this.positionIdBytes = positionIdBytes;
|
|
176
|
+
this.outcomeIndex = outcomeIndex;
|
|
177
|
+
this.sharesBytes = sharesBytes;
|
|
178
|
+
this.collateralTokenAddressBytes = collateralTokenAddressBytes;
|
|
179
|
+
this.collateralDecimals = collateralDecimals;
|
|
180
|
+
this.maxPayoutBytes = maxPayoutBytes;
|
|
181
|
+
this.status = status;
|
|
182
|
+
this.payoutPerShareBytes = payoutPerShareBytes;
|
|
183
|
+
this.expiryAt = expiryAt;
|
|
184
|
+
this.negativeRisk = negativeRisk;
|
|
185
|
+
this.currentPriceBytes = currentPriceBytes;
|
|
186
|
+
this.marketTitle = marketTitle;
|
|
187
|
+
this.outcome = outcome;
|
|
188
|
+
this.marketSlug = marketSlug;
|
|
189
|
+
this.marketUrl = marketUrl;
|
|
190
|
+
}
|
|
191
|
+
}
|
package/package.json
CHANGED