@drift-labs/sdk 2.28.0-beta.3 → 2.28.0-beta.5

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.28.0-beta.3",
2
+ "version": "2.28.0-beta.5",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -4285,22 +4285,35 @@
4285
4285
  "fields": [
4286
4286
  {
4287
4287
  "name": "pubkey",
4288
+ "docs": [
4289
+ "The perp market's address. It is a pda of the market index"
4290
+ ],
4288
4291
  "type": "publicKey"
4289
4292
  },
4290
4293
  {
4291
4294
  "name": "amm",
4295
+ "docs": [
4296
+ "The automated market maker"
4297
+ ],
4292
4298
  "type": {
4293
4299
  "defined": "AMM"
4294
4300
  }
4295
4301
  },
4296
4302
  {
4297
4303
  "name": "pnlPool",
4304
+ "docs": [
4305
+ "The market's pnl pool. When users settle negative pnl, the balance increases.",
4306
+ "When users settle positive pnl, the balance decreases. Can not go negative."
4307
+ ],
4298
4308
  "type": {
4299
4309
  "defined": "PoolBalance"
4300
4310
  }
4301
4311
  },
4302
4312
  {
4303
4313
  "name": "name",
4314
+ "docs": [
4315
+ "Encoded display name for the perp market e.g. SOL-PERP"
4316
+ ],
4304
4317
  "type": {
4305
4318
  "array": [
4306
4319
  "u8",
@@ -4310,72 +4323,138 @@
4310
4323
  },
4311
4324
  {
4312
4325
  "name": "insuranceClaim",
4326
+ "docs": [
4327
+ "The perp market's claim on the insurance fund"
4328
+ ],
4313
4329
  "type": {
4314
4330
  "defined": "InsuranceClaim"
4315
4331
  }
4316
4332
  },
4317
4333
  {
4318
4334
  "name": "unrealizedPnlMaxImbalance",
4335
+ "docs": [
4336
+ "The max pnl imbalance before positive pnl asset weight is discounted",
4337
+ "pnl imbalance is the difference between long and short pnl. When it's greater than 0,",
4338
+ "the amm has negative pnl and the initial asset weight for positive pnl is discounted",
4339
+ "precision = QUOTE_PRECISION"
4340
+ ],
4319
4341
  "type": "u64"
4320
4342
  },
4321
4343
  {
4322
4344
  "name": "expiryTs",
4345
+ "docs": [
4346
+ "The ts when the market will be expired. Only set if market is in reduce only mode"
4347
+ ],
4323
4348
  "type": "i64"
4324
4349
  },
4325
4350
  {
4326
4351
  "name": "expiryPrice",
4352
+ "docs": [
4353
+ "The price at which positions will be settled. Only set if market is expired",
4354
+ "precision = PRICE_PRECISION"
4355
+ ],
4327
4356
  "type": "i64"
4328
4357
  },
4329
4358
  {
4330
4359
  "name": "nextFillRecordId",
4360
+ "docs": [
4361
+ "Every trade has a fill record id. This is the next id to be used"
4362
+ ],
4331
4363
  "type": "u64"
4332
4364
  },
4333
4365
  {
4334
4366
  "name": "nextFundingRateRecordId",
4367
+ "docs": [
4368
+ "Every funding rate update has a record id. This is the next id to be used"
4369
+ ],
4335
4370
  "type": "u64"
4336
4371
  },
4337
4372
  {
4338
4373
  "name": "nextCurveRecordId",
4374
+ "docs": [
4375
+ "Every amm k updated has a record id. This is the next id to be used"
4376
+ ],
4339
4377
  "type": "u64"
4340
4378
  },
4341
4379
  {
4342
4380
  "name": "imfFactor",
4381
+ "docs": [
4382
+ "The initial margin fraction factor. Used to increase margin ratio for large positions",
4383
+ "precision: MARGIN_PRECISION"
4384
+ ],
4343
4385
  "type": "u32"
4344
4386
  },
4345
4387
  {
4346
4388
  "name": "unrealizedPnlImfFactor",
4389
+ "docs": [
4390
+ "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl",
4391
+ "precision: MARGIN_PRECISION"
4392
+ ],
4347
4393
  "type": "u32"
4348
4394
  },
4349
4395
  {
4350
4396
  "name": "liquidatorFee",
4397
+ "docs": [
4398
+ "The fee the liquidator is paid for taking over perp position",
4399
+ "precision: LIQUIDATOR_FEE_PRECISION"
4400
+ ],
4351
4401
  "type": "u32"
4352
4402
  },
4353
4403
  {
4354
4404
  "name": "ifLiquidationFee",
4405
+ "docs": [
4406
+ "The fee the insurance fund receives from liquidation",
4407
+ "precision: LIQUIDATOR_FEE_PRECISION"
4408
+ ],
4355
4409
  "type": "u32"
4356
4410
  },
4357
4411
  {
4358
4412
  "name": "marginRatioInitial",
4413
+ "docs": [
4414
+ "The margin ratio which determines how much collateral is required to open a position",
4415
+ "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position",
4416
+ "precision: MARGIN_PRECISION"
4417
+ ],
4359
4418
  "type": "u32"
4360
4419
  },
4361
4420
  {
4362
4421
  "name": "marginRatioMaintenance",
4422
+ "docs": [
4423
+ "The margin ratio which determines when a user will be liquidated",
4424
+ "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position",
4425
+ "else they will be liquidated",
4426
+ "precision: MARGIN_PRECISION"
4427
+ ],
4363
4428
  "type": "u32"
4364
4429
  },
4365
4430
  {
4366
4431
  "name": "unrealizedPnlInitialAssetWeight",
4432
+ "docs": [
4433
+ "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1",
4434
+ "precision: SPOT_WEIGHT_PRECISION"
4435
+ ],
4367
4436
  "type": "u32"
4368
4437
  },
4369
4438
  {
4370
4439
  "name": "unrealizedPnlMaintenanceAssetWeight",
4440
+ "docs": [
4441
+ "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1",
4442
+ "precision: SPOT_WEIGHT_PRECISION"
4443
+ ],
4371
4444
  "type": "u32"
4372
4445
  },
4373
4446
  {
4374
4447
  "name": "numberOfUsersWithBase",
4448
+ "docs": [
4449
+ "number of users in a position (base)"
4450
+ ],
4375
4451
  "type": "u32"
4376
4452
  },
4377
4453
  {
4378
4454
  "name": "numberOfUsers",
4455
+ "docs": [
4456
+ "number of users in a position (pnl) or pnl (quote)"
4457
+ ],
4379
4458
  "type": "u32"
4380
4459
  },
4381
4460
  {
@@ -4384,18 +4463,29 @@
4384
4463
  },
4385
4464
  {
4386
4465
  "name": "status",
4466
+ "docs": [
4467
+ "Whether a market is active, reduce only, expired, etc",
4468
+ "Affects whether users can open/close positions"
4469
+ ],
4387
4470
  "type": {
4388
4471
  "defined": "MarketStatus"
4389
4472
  }
4390
4473
  },
4391
4474
  {
4392
4475
  "name": "contractType",
4476
+ "docs": [
4477
+ "Currently only Perpetual markets are supported"
4478
+ ],
4393
4479
  "type": {
4394
4480
  "defined": "ContractType"
4395
4481
  }
4396
4482
  },
4397
4483
  {
4398
4484
  "name": "contractTier",
4485
+ "docs": [
4486
+ "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance",
4487
+ "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first"
4488
+ ],
4399
4489
  "type": {
4400
4490
  "defined": "ContractTier"
4401
4491
  }
@@ -4406,6 +4496,9 @@
4406
4496
  },
4407
4497
  {
4408
4498
  "name": "quoteSpotMarketIndex",
4499
+ "docs": [
4500
+ "The spot market that pnl is settled in"
4501
+ ],
4409
4502
  "type": "u16"
4410
4503
  },
4411
4504
  {
@@ -4427,22 +4520,38 @@
4427
4520
  "fields": [
4428
4521
  {
4429
4522
  "name": "pubkey",
4523
+ "docs": [
4524
+ "The address of the spot market. It is a pda of the market index"
4525
+ ],
4430
4526
  "type": "publicKey"
4431
4527
  },
4432
4528
  {
4433
4529
  "name": "oracle",
4530
+ "docs": [
4531
+ "The oracle used to price the markets deposits/borrows"
4532
+ ],
4434
4533
  "type": "publicKey"
4435
4534
  },
4436
4535
  {
4437
4536
  "name": "mint",
4537
+ "docs": [
4538
+ "The token mint of the market"
4539
+ ],
4438
4540
  "type": "publicKey"
4439
4541
  },
4440
4542
  {
4441
4543
  "name": "vault",
4544
+ "docs": [
4545
+ "The vault used to store the market's deposits",
4546
+ "The amount in the vault should be equal to or greater than deposits - borrows"
4547
+ ],
4442
4548
  "type": "publicKey"
4443
4549
  },
4444
4550
  {
4445
4551
  "name": "name",
4552
+ "docs": [
4553
+ "The encoded display name fo the market e.g. SOL"
4554
+ ],
4446
4555
  "type": {
4447
4556
  "array": [
4448
4557
  "u8",
@@ -4464,148 +4573,294 @@
4464
4573
  },
4465
4574
  {
4466
4575
  "name": "revenuePool",
4576
+ "docs": [
4577
+ "Revenue the protocol has collected in this markets token",
4578
+ "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool"
4579
+ ],
4467
4580
  "type": {
4468
4581
  "defined": "PoolBalance"
4469
4582
  }
4470
4583
  },
4471
4584
  {
4472
4585
  "name": "spotFeePool",
4586
+ "docs": [
4587
+ "The fees collected from swaps between this market and the quote market",
4588
+ "Is settled to the quote markets revenue pool"
4589
+ ],
4473
4590
  "type": {
4474
4591
  "defined": "PoolBalance"
4475
4592
  }
4476
4593
  },
4477
4594
  {
4478
4595
  "name": "insuranceFund",
4596
+ "docs": [
4597
+ "Details on the insurance fund covering bankruptcies in this markets token",
4598
+ "Covers bankruptcies for borrows with this markets token and perps settling in this markets token"
4599
+ ],
4479
4600
  "type": {
4480
4601
  "defined": "InsuranceFund"
4481
4602
  }
4482
4603
  },
4483
4604
  {
4484
4605
  "name": "totalSpotFee",
4606
+ "docs": [
4607
+ "The total spot fees collected for this market",
4608
+ "precision: QUOTE_PRECISION"
4609
+ ],
4485
4610
  "type": "u128"
4486
4611
  },
4487
4612
  {
4488
4613
  "name": "depositBalance",
4614
+ "docs": [
4615
+ "The sum of the scaled balances for deposits across users and pool balances",
4616
+ "To convert to the deposit token amount, multiply by the cumulative deposit interest",
4617
+ "precision: SPOT_BALANCE_PRECISION"
4618
+ ],
4489
4619
  "type": "u128"
4490
4620
  },
4491
4621
  {
4492
4622
  "name": "borrowBalance",
4623
+ "docs": [
4624
+ "The sum of the scaled balances for borrows across users and pool balances",
4625
+ "To convert to the borrow token amount, multiply by the cumulative borrow interest",
4626
+ "precision: SPOT_BALANCE_PRECISION"
4627
+ ],
4493
4628
  "type": "u128"
4494
4629
  },
4495
4630
  {
4496
4631
  "name": "cumulativeDepositInterest",
4632
+ "docs": [
4633
+ "The cumulative interest earned by depositors",
4634
+ "Used to calculate the deposit token amount from the deposit balance",
4635
+ "precision: SPOT_CUMULATIVE_INTEREST_PRECISION"
4636
+ ],
4497
4637
  "type": "u128"
4498
4638
  },
4499
4639
  {
4500
4640
  "name": "cumulativeBorrowInterest",
4641
+ "docs": [
4642
+ "The cumulative interest earned by borrowers",
4643
+ "Used to calculate the borrow token amount from the borrow balance",
4644
+ "precision: SPOT_CUMULATIVE_INTEREST_PRECISION"
4645
+ ],
4501
4646
  "type": "u128"
4502
4647
  },
4503
4648
  {
4504
4649
  "name": "totalSocialLoss",
4650
+ "docs": [
4651
+ "The total socialized loss from borrows, in the mint's token",
4652
+ "precision: token mint precision"
4653
+ ],
4505
4654
  "type": "u128"
4506
4655
  },
4507
4656
  {
4508
4657
  "name": "totalQuoteSocialLoss",
4658
+ "docs": [
4659
+ "The total socialized loss from borrows, in the quote market's token",
4660
+ "preicision: QUOTE_PRECISION"
4661
+ ],
4509
4662
  "type": "u128"
4510
4663
  },
4511
4664
  {
4512
4665
  "name": "withdrawGuardThreshold",
4666
+ "docs": [
4667
+ "no withdraw limits/guards when deposits below this threshold",
4668
+ "precision: token mint precision"
4669
+ ],
4513
4670
  "type": "u64"
4514
4671
  },
4515
4672
  {
4516
4673
  "name": "maxTokenDeposits",
4674
+ "docs": [
4675
+ "The max amount of token deposits in this market",
4676
+ "0 if there is no limit",
4677
+ "precision: token mint precision"
4678
+ ],
4517
4679
  "type": "u64"
4518
4680
  },
4519
4681
  {
4520
4682
  "name": "depositTokenTwap",
4683
+ "docs": [
4684
+ "24hr average of deposit token amount",
4685
+ "precision: token mint precision"
4686
+ ],
4521
4687
  "type": "u64"
4522
4688
  },
4523
4689
  {
4524
4690
  "name": "borrowTokenTwap",
4691
+ "docs": [
4692
+ "24hr average of borrow token amount",
4693
+ "precision: token mint precision"
4694
+ ],
4525
4695
  "type": "u64"
4526
4696
  },
4527
4697
  {
4528
4698
  "name": "utilizationTwap",
4699
+ "docs": [
4700
+ "24hr average of utilization",
4701
+ "which is borrow amount over token amount",
4702
+ "precision: SPOT_UTILIZATION_PRECISION"
4703
+ ],
4529
4704
  "type": "u64"
4530
4705
  },
4531
4706
  {
4532
4707
  "name": "lastInterestTs",
4708
+ "docs": [
4709
+ "Last time the cumulative deposit and borrow interest was updated"
4710
+ ],
4533
4711
  "type": "u64"
4534
4712
  },
4535
4713
  {
4536
4714
  "name": "lastTwapTs",
4715
+ "docs": [
4716
+ "Last time the deposit/borrow/utilization averages were updated"
4717
+ ],
4537
4718
  "type": "u64"
4538
4719
  },
4539
4720
  {
4540
4721
  "name": "expiryTs",
4722
+ "docs": [
4723
+ "The time the market is set to expire. Only set if market is in reduce only mode"
4724
+ ],
4541
4725
  "type": "i64"
4542
4726
  },
4543
4727
  {
4544
4728
  "name": "orderStepSize",
4729
+ "docs": [
4730
+ "Spot orders must be a multiple of the step size",
4731
+ "precision: token mint precision"
4732
+ ],
4545
4733
  "type": "u64"
4546
4734
  },
4547
4735
  {
4548
4736
  "name": "orderTickSize",
4737
+ "docs": [
4738
+ "Spot orders must be a multiple of the tick size",
4739
+ "precision: QUOTE_PRECISION"
4740
+ ],
4549
4741
  "type": "u64"
4550
4742
  },
4551
4743
  {
4552
4744
  "name": "minOrderSize",
4745
+ "docs": [
4746
+ "The minimum order size",
4747
+ "precision: token mint precision"
4748
+ ],
4553
4749
  "type": "u64"
4554
4750
  },
4555
4751
  {
4556
4752
  "name": "maxPositionSize",
4753
+ "docs": [
4754
+ "The maximum spot position size",
4755
+ "if the limit is 0, there is no limit",
4756
+ "precision: token mint precision"
4757
+ ],
4557
4758
  "type": "u64"
4558
4759
  },
4559
4760
  {
4560
4761
  "name": "nextFillRecordId",
4762
+ "docs": [
4763
+ "Every spot trade has a fill record id. This is the next id to use"
4764
+ ],
4561
4765
  "type": "u64"
4562
4766
  },
4563
4767
  {
4564
4768
  "name": "nextDepositRecordId",
4769
+ "docs": [
4770
+ "Every deposit has a deposit record id. This is the next id to use"
4771
+ ],
4565
4772
  "type": "u64"
4566
4773
  },
4567
4774
  {
4568
4775
  "name": "initialAssetWeight",
4776
+ "docs": [
4777
+ "The initial asset weight used to calculate a deposits contribution to a users initial total collateral",
4778
+ "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral",
4779
+ "precision: SPOT_WEIGHT_PRECISION"
4780
+ ],
4569
4781
  "type": "u32"
4570
4782
  },
4571
4783
  {
4572
4784
  "name": "maintenanceAssetWeight",
4785
+ "docs": [
4786
+ "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral",
4787
+ "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral",
4788
+ "precision: SPOT_WEIGHT_PRECISION"
4789
+ ],
4573
4790
  "type": "u32"
4574
4791
  },
4575
4792
  {
4576
4793
  "name": "initialLiabilityWeight",
4794
+ "docs": [
4795
+ "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement",
4796
+ "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement",
4797
+ "precision: SPOT_WEIGHT_PRECISION"
4798
+ ],
4577
4799
  "type": "u32"
4578
4800
  },
4579
4801
  {
4580
4802
  "name": "maintenanceLiabilityWeight",
4803
+ "docs": [
4804
+ "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement",
4805
+ "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement",
4806
+ "precision: SPOT_WEIGHT_PRECISION"
4807
+ ],
4581
4808
  "type": "u32"
4582
4809
  },
4583
4810
  {
4584
4811
  "name": "imfFactor",
4812
+ "docs": [
4813
+ "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions",
4814
+ "precision: MARGIN_PRECISION"
4815
+ ],
4585
4816
  "type": "u32"
4586
4817
  },
4587
4818
  {
4588
4819
  "name": "liquidatorFee",
4820
+ "docs": [
4821
+ "The fee the liquidator is paid for taking over borrow/deposit",
4822
+ "precision: LIQUIDATOR_FEE_PRECISION"
4823
+ ],
4589
4824
  "type": "u32"
4590
4825
  },
4591
4826
  {
4592
4827
  "name": "ifLiquidationFee",
4828
+ "docs": [
4829
+ "The fee the insurance fund receives from liquidation",
4830
+ "precision: LIQUIDATOR_FEE_PRECISION"
4831
+ ],
4593
4832
  "type": "u32"
4594
4833
  },
4595
4834
  {
4596
4835
  "name": "optimalUtilization",
4836
+ "docs": [
4837
+ "The optimal utilization rate for this market.",
4838
+ "Used to determine the markets borrow rate",
4839
+ "precision: SPOT_UTILIZATION_PRECISION"
4840
+ ],
4597
4841
  "type": "u32"
4598
4842
  },
4599
4843
  {
4600
4844
  "name": "optimalBorrowRate",
4845
+ "docs": [
4846
+ "The borrow rate for this market when the market has optimal utilization",
4847
+ "precision: SPOT_RATE_PRECISION"
4848
+ ],
4601
4849
  "type": "u32"
4602
4850
  },
4603
4851
  {
4604
4852
  "name": "maxBorrowRate",
4853
+ "docs": [
4854
+ "The borrow rate for this market when the market has 1000 utilization",
4855
+ "precision: SPOT_RATE_PRECISION"
4856
+ ],
4605
4857
  "type": "u32"
4606
4858
  },
4607
4859
  {
4608
4860
  "name": "decimals",
4861
+ "docs": [
4862
+ "The market's token mint's decimals. To from decimals to a precision, 10^decimals"
4863
+ ],
4609
4864
  "type": "u32"
4610
4865
  },
4611
4866
  {
@@ -4614,6 +4869,9 @@
4614
4869
  },
4615
4870
  {
4616
4871
  "name": "ordersEnabled",
4872
+ "docs": [
4873
+ "Whether or not spot trading is enabled"
4874
+ ],
4617
4875
  "type": "bool"
4618
4876
  },
4619
4877
  {
@@ -4630,6 +4888,9 @@
4630
4888
  },
4631
4889
  {
4632
4890
  "name": "assetTier",
4891
+ "docs": [
4892
+ "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated"
4893
+ ],
4633
4894
  "type": {
4634
4895
  "defined": "AssetTier"
4635
4896
  }
@@ -4764,14 +5025,23 @@
4764
5025
  "fields": [
4765
5026
  {
4766
5027
  "name": "authority",
5028
+ "docs": [
5029
+ "The owner/authority of the account"
5030
+ ],
4767
5031
  "type": "publicKey"
4768
5032
  },
4769
5033
  {
4770
5034
  "name": "delegate",
5035
+ "docs": [
5036
+ "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw"
5037
+ ],
4771
5038
  "type": "publicKey"
4772
5039
  },
4773
5040
  {
4774
5041
  "name": "name",
5042
+ "docs": [
5043
+ "Encoded display name e.g. \"toly\""
5044
+ ],
4775
5045
  "type": {
4776
5046
  "array": [
4777
5047
  "u8",
@@ -4781,6 +5051,9 @@
4781
5051
  },
4782
5052
  {
4783
5053
  "name": "spotPositions",
5054
+ "docs": [
5055
+ "The user's spot positions"
5056
+ ],
4784
5057
  "type": {
4785
5058
  "array": [
4786
5059
  {
@@ -4792,6 +5065,9 @@
4792
5065
  },
4793
5066
  {
4794
5067
  "name": "perpPositions",
5068
+ "docs": [
5069
+ "The user's perp positions"
5070
+ ],
4795
5071
  "type": {
4796
5072
  "array": [
4797
5073
  {
@@ -4803,6 +5079,9 @@
4803
5079
  },
4804
5080
  {
4805
5081
  "name": "orders",
5082
+ "docs": [
5083
+ "The user's orders"
5084
+ ],
4806
5085
  "type": {
4807
5086
  "array": [
4808
5087
  {
@@ -4814,68 +5093,125 @@
4814
5093
  },
4815
5094
  {
4816
5095
  "name": "lastAddPerpLpSharesTs",
5096
+ "docs": [
5097
+ "The last time the user added perp lp positions"
5098
+ ],
4817
5099
  "type": "i64"
4818
5100
  },
4819
5101
  {
4820
5102
  "name": "totalDeposits",
5103
+ "docs": [
5104
+ "The total values of deposits the user has made",
5105
+ "precision: QUOTE_PRECISION"
5106
+ ],
4821
5107
  "type": "u64"
4822
5108
  },
4823
5109
  {
4824
5110
  "name": "totalWithdraws",
5111
+ "docs": [
5112
+ "The total values of withdrawals the user has made",
5113
+ "precision: QUOTE_PRECISION"
5114
+ ],
4825
5115
  "type": "u64"
4826
5116
  },
4827
5117
  {
4828
5118
  "name": "totalSocialLoss",
5119
+ "docs": [
5120
+ "The total socialized loss the users has incurred upon the protocol",
5121
+ "precision: QUOTE_PRECISION"
5122
+ ],
4829
5123
  "type": "u64"
4830
5124
  },
4831
5125
  {
4832
5126
  "name": "settledPerpPnl",
5127
+ "docs": [
5128
+ "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps",
5129
+ "precision: QUOTE_PRECISION"
5130
+ ],
4833
5131
  "type": "i64"
4834
5132
  },
4835
5133
  {
4836
5134
  "name": "cumulativeSpotFees",
5135
+ "docs": [
5136
+ "Fees (taker fees, maker rebate, filler reward) for spot",
5137
+ "precision: QUOTE_PRECISION"
5138
+ ],
4837
5139
  "type": "i64"
4838
5140
  },
4839
5141
  {
4840
5142
  "name": "cumulativePerpFunding",
5143
+ "docs": [
5144
+ "Cumulative funding paid/received for perps",
5145
+ "precision: QUOTE_PRECISION"
5146
+ ],
4841
5147
  "type": "i64"
4842
5148
  },
4843
5149
  {
4844
5150
  "name": "liquidationMarginFreed",
5151
+ "docs": [
5152
+ "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time",
5153
+ "Defaults to zero when not being liquidated",
5154
+ "precision: QUOTE_PRECISION"
5155
+ ],
4845
5156
  "type": "u64"
4846
5157
  },
4847
5158
  {
4848
5159
  "name": "lastActiveSlot",
5160
+ "docs": [
5161
+ "The last slot a user was active. Used to determine if a user is idle"
5162
+ ],
4849
5163
  "type": "u64"
4850
5164
  },
4851
5165
  {
4852
5166
  "name": "nextOrderId",
5167
+ "docs": [
5168
+ "Every user order has an order id. This is the next order id to be used"
5169
+ ],
4853
5170
  "type": "u32"
4854
5171
  },
4855
5172
  {
4856
5173
  "name": "maxMarginRatio",
5174
+ "docs": [
5175
+ "Custom max initial margin ratio for the user"
5176
+ ],
4857
5177
  "type": "u32"
4858
5178
  },
4859
5179
  {
4860
5180
  "name": "nextLiquidationId",
5181
+ "docs": [
5182
+ "The next liquidation id to be used for user"
5183
+ ],
4861
5184
  "type": "u16"
4862
5185
  },
4863
5186
  {
4864
5187
  "name": "subAccountId",
5188
+ "docs": [
5189
+ "The sub account id for this user"
5190
+ ],
4865
5191
  "type": "u16"
4866
5192
  },
4867
5193
  {
4868
5194
  "name": "status",
5195
+ "docs": [
5196
+ "Whether the user is active, being liquidated or bankrupt"
5197
+ ],
4869
5198
  "type": {
4870
5199
  "defined": "UserStatus"
4871
5200
  }
4872
5201
  },
4873
5202
  {
4874
5203
  "name": "isMarginTradingEnabled",
5204
+ "docs": [
5205
+ "Whether the user has enabled margin trading"
5206
+ ],
4875
5207
  "type": "bool"
4876
5208
  },
4877
5209
  {
4878
5210
  "name": "idle",
5211
+ "docs": [
5212
+ "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows",
5213
+ "Off-chain keeper bots can ignore users that are idle"
5214
+ ],
4879
5215
  "type": "bool"
4880
5216
  },
4881
5217
  {
@@ -4897,60 +5233,107 @@
4897
5233
  "fields": [
4898
5234
  {
4899
5235
  "name": "authority",
5236
+ "docs": [
5237
+ "The authority for all of a users sub accounts"
5238
+ ],
4900
5239
  "type": "publicKey"
4901
5240
  },
4902
5241
  {
4903
5242
  "name": "referrer",
5243
+ "docs": [
5244
+ "The address that referred this user"
5245
+ ],
4904
5246
  "type": "publicKey"
4905
5247
  },
4906
5248
  {
4907
5249
  "name": "fees",
5250
+ "docs": [
5251
+ "Stats on the fees paid by the user"
5252
+ ],
4908
5253
  "type": {
4909
5254
  "defined": "UserFees"
4910
5255
  }
4911
5256
  },
4912
5257
  {
4913
5258
  "name": "nextEpochTs",
5259
+ "docs": [
5260
+ "The timestamp of the next epoch",
5261
+ "Epoch is used to limit referrer rewards earned in single epoch"
5262
+ ],
4914
5263
  "type": "i64"
4915
5264
  },
4916
5265
  {
4917
5266
  "name": "makerVolume30d",
5267
+ "docs": [
5268
+ "Rolling 30day maker volume for user",
5269
+ "precision: QUOTE_PRECISION"
5270
+ ],
4918
5271
  "type": "u64"
4919
5272
  },
4920
5273
  {
4921
5274
  "name": "takerVolume30d",
5275
+ "docs": [
5276
+ "Rolling 30day taker volume for user",
5277
+ "precision: QUOTE_PRECISION"
5278
+ ],
4922
5279
  "type": "u64"
4923
5280
  },
4924
5281
  {
4925
5282
  "name": "fillerVolume30d",
5283
+ "docs": [
5284
+ "Rolling 30day filler volume for user",
5285
+ "precision: QUOTE_PRECISION"
5286
+ ],
4926
5287
  "type": "u64"
4927
5288
  },
4928
5289
  {
4929
5290
  "name": "lastMakerVolume30dTs",
5291
+ "docs": [
5292
+ "last time the maker volume was updated"
5293
+ ],
4930
5294
  "type": "i64"
4931
5295
  },
4932
5296
  {
4933
5297
  "name": "lastTakerVolume30dTs",
5298
+ "docs": [
5299
+ "last time the taker volume was updated"
5300
+ ],
4934
5301
  "type": "i64"
4935
5302
  },
4936
5303
  {
4937
5304
  "name": "lastFillerVolume30dTs",
5305
+ "docs": [
5306
+ "last time the filler volume was updated"
5307
+ ],
4938
5308
  "type": "i64"
4939
5309
  },
4940
5310
  {
4941
5311
  "name": "ifStakedQuoteAssetAmount",
5312
+ "docs": [
5313
+ "The amount of tokens staked in the quote spot markets if"
5314
+ ],
4942
5315
  "type": "u64"
4943
5316
  },
4944
5317
  {
4945
5318
  "name": "numberOfSubAccounts",
5319
+ "docs": [
5320
+ "The current number of sub accounts"
5321
+ ],
4946
5322
  "type": "u16"
4947
5323
  },
4948
5324
  {
4949
5325
  "name": "numberOfSubAccountsCreated",
5326
+ "docs": [
5327
+ "The number of sub accounts created. Can be greater than the number of sub accounts if user",
5328
+ "has deleted sub accounts"
5329
+ ],
4950
5330
  "type": "u16"
4951
5331
  },
4952
5332
  {
4953
5333
  "name": "isReferrer",
5334
+ "docs": [
5335
+ "Whether the user is a referrer. Sub account 0 can not be deleted if user is a referrer"
5336
+ ],
4954
5337
  "type": "bool"
4955
5338
  },
4956
5339
  {
@@ -5401,10 +5784,16 @@
5401
5784
  "fields": [
5402
5785
  {
5403
5786
  "name": "lastOraclePrice",
5787
+ "docs": [
5788
+ "precision: PRICE_PRECISION"
5789
+ ],
5404
5790
  "type": "i64"
5405
5791
  },
5406
5792
  {
5407
5793
  "name": "lastOracleConf",
5794
+ "docs": [
5795
+ "precision: PRICE_PRECISION"
5796
+ ],
5408
5797
  "type": "u64"
5409
5798
  },
5410
5799
  {
@@ -5413,10 +5802,16 @@
5413
5802
  },
5414
5803
  {
5415
5804
  "name": "lastOraclePriceTwap",
5805
+ "docs": [
5806
+ "precision: PRICE_PRECISION"
5807
+ ],
5416
5808
  "type": "i64"
5417
5809
  },
5418
5810
  {
5419
5811
  "name": "lastOraclePriceTwap5min",
5812
+ "docs": [
5813
+ "precision: PRICE_PRECISION"
5814
+ ],
5420
5815
  "type": "i64"
5421
5816
  },
5422
5817
  {
@@ -5433,18 +5828,30 @@
5433
5828
  "fields": [
5434
5829
  {
5435
5830
  "name": "lastIndexBidPrice",
5831
+ "docs": [
5832
+ "precision: PRICE_PRECISION"
5833
+ ],
5436
5834
  "type": "u64"
5437
5835
  },
5438
5836
  {
5439
5837
  "name": "lastIndexAskPrice",
5838
+ "docs": [
5839
+ "precision: PRICE_PRECISION"
5840
+ ],
5440
5841
  "type": "u64"
5441
5842
  },
5442
5843
  {
5443
5844
  "name": "lastIndexPriceTwap",
5845
+ "docs": [
5846
+ "precision: PRICE_PRECISION"
5847
+ ],
5444
5848
  "type": "u64"
5445
5849
  },
5446
5850
  {
5447
5851
  "name": "lastIndexPriceTwap5min",
5852
+ "docs": [
5853
+ "precision: PRICE_PRECISION"
5854
+ ],
5448
5855
  "type": "u64"
5449
5856
  },
5450
5857
  {
@@ -5461,22 +5868,43 @@
5461
5868
  "fields": [
5462
5869
  {
5463
5870
  "name": "revenueWithdrawSinceLastSettle",
5871
+ "docs": [
5872
+ "The amount of revenue last settled",
5873
+ "Positive if funds left the perp market,",
5874
+ "negative if funds were pulled into the perp market",
5875
+ "precision: QUOTE_PRECISION"
5876
+ ],
5464
5877
  "type": "i64"
5465
5878
  },
5466
5879
  {
5467
5880
  "name": "maxRevenueWithdrawPerPeriod",
5881
+ "docs": [
5882
+ "The max amount of revenue that can be withdrawn per period",
5883
+ "precision: QUOTE_PRECISION"
5884
+ ],
5468
5885
  "type": "u64"
5469
5886
  },
5470
5887
  {
5471
5888
  "name": "quoteMaxInsurance",
5889
+ "docs": [
5890
+ "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits",
5891
+ "precision: QUOTE_PRECISION"
5892
+ ],
5472
5893
  "type": "u64"
5473
5894
  },
5474
5895
  {
5475
5896
  "name": "quoteSettledInsurance",
5897
+ "docs": [
5898
+ "The amount of insurance that has been used to resolve bankruptcy and pnl deficits",
5899
+ "precision: QUOTE_PRECISION"
5900
+ ],
5476
5901
  "type": "u64"
5477
5902
  },
5478
5903
  {
5479
5904
  "name": "lastRevenueWithdrawTs",
5905
+ "docs": [
5906
+ "The last time revenue was settled in/out of market"
5907
+ ],
5480
5908
  "type": "i64"
5481
5909
  }
5482
5910
  ]
@@ -5489,10 +5917,18 @@
5489
5917
  "fields": [
5490
5918
  {
5491
5919
  "name": "scaledBalance",
5920
+ "docs": [
5921
+ "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative",
5922
+ "deposit interest",
5923
+ "precision: SPOT_BALANCE_PRECISION"
5924
+ ],
5492
5925
  "type": "u128"
5493
5926
  },
5494
5927
  {
5495
5928
  "name": "marketIndex",
5929
+ "docs": [
5930
+ "The spot market the pool is for"
5931
+ ],
5496
5932
  "type": "u16"
5497
5933
  },
5498
5934
  {
@@ -5514,308 +5950,536 @@
5514
5950
  "fields": [
5515
5951
  {
5516
5952
  "name": "oracle",
5953
+ "docs": [
5954
+ "oracle price data public key"
5955
+ ],
5517
5956
  "type": "publicKey"
5518
5957
  },
5519
5958
  {
5520
5959
  "name": "historicalOracleData",
5960
+ "docs": [
5961
+ "stores historically witnessed oracle data"
5962
+ ],
5521
5963
  "type": {
5522
5964
  "defined": "HistoricalOracleData"
5523
5965
  }
5524
5966
  },
5525
5967
  {
5526
5968
  "name": "baseAssetAmountPerLp",
5969
+ "docs": [
5970
+ "accumulated base asset amount since inception per lp share"
5971
+ ],
5527
5972
  "type": "i128"
5528
5973
  },
5529
5974
  {
5530
5975
  "name": "quoteAssetAmountPerLp",
5976
+ "docs": [
5977
+ "accumulated quote asset amount since inception per lp share"
5978
+ ],
5531
5979
  "type": "i128"
5532
5980
  },
5533
5981
  {
5534
5982
  "name": "feePool",
5983
+ "docs": [
5984
+ "partition of fees from perp market trading moved from pnl settlements"
5985
+ ],
5535
5986
  "type": {
5536
5987
  "defined": "PoolBalance"
5537
5988
  }
5538
5989
  },
5539
5990
  {
5540
5991
  "name": "baseAssetReserve",
5992
+ "docs": [
5993
+ "`x` reserves for constant product mm formula (x * y = k)"
5994
+ ],
5541
5995
  "type": "u128"
5542
5996
  },
5543
5997
  {
5544
5998
  "name": "quoteAssetReserve",
5999
+ "docs": [
6000
+ "`y` reserves for constant product mm formula (x * y = k)"
6001
+ ],
5545
6002
  "type": "u128"
5546
6003
  },
5547
6004
  {
5548
6005
  "name": "concentrationCoef",
6006
+ "docs": [
6007
+ "determines how close the min/max base asset reserve sit vs base reserves",
6008
+ "allow for decreasing slippage without increasing liquidity and v.v."
6009
+ ],
5549
6010
  "type": "u128"
5550
6011
  },
5551
6012
  {
5552
6013
  "name": "minBaseAssetReserve",
6014
+ "docs": [
6015
+ "minimum base_asset_reserve allowed before AMM is unavailable"
6016
+ ],
5553
6017
  "type": "u128"
5554
6018
  },
5555
6019
  {
5556
6020
  "name": "maxBaseAssetReserve",
6021
+ "docs": [
6022
+ "maximum base_asset_reserve allowed before AMM is unavailable"
6023
+ ],
5557
6024
  "type": "u128"
5558
6025
  },
5559
6026
  {
5560
6027
  "name": "sqrtK",
6028
+ "docs": [
6029
+ "`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues"
6030
+ ],
5561
6031
  "type": "u128"
5562
6032
  },
5563
6033
  {
5564
6034
  "name": "pegMultiplier",
6035
+ "docs": [
6036
+ "normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced"
6037
+ ],
5565
6038
  "type": "u128"
5566
6039
  },
5567
6040
  {
5568
6041
  "name": "terminalQuoteAssetReserve",
6042
+ "docs": [
6043
+ "y when market is balanced. stored to save computation"
6044
+ ],
5569
6045
  "type": "u128"
5570
6046
  },
5571
6047
  {
5572
6048
  "name": "baseAssetAmountLong",
6049
+ "docs": [
6050
+ "tracks number of total longs in market (regardless of counterparty)"
6051
+ ],
5573
6052
  "type": "i128"
5574
6053
  },
5575
6054
  {
5576
6055
  "name": "baseAssetAmountShort",
6056
+ "docs": [
6057
+ "tracks number of total shorts in market (regardless of counterparty)"
6058
+ ],
5577
6059
  "type": "i128"
5578
6060
  },
5579
6061
  {
5580
6062
  "name": "baseAssetAmountWithAmm",
6063
+ "docs": [
6064
+ "tracks net position (longs-shorts) in market with AMM as counterparty"
6065
+ ],
5581
6066
  "type": "i128"
5582
6067
  },
5583
6068
  {
5584
6069
  "name": "baseAssetAmountWithUnsettledLp",
6070
+ "docs": [
6071
+ "tracks net position (longs-shorts) in market with LPs as counterparty"
6072
+ ],
5585
6073
  "type": "i128"
5586
6074
  },
5587
6075
  {
5588
6076
  "name": "maxOpenInterest",
6077
+ "docs": [
6078
+ "max allowed open interest, blocks trades that breach this value"
6079
+ ],
5589
6080
  "type": "u128"
5590
6081
  },
5591
6082
  {
5592
6083
  "name": "quoteAssetAmount",
6084
+ "docs": [
6085
+ "sum of all user's perp quote_asset_amount in market"
6086
+ ],
5593
6087
  "type": "i128"
5594
6088
  },
5595
6089
  {
5596
6090
  "name": "quoteEntryAmountLong",
6091
+ "docs": [
6092
+ "sum of all long user's quote_entry_amount in market"
6093
+ ],
5597
6094
  "type": "i128"
5598
6095
  },
5599
6096
  {
5600
6097
  "name": "quoteEntryAmountShort",
6098
+ "docs": [
6099
+ "sum of all short user's quote_entry_amount in market"
6100
+ ],
5601
6101
  "type": "i128"
5602
6102
  },
5603
6103
  {
5604
6104
  "name": "quoteBreakEvenAmountLong",
6105
+ "docs": [
6106
+ "sum of all long user's quote_break_even_amount in market"
6107
+ ],
5605
6108
  "type": "i128"
5606
6109
  },
5607
6110
  {
5608
6111
  "name": "quoteBreakEvenAmountShort",
6112
+ "docs": [
6113
+ "sum of all short user's quote_break_even_amount in market"
6114
+ ],
5609
6115
  "type": "i128"
5610
6116
  },
5611
6117
  {
5612
6118
  "name": "userLpShares",
6119
+ "docs": [
6120
+ "total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)"
6121
+ ],
5613
6122
  "type": "u128"
5614
6123
  },
5615
6124
  {
5616
6125
  "name": "lastFundingRate",
6126
+ "docs": [
6127
+ "last funding rate in this perp market (unit is quote per base)"
6128
+ ],
5617
6129
  "type": "i64"
5618
6130
  },
5619
6131
  {
5620
6132
  "name": "lastFundingRateLong",
6133
+ "docs": [
6134
+ "last funding rate for longs in this perp market (unit is quote per base)"
6135
+ ],
5621
6136
  "type": "i64"
5622
6137
  },
5623
6138
  {
5624
6139
  "name": "lastFundingRateShort",
6140
+ "docs": [
6141
+ "last funding rate for shorts in this perp market (unit is quote per base)"
6142
+ ],
5625
6143
  "type": "i64"
5626
6144
  },
5627
6145
  {
5628
6146
  "name": "last24hAvgFundingRate",
6147
+ "docs": [
6148
+ "estimate of last 24h of funding rate perp market (unit is quote per base)"
6149
+ ],
5629
6150
  "type": "i64"
5630
6151
  },
5631
6152
  {
5632
6153
  "name": "totalFee",
6154
+ "docs": [
6155
+ "total fees collected by this perp market"
6156
+ ],
5633
6157
  "type": "i128"
5634
6158
  },
5635
6159
  {
5636
6160
  "name": "totalMmFee",
6161
+ "docs": [
6162
+ "total fees collected by the vAMM's bid/ask spread"
6163
+ ],
5637
6164
  "type": "i128"
5638
6165
  },
5639
6166
  {
5640
6167
  "name": "totalExchangeFee",
6168
+ "docs": [
6169
+ "total fees collected by exchange fee schedule"
6170
+ ],
5641
6171
  "type": "u128"
5642
6172
  },
5643
6173
  {
5644
6174
  "name": "totalFeeMinusDistributions",
6175
+ "docs": [
6176
+ "total fees minus any recognized upnl and pool withdraws"
6177
+ ],
5645
6178
  "type": "i128"
5646
6179
  },
5647
6180
  {
5648
6181
  "name": "totalFeeWithdrawn",
6182
+ "docs": [
6183
+ "sum of all fees from fee pool withdrawn to revenue pool"
6184
+ ],
5649
6185
  "type": "u128"
5650
6186
  },
5651
6187
  {
5652
6188
  "name": "totalLiquidationFee",
6189
+ "docs": [
6190
+ "all fees collected by market for liquidations"
6191
+ ],
5653
6192
  "type": "u128"
5654
6193
  },
5655
6194
  {
5656
6195
  "name": "cumulativeFundingRateLong",
6196
+ "docs": [
6197
+ "accumulated funding rate for longs since inception in market"
6198
+ ],
5657
6199
  "type": "i128"
5658
6200
  },
5659
6201
  {
5660
6202
  "name": "cumulativeFundingRateShort",
6203
+ "docs": [
6204
+ "accumulated funding rate for shorts since inception in market"
6205
+ ],
5661
6206
  "type": "i128"
5662
6207
  },
5663
6208
  {
5664
6209
  "name": "totalSocialLoss",
6210
+ "docs": [
6211
+ "accumulated social loss paid by users since inception in market"
6212
+ ],
5665
6213
  "type": "u128"
5666
6214
  },
5667
6215
  {
5668
6216
  "name": "askBaseAssetReserve",
6217
+ "docs": [
6218
+ "transformed base_asset_reserve for users going long"
6219
+ ],
5669
6220
  "type": "u128"
5670
6221
  },
5671
6222
  {
5672
6223
  "name": "askQuoteAssetReserve",
6224
+ "docs": [
6225
+ "transformed quote_asset_reserve for users going long"
6226
+ ],
5673
6227
  "type": "u128"
5674
6228
  },
5675
6229
  {
5676
6230
  "name": "bidBaseAssetReserve",
6231
+ "docs": [
6232
+ "transformed base_asset_reserve for users going short"
6233
+ ],
5677
6234
  "type": "u128"
5678
6235
  },
5679
6236
  {
5680
6237
  "name": "bidQuoteAssetReserve",
6238
+ "docs": [
6239
+ "transformed quote_asset_reserve for users going short"
6240
+ ],
5681
6241
  "type": "u128"
5682
6242
  },
5683
6243
  {
5684
6244
  "name": "lastOracleNormalisedPrice",
6245
+ "docs": [
6246
+ "the last seen oracle price partially shrunk toward the amm reserve price"
6247
+ ],
5685
6248
  "type": "i64"
5686
6249
  },
5687
6250
  {
5688
6251
  "name": "lastOracleReservePriceSpreadPct",
6252
+ "docs": [
6253
+ "the gap between the oracle price and the reserve price = y * peg_multiplier / x"
6254
+ ],
5689
6255
  "type": "i64"
5690
6256
  },
5691
6257
  {
5692
6258
  "name": "lastBidPriceTwap",
6259
+ "docs": [
6260
+ "average estimate of bid price over funding_period"
6261
+ ],
5693
6262
  "type": "u64"
5694
6263
  },
5695
6264
  {
5696
6265
  "name": "lastAskPriceTwap",
6266
+ "docs": [
6267
+ "average estimate of ask price over funding_period"
6268
+ ],
5697
6269
  "type": "u64"
5698
6270
  },
5699
6271
  {
5700
6272
  "name": "lastMarkPriceTwap",
6273
+ "docs": [
6274
+ "average estimate of (bid+ask)/2 price over funding_period"
6275
+ ],
5701
6276
  "type": "u64"
5702
6277
  },
5703
6278
  {
5704
6279
  "name": "lastMarkPriceTwap5min",
6280
+ "docs": [
6281
+ "average estimate of (bid+ask)/2 price over FIVE_MINUTES"
6282
+ ],
5705
6283
  "type": "u64"
5706
6284
  },
5707
6285
  {
5708
6286
  "name": "lastUpdateSlot",
6287
+ "docs": [
6288
+ "the last blockchain slot the amm was updated"
6289
+ ],
5709
6290
  "type": "u64"
5710
6291
  },
5711
6292
  {
5712
6293
  "name": "lastOracleConfPct",
6294
+ "docs": [
6295
+ "the pct size of the oracle confidence interval",
6296
+ "PERCENTAGE_PRECISION"
6297
+ ],
5713
6298
  "type": "u64"
5714
6299
  },
5715
6300
  {
5716
6301
  "name": "netRevenueSinceLastFunding",
6302
+ "docs": [
6303
+ "the total_fee_minus_distribution change since the last funding update"
6304
+ ],
5717
6305
  "type": "i64"
5718
6306
  },
5719
6307
  {
5720
6308
  "name": "lastFundingRateTs",
6309
+ "docs": [
6310
+ "the last funding rate update unix_timestamp"
6311
+ ],
5721
6312
  "type": "i64"
5722
6313
  },
5723
6314
  {
5724
6315
  "name": "fundingPeriod",
6316
+ "docs": [
6317
+ "the peridocity of the funding rate updates"
6318
+ ],
5725
6319
  "type": "i64"
5726
6320
  },
5727
6321
  {
5728
6322
  "name": "orderStepSize",
6323
+ "docs": [
6324
+ "the base step size (increment) of orders"
6325
+ ],
5729
6326
  "type": "u64"
5730
6327
  },
5731
6328
  {
5732
6329
  "name": "orderTickSize",
6330
+ "docs": [
6331
+ "the price tick size of orders"
6332
+ ],
5733
6333
  "type": "u64"
5734
6334
  },
5735
6335
  {
5736
6336
  "name": "minOrderSize",
6337
+ "docs": [
6338
+ "the minimum base size of an order"
6339
+ ],
5737
6340
  "type": "u64"
5738
6341
  },
5739
6342
  {
5740
6343
  "name": "maxPositionSize",
6344
+ "docs": [
6345
+ "the max base size a single user can have"
6346
+ ],
5741
6347
  "type": "u64"
5742
6348
  },
5743
6349
  {
5744
6350
  "name": "volume24h",
6351
+ "docs": [
6352
+ "estimated total of volume in market",
6353
+ "QUOTE_PRECISION"
6354
+ ],
5745
6355
  "type": "u64"
5746
6356
  },
5747
6357
  {
5748
6358
  "name": "longIntensityVolume",
6359
+ "docs": [
6360
+ "the volume intensity of long fills against AMM"
6361
+ ],
5749
6362
  "type": "u64"
5750
6363
  },
5751
6364
  {
5752
6365
  "name": "shortIntensityVolume",
6366
+ "docs": [
6367
+ "the volume intensity of short fills against AMM"
6368
+ ],
5753
6369
  "type": "u64"
5754
6370
  },
5755
6371
  {
5756
6372
  "name": "lastTradeTs",
6373
+ "docs": [
6374
+ "the blockchain unix timestamp at the time of the last trade"
6375
+ ],
5757
6376
  "type": "i64"
5758
6377
  },
5759
6378
  {
5760
6379
  "name": "markStd",
6380
+ "docs": [
6381
+ "estimate of standard deviation of the fill (mark) prices"
6382
+ ],
5761
6383
  "type": "u64"
5762
6384
  },
5763
6385
  {
5764
6386
  "name": "oracleStd",
6387
+ "docs": [
6388
+ "estimate of standard deviation of the oracle price at each update"
6389
+ ],
5765
6390
  "type": "u64"
5766
6391
  },
5767
6392
  {
5768
6393
  "name": "lastMarkPriceTwapTs",
6394
+ "docs": [
6395
+ "the last unix_timestamp the mark twap was updated"
6396
+ ],
5769
6397
  "type": "i64"
5770
6398
  },
5771
6399
  {
5772
6400
  "name": "baseSpread",
6401
+ "docs": [
6402
+ "the minimum spread the AMM can quote. also used as step size for some spread logic increases."
6403
+ ],
5773
6404
  "type": "u32"
5774
6405
  },
5775
6406
  {
5776
6407
  "name": "maxSpread",
6408
+ "docs": [
6409
+ "the maximum spread the AMM can quote"
6410
+ ],
5777
6411
  "type": "u32"
5778
6412
  },
5779
6413
  {
5780
6414
  "name": "longSpread",
6415
+ "docs": [
6416
+ "the spread for asks vs the reserve price"
6417
+ ],
5781
6418
  "type": "u32"
5782
6419
  },
5783
6420
  {
5784
6421
  "name": "shortSpread",
6422
+ "docs": [
6423
+ "the spread for bids vs the reserve price"
6424
+ ],
5785
6425
  "type": "u32"
5786
6426
  },
5787
6427
  {
5788
6428
  "name": "longIntensityCount",
6429
+ "docs": [
6430
+ "the count intensity of long fills against AMM"
6431
+ ],
5789
6432
  "type": "u32"
5790
6433
  },
5791
6434
  {
5792
6435
  "name": "shortIntensityCount",
6436
+ "docs": [
6437
+ "the count intensity of short fills against AMM"
6438
+ ],
5793
6439
  "type": "u32"
5794
6440
  },
5795
6441
  {
5796
6442
  "name": "maxFillReserveFraction",
6443
+ "docs": [
6444
+ "the fraction of total available liquidity a single fill on the AMM can consume"
6445
+ ],
5797
6446
  "type": "u16"
5798
6447
  },
5799
6448
  {
5800
6449
  "name": "maxSlippageRatio",
6450
+ "docs": [
6451
+ "the maximum slippage a single fill on the AMM can push"
6452
+ ],
5801
6453
  "type": "u16"
5802
6454
  },
5803
6455
  {
5804
6456
  "name": "curveUpdateIntensity",
6457
+ "docs": [
6458
+ "the update intensity of AMM formulaic updates (adjusting k). 0-100"
6459
+ ],
5805
6460
  "type": "u8"
5806
6461
  },
5807
6462
  {
5808
6463
  "name": "ammJitIntensity",
6464
+ "docs": [
6465
+ "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation."
6466
+ ],
5809
6467
  "type": "u8"
5810
6468
  },
5811
6469
  {
5812
6470
  "name": "oracleSource",
6471
+ "docs": [
6472
+ "the oracle provider information. used to decode/scale the oracle public key"
6473
+ ],
5813
6474
  "type": {
5814
6475
  "defined": "OracleSource"
5815
6476
  }
5816
6477
  },
5817
6478
  {
5818
6479
  "name": "lastOracleValid",
6480
+ "docs": [
6481
+ "tracks whether the oracle was considered valid at the last AMM update"
6482
+ ],
5819
6483
  "type": "bool"
5820
6484
  },
5821
6485
  {
@@ -6034,26 +6698,50 @@
6034
6698
  "fields": [
6035
6699
  {
6036
6700
  "name": "totalFeePaid",
6701
+ "docs": [
6702
+ "Total taker fee paid",
6703
+ "precision: QUOTE_PRECISION"
6704
+ ],
6037
6705
  "type": "u64"
6038
6706
  },
6039
6707
  {
6040
6708
  "name": "totalFeeRebate",
6709
+ "docs": [
6710
+ "Total maker fee rebate",
6711
+ "precision: QUOTE_PRECISION"
6712
+ ],
6041
6713
  "type": "u64"
6042
6714
  },
6043
6715
  {
6044
6716
  "name": "totalTokenDiscount",
6717
+ "docs": [
6718
+ "Total discount from holding token",
6719
+ "precision: QUOTE_PRECISION"
6720
+ ],
6045
6721
  "type": "u64"
6046
6722
  },
6047
6723
  {
6048
6724
  "name": "totalRefereeDiscount",
6725
+ "docs": [
6726
+ "Total discount from being referred",
6727
+ "precision: QUOTE_PRECISION"
6728
+ ],
6049
6729
  "type": "u64"
6050
6730
  },
6051
6731
  {
6052
6732
  "name": "totalReferrerReward",
6733
+ "docs": [
6734
+ "Total reward to referrer",
6735
+ "precision: QUOTE_PRECISION"
6736
+ ],
6053
6737
  "type": "u64"
6054
6738
  },
6055
6739
  {
6056
6740
  "name": "currentEpochReferrerReward",
6741
+ "docs": [
6742
+ "Total reward to referrer this epoch",
6743
+ "precision: QUOTE_PRECISION"
6744
+ ],
6057
6745
  "type": "u64"
6058
6746
  }
6059
6747
  ]
@@ -6066,32 +6754,58 @@
6066
6754
  "fields": [
6067
6755
  {
6068
6756
  "name": "scaledBalance",
6757
+ "docs": [
6758
+ "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow",
6759
+ "interest of corresponding market.",
6760
+ "precision: SPOT_BALANCE_PRECISION"
6761
+ ],
6069
6762
  "type": "u64"
6070
6763
  },
6071
6764
  {
6072
6765
  "name": "openBids",
6766
+ "docs": [
6767
+ "How many spot bids the user has open",
6768
+ "precision: token mint precision"
6769
+ ],
6073
6770
  "type": "i64"
6074
6771
  },
6075
6772
  {
6076
6773
  "name": "openAsks",
6774
+ "docs": [
6775
+ "How many spot asks the user has open",
6776
+ "precision: token mint precision"
6777
+ ],
6077
6778
  "type": "i64"
6078
6779
  },
6079
6780
  {
6080
6781
  "name": "cumulativeDeposits",
6782
+ "docs": [
6783
+ "The cumulative deposits/borrows a user has made into a market",
6784
+ "precision: token mint precision"
6785
+ ],
6081
6786
  "type": "i64"
6082
6787
  },
6083
6788
  {
6084
6789
  "name": "marketIndex",
6790
+ "docs": [
6791
+ "The market index of the corresponding spot market"
6792
+ ],
6085
6793
  "type": "u16"
6086
6794
  },
6087
6795
  {
6088
6796
  "name": "balanceType",
6797
+ "docs": [
6798
+ "Whether the position is deposit or borrow"
6799
+ ],
6089
6800
  "type": {
6090
6801
  "defined": "SpotBalanceType"
6091
6802
  }
6092
6803
  },
6093
6804
  {
6094
6805
  "name": "openOrders",
6806
+ "docs": [
6807
+ "Number of open orders"
6808
+ ],
6095
6809
  "type": "u8"
6096
6810
  },
6097
6811
  {
@@ -6113,58 +6827,119 @@
6113
6827
  "fields": [
6114
6828
  {
6115
6829
  "name": "lastCumulativeFundingRate",
6830
+ "docs": [
6831
+ "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user",
6832
+ "precision: FUNDING_RATE_PRECISION"
6833
+ ],
6116
6834
  "type": "i64"
6117
6835
  },
6118
6836
  {
6119
6837
  "name": "baseAssetAmount",
6838
+ "docs": [
6839
+ "the size of the users perp position",
6840
+ "precision: BASE_PRECISION"
6841
+ ],
6120
6842
  "type": "i64"
6121
6843
  },
6122
6844
  {
6123
6845
  "name": "quoteAssetAmount",
6846
+ "docs": [
6847
+ "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees",
6848
+ "Updated when the user open/closes position or settles pnl. Includes fees/funding",
6849
+ "precision: QUOTE_PRECISION"
6850
+ ],
6124
6851
  "type": "i64"
6125
6852
  },
6126
6853
  {
6127
6854
  "name": "quoteBreakEvenAmount",
6855
+ "docs": [
6856
+ "The amount of quote the user would need to exit their position at to break even",
6857
+ "Updated when the user open/closes position or settles pnl. Includes fees/funding",
6858
+ "precision: QUOTE_PRECISION"
6859
+ ],
6128
6860
  "type": "i64"
6129
6861
  },
6130
6862
  {
6131
6863
  "name": "quoteEntryAmount",
6864
+ "docs": [
6865
+ "The amount quote the user entered the position with. Equal to base asset amount * avg entry price",
6866
+ "Updated when the user open/closes position. Excludes fees/funding",
6867
+ "precision: QUOTE_PRECISION"
6868
+ ],
6132
6869
  "type": "i64"
6133
6870
  },
6134
6871
  {
6135
6872
  "name": "openBids",
6873
+ "docs": [
6874
+ "The amount of open bids the user has in this perp market",
6875
+ "precision: BASE_PRECISION"
6876
+ ],
6136
6877
  "type": "i64"
6137
6878
  },
6138
6879
  {
6139
6880
  "name": "openAsks",
6881
+ "docs": [
6882
+ "The amount of open asks the user has in this perp market",
6883
+ "precision: BASE_PRECISION"
6884
+ ],
6140
6885
  "type": "i64"
6141
6886
  },
6142
6887
  {
6143
6888
  "name": "settledPnl",
6889
+ "docs": [
6890
+ "The amount of pnl settled in this market since opening the position",
6891
+ "precision: QUOTE_PRECISION"
6892
+ ],
6144
6893
  "type": "i64"
6145
6894
  },
6146
6895
  {
6147
6896
  "name": "lpShares",
6897
+ "docs": [
6898
+ "The number of lp (liquidity provider) shares the user has in this perp market",
6899
+ "LP shares allow users to provide liquidity via the AMM",
6900
+ "precision: BASE_PRECISION"
6901
+ ],
6148
6902
  "type": "u64"
6149
6903
  },
6150
6904
  {
6151
6905
  "name": "lastBaseAssetAmountPerLp",
6906
+ "docs": [
6907
+ "The last base asset amount per lp the amm had",
6908
+ "Used to settle the users lp position",
6909
+ "precision: BASE_PRECISION"
6910
+ ],
6152
6911
  "type": "i64"
6153
6912
  },
6154
6913
  {
6155
6914
  "name": "lastQuoteAssetAmountPerLp",
6915
+ "docs": [
6916
+ "The last quote asset amount per lp the amm had",
6917
+ "Used to settle the users lp position",
6918
+ "precision: QUOTE_PRECISION"
6919
+ ],
6156
6920
  "type": "i64"
6157
6921
  },
6158
6922
  {
6159
6923
  "name": "remainderBaseAssetAmount",
6924
+ "docs": [
6925
+ "Settling LP position can lead to a small amount of base asset being left over smaller than step size",
6926
+ "This records that remainder so it can be settled later on",
6927
+ "precision: BASE_PRECISION"
6928
+ ],
6160
6929
  "type": "i32"
6161
6930
  },
6162
6931
  {
6163
6932
  "name": "marketIndex",
6933
+ "docs": [
6934
+ "The market index for the perp market"
6935
+ ],
6164
6936
  "type": "u16"
6165
6937
  },
6166
6938
  {
6167
6939
  "name": "openOrders",
6940
+ "docs": [
6941
+ "The number of open orders"
6942
+ ],
6168
6943
  "type": "u8"
6169
6944
  },
6170
6945
  {
@@ -6186,106 +6961,186 @@
6186
6961
  "fields": [
6187
6962
  {
6188
6963
  "name": "slot",
6964
+ "docs": [
6965
+ "The slot the order was placed"
6966
+ ],
6189
6967
  "type": "u64"
6190
6968
  },
6191
6969
  {
6192
6970
  "name": "price",
6971
+ "docs": [
6972
+ "The limit price for the order (can be 0 for market orders)",
6973
+ "For orders with an auction, this price isn't used until the auction is complete",
6974
+ "precision: PRICE_PRECISION"
6975
+ ],
6193
6976
  "type": "u64"
6194
6977
  },
6195
6978
  {
6196
6979
  "name": "baseAssetAmount",
6980
+ "docs": [
6981
+ "The size of the order",
6982
+ "precision for perps: BASE_PRECISION",
6983
+ "precision for spot: token mint precision"
6984
+ ],
6197
6985
  "type": "u64"
6198
6986
  },
6199
6987
  {
6200
6988
  "name": "baseAssetAmountFilled",
6989
+ "docs": [
6990
+ "The amount of the order filled",
6991
+ "precision for perps: BASE_PRECISION",
6992
+ "precision for spot: token mint precision"
6993
+ ],
6201
6994
  "type": "u64"
6202
6995
  },
6203
6996
  {
6204
6997
  "name": "quoteAssetAmountFilled",
6998
+ "docs": [
6999
+ "The amount of quote filled for the order",
7000
+ "precision: QUOTE_PRECISION"
7001
+ ],
6205
7002
  "type": "u64"
6206
7003
  },
6207
7004
  {
6208
7005
  "name": "triggerPrice",
7006
+ "docs": [
7007
+ "At what price the order will be triggered. Only relevant for trigger orders",
7008
+ "precision: PRICE_PRECISION"
7009
+ ],
6209
7010
  "type": "u64"
6210
7011
  },
6211
7012
  {
6212
7013
  "name": "auctionStartPrice",
7014
+ "docs": [
7015
+ "The start price for the auction. Only relevant for market/oracle orders",
7016
+ "precision: PRICE_PRECISION"
7017
+ ],
6213
7018
  "type": "i64"
6214
7019
  },
6215
7020
  {
6216
7021
  "name": "auctionEndPrice",
7022
+ "docs": [
7023
+ "The end price for the auction. Only relevant for market/oracle orders",
7024
+ "precision: PRICE_PRECISION"
7025
+ ],
6217
7026
  "type": "i64"
6218
7027
  },
6219
7028
  {
6220
7029
  "name": "maxTs",
7030
+ "docs": [
7031
+ "The time when the order will expire"
7032
+ ],
6221
7033
  "type": "i64"
6222
7034
  },
6223
7035
  {
6224
7036
  "name": "oraclePriceOffset",
7037
+ "docs": [
7038
+ "If set, the order limit price is the oracle price + this offset",
7039
+ "precision: PRICE_PRECISION"
7040
+ ],
6225
7041
  "type": "i32"
6226
7042
  },
6227
7043
  {
6228
7044
  "name": "orderId",
7045
+ "docs": [
7046
+ "The id for the order. Each users has their own order id space"
7047
+ ],
6229
7048
  "type": "u32"
6230
7049
  },
6231
7050
  {
6232
7051
  "name": "marketIndex",
7052
+ "docs": [
7053
+ "The perp/spot market index"
7054
+ ],
6233
7055
  "type": "u16"
6234
7056
  },
6235
7057
  {
6236
7058
  "name": "status",
7059
+ "docs": [
7060
+ "Whether the order is open or unused"
7061
+ ],
6237
7062
  "type": {
6238
7063
  "defined": "OrderStatus"
6239
7064
  }
6240
7065
  },
6241
7066
  {
6242
7067
  "name": "orderType",
7068
+ "docs": [
7069
+ "The type of order"
7070
+ ],
6243
7071
  "type": {
6244
7072
  "defined": "OrderType"
6245
7073
  }
6246
7074
  },
6247
7075
  {
6248
7076
  "name": "marketType",
7077
+ "docs": [
7078
+ "Whether market is spot or perp"
7079
+ ],
6249
7080
  "type": {
6250
7081
  "defined": "MarketType"
6251
7082
  }
6252
7083
  },
6253
7084
  {
6254
7085
  "name": "userOrderId",
7086
+ "docs": [
7087
+ "User generated order id. Can make it easier to place/cancel orders"
7088
+ ],
6255
7089
  "type": "u8"
6256
7090
  },
6257
7091
  {
6258
7092
  "name": "existingPositionDirection",
7093
+ "docs": [
7094
+ "What the users position was when the order was placed"
7095
+ ],
6259
7096
  "type": {
6260
7097
  "defined": "PositionDirection"
6261
7098
  }
6262
7099
  },
6263
7100
  {
6264
7101
  "name": "direction",
7102
+ "docs": [
7103
+ "Whether the user is going long or short. LONG = bid, SHORT = ask"
7104
+ ],
6265
7105
  "type": {
6266
7106
  "defined": "PositionDirection"
6267
7107
  }
6268
7108
  },
6269
7109
  {
6270
7110
  "name": "reduceOnly",
7111
+ "docs": [
7112
+ "Whether the order is allowed to only reduce position size"
7113
+ ],
6271
7114
  "type": "bool"
6272
7115
  },
6273
7116
  {
6274
7117
  "name": "postOnly",
7118
+ "docs": [
7119
+ "Whether the order must be a maker"
7120
+ ],
6275
7121
  "type": "bool"
6276
7122
  },
6277
7123
  {
6278
7124
  "name": "immediateOrCancel",
7125
+ "docs": [
7126
+ "Whether the order must be canceled the same slot it is placed"
7127
+ ],
6279
7128
  "type": "bool"
6280
7129
  },
6281
7130
  {
6282
7131
  "name": "triggerCondition",
7132
+ "docs": [
7133
+ "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders"
7134
+ ],
6283
7135
  "type": {
6284
7136
  "defined": "OrderTriggerCondition"
6285
7137
  }
6286
7138
  },
6287
7139
  {
6288
7140
  "name": "auctionDuration",
7141
+ "docs": [
7142
+ "How many slots the auction lasts"
7143
+ ],
6289
7144
  "type": "u8"
6290
7145
  },
6291
7146
  {