@myx-trade/sdk 0.1.215 → 0.1.216
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 +1386 -5
- package/dist/index.d.ts +1386 -5
- package/dist/index.js +90 -5
- package/dist/index.mjs +90 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1807,7 +1807,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
|
|
|
1807
1807
|
// package.json
|
|
1808
1808
|
var package_default = {
|
|
1809
1809
|
name: "@myx-trade/sdk",
|
|
1810
|
-
version: "0.1.
|
|
1810
|
+
version: "0.1.216",
|
|
1811
1811
|
private: false,
|
|
1812
1812
|
publishConfig: {
|
|
1813
1813
|
access: "public"
|
|
@@ -11474,6 +11474,11 @@ var getBrokerSingerContract = async (chainId, brokerAddress) => {
|
|
|
11474
11474
|
var getSeamlessBrokerContract = async (brokerAddress, singer) => {
|
|
11475
11475
|
return getContract(brokerAddress, Broker_default, singer);
|
|
11476
11476
|
};
|
|
11477
|
+
var getBrokerContract = async (chainId, brokerAddress) => {
|
|
11478
|
+
const address = brokerAddress;
|
|
11479
|
+
const provider = getJSONProvider(chainId);
|
|
11480
|
+
return getContract(address, Broker_default, provider);
|
|
11481
|
+
};
|
|
11477
11482
|
var getPythContract = async (chainId, type = 0 /* JSON */) => {
|
|
11478
11483
|
const addresses = address_default[chainId];
|
|
11479
11484
|
const address = addresses.PYTH;
|
|
@@ -22214,6 +22219,60 @@ var Seamless = class {
|
|
|
22214
22219
|
}
|
|
22215
22220
|
};
|
|
22216
22221
|
|
|
22222
|
+
// src/manager/base/BaseMyxClient.ts
|
|
22223
|
+
var BaseMyxClient = class {
|
|
22224
|
+
constructor(client2) {
|
|
22225
|
+
this.client = client2;
|
|
22226
|
+
}
|
|
22227
|
+
getConfig() {
|
|
22228
|
+
return this.client.getConfigManager()?.getConfig();
|
|
22229
|
+
}
|
|
22230
|
+
async getSigner() {
|
|
22231
|
+
const config = this.getConfig();
|
|
22232
|
+
if (!config?.signer) {
|
|
22233
|
+
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
|
|
22234
|
+
}
|
|
22235
|
+
return config.signer;
|
|
22236
|
+
}
|
|
22237
|
+
getAddressConfig() {
|
|
22238
|
+
const config = this.getConfig();
|
|
22239
|
+
const chainId = config?.chainId;
|
|
22240
|
+
if (!chainId || isSupportedChainFn(chainId)) {
|
|
22241
|
+
throw new MyxSDKError("INVALID_CHAIN_ID" /* InvalidChainId */, "Invalid chain id");
|
|
22242
|
+
}
|
|
22243
|
+
return address_default[chainId];
|
|
22244
|
+
}
|
|
22245
|
+
async connectContract(contract) {
|
|
22246
|
+
return contract.connect(await this.getSigner());
|
|
22247
|
+
}
|
|
22248
|
+
async getBrokerContract() {
|
|
22249
|
+
const config = this.getConfig();
|
|
22250
|
+
if (!config?.brokerAddress) {
|
|
22251
|
+
throw new MyxSDKError(
|
|
22252
|
+
"INVALID_BROKER_ADDRESS" /* InvalidBrokerAddress */,
|
|
22253
|
+
"Invalid broker address"
|
|
22254
|
+
);
|
|
22255
|
+
}
|
|
22256
|
+
return getBrokerContract(config.chainId, config.brokerAddress);
|
|
22257
|
+
}
|
|
22258
|
+
};
|
|
22259
|
+
|
|
22260
|
+
// src/manager/referrals/index.tsx
|
|
22261
|
+
var Referrals = class extends BaseMyxClient {
|
|
22262
|
+
constructor(client2) {
|
|
22263
|
+
super(client2);
|
|
22264
|
+
}
|
|
22265
|
+
async claimRebate() {
|
|
22266
|
+
const usdcAddress = this.getAddressConfig().USDC;
|
|
22267
|
+
const brokerContract = await this.connectContract(
|
|
22268
|
+
await this.getBrokerContract()
|
|
22269
|
+
);
|
|
22270
|
+
const tx = await brokerContract.claimRebate(usdcAddress);
|
|
22271
|
+
const receipt = await tx.wait();
|
|
22272
|
+
return receipt;
|
|
22273
|
+
}
|
|
22274
|
+
};
|
|
22275
|
+
|
|
22217
22276
|
// src/manager/index.ts
|
|
22218
22277
|
var MyxClient = class {
|
|
22219
22278
|
/**
|
|
@@ -22232,12 +22291,38 @@ var MyxClient = class {
|
|
|
22232
22291
|
lp.getMarkets().then();
|
|
22233
22292
|
this.utils = new Utils(this.configManager, this.logger);
|
|
22234
22293
|
this.api = new Api(this.configManager, this.logger);
|
|
22235
|
-
this.account = new Account(
|
|
22236
|
-
|
|
22294
|
+
this.account = new Account(
|
|
22295
|
+
this.configManager,
|
|
22296
|
+
this.logger,
|
|
22297
|
+
this.utils,
|
|
22298
|
+
this
|
|
22299
|
+
);
|
|
22300
|
+
this.seamless = new Seamless(
|
|
22301
|
+
this.configManager,
|
|
22302
|
+
this.logger,
|
|
22303
|
+
this.utils,
|
|
22304
|
+
this.account,
|
|
22305
|
+
this.api
|
|
22306
|
+
);
|
|
22237
22307
|
this.markets = new Markets(this.configManager, this.utils, this.api);
|
|
22238
|
-
this.position = new Position(
|
|
22239
|
-
|
|
22308
|
+
this.position = new Position(
|
|
22309
|
+
this.configManager,
|
|
22310
|
+
this.logger,
|
|
22311
|
+
this.utils,
|
|
22312
|
+
this.seamless,
|
|
22313
|
+
this.account,
|
|
22314
|
+
this.api
|
|
22315
|
+
);
|
|
22316
|
+
this.order = new Order(
|
|
22317
|
+
this.configManager,
|
|
22318
|
+
this.logger,
|
|
22319
|
+
this.utils,
|
|
22320
|
+
this.seamless,
|
|
22321
|
+
this.account,
|
|
22322
|
+
this.api
|
|
22323
|
+
);
|
|
22240
22324
|
this.subscription = new SubScription(this.configManager, this.logger);
|
|
22325
|
+
this.referrals = new Referrals(this);
|
|
22241
22326
|
}
|
|
22242
22327
|
/**
|
|
22243
22328
|
* auth the client
|
package/dist/index.mjs
CHANGED
|
@@ -1731,7 +1731,7 @@ var RotationProvider = class extends BaseProvider {
|
|
|
1731
1731
|
// package.json
|
|
1732
1732
|
var package_default = {
|
|
1733
1733
|
name: "@myx-trade/sdk",
|
|
1734
|
-
version: "0.1.
|
|
1734
|
+
version: "0.1.216",
|
|
1735
1735
|
private: false,
|
|
1736
1736
|
publishConfig: {
|
|
1737
1737
|
access: "public"
|
|
@@ -11398,6 +11398,11 @@ var getBrokerSingerContract = async (chainId, brokerAddress) => {
|
|
|
11398
11398
|
var getSeamlessBrokerContract = async (brokerAddress, singer) => {
|
|
11399
11399
|
return getContract(brokerAddress, Broker_default, singer);
|
|
11400
11400
|
};
|
|
11401
|
+
var getBrokerContract = async (chainId, brokerAddress) => {
|
|
11402
|
+
const address = brokerAddress;
|
|
11403
|
+
const provider = getJSONProvider(chainId);
|
|
11404
|
+
return getContract(address, Broker_default, provider);
|
|
11405
|
+
};
|
|
11401
11406
|
var getPythContract = async (chainId, type = 0 /* JSON */) => {
|
|
11402
11407
|
const addresses = address_default[chainId];
|
|
11403
11408
|
const address = addresses.PYTH;
|
|
@@ -22138,6 +22143,60 @@ var Seamless = class {
|
|
|
22138
22143
|
}
|
|
22139
22144
|
};
|
|
22140
22145
|
|
|
22146
|
+
// src/manager/base/BaseMyxClient.ts
|
|
22147
|
+
var BaseMyxClient = class {
|
|
22148
|
+
constructor(client2) {
|
|
22149
|
+
this.client = client2;
|
|
22150
|
+
}
|
|
22151
|
+
getConfig() {
|
|
22152
|
+
return this.client.getConfigManager()?.getConfig();
|
|
22153
|
+
}
|
|
22154
|
+
async getSigner() {
|
|
22155
|
+
const config = this.getConfig();
|
|
22156
|
+
if (!config?.signer) {
|
|
22157
|
+
throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
|
|
22158
|
+
}
|
|
22159
|
+
return config.signer;
|
|
22160
|
+
}
|
|
22161
|
+
getAddressConfig() {
|
|
22162
|
+
const config = this.getConfig();
|
|
22163
|
+
const chainId = config?.chainId;
|
|
22164
|
+
if (!chainId || isSupportedChainFn(chainId)) {
|
|
22165
|
+
throw new MyxSDKError("INVALID_CHAIN_ID" /* InvalidChainId */, "Invalid chain id");
|
|
22166
|
+
}
|
|
22167
|
+
return address_default[chainId];
|
|
22168
|
+
}
|
|
22169
|
+
async connectContract(contract) {
|
|
22170
|
+
return contract.connect(await this.getSigner());
|
|
22171
|
+
}
|
|
22172
|
+
async getBrokerContract() {
|
|
22173
|
+
const config = this.getConfig();
|
|
22174
|
+
if (!config?.brokerAddress) {
|
|
22175
|
+
throw new MyxSDKError(
|
|
22176
|
+
"INVALID_BROKER_ADDRESS" /* InvalidBrokerAddress */,
|
|
22177
|
+
"Invalid broker address"
|
|
22178
|
+
);
|
|
22179
|
+
}
|
|
22180
|
+
return getBrokerContract(config.chainId, config.brokerAddress);
|
|
22181
|
+
}
|
|
22182
|
+
};
|
|
22183
|
+
|
|
22184
|
+
// src/manager/referrals/index.tsx
|
|
22185
|
+
var Referrals = class extends BaseMyxClient {
|
|
22186
|
+
constructor(client2) {
|
|
22187
|
+
super(client2);
|
|
22188
|
+
}
|
|
22189
|
+
async claimRebate() {
|
|
22190
|
+
const usdcAddress = this.getAddressConfig().USDC;
|
|
22191
|
+
const brokerContract = await this.connectContract(
|
|
22192
|
+
await this.getBrokerContract()
|
|
22193
|
+
);
|
|
22194
|
+
const tx = await brokerContract.claimRebate(usdcAddress);
|
|
22195
|
+
const receipt = await tx.wait();
|
|
22196
|
+
return receipt;
|
|
22197
|
+
}
|
|
22198
|
+
};
|
|
22199
|
+
|
|
22141
22200
|
// src/manager/index.ts
|
|
22142
22201
|
var MyxClient = class {
|
|
22143
22202
|
/**
|
|
@@ -22156,12 +22215,38 @@ var MyxClient = class {
|
|
|
22156
22215
|
lp.getMarkets().then();
|
|
22157
22216
|
this.utils = new Utils(this.configManager, this.logger);
|
|
22158
22217
|
this.api = new Api(this.configManager, this.logger);
|
|
22159
|
-
this.account = new Account(
|
|
22160
|
-
|
|
22218
|
+
this.account = new Account(
|
|
22219
|
+
this.configManager,
|
|
22220
|
+
this.logger,
|
|
22221
|
+
this.utils,
|
|
22222
|
+
this
|
|
22223
|
+
);
|
|
22224
|
+
this.seamless = new Seamless(
|
|
22225
|
+
this.configManager,
|
|
22226
|
+
this.logger,
|
|
22227
|
+
this.utils,
|
|
22228
|
+
this.account,
|
|
22229
|
+
this.api
|
|
22230
|
+
);
|
|
22161
22231
|
this.markets = new Markets(this.configManager, this.utils, this.api);
|
|
22162
|
-
this.position = new Position(
|
|
22163
|
-
|
|
22232
|
+
this.position = new Position(
|
|
22233
|
+
this.configManager,
|
|
22234
|
+
this.logger,
|
|
22235
|
+
this.utils,
|
|
22236
|
+
this.seamless,
|
|
22237
|
+
this.account,
|
|
22238
|
+
this.api
|
|
22239
|
+
);
|
|
22240
|
+
this.order = new Order(
|
|
22241
|
+
this.configManager,
|
|
22242
|
+
this.logger,
|
|
22243
|
+
this.utils,
|
|
22244
|
+
this.seamless,
|
|
22245
|
+
this.account,
|
|
22246
|
+
this.api
|
|
22247
|
+
);
|
|
22164
22248
|
this.subscription = new SubScription(this.configManager, this.logger);
|
|
22249
|
+
this.referrals = new Referrals(this);
|
|
22165
22250
|
}
|
|
22166
22251
|
/**
|
|
22167
22252
|
* auth the client
|