@myx-trade/sdk 0.1.33 → 0.1.35

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/dist/index.d.mts CHANGED
@@ -128,7 +128,7 @@ declare const TimeInForce: {
128
128
  };
129
129
  type TimeInForce = (typeof TimeInForce)[keyof typeof TimeInForce];
130
130
  interface Position$1 {
131
- userPositionSalt: string;
131
+ positionId: string;
132
132
  poolId: string;
133
133
  direction: Direction;
134
134
  size: string;
@@ -145,7 +145,7 @@ interface Position$1 {
145
145
  interface Order$1 {
146
146
  orderId: string;
147
147
  poolId: string;
148
- userPositionSalt?: string;
148
+ positionId: string;
149
149
  orderType: OrderType;
150
150
  triggerType: TriggerType;
151
151
  operation: OperationType;
@@ -175,7 +175,7 @@ interface PlaceOrderParams {
175
175
  chainId: number;
176
176
  address: string;
177
177
  poolId: string;
178
- userPositionSalt: number;
178
+ positionId: number;
179
179
  orderType: OrderType;
180
180
  triggerType: TriggerType;
181
181
  direction: Direction;
@@ -196,7 +196,7 @@ interface PositionTpSlOrderParams {
196
196
  chainId: number;
197
197
  address: string;
198
198
  poolId: string;
199
- userPositionSalt: number;
199
+ positionId: number;
200
200
  executionFeeToken: string;
201
201
  tpTriggerType: TriggerType;
202
202
  slTriggerType: TriggerType;
@@ -1180,7 +1180,11 @@ declare class ConfigManager {
1180
1180
  * @param forceRefresh 是否强制刷新
1181
1181
  * @returns Promise<string | null> 有效的 accessToken 或 null
1182
1182
  */
1183
+ private _getAccessTokenQueue;
1184
+ private _isGettingAccessToken;
1183
1185
  getAccessToken(forceRefresh?: boolean): Promise<string | null>;
1186
+ private _processAccessTokenQueue;
1187
+ private _getAccessToken;
1184
1188
  /**
1185
1189
  * 设置 accessToken 和过期时间
1186
1190
  * @param token accessToken
@@ -1275,6 +1279,20 @@ declare class Utils {
1275
1279
  code: number;
1276
1280
  message: any;
1277
1281
  }>;
1282
+ getUserTradingFeeRate(assetClass: number): Promise<{
1283
+ code: number;
1284
+ data: {
1285
+ takerFeeRate: any;
1286
+ makerFeeRate: any;
1287
+ baseTakerFeeRate: any;
1288
+ baseMakerFeeRate: any;
1289
+ };
1290
+ message?: undefined;
1291
+ } | {
1292
+ code: number;
1293
+ message: any;
1294
+ data?: undefined;
1295
+ }>;
1278
1296
  getNetworkFee(quoteAddress: string): Promise<any>;
1279
1297
  getOraclePrice(poolId: string): Promise<{
1280
1298
  poolId: string;
package/dist/index.d.ts CHANGED
@@ -128,7 +128,7 @@ declare const TimeInForce: {
128
128
  };
129
129
  type TimeInForce = (typeof TimeInForce)[keyof typeof TimeInForce];
130
130
  interface Position$1 {
131
- userPositionSalt: string;
131
+ positionId: string;
132
132
  poolId: string;
133
133
  direction: Direction;
134
134
  size: string;
@@ -145,7 +145,7 @@ interface Position$1 {
145
145
  interface Order$1 {
146
146
  orderId: string;
147
147
  poolId: string;
148
- userPositionSalt?: string;
148
+ positionId: string;
149
149
  orderType: OrderType;
150
150
  triggerType: TriggerType;
151
151
  operation: OperationType;
@@ -175,7 +175,7 @@ interface PlaceOrderParams {
175
175
  chainId: number;
176
176
  address: string;
177
177
  poolId: string;
178
- userPositionSalt: number;
178
+ positionId: number;
179
179
  orderType: OrderType;
180
180
  triggerType: TriggerType;
181
181
  direction: Direction;
@@ -196,7 +196,7 @@ interface PositionTpSlOrderParams {
196
196
  chainId: number;
197
197
  address: string;
198
198
  poolId: string;
199
- userPositionSalt: number;
199
+ positionId: number;
200
200
  executionFeeToken: string;
201
201
  tpTriggerType: TriggerType;
202
202
  slTriggerType: TriggerType;
@@ -1180,7 +1180,11 @@ declare class ConfigManager {
1180
1180
  * @param forceRefresh 是否强制刷新
1181
1181
  * @returns Promise<string | null> 有效的 accessToken 或 null
1182
1182
  */
1183
+ private _getAccessTokenQueue;
1184
+ private _isGettingAccessToken;
1183
1185
  getAccessToken(forceRefresh?: boolean): Promise<string | null>;
1186
+ private _processAccessTokenQueue;
1187
+ private _getAccessToken;
1184
1188
  /**
1185
1189
  * 设置 accessToken 和过期时间
1186
1190
  * @param token accessToken
@@ -1275,6 +1279,20 @@ declare class Utils {
1275
1279
  code: number;
1276
1280
  message: any;
1277
1281
  }>;
1282
+ getUserTradingFeeRate(assetClass: number): Promise<{
1283
+ code: number;
1284
+ data: {
1285
+ takerFeeRate: any;
1286
+ makerFeeRate: any;
1287
+ baseTakerFeeRate: any;
1288
+ baseMakerFeeRate: any;
1289
+ };
1290
+ message?: undefined;
1291
+ } | {
1292
+ code: number;
1293
+ message: any;
1294
+ data?: undefined;
1295
+ }>;
1278
1296
  getNetworkFee(quoteAddress: string): Promise<any>;
1279
1297
  getOraclePrice(poolId: string): Promise<{
1280
1298
  poolId: string;
package/dist/index.js CHANGED
@@ -1467,14 +1467,14 @@ function isSupportedChainFn(chainId2) {
1467
1467
  // src/config/address/ARB_TEST_SEPOLIA.ts
1468
1468
  var import_ethers = require("ethers");
1469
1469
  var ARB_TEST_SEPOLIA = {
1470
- USDC: "",
1471
- POOL_MANAGER: "0x29fA92d5f47051E49Ab9001A3cbd8091c34c5638",
1472
- Account: "0x900F3003c59b9c55A09CEB7b3134A53E511531C3",
1470
+ USDC: "0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",
1471
+ POOL_MANAGER: "0xA4A1dfbe40cB725A79D34bd529f0C1b54AB46954",
1472
+ Account: "0x6136899e8c77C452bc46AcD786aA2C09fD31f947",
1473
1473
  POOL_VIEW: "",
1474
1474
  HYPER_VAULT: import_ethers.ZeroAddress,
1475
1475
  FEE_COLLECTOR: "",
1476
- POSITION_MANAGER: "0x520435fA110549aE7eA1894839575a62cbF5A8D5",
1477
- ORDER_MANAGER: "0x4eDe4E20162551F293B9D6f33E8567314fb5612f",
1476
+ POSITION_MANAGER: "0x002F28be205E9A1e279d2eeF1f5e472CeA1d910C",
1477
+ ORDER_MANAGER: "0x3A3C7c4588Fb2aE46A4108994a47712E03F96B23",
1478
1478
  TRUSTED_FORWARDER: "",
1479
1479
  FRONT_FACET: "",
1480
1480
  // router address
@@ -1483,21 +1483,19 @@ var ARB_TEST_SEPOLIA = {
1483
1483
  FAUCET: "",
1484
1484
  UI_POOL_DATA_PROVIDER: "",
1485
1485
  UI_POSITION_DATA_PROVIDER: "",
1486
- PYTH: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",
1486
+ PYTH: "0x361360Def495BfB4F0BE59AB11878D042c458155",
1487
1487
  // !!! 非Pyth Adapter
1488
1488
  MYX: import_ethers.ZeroAddress,
1489
1489
  ERC20: "0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",
1490
- LIQUIDITY_ROUTER: "0x3533595E0546CCA3CEa58bD23f2733BbCE057F44",
1491
- BASE_POOL: "0x4b86814b748D2ae323a8449b98C5add6D07901F3",
1492
- QUOTE_POOL: "0x22342d91b372ED991aB5A93bdC31706E4971Cec2",
1493
- BROKER: "0x461A33C5E75c292A45f8c961ab816060a94AfbA0",
1494
- // MYXBroker
1495
- ORACLE: "0x38aC036082810F43f83c2bca0Ab2518703d74738",
1490
+ LIQUIDITY_ROUTER: "0xd185C3f675d991735FCF6885Ff6BADE02A21313d",
1491
+ BASE_POOL: "0x2c6AdaE4A01836487842b7369c1db3F441871E83",
1492
+ QUOTE_POOL: "0xe1Ff495206635570A8Eaf9517125Ce66a2d09d32",
1493
+ ORACLE: "0x574001F6cB520b15d5a6db9F7B7a0ebf1A8E25c0",
1496
1494
  // MYXOracle
1497
- EIP7702Delegation: "0xDec0Eb393c362e459B124F4A27E21BCD10D45B41",
1498
- MARKET_MANAGER: "0x26645ba85E6294f4AE4605C56967B0A16BcB9cBb",
1499
- DATA_PROVIDER: "0xc4472860fA175d0E8b5a73620778799469232763",
1500
- ORACLE_RESERVE: "0x513AE26EdD58E1fD209c68Ed790585fFb08Fd740"
1495
+ EIP7702Delegation: "0x4e1B9aDf5Aa4a893f578c8502E6E28841b2403f3",
1496
+ MARKET_MANAGER: "0x12AD75316A92a66b92c79080c555594314e7aFB3",
1497
+ DATA_PROVIDER: "0x726A4978eDcb974B9889BC6f5Ee2Ec06D703038E",
1498
+ ORACLE_RESERVE: "0xC46b81c38091933f4811EC16E93553f9801EB863"
1501
1499
  };
1502
1500
 
1503
1501
  // src/config/address.ts
@@ -1827,7 +1825,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1827
1825
  // package.json
1828
1826
  var package_default = {
1829
1827
  name: "@myx-trade/sdk",
1830
- version: "0.1.33",
1828
+ version: "0.1.35",
1831
1829
  private: false,
1832
1830
  publishConfig: {
1833
1831
  access: "public"
@@ -1861,7 +1859,8 @@ var package_default = {
1861
1859
  "publish:patch": "node scripts/publish.js patch",
1862
1860
  "publish:minor": "node scripts/publish.js minor",
1863
1861
  "publish:major": "node scripts/publish.js major",
1864
- "publish:no-bump": "npm run build && npm publish --access public"
1862
+ "publish:no-bump": "npm run build && npm publish --access public",
1863
+ "type-check": "echo 'Skipping type-check for @myx-trade/sdk'"
1865
1864
  },
1866
1865
  keywords: [
1867
1866
  "trading",
@@ -5682,11 +5681,15 @@ var Broker_default = [
5682
5681
  },
5683
5682
  {
5684
5683
  type: "function",
5685
- name: "placeOrder",
5684
+ name: "placeOrderWithPosition",
5686
5685
  constant: false,
5687
5686
  stateMutability: "payable",
5688
5687
  payable: true,
5689
5688
  inputs: [
5689
+ {
5690
+ type: "bytes32",
5691
+ name: "positionId"
5692
+ },
5690
5693
  {
5691
5694
  type: "tuple",
5692
5695
  name: "orderParams",
@@ -5700,8 +5703,100 @@ var Broker_default = [
5700
5703
  name: "poolId"
5701
5704
  },
5702
5705
  {
5703
- type: "uint64",
5704
- name: "userPositionSalt"
5706
+ type: "uint8",
5707
+ name: "orderType"
5708
+ },
5709
+ {
5710
+ type: "uint8",
5711
+ name: "triggerType"
5712
+ },
5713
+ {
5714
+ type: "uint8",
5715
+ name: "operation"
5716
+ },
5717
+ {
5718
+ type: "uint8",
5719
+ name: "direction"
5720
+ },
5721
+ {
5722
+ type: "uint256",
5723
+ name: "collateralAmount"
5724
+ },
5725
+ {
5726
+ type: "uint256",
5727
+ name: "size"
5728
+ },
5729
+ {
5730
+ type: "uint256",
5731
+ name: "price"
5732
+ },
5733
+ {
5734
+ type: "uint8",
5735
+ name: "timeInForce"
5736
+ },
5737
+ {
5738
+ type: "bool",
5739
+ name: "postOnly"
5740
+ },
5741
+ {
5742
+ type: "uint16",
5743
+ name: "slippagePct"
5744
+ },
5745
+ {
5746
+ type: "address",
5747
+ name: "executionFeeToken"
5748
+ },
5749
+ {
5750
+ type: "uint16",
5751
+ name: "leverage"
5752
+ },
5753
+ {
5754
+ type: "uint256",
5755
+ name: "tpSize"
5756
+ },
5757
+ {
5758
+ type: "uint256",
5759
+ name: "tpPrice"
5760
+ },
5761
+ {
5762
+ type: "uint256",
5763
+ name: "slSize"
5764
+ },
5765
+ {
5766
+ type: "uint256",
5767
+ name: "slPrice"
5768
+ },
5769
+ {
5770
+ type: "bool",
5771
+ name: "useAccountBalance"
5772
+ }
5773
+ ]
5774
+ }
5775
+ ],
5776
+ outputs: []
5777
+ },
5778
+ {
5779
+ type: "function",
5780
+ name: "placeOrderWithSalt",
5781
+ constant: false,
5782
+ stateMutability: "payable",
5783
+ payable: true,
5784
+ inputs: [
5785
+ {
5786
+ type: "uint64",
5787
+ name: "userPositionSalt"
5788
+ },
5789
+ {
5790
+ type: "tuple",
5791
+ name: "orderParams",
5792
+ components: [
5793
+ {
5794
+ type: "address",
5795
+ name: "user"
5796
+ },
5797
+ {
5798
+ type: "bytes32",
5799
+ name: "poolId"
5705
5800
  },
5706
5801
  {
5707
5802
  type: "uint8",
@@ -5778,11 +5873,15 @@ var Broker_default = [
5778
5873
  },
5779
5874
  {
5780
5875
  type: "function",
5781
- name: "placeOrders",
5876
+ name: "placeOrdersWithPosition",
5782
5877
  constant: false,
5783
5878
  stateMutability: "payable",
5784
5879
  payable: true,
5785
5880
  inputs: [
5881
+ {
5882
+ type: "bytes32[]",
5883
+ name: "positionIds"
5884
+ },
5786
5885
  {
5787
5886
  type: "tuple[]",
5788
5887
  name: "orderParams",
@@ -5796,8 +5895,100 @@ var Broker_default = [
5796
5895
  name: "poolId"
5797
5896
  },
5798
5897
  {
5799
- type: "uint64",
5800
- name: "userPositionSalt"
5898
+ type: "uint8",
5899
+ name: "orderType"
5900
+ },
5901
+ {
5902
+ type: "uint8",
5903
+ name: "triggerType"
5904
+ },
5905
+ {
5906
+ type: "uint8",
5907
+ name: "operation"
5908
+ },
5909
+ {
5910
+ type: "uint8",
5911
+ name: "direction"
5912
+ },
5913
+ {
5914
+ type: "uint256",
5915
+ name: "collateralAmount"
5916
+ },
5917
+ {
5918
+ type: "uint256",
5919
+ name: "size"
5920
+ },
5921
+ {
5922
+ type: "uint256",
5923
+ name: "price"
5924
+ },
5925
+ {
5926
+ type: "uint8",
5927
+ name: "timeInForce"
5928
+ },
5929
+ {
5930
+ type: "bool",
5931
+ name: "postOnly"
5932
+ },
5933
+ {
5934
+ type: "uint16",
5935
+ name: "slippagePct"
5936
+ },
5937
+ {
5938
+ type: "address",
5939
+ name: "executionFeeToken"
5940
+ },
5941
+ {
5942
+ type: "uint16",
5943
+ name: "leverage"
5944
+ },
5945
+ {
5946
+ type: "uint256",
5947
+ name: "tpSize"
5948
+ },
5949
+ {
5950
+ type: "uint256",
5951
+ name: "tpPrice"
5952
+ },
5953
+ {
5954
+ type: "uint256",
5955
+ name: "slSize"
5956
+ },
5957
+ {
5958
+ type: "uint256",
5959
+ name: "slPrice"
5960
+ },
5961
+ {
5962
+ type: "bool",
5963
+ name: "useAccountBalance"
5964
+ }
5965
+ ]
5966
+ }
5967
+ ],
5968
+ outputs: []
5969
+ },
5970
+ {
5971
+ type: "function",
5972
+ name: "placeOrdersWithSalt",
5973
+ constant: false,
5974
+ stateMutability: "payable",
5975
+ payable: true,
5976
+ inputs: [
5977
+ {
5978
+ type: "uint64[]",
5979
+ name: "userPositionSalts"
5980
+ },
5981
+ {
5982
+ type: "tuple[]",
5983
+ name: "orderParams",
5984
+ components: [
5985
+ {
5986
+ type: "address",
5987
+ name: "user"
5988
+ },
5989
+ {
5990
+ type: "bytes32",
5991
+ name: "poolId"
5801
5992
  },
5802
5993
  {
5803
5994
  type: "uint8",
@@ -12078,6 +12269,13 @@ var SubScription = class {
12078
12269
  var ConfigManager = class {
12079
12270
  // accessToken 过期时间
12080
12271
  constructor(config) {
12272
+ /**
12273
+ * 获取有效的 accessToken,自动处理获取和刷新
12274
+ * @param forceRefresh 是否强制刷新
12275
+ * @returns Promise<string | null> 有效的 accessToken 或 null
12276
+ */
12277
+ this._getAccessTokenQueue = [];
12278
+ this._isGettingAccessToken = false;
12081
12279
  const mergedConfig = {
12082
12280
  isTestnet: false,
12083
12281
  ...config
@@ -12118,13 +12316,36 @@ var ConfigManager = class {
12118
12316
  );
12119
12317
  }
12120
12318
  }
12121
- /**
12122
- * 获取有效的 accessToken,自动处理获取和刷新
12123
- * @param forceRefresh 是否强制刷新
12124
- * @returns Promise<string | null> 有效的 accessToken 或 null
12125
- */
12126
12319
  async getAccessToken(forceRefresh = false) {
12320
+ return new Promise((resolve, reject) => {
12321
+ this._getAccessTokenQueue.push({
12322
+ resolve,
12323
+ reject,
12324
+ forceRefresh
12325
+ });
12326
+ this._processAccessTokenQueue();
12327
+ });
12328
+ }
12329
+ _processAccessTokenQueue() {
12330
+ if (this._isGettingAccessToken) {
12331
+ return;
12332
+ }
12333
+ this._isGettingAccessToken = true;
12334
+ const item = this._getAccessTokenQueue.shift();
12335
+ if (item) {
12336
+ this._getAccessToken(item.forceRefresh).then(item.resolve).catch(item.reject).finally(() => {
12337
+ this._isGettingAccessToken = false;
12338
+ if (this._getAccessTokenQueue.length > 0) {
12339
+ this._processAccessTokenQueue();
12340
+ }
12341
+ });
12342
+ } else {
12343
+ this._isGettingAccessToken = false;
12344
+ }
12345
+ }
12346
+ async _getAccessToken(forceRefresh = false) {
12127
12347
  if (!forceRefresh && this.isAccessTokenValid()) {
12348
+ this._isGettingAccessToken = false;
12128
12349
  return this.accessToken;
12129
12350
  }
12130
12351
  if (!this.config.getAccessToken) {
@@ -12180,7 +12401,7 @@ var ConfigManager = class {
12180
12401
  * @returns boolean token 是否有效
12181
12402
  */
12182
12403
  isAccessTokenValid() {
12183
- if (!this.accessToken || !this.accessTokenExpiry) {
12404
+ if (!this.accessToken || !this.accessTokenExpiry || !this.config.getAccessToken || !this.config.signer) {
12184
12405
  return false;
12185
12406
  }
12186
12407
  return Date.now() < this.accessTokenExpiry;
@@ -12575,7 +12796,7 @@ var Position = class {
12575
12796
  }
12576
12797
  }
12577
12798
  const brokerContract = getContract(
12578
- contractAddress.BROKER,
12799
+ config.brokerAddress,
12579
12800
  Broker_default,
12580
12801
  config.signer
12581
12802
  );
@@ -12706,7 +12927,7 @@ var Order = class {
12706
12927
  console.log("createIncreaseOrder params--->", {
12707
12928
  user: params.address,
12708
12929
  poolId: params.poolId,
12709
- userPositionSalt: params.userPositionSalt,
12930
+ positionId: params.positionId,
12710
12931
  orderType: params.orderType,
12711
12932
  triggerType: params.triggerType,
12712
12933
  operation: OperationType.INCREASE,
@@ -12725,10 +12946,9 @@ var Order = class {
12725
12946
  slPrice: params.slPrice ? params.slPrice : 0,
12726
12947
  useAccountBalance: false
12727
12948
  });
12728
- const gasLimit = await brokerContract.placeOrder.estimateGas({
12949
+ const gasLimit = await brokerContract.placeOrderWithPosition.estimateGas(params.positionId.toString(), {
12729
12950
  user: params.address,
12730
12951
  poolId: params.poolId,
12731
- userPositionSalt: params.userPositionSalt,
12732
12952
  orderType: params.orderType,
12733
12953
  triggerType: params.triggerType,
12734
12954
  operation: OperationType.INCREASE,
@@ -12747,11 +12967,11 @@ var Order = class {
12747
12967
  slPrice: params.slPrice ? params.slPrice : 0,
12748
12968
  useAccountBalance: false
12749
12969
  });
12750
- const transaction = await brokerContract.placeOrder(
12970
+ const transaction = await brokerContract.placeOrderWithPosition(
12971
+ params.positionId.toString(),
12751
12972
  {
12752
12973
  user: params.address,
12753
12974
  poolId: params.poolId,
12754
- userPositionSalt: params.userPositionSalt,
12755
12975
  orderType: params.orderType,
12756
12976
  triggerType: params.triggerType,
12757
12977
  operation: OperationType.INCREASE,
@@ -12823,7 +13043,7 @@ var Order = class {
12823
13043
  console.log("createDecreaseOrder params--->", {
12824
13044
  user: params.address,
12825
13045
  poolId: params.poolId,
12826
- userPositionSalt: params.userPositionSalt,
13046
+ positionId: params.positionId,
12827
13047
  orderType: params.orderType,
12828
13048
  triggerType: params.triggerType,
12829
13049
  operation: OperationType.DECREASE,
@@ -12837,10 +13057,9 @@ var Order = class {
12837
13057
  executionFeeToken: params.executionFeeToken,
12838
13058
  leverage: params.leverage
12839
13059
  });
12840
- const gasLimit = await brokerContract.placeOrder.estimateGas({
13060
+ const gasLimit = await brokerContract.placeOrderWithPosition.estimateGas(params.positionId.toString(), {
12841
13061
  user: params.address,
12842
13062
  poolId: params.poolId,
12843
- userPositionSalt: params.userPositionSalt,
12844
13063
  orderType: params.orderType,
12845
13064
  triggerType: params.triggerType,
12846
13065
  operation: OperationType.DECREASE,
@@ -12859,11 +13078,11 @@ var Order = class {
12859
13078
  slPrice: 0,
12860
13079
  useAccountBalance: false
12861
13080
  });
12862
- const transaction = await brokerContract.placeOrder(
13081
+ const transaction = await brokerContract.placeOrderWithPosition(
13082
+ params.positionId.toString(),
12863
13083
  {
12864
13084
  user: params.address,
12865
13085
  poolId: params.poolId,
12866
- userPositionSalt: params.userPositionSalt,
12867
13086
  orderType: params.orderType,
12868
13087
  triggerType: params.triggerType,
12869
13088
  operation: OperationType.DECREASE,
@@ -12938,7 +13157,6 @@ var Order = class {
12938
13157
  {
12939
13158
  user: params.address,
12940
13159
  poolId: params.poolId,
12941
- userPositionSalt: params.userPositionSalt,
12942
13160
  orderType: OrderType.STOP,
12943
13161
  triggerType: params.tpTriggerType,
12944
13162
  operation: OperationType.DECREASE,
@@ -12960,7 +13178,6 @@ var Order = class {
12960
13178
  {
12961
13179
  user: params.address,
12962
13180
  poolId: params.poolId,
12963
- userPositionSalt: params.userPositionSalt,
12964
13181
  orderType: OrderType.STOP,
12965
13182
  triggerType: params.slTriggerType,
12966
13183
  operation: OperationType.DECREASE,
@@ -12981,8 +13198,8 @@ var Order = class {
12981
13198
  }
12982
13199
  ];
12983
13200
  console.log("createPositionTpSlOrder data--->", data2);
12984
- const gasLimit2 = await brokerContract.placeOrders.estimateGas(data2);
12985
- const transaction2 = await brokerContract.placeOrders(data2, {
13201
+ const gasLimit2 = await brokerContract.placeOrdersWithPosition.estimateGas([params.positionId.toString(), params.positionId.toString()], data2);
13202
+ const transaction2 = await brokerContract.placeOrdersWithPosition([params.positionId.toString(), params.positionId.toString()], data2, {
12986
13203
  gasLimit: gasLimit2 * 120n / 100n
12987
13204
  });
12988
13205
  this.logger.info("Transaction sent:", transaction2.hash);
@@ -13018,7 +13235,6 @@ var Order = class {
13018
13235
  const data = {
13019
13236
  user: params.address,
13020
13237
  poolId: params.poolId,
13021
- userPositionSalt: params.userPositionSalt,
13022
13238
  orderType: OrderType.STOP,
13023
13239
  triggerType: params.tpSize !== "0" ? params.tpTriggerType : params.slTriggerType,
13024
13240
  operation: OperationType.DECREASE,
@@ -13038,8 +13254,8 @@ var Order = class {
13038
13254
  useAccountBalance: false
13039
13255
  };
13040
13256
  console.log("createPositionTpSlOrder data--->", data);
13041
- const gasLimit = await brokerContract.placeOrder.estimateGas(data);
13042
- const transaction = await brokerContract.placeOrder(data, {
13257
+ const gasLimit = await brokerContract.placeOrderWithPosition.estimateGas(params.positionId.toString(), data);
13258
+ const transaction = await brokerContract.placeOrderWithPosition(params.positionId.toString(), data, {
13043
13259
  gasLimit: gasLimit * 120n / 100n
13044
13260
  });
13045
13261
  this.logger.info("Transaction sent:", transaction.hash);
@@ -17018,6 +17234,37 @@ var Utils = class {
17018
17234
  };
17019
17235
  }
17020
17236
  }
17237
+ async getUserTradingFeeRate(assetClass) {
17238
+ const config = this.configManager.getConfig();
17239
+ const brokerAddress = config.brokerAddress;
17240
+ const brokerContract = new import_ethers26.ethers.Contract(
17241
+ brokerAddress,
17242
+ Broker_default,
17243
+ config.signer
17244
+ );
17245
+ try {
17246
+ const userFeeRate = await brokerContract.getUserFeeRate(
17247
+ config.signer?.getAddress(),
17248
+ assetClass
17249
+ );
17250
+ return {
17251
+ code: 0,
17252
+ data: {
17253
+ takerFeeRate: userFeeRate[0].toString(),
17254
+ makerFeeRate: userFeeRate[1].toString(),
17255
+ baseTakerFeeRate: userFeeRate[2].toString(),
17256
+ baseMakerFeeRate: userFeeRate[3].toString()
17257
+ }
17258
+ };
17259
+ } catch (error) {
17260
+ this.logger.error("Error getting user trading fee rate:", error);
17261
+ return {
17262
+ code: -1,
17263
+ // @ts-ignore
17264
+ message: error?.message
17265
+ };
17266
+ }
17267
+ }
17021
17268
  async getNetworkFee(quoteAddress) {
17022
17269
  const config = this.configManager.getConfig();
17023
17270
  const orderManagerAddress = getContractAddressByChainId(
package/dist/index.mjs CHANGED
@@ -1376,14 +1376,14 @@ function isSupportedChainFn(chainId2) {
1376
1376
  // src/config/address/ARB_TEST_SEPOLIA.ts
1377
1377
  import { ZeroAddress } from "ethers";
1378
1378
  var ARB_TEST_SEPOLIA = {
1379
- USDC: "",
1380
- POOL_MANAGER: "0x29fA92d5f47051E49Ab9001A3cbd8091c34c5638",
1381
- Account: "0x900F3003c59b9c55A09CEB7b3134A53E511531C3",
1379
+ USDC: "0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",
1380
+ POOL_MANAGER: "0xA4A1dfbe40cB725A79D34bd529f0C1b54AB46954",
1381
+ Account: "0x6136899e8c77C452bc46AcD786aA2C09fD31f947",
1382
1382
  POOL_VIEW: "",
1383
1383
  HYPER_VAULT: ZeroAddress,
1384
1384
  FEE_COLLECTOR: "",
1385
- POSITION_MANAGER: "0x520435fA110549aE7eA1894839575a62cbF5A8D5",
1386
- ORDER_MANAGER: "0x4eDe4E20162551F293B9D6f33E8567314fb5612f",
1385
+ POSITION_MANAGER: "0x002F28be205E9A1e279d2eeF1f5e472CeA1d910C",
1386
+ ORDER_MANAGER: "0x3A3C7c4588Fb2aE46A4108994a47712E03F96B23",
1387
1387
  TRUSTED_FORWARDER: "",
1388
1388
  FRONT_FACET: "",
1389
1389
  // router address
@@ -1392,21 +1392,19 @@ var ARB_TEST_SEPOLIA = {
1392
1392
  FAUCET: "",
1393
1393
  UI_POOL_DATA_PROVIDER: "",
1394
1394
  UI_POSITION_DATA_PROVIDER: "",
1395
- PYTH: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",
1395
+ PYTH: "0x361360Def495BfB4F0BE59AB11878D042c458155",
1396
1396
  // !!! 非Pyth Adapter
1397
1397
  MYX: ZeroAddress,
1398
1398
  ERC20: "0x7E248Ec1721639413A280d9E82e2862Cae2E6E28",
1399
- LIQUIDITY_ROUTER: "0x3533595E0546CCA3CEa58bD23f2733BbCE057F44",
1400
- BASE_POOL: "0x4b86814b748D2ae323a8449b98C5add6D07901F3",
1401
- QUOTE_POOL: "0x22342d91b372ED991aB5A93bdC31706E4971Cec2",
1402
- BROKER: "0x461A33C5E75c292A45f8c961ab816060a94AfbA0",
1403
- // MYXBroker
1404
- ORACLE: "0x38aC036082810F43f83c2bca0Ab2518703d74738",
1399
+ LIQUIDITY_ROUTER: "0xd185C3f675d991735FCF6885Ff6BADE02A21313d",
1400
+ BASE_POOL: "0x2c6AdaE4A01836487842b7369c1db3F441871E83",
1401
+ QUOTE_POOL: "0xe1Ff495206635570A8Eaf9517125Ce66a2d09d32",
1402
+ ORACLE: "0x574001F6cB520b15d5a6db9F7B7a0ebf1A8E25c0",
1405
1403
  // MYXOracle
1406
- EIP7702Delegation: "0xDec0Eb393c362e459B124F4A27E21BCD10D45B41",
1407
- MARKET_MANAGER: "0x26645ba85E6294f4AE4605C56967B0A16BcB9cBb",
1408
- DATA_PROVIDER: "0xc4472860fA175d0E8b5a73620778799469232763",
1409
- ORACLE_RESERVE: "0x513AE26EdD58E1fD209c68Ed790585fFb08Fd740"
1404
+ EIP7702Delegation: "0x4e1B9aDf5Aa4a893f578c8502E6E28841b2403f3",
1405
+ MARKET_MANAGER: "0x12AD75316A92a66b92c79080c555594314e7aFB3",
1406
+ DATA_PROVIDER: "0x726A4978eDcb974B9889BC6f5Ee2Ec06D703038E",
1407
+ ORACLE_RESERVE: "0xC46b81c38091933f4811EC16E93553f9801EB863"
1410
1408
  };
1411
1409
 
1412
1410
  // src/config/address.ts
@@ -1742,7 +1740,7 @@ var RotationProvider = class extends BaseProvider {
1742
1740
  // package.json
1743
1741
  var package_default = {
1744
1742
  name: "@myx-trade/sdk",
1745
- version: "0.1.33",
1743
+ version: "0.1.35",
1746
1744
  private: false,
1747
1745
  publishConfig: {
1748
1746
  access: "public"
@@ -1776,7 +1774,8 @@ var package_default = {
1776
1774
  "publish:patch": "node scripts/publish.js patch",
1777
1775
  "publish:minor": "node scripts/publish.js minor",
1778
1776
  "publish:major": "node scripts/publish.js major",
1779
- "publish:no-bump": "npm run build && npm publish --access public"
1777
+ "publish:no-bump": "npm run build && npm publish --access public",
1778
+ "type-check": "echo 'Skipping type-check for @myx-trade/sdk'"
1780
1779
  },
1781
1780
  keywords: [
1782
1781
  "trading",
@@ -5597,11 +5596,15 @@ var Broker_default = [
5597
5596
  },
5598
5597
  {
5599
5598
  type: "function",
5600
- name: "placeOrder",
5599
+ name: "placeOrderWithPosition",
5601
5600
  constant: false,
5602
5601
  stateMutability: "payable",
5603
5602
  payable: true,
5604
5603
  inputs: [
5604
+ {
5605
+ type: "bytes32",
5606
+ name: "positionId"
5607
+ },
5605
5608
  {
5606
5609
  type: "tuple",
5607
5610
  name: "orderParams",
@@ -5615,8 +5618,100 @@ var Broker_default = [
5615
5618
  name: "poolId"
5616
5619
  },
5617
5620
  {
5618
- type: "uint64",
5619
- name: "userPositionSalt"
5621
+ type: "uint8",
5622
+ name: "orderType"
5623
+ },
5624
+ {
5625
+ type: "uint8",
5626
+ name: "triggerType"
5627
+ },
5628
+ {
5629
+ type: "uint8",
5630
+ name: "operation"
5631
+ },
5632
+ {
5633
+ type: "uint8",
5634
+ name: "direction"
5635
+ },
5636
+ {
5637
+ type: "uint256",
5638
+ name: "collateralAmount"
5639
+ },
5640
+ {
5641
+ type: "uint256",
5642
+ name: "size"
5643
+ },
5644
+ {
5645
+ type: "uint256",
5646
+ name: "price"
5647
+ },
5648
+ {
5649
+ type: "uint8",
5650
+ name: "timeInForce"
5651
+ },
5652
+ {
5653
+ type: "bool",
5654
+ name: "postOnly"
5655
+ },
5656
+ {
5657
+ type: "uint16",
5658
+ name: "slippagePct"
5659
+ },
5660
+ {
5661
+ type: "address",
5662
+ name: "executionFeeToken"
5663
+ },
5664
+ {
5665
+ type: "uint16",
5666
+ name: "leverage"
5667
+ },
5668
+ {
5669
+ type: "uint256",
5670
+ name: "tpSize"
5671
+ },
5672
+ {
5673
+ type: "uint256",
5674
+ name: "tpPrice"
5675
+ },
5676
+ {
5677
+ type: "uint256",
5678
+ name: "slSize"
5679
+ },
5680
+ {
5681
+ type: "uint256",
5682
+ name: "slPrice"
5683
+ },
5684
+ {
5685
+ type: "bool",
5686
+ name: "useAccountBalance"
5687
+ }
5688
+ ]
5689
+ }
5690
+ ],
5691
+ outputs: []
5692
+ },
5693
+ {
5694
+ type: "function",
5695
+ name: "placeOrderWithSalt",
5696
+ constant: false,
5697
+ stateMutability: "payable",
5698
+ payable: true,
5699
+ inputs: [
5700
+ {
5701
+ type: "uint64",
5702
+ name: "userPositionSalt"
5703
+ },
5704
+ {
5705
+ type: "tuple",
5706
+ name: "orderParams",
5707
+ components: [
5708
+ {
5709
+ type: "address",
5710
+ name: "user"
5711
+ },
5712
+ {
5713
+ type: "bytes32",
5714
+ name: "poolId"
5620
5715
  },
5621
5716
  {
5622
5717
  type: "uint8",
@@ -5693,11 +5788,15 @@ var Broker_default = [
5693
5788
  },
5694
5789
  {
5695
5790
  type: "function",
5696
- name: "placeOrders",
5791
+ name: "placeOrdersWithPosition",
5697
5792
  constant: false,
5698
5793
  stateMutability: "payable",
5699
5794
  payable: true,
5700
5795
  inputs: [
5796
+ {
5797
+ type: "bytes32[]",
5798
+ name: "positionIds"
5799
+ },
5701
5800
  {
5702
5801
  type: "tuple[]",
5703
5802
  name: "orderParams",
@@ -5711,8 +5810,100 @@ var Broker_default = [
5711
5810
  name: "poolId"
5712
5811
  },
5713
5812
  {
5714
- type: "uint64",
5715
- name: "userPositionSalt"
5813
+ type: "uint8",
5814
+ name: "orderType"
5815
+ },
5816
+ {
5817
+ type: "uint8",
5818
+ name: "triggerType"
5819
+ },
5820
+ {
5821
+ type: "uint8",
5822
+ name: "operation"
5823
+ },
5824
+ {
5825
+ type: "uint8",
5826
+ name: "direction"
5827
+ },
5828
+ {
5829
+ type: "uint256",
5830
+ name: "collateralAmount"
5831
+ },
5832
+ {
5833
+ type: "uint256",
5834
+ name: "size"
5835
+ },
5836
+ {
5837
+ type: "uint256",
5838
+ name: "price"
5839
+ },
5840
+ {
5841
+ type: "uint8",
5842
+ name: "timeInForce"
5843
+ },
5844
+ {
5845
+ type: "bool",
5846
+ name: "postOnly"
5847
+ },
5848
+ {
5849
+ type: "uint16",
5850
+ name: "slippagePct"
5851
+ },
5852
+ {
5853
+ type: "address",
5854
+ name: "executionFeeToken"
5855
+ },
5856
+ {
5857
+ type: "uint16",
5858
+ name: "leverage"
5859
+ },
5860
+ {
5861
+ type: "uint256",
5862
+ name: "tpSize"
5863
+ },
5864
+ {
5865
+ type: "uint256",
5866
+ name: "tpPrice"
5867
+ },
5868
+ {
5869
+ type: "uint256",
5870
+ name: "slSize"
5871
+ },
5872
+ {
5873
+ type: "uint256",
5874
+ name: "slPrice"
5875
+ },
5876
+ {
5877
+ type: "bool",
5878
+ name: "useAccountBalance"
5879
+ }
5880
+ ]
5881
+ }
5882
+ ],
5883
+ outputs: []
5884
+ },
5885
+ {
5886
+ type: "function",
5887
+ name: "placeOrdersWithSalt",
5888
+ constant: false,
5889
+ stateMutability: "payable",
5890
+ payable: true,
5891
+ inputs: [
5892
+ {
5893
+ type: "uint64[]",
5894
+ name: "userPositionSalts"
5895
+ },
5896
+ {
5897
+ type: "tuple[]",
5898
+ name: "orderParams",
5899
+ components: [
5900
+ {
5901
+ type: "address",
5902
+ name: "user"
5903
+ },
5904
+ {
5905
+ type: "bytes32",
5906
+ name: "poolId"
5716
5907
  },
5717
5908
  {
5718
5909
  type: "uint8",
@@ -11993,6 +12184,13 @@ var SubScription = class {
11993
12184
  var ConfigManager = class {
11994
12185
  // accessToken 过期时间
11995
12186
  constructor(config) {
12187
+ /**
12188
+ * 获取有效的 accessToken,自动处理获取和刷新
12189
+ * @param forceRefresh 是否强制刷新
12190
+ * @returns Promise<string | null> 有效的 accessToken 或 null
12191
+ */
12192
+ this._getAccessTokenQueue = [];
12193
+ this._isGettingAccessToken = false;
11996
12194
  const mergedConfig = {
11997
12195
  isTestnet: false,
11998
12196
  ...config
@@ -12033,13 +12231,36 @@ var ConfigManager = class {
12033
12231
  );
12034
12232
  }
12035
12233
  }
12036
- /**
12037
- * 获取有效的 accessToken,自动处理获取和刷新
12038
- * @param forceRefresh 是否强制刷新
12039
- * @returns Promise<string | null> 有效的 accessToken 或 null
12040
- */
12041
12234
  async getAccessToken(forceRefresh = false) {
12235
+ return new Promise((resolve, reject) => {
12236
+ this._getAccessTokenQueue.push({
12237
+ resolve,
12238
+ reject,
12239
+ forceRefresh
12240
+ });
12241
+ this._processAccessTokenQueue();
12242
+ });
12243
+ }
12244
+ _processAccessTokenQueue() {
12245
+ if (this._isGettingAccessToken) {
12246
+ return;
12247
+ }
12248
+ this._isGettingAccessToken = true;
12249
+ const item = this._getAccessTokenQueue.shift();
12250
+ if (item) {
12251
+ this._getAccessToken(item.forceRefresh).then(item.resolve).catch(item.reject).finally(() => {
12252
+ this._isGettingAccessToken = false;
12253
+ if (this._getAccessTokenQueue.length > 0) {
12254
+ this._processAccessTokenQueue();
12255
+ }
12256
+ });
12257
+ } else {
12258
+ this._isGettingAccessToken = false;
12259
+ }
12260
+ }
12261
+ async _getAccessToken(forceRefresh = false) {
12042
12262
  if (!forceRefresh && this.isAccessTokenValid()) {
12263
+ this._isGettingAccessToken = false;
12043
12264
  return this.accessToken;
12044
12265
  }
12045
12266
  if (!this.config.getAccessToken) {
@@ -12095,7 +12316,7 @@ var ConfigManager = class {
12095
12316
  * @returns boolean token 是否有效
12096
12317
  */
12097
12318
  isAccessTokenValid() {
12098
- if (!this.accessToken || !this.accessTokenExpiry) {
12319
+ if (!this.accessToken || !this.accessTokenExpiry || !this.config.getAccessToken || !this.config.signer) {
12099
12320
  return false;
12100
12321
  }
12101
12322
  return Date.now() < this.accessTokenExpiry;
@@ -12490,7 +12711,7 @@ var Position = class {
12490
12711
  }
12491
12712
  }
12492
12713
  const brokerContract = getContract(
12493
- contractAddress.BROKER,
12714
+ config.brokerAddress,
12494
12715
  Broker_default,
12495
12716
  config.signer
12496
12717
  );
@@ -12621,7 +12842,7 @@ var Order = class {
12621
12842
  console.log("createIncreaseOrder params--->", {
12622
12843
  user: params.address,
12623
12844
  poolId: params.poolId,
12624
- userPositionSalt: params.userPositionSalt,
12845
+ positionId: params.positionId,
12625
12846
  orderType: params.orderType,
12626
12847
  triggerType: params.triggerType,
12627
12848
  operation: OperationType.INCREASE,
@@ -12640,10 +12861,9 @@ var Order = class {
12640
12861
  slPrice: params.slPrice ? params.slPrice : 0,
12641
12862
  useAccountBalance: false
12642
12863
  });
12643
- const gasLimit = await brokerContract.placeOrder.estimateGas({
12864
+ const gasLimit = await brokerContract.placeOrderWithPosition.estimateGas(params.positionId.toString(), {
12644
12865
  user: params.address,
12645
12866
  poolId: params.poolId,
12646
- userPositionSalt: params.userPositionSalt,
12647
12867
  orderType: params.orderType,
12648
12868
  triggerType: params.triggerType,
12649
12869
  operation: OperationType.INCREASE,
@@ -12662,11 +12882,11 @@ var Order = class {
12662
12882
  slPrice: params.slPrice ? params.slPrice : 0,
12663
12883
  useAccountBalance: false
12664
12884
  });
12665
- const transaction = await brokerContract.placeOrder(
12885
+ const transaction = await brokerContract.placeOrderWithPosition(
12886
+ params.positionId.toString(),
12666
12887
  {
12667
12888
  user: params.address,
12668
12889
  poolId: params.poolId,
12669
- userPositionSalt: params.userPositionSalt,
12670
12890
  orderType: params.orderType,
12671
12891
  triggerType: params.triggerType,
12672
12892
  operation: OperationType.INCREASE,
@@ -12738,7 +12958,7 @@ var Order = class {
12738
12958
  console.log("createDecreaseOrder params--->", {
12739
12959
  user: params.address,
12740
12960
  poolId: params.poolId,
12741
- userPositionSalt: params.userPositionSalt,
12961
+ positionId: params.positionId,
12742
12962
  orderType: params.orderType,
12743
12963
  triggerType: params.triggerType,
12744
12964
  operation: OperationType.DECREASE,
@@ -12752,10 +12972,9 @@ var Order = class {
12752
12972
  executionFeeToken: params.executionFeeToken,
12753
12973
  leverage: params.leverage
12754
12974
  });
12755
- const gasLimit = await brokerContract.placeOrder.estimateGas({
12975
+ const gasLimit = await brokerContract.placeOrderWithPosition.estimateGas(params.positionId.toString(), {
12756
12976
  user: params.address,
12757
12977
  poolId: params.poolId,
12758
- userPositionSalt: params.userPositionSalt,
12759
12978
  orderType: params.orderType,
12760
12979
  triggerType: params.triggerType,
12761
12980
  operation: OperationType.DECREASE,
@@ -12774,11 +12993,11 @@ var Order = class {
12774
12993
  slPrice: 0,
12775
12994
  useAccountBalance: false
12776
12995
  });
12777
- const transaction = await brokerContract.placeOrder(
12996
+ const transaction = await brokerContract.placeOrderWithPosition(
12997
+ params.positionId.toString(),
12778
12998
  {
12779
12999
  user: params.address,
12780
13000
  poolId: params.poolId,
12781
- userPositionSalt: params.userPositionSalt,
12782
13001
  orderType: params.orderType,
12783
13002
  triggerType: params.triggerType,
12784
13003
  operation: OperationType.DECREASE,
@@ -12853,7 +13072,6 @@ var Order = class {
12853
13072
  {
12854
13073
  user: params.address,
12855
13074
  poolId: params.poolId,
12856
- userPositionSalt: params.userPositionSalt,
12857
13075
  orderType: OrderType.STOP,
12858
13076
  triggerType: params.tpTriggerType,
12859
13077
  operation: OperationType.DECREASE,
@@ -12875,7 +13093,6 @@ var Order = class {
12875
13093
  {
12876
13094
  user: params.address,
12877
13095
  poolId: params.poolId,
12878
- userPositionSalt: params.userPositionSalt,
12879
13096
  orderType: OrderType.STOP,
12880
13097
  triggerType: params.slTriggerType,
12881
13098
  operation: OperationType.DECREASE,
@@ -12896,8 +13113,8 @@ var Order = class {
12896
13113
  }
12897
13114
  ];
12898
13115
  console.log("createPositionTpSlOrder data--->", data2);
12899
- const gasLimit2 = await brokerContract.placeOrders.estimateGas(data2);
12900
- const transaction2 = await brokerContract.placeOrders(data2, {
13116
+ const gasLimit2 = await brokerContract.placeOrdersWithPosition.estimateGas([params.positionId.toString(), params.positionId.toString()], data2);
13117
+ const transaction2 = await brokerContract.placeOrdersWithPosition([params.positionId.toString(), params.positionId.toString()], data2, {
12901
13118
  gasLimit: gasLimit2 * 120n / 100n
12902
13119
  });
12903
13120
  this.logger.info("Transaction sent:", transaction2.hash);
@@ -12933,7 +13150,6 @@ var Order = class {
12933
13150
  const data = {
12934
13151
  user: params.address,
12935
13152
  poolId: params.poolId,
12936
- userPositionSalt: params.userPositionSalt,
12937
13153
  orderType: OrderType.STOP,
12938
13154
  triggerType: params.tpSize !== "0" ? params.tpTriggerType : params.slTriggerType,
12939
13155
  operation: OperationType.DECREASE,
@@ -12953,8 +13169,8 @@ var Order = class {
12953
13169
  useAccountBalance: false
12954
13170
  };
12955
13171
  console.log("createPositionTpSlOrder data--->", data);
12956
- const gasLimit = await brokerContract.placeOrder.estimateGas(data);
12957
- const transaction = await brokerContract.placeOrder(data, {
13172
+ const gasLimit = await brokerContract.placeOrderWithPosition.estimateGas(params.positionId.toString(), data);
13173
+ const transaction = await brokerContract.placeOrderWithPosition(params.positionId.toString(), data, {
12958
13174
  gasLimit: gasLimit * 120n / 100n
12959
13175
  });
12960
13176
  this.logger.info("Transaction sent:", transaction.hash);
@@ -16933,6 +17149,37 @@ var Utils = class {
16933
17149
  };
16934
17150
  }
16935
17151
  }
17152
+ async getUserTradingFeeRate(assetClass) {
17153
+ const config = this.configManager.getConfig();
17154
+ const brokerAddress = config.brokerAddress;
17155
+ const brokerContract = new ethers7.Contract(
17156
+ brokerAddress,
17157
+ Broker_default,
17158
+ config.signer
17159
+ );
17160
+ try {
17161
+ const userFeeRate = await brokerContract.getUserFeeRate(
17162
+ config.signer?.getAddress(),
17163
+ assetClass
17164
+ );
17165
+ return {
17166
+ code: 0,
17167
+ data: {
17168
+ takerFeeRate: userFeeRate[0].toString(),
17169
+ makerFeeRate: userFeeRate[1].toString(),
17170
+ baseTakerFeeRate: userFeeRate[2].toString(),
17171
+ baseMakerFeeRate: userFeeRate[3].toString()
17172
+ }
17173
+ };
17174
+ } catch (error) {
17175
+ this.logger.error("Error getting user trading fee rate:", error);
17176
+ return {
17177
+ code: -1,
17178
+ // @ts-ignore
17179
+ message: error?.message
17180
+ };
17181
+ }
17182
+ }
16936
17183
  async getNetworkFee(quoteAddress) {
16937
17184
  const config = this.configManager.getConfig();
16938
17185
  const orderManagerAddress = getContractAddressByChainId(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -34,7 +34,8 @@
34
34
  "publish:patch": "node scripts/publish.js patch",
35
35
  "publish:minor": "node scripts/publish.js minor",
36
36
  "publish:major": "node scripts/publish.js major",
37
- "publish:no-bump": "npm run build && npm publish --access public"
37
+ "publish:no-bump": "npm run build && npm publish --access public",
38
+ "type-check": "echo 'Skipping type-check for @myx-trade/sdk'"
38
39
  },
39
40
  "keywords": [
40
41
  "trading",