@myx-trade/sdk 0.1.241 → 0.1.243

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.
Files changed (3) hide show
  1. package/dist/index.js +15 -602
  2. package/dist/index.mjs +15 -602
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1493,7 +1493,7 @@ var BSC_TEST_NET = {
1493
1493
  Account: "0xf708d4702f4db570f585cb90DdbB79d327f74f79",
1494
1494
  POSITION_MANAGER: "0x4f7D3158c667d289d76F11598B1C1d0A36B2b146",
1495
1495
  ORDER_MANAGER: "0x5681BFF512F7F50fE238E09FDe96987c85cDadB4",
1496
- PYTH: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",
1496
+ PYTH: "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",
1497
1497
  // !!! 非Pyth Adapter
1498
1498
  ERC20: "0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",
1499
1499
  LIQUIDITY_ROUTER: "0x255fAb155BEf51F1E41fb082038846362Ec8b11e",
@@ -1836,7 +1836,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1836
1836
  // package.json
1837
1837
  var package_default = {
1838
1838
  name: "@myx-trade/sdk",
1839
- version: "0.1.241",
1839
+ version: "0.1.243",
1840
1840
  private: false,
1841
1841
  publishConfig: {
1842
1842
  access: "public"
@@ -1966,13 +1966,13 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode3) => {
1966
1966
  ErrorCode3["NETWORK_ERROR"] = "ERR_NETWORK";
1967
1967
  return ErrorCode3;
1968
1968
  })(ErrorCode || {});
1969
- var MarketPoolState = /* @__PURE__ */ ((MarketPoolState3) => {
1970
- MarketPoolState3[MarketPoolState3["Cook"] = 0] = "Cook";
1971
- MarketPoolState3[MarketPoolState3["Primed"] = 1] = "Primed";
1972
- MarketPoolState3[MarketPoolState3["Trench"] = 2] = "Trench";
1973
- MarketPoolState3[MarketPoolState3["PreBench"] = 3] = "PreBench";
1974
- MarketPoolState3[MarketPoolState3["Bench"] = 4] = "Bench";
1975
- return MarketPoolState3;
1969
+ var MarketPoolState = /* @__PURE__ */ ((MarketPoolState2) => {
1970
+ MarketPoolState2[MarketPoolState2["Cook"] = 0] = "Cook";
1971
+ MarketPoolState2[MarketPoolState2["Primed"] = 1] = "Primed";
1972
+ MarketPoolState2[MarketPoolState2["Trench"] = 2] = "Trench";
1973
+ MarketPoolState2[MarketPoolState2["PreBench"] = 3] = "PreBench";
1974
+ MarketPoolState2[MarketPoolState2["Bench"] = 4] = "Bench";
1975
+ return MarketPoolState2;
1976
1976
  })(MarketPoolState || {});
1977
1977
  var OracleType = /* @__PURE__ */ ((OracleType6) => {
1978
1978
  OracleType6[OracleType6["Chainlink"] = 1] = "Chainlink";
@@ -8123,555 +8123,6 @@ var OrderManager_default = [
8123
8123
  }
8124
8124
  ];
8125
8125
 
8126
- // src/abi/IPyth.json
8127
- var IPyth_default = [
8128
- {
8129
- anonymous: false,
8130
- inputs: [
8131
- {
8132
- indexed: true,
8133
- internalType: "bytes32",
8134
- name: "id",
8135
- type: "bytes32"
8136
- },
8137
- {
8138
- indexed: false,
8139
- internalType: "uint64",
8140
- name: "publishTime",
8141
- type: "uint64"
8142
- },
8143
- {
8144
- indexed: false,
8145
- internalType: "int64",
8146
- name: "price",
8147
- type: "int64"
8148
- },
8149
- {
8150
- indexed: false,
8151
- internalType: "uint64",
8152
- name: "conf",
8153
- type: "uint64"
8154
- }
8155
- ],
8156
- name: "PriceFeedUpdate",
8157
- type: "event"
8158
- },
8159
- {
8160
- inputs: [
8161
- {
8162
- internalType: "bytes32",
8163
- name: "id",
8164
- type: "bytes32"
8165
- }
8166
- ],
8167
- name: "getEmaPrice",
8168
- outputs: [
8169
- {
8170
- components: [
8171
- {
8172
- internalType: "int64",
8173
- name: "price",
8174
- type: "int64"
8175
- },
8176
- {
8177
- internalType: "uint64",
8178
- name: "conf",
8179
- type: "uint64"
8180
- },
8181
- {
8182
- internalType: "int32",
8183
- name: "expo",
8184
- type: "int32"
8185
- },
8186
- {
8187
- internalType: "uint256",
8188
- name: "publishTime",
8189
- type: "uint256"
8190
- }
8191
- ],
8192
- internalType: "struct PythStructs.Price",
8193
- name: "price",
8194
- type: "tuple"
8195
- }
8196
- ],
8197
- stateMutability: "view",
8198
- type: "function"
8199
- },
8200
- {
8201
- inputs: [
8202
- {
8203
- internalType: "bytes32",
8204
- name: "id",
8205
- type: "bytes32"
8206
- },
8207
- {
8208
- internalType: "uint256",
8209
- name: "age",
8210
- type: "uint256"
8211
- }
8212
- ],
8213
- name: "getEmaPriceNoOlderThan",
8214
- outputs: [
8215
- {
8216
- components: [
8217
- {
8218
- internalType: "int64",
8219
- name: "price",
8220
- type: "int64"
8221
- },
8222
- {
8223
- internalType: "uint64",
8224
- name: "conf",
8225
- type: "uint64"
8226
- },
8227
- {
8228
- internalType: "int32",
8229
- name: "expo",
8230
- type: "int32"
8231
- },
8232
- {
8233
- internalType: "uint256",
8234
- name: "publishTime",
8235
- type: "uint256"
8236
- }
8237
- ],
8238
- internalType: "struct PythStructs.Price",
8239
- name: "price",
8240
- type: "tuple"
8241
- }
8242
- ],
8243
- stateMutability: "view",
8244
- type: "function"
8245
- },
8246
- {
8247
- inputs: [
8248
- {
8249
- internalType: "bytes32",
8250
- name: "id",
8251
- type: "bytes32"
8252
- }
8253
- ],
8254
- name: "getEmaPriceUnsafe",
8255
- outputs: [
8256
- {
8257
- components: [
8258
- {
8259
- internalType: "int64",
8260
- name: "price",
8261
- type: "int64"
8262
- },
8263
- {
8264
- internalType: "uint64",
8265
- name: "conf",
8266
- type: "uint64"
8267
- },
8268
- {
8269
- internalType: "int32",
8270
- name: "expo",
8271
- type: "int32"
8272
- },
8273
- {
8274
- internalType: "uint256",
8275
- name: "publishTime",
8276
- type: "uint256"
8277
- }
8278
- ],
8279
- internalType: "struct PythStructs.Price",
8280
- name: "price",
8281
- type: "tuple"
8282
- }
8283
- ],
8284
- stateMutability: "view",
8285
- type: "function"
8286
- },
8287
- {
8288
- inputs: [
8289
- {
8290
- internalType: "bytes32",
8291
- name: "id",
8292
- type: "bytes32"
8293
- }
8294
- ],
8295
- name: "getPrice",
8296
- outputs: [
8297
- {
8298
- components: [
8299
- {
8300
- internalType: "int64",
8301
- name: "price",
8302
- type: "int64"
8303
- },
8304
- {
8305
- internalType: "uint64",
8306
- name: "conf",
8307
- type: "uint64"
8308
- },
8309
- {
8310
- internalType: "int32",
8311
- name: "expo",
8312
- type: "int32"
8313
- },
8314
- {
8315
- internalType: "uint256",
8316
- name: "publishTime",
8317
- type: "uint256"
8318
- }
8319
- ],
8320
- internalType: "struct PythStructs.Price",
8321
- name: "price",
8322
- type: "tuple"
8323
- }
8324
- ],
8325
- stateMutability: "view",
8326
- type: "function"
8327
- },
8328
- {
8329
- inputs: [
8330
- {
8331
- internalType: "bytes32",
8332
- name: "id",
8333
- type: "bytes32"
8334
- },
8335
- {
8336
- internalType: "uint256",
8337
- name: "age",
8338
- type: "uint256"
8339
- }
8340
- ],
8341
- name: "getPriceNoOlderThan",
8342
- outputs: [
8343
- {
8344
- components: [
8345
- {
8346
- internalType: "int64",
8347
- name: "price",
8348
- type: "int64"
8349
- },
8350
- {
8351
- internalType: "uint64",
8352
- name: "conf",
8353
- type: "uint64"
8354
- },
8355
- {
8356
- internalType: "int32",
8357
- name: "expo",
8358
- type: "int32"
8359
- },
8360
- {
8361
- internalType: "uint256",
8362
- name: "publishTime",
8363
- type: "uint256"
8364
- }
8365
- ],
8366
- internalType: "struct PythStructs.Price",
8367
- name: "price",
8368
- type: "tuple"
8369
- }
8370
- ],
8371
- stateMutability: "view",
8372
- type: "function"
8373
- },
8374
- {
8375
- inputs: [
8376
- {
8377
- internalType: "bytes32",
8378
- name: "id",
8379
- type: "bytes32"
8380
- }
8381
- ],
8382
- name: "getPriceUnsafe",
8383
- outputs: [
8384
- {
8385
- components: [
8386
- {
8387
- internalType: "int64",
8388
- name: "price",
8389
- type: "int64"
8390
- },
8391
- {
8392
- internalType: "uint64",
8393
- name: "conf",
8394
- type: "uint64"
8395
- },
8396
- {
8397
- internalType: "int32",
8398
- name: "expo",
8399
- type: "int32"
8400
- },
8401
- {
8402
- internalType: "uint256",
8403
- name: "publishTime",
8404
- type: "uint256"
8405
- }
8406
- ],
8407
- internalType: "struct PythStructs.Price",
8408
- name: "price",
8409
- type: "tuple"
8410
- }
8411
- ],
8412
- stateMutability: "view",
8413
- type: "function"
8414
- },
8415
- {
8416
- inputs: [
8417
- {
8418
- internalType: "bytes[]",
8419
- name: "updateData",
8420
- type: "bytes[]"
8421
- }
8422
- ],
8423
- name: "getUpdateFee",
8424
- outputs: [
8425
- {
8426
- internalType: "uint256",
8427
- name: "feeAmount",
8428
- type: "uint256"
8429
- }
8430
- ],
8431
- stateMutability: "view",
8432
- type: "function"
8433
- },
8434
- {
8435
- inputs: [],
8436
- name: "getValidTimePeriod",
8437
- outputs: [
8438
- {
8439
- internalType: "uint256",
8440
- name: "validTimePeriod",
8441
- type: "uint256"
8442
- }
8443
- ],
8444
- stateMutability: "view",
8445
- type: "function"
8446
- },
8447
- {
8448
- inputs: [
8449
- {
8450
- internalType: "bytes[]",
8451
- name: "updateData",
8452
- type: "bytes[]"
8453
- },
8454
- {
8455
- internalType: "bytes32[]",
8456
- name: "priceIds",
8457
- type: "bytes32[]"
8458
- },
8459
- {
8460
- internalType: "uint64",
8461
- name: "minPublishTime",
8462
- type: "uint64"
8463
- },
8464
- {
8465
- internalType: "uint64",
8466
- name: "maxPublishTime",
8467
- type: "uint64"
8468
- }
8469
- ],
8470
- name: "parsePriceFeedUpdates",
8471
- outputs: [
8472
- {
8473
- components: [
8474
- {
8475
- internalType: "bytes32",
8476
- name: "id",
8477
- type: "bytes32"
8478
- },
8479
- {
8480
- components: [
8481
- {
8482
- internalType: "int64",
8483
- name: "price",
8484
- type: "int64"
8485
- },
8486
- {
8487
- internalType: "uint64",
8488
- name: "conf",
8489
- type: "uint64"
8490
- },
8491
- {
8492
- internalType: "int32",
8493
- name: "expo",
8494
- type: "int32"
8495
- },
8496
- {
8497
- internalType: "uint256",
8498
- name: "publishTime",
8499
- type: "uint256"
8500
- }
8501
- ],
8502
- internalType: "struct PythStructs.Price",
8503
- name: "price",
8504
- type: "tuple"
8505
- },
8506
- {
8507
- components: [
8508
- {
8509
- internalType: "int64",
8510
- name: "price",
8511
- type: "int64"
8512
- },
8513
- {
8514
- internalType: "uint64",
8515
- name: "conf",
8516
- type: "uint64"
8517
- },
8518
- {
8519
- internalType: "int32",
8520
- name: "expo",
8521
- type: "int32"
8522
- },
8523
- {
8524
- internalType: "uint256",
8525
- name: "publishTime",
8526
- type: "uint256"
8527
- }
8528
- ],
8529
- internalType: "struct PythStructs.Price",
8530
- name: "emaPrice",
8531
- type: "tuple"
8532
- }
8533
- ],
8534
- internalType: "struct PythStructs.PriceFeed[]",
8535
- name: "priceFeeds",
8536
- type: "tuple[]"
8537
- }
8538
- ],
8539
- stateMutability: "payable",
8540
- type: "function"
8541
- },
8542
- {
8543
- inputs: [
8544
- {
8545
- internalType: "bytes[]",
8546
- name: "updateData",
8547
- type: "bytes[]"
8548
- },
8549
- {
8550
- internalType: "bytes32[]",
8551
- name: "priceIds",
8552
- type: "bytes32[]"
8553
- },
8554
- {
8555
- internalType: "uint64",
8556
- name: "minPublishTime",
8557
- type: "uint64"
8558
- },
8559
- {
8560
- internalType: "uint64",
8561
- name: "maxPublishTime",
8562
- type: "uint64"
8563
- }
8564
- ],
8565
- name: "parsePriceFeedUpdatesUnique",
8566
- outputs: [
8567
- {
8568
- components: [
8569
- {
8570
- internalType: "bytes32",
8571
- name: "id",
8572
- type: "bytes32"
8573
- },
8574
- {
8575
- components: [
8576
- {
8577
- internalType: "int64",
8578
- name: "price",
8579
- type: "int64"
8580
- },
8581
- {
8582
- internalType: "uint64",
8583
- name: "conf",
8584
- type: "uint64"
8585
- },
8586
- {
8587
- internalType: "int32",
8588
- name: "expo",
8589
- type: "int32"
8590
- },
8591
- {
8592
- internalType: "uint256",
8593
- name: "publishTime",
8594
- type: "uint256"
8595
- }
8596
- ],
8597
- internalType: "struct PythStructs.Price",
8598
- name: "price",
8599
- type: "tuple"
8600
- },
8601
- {
8602
- components: [
8603
- {
8604
- internalType: "int64",
8605
- name: "price",
8606
- type: "int64"
8607
- },
8608
- {
8609
- internalType: "uint64",
8610
- name: "conf",
8611
- type: "uint64"
8612
- },
8613
- {
8614
- internalType: "int32",
8615
- name: "expo",
8616
- type: "int32"
8617
- },
8618
- {
8619
- internalType: "uint256",
8620
- name: "publishTime",
8621
- type: "uint256"
8622
- }
8623
- ],
8624
- internalType: "struct PythStructs.Price",
8625
- name: "emaPrice",
8626
- type: "tuple"
8627
- }
8628
- ],
8629
- internalType: "struct PythStructs.PriceFeed[]",
8630
- name: "priceFeeds",
8631
- type: "tuple[]"
8632
- }
8633
- ],
8634
- stateMutability: "payable",
8635
- type: "function"
8636
- },
8637
- {
8638
- inputs: [
8639
- {
8640
- internalType: "bytes[]",
8641
- name: "updateData",
8642
- type: "bytes[]"
8643
- }
8644
- ],
8645
- name: "updatePriceFeeds",
8646
- outputs: [],
8647
- stateMutability: "payable",
8648
- type: "function"
8649
- },
8650
- {
8651
- inputs: [
8652
- {
8653
- internalType: "bytes[]",
8654
- name: "updateData",
8655
- type: "bytes[]"
8656
- },
8657
- {
8658
- internalType: "bytes32[]",
8659
- name: "priceIds",
8660
- type: "bytes32[]"
8661
- },
8662
- {
8663
- internalType: "uint64[]",
8664
- name: "publishTimes",
8665
- type: "uint64[]"
8666
- }
8667
- ],
8668
- name: "updatePriceFeedsIfNecessary",
8669
- outputs: [],
8670
- stateMutability: "payable",
8671
- type: "function"
8672
- }
8673
- ];
8674
-
8675
8126
  // src/abi/PoolToken.json
8676
8127
  var PoolToken_default = [
8677
8128
  {
@@ -11550,12 +11001,6 @@ var getBrokerContract = async (chainId, brokerAddress) => {
11550
11001
  const provider = getJSONProvider(chainId);
11551
11002
  return getContract(address, Broker_default, provider);
11552
11003
  };
11553
- var getPythContract = async (chainId, type = 0 /* JSON */) => {
11554
- const addresses = address_default[chainId];
11555
- const address = addresses.PYTH;
11556
- const provider = type === 0 /* JSON */ ? getJSONProvider(chainId) : await getSignerProvider(chainId);
11557
- return getContract(address, IPyth_default, provider);
11558
- };
11559
11004
  var getPoolTokenContract = async (chainId, lpTokenAddress, type = 0 /* JSON */) => {
11560
11005
  const address = lpTokenAddress;
11561
11006
  const provider = type === 0 /* JSON */ ? getJSONProvider(chainId) : await getSignerProvider(chainId);
@@ -11970,11 +11415,6 @@ var parsePriceData = async (chainId, data) => {
11970
11415
  data.map(async (item) => {
11971
11416
  const { publishTime, vaa, oracleType, nativeFee, price, poolId } = item;
11972
11417
  let value = !(0, import_lodash_es2.isNil)(nativeFee) ? BigInt(nativeFee) : 1n;
11973
- if (oracleType === 2 /* Pyth */) {
11974
- const PythContract = await getPythContract(chainId);
11975
- const v = await PythContract.getUpdateFee([vaa]);
11976
- value = v;
11977
- }
11978
11418
  return {
11979
11419
  poolId,
11980
11420
  price,
@@ -13675,7 +13115,7 @@ var TESTNET_CHAIN_IDS = [
13675
13115
  ];
13676
13116
  var BETA_ENV_CHAIN_IDS = [
13677
13117
  97 /* BSC_TESTNET */,
13678
- 59141 /* LINEA_SEPOLIA */
13118
+ 421614 /* ARB_TESTNET */
13679
13119
  ];
13680
13120
 
13681
13121
  // src/manager/const/socket.ts
@@ -14327,12 +13767,6 @@ var Position = class {
14327
13767
  throw new Error(approvalResult.message);
14328
13768
  }
14329
13769
  }
14330
- const gasLimit = await brokerContract.updatePriceAndAdjustCollateral.estimateGas(
14331
- [updateParams],
14332
- depositData,
14333
- positionId,
14334
- adjustAmount
14335
- );
14336
13770
  const transaction = await brokerContract.updatePriceAndAdjustCollateral(
14337
13771
  [updateParams],
14338
13772
  depositData,
@@ -14340,7 +13774,7 @@ var Position = class {
14340
13774
  adjustAmount,
14341
13775
  {
14342
13776
  value: BigInt(priceData?.value ?? "1"),
14343
- gas: gasLimit * TRADE_GAS_LIMIT_RATIO[chainId] / 100n
13777
+ gas: BigInt(1e7) * TRADE_GAS_LIMIT_RATIO[chainId] / 100n
14344
13778
  }
14345
13779
  );
14346
13780
  const hash = await transaction.wait();
@@ -19591,7 +19025,7 @@ var BSC_BETA_NET = {
19591
19025
  Account: "0xf708d4702f4db570f585cb90DdbB79d327f74f79",
19592
19026
  POSITION_MANAGER: "0x4f7D3158c667d289d76F11598B1C1d0A36B2b146",
19593
19027
  ORDER_MANAGER: "0x5681BFF512F7F50fE238E09FDe96987c85cDadB4",
19594
- PYTH: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",
19028
+ PYTH: "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",
19595
19029
  // !!! 非Pyth Adapter
19596
19030
  ERC20: "0xe944d7c0f7005a76E898Ee3B9Ec10479EbA9Cc02",
19597
19031
  LIQUIDITY_ROUTER: "0x255fAb155BEf51F1E41fb082038846362Ec8b11e",
@@ -21996,7 +21430,6 @@ var Seamless = class {
21996
21430
  const masterAddress = await config.signer.getAddress();
21997
21431
  const forwarderContract = await getForwarderContract(chainId);
21998
21432
  const forwarderAddress = forwarderContract.target;
21999
- const brokerAddress = config.brokerAddress;
22000
21433
  const erc20Contract = new import_ethers27.ethers.Contract(
22001
21434
  contractAddress.ERC20,
22002
21435
  ERC20Token_default,
@@ -22004,16 +21437,6 @@ var Seamless = class {
22004
21437
  );
22005
21438
  try {
22006
21439
  const nonces = await erc20Contract.nonces(masterAddress);
22007
- const brokerSignPermit = await signPermit(
22008
- config.signer,
22009
- // 使用 signer 而不是 provider
22010
- erc20Contract,
22011
- masterAddress,
22012
- brokerAddress,
22013
- import_ethers27.ethers.MaxUint256.toString(),
22014
- nonces.toString(),
22015
- deadline.toString()
22016
- );
22017
21440
  const forwarderSignPermit = await signPermit(
22018
21441
  config.signer,
22019
21442
  // 使用 signer 而不是 provider
@@ -22021,7 +21444,7 @@ var Seamless = class {
22021
21444
  masterAddress,
22022
21445
  forwarderAddress,
22023
21446
  import_ethers27.ethers.MaxUint256.toString(),
22024
- (nonces + BigInt(1)).toString(),
21447
+ nonces.toString(),
22025
21448
  deadline.toString()
22026
21449
  );
22027
21450
  const accountSignPermit = await signPermit(
@@ -22031,19 +21454,9 @@ var Seamless = class {
22031
21454
  masterAddress,
22032
21455
  contractAddress.Account,
22033
21456
  import_ethers27.ethers.MaxUint256.toString(),
22034
- (nonces + BigInt(2)).toString(),
21457
+ (nonces + BigInt(1)).toString(),
22035
21458
  deadline.toString()
22036
21459
  );
22037
- const brokerSeamlessUSDPermitParams = {
22038
- token: erc20Contract.target,
22039
- owner: masterAddress,
22040
- spender: brokerAddress,
22041
- value: import_ethers27.ethers.MaxUint256,
22042
- deadline,
22043
- v: brokerSignPermit.v,
22044
- r: brokerSignPermit.r,
22045
- s: brokerSignPermit.s
22046
- };
22047
21460
  const forwarderPermitParams = {
22048
21461
  token: erc20Contract.target,
22049
21462
  owner: masterAddress,
@@ -22064,7 +21477,7 @@ var Seamless = class {
22064
21477
  r: accountSignPermit.r,
22065
21478
  s: accountSignPermit.s
22066
21479
  };
22067
- return [brokerSeamlessUSDPermitParams, forwarderPermitParams, accountPermitParams];
21480
+ return [forwarderPermitParams, accountPermitParams];
22068
21481
  } catch (error) {
22069
21482
  this.logger.error("error-->", error);
22070
21483
  throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");