@mento-protocol/mento-sdk 0.2.8 → 1.0.1
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/cjs/constants/addresses.js +7 -7
- package/dist/cjs/interfaces/tradingLimitsConfig.d.ts +2 -0
- package/dist/cjs/interfaces/tradingLimitsState.d.ts +2 -0
- package/dist/cjs/limits.js +8 -0
- package/dist/cjs/mento.d.ts +3 -3
- package/dist/cjs/mento.js +15 -8
- package/dist/esm/constants/addresses.js +7 -7
- package/dist/esm/interfaces/tradingLimitsConfig.d.ts +2 -0
- package/dist/esm/interfaces/tradingLimitsState.d.ts +2 -0
- package/dist/esm/limits.js +8 -0
- package/dist/esm/mento.d.ts +3 -3
- package/dist/esm/mento.js +15 -8
- package/package.json +1 -1
|
@@ -48,13 +48,13 @@ exports.addresses = {
|
|
|
48
48
|
SortedOracles: '0xFdd8bD58115FfBf04e47411c1d228eCC45E93075',
|
|
49
49
|
},
|
|
50
50
|
[enums_1.ChainId.BAKLAVA]: {
|
|
51
|
-
GovernanceFactory: '
|
|
52
|
-
Airgrab: '
|
|
53
|
-
Emission: '
|
|
54
|
-
MentoGovernor: '
|
|
55
|
-
MentoToken: '
|
|
56
|
-
TimelockController: '
|
|
57
|
-
Locking: '
|
|
51
|
+
GovernanceFactory: '0xe23A28a92B95c743fC0F09c16a6b2E6D59F234Fa',
|
|
52
|
+
Airgrab: '0xNotDeployed',
|
|
53
|
+
Emission: '0xNotDeployed',
|
|
54
|
+
MentoGovernor: '0xf1873597aA9757f57BA8Ed84a3EDb2E3217EF09f',
|
|
55
|
+
MentoToken: '0x8942330eCB5A6c808aac3Aec3C6aab6D8CF436FE',
|
|
56
|
+
TimelockController: '0x8c045769087F9de69B70949ED7fC23c14Db71e20',
|
|
57
|
+
Locking: '0x1E15b108c51a0cAEAFf1a0E6f27A853Bde1AA2e6',
|
|
58
58
|
Broker: '0x6723749339e320E1EFcd9f1B0D997ecb45587208',
|
|
59
59
|
BiPoolManager: '0xFF9a3da00F42839CD6D33AD7adf50bCc97B41411',
|
|
60
60
|
BreakerBox: '0x5Ea5A5F694F10de979BEeC7b8041E9f931F54bc7',
|
package/dist/cjs/limits.js
CHANGED
|
@@ -24,6 +24,7 @@ function getLimitsConfig(broker, exchangeId, asset) {
|
|
|
24
24
|
const limitId = getLimitId(exchangeId, asset);
|
|
25
25
|
const cfg = yield broker.tradingLimitsConfig(limitId);
|
|
26
26
|
return {
|
|
27
|
+
asset,
|
|
27
28
|
timestep0: cfg['timestep0'],
|
|
28
29
|
timestep1: cfg['timestep1'],
|
|
29
30
|
limit0: cfg['limit0'],
|
|
@@ -54,6 +55,7 @@ function getLimitsState(broker, exchangeId, asset) {
|
|
|
54
55
|
const isL0Outdated = isL0Enabled && nowEpoch > state['lastUpdated0'] + cfg.timestep0;
|
|
55
56
|
const isL1Outdated = isL1Enabled && nowEpoch > state['lastUpdated1'] + cfg.timestep1;
|
|
56
57
|
return {
|
|
58
|
+
asset,
|
|
57
59
|
lastUpdated0: isL0Outdated ? nowEpoch : state['lastUpdated0'],
|
|
58
60
|
lastUpdated1: isL1Outdated ? nowEpoch : state['lastUpdated1'],
|
|
59
61
|
netflow0: isL0Outdated ? 0 : state['netflow0'],
|
|
@@ -102,6 +104,12 @@ function getLimits(broker, exchangeId, asset) {
|
|
|
102
104
|
until: timestampIn2030,
|
|
103
105
|
});
|
|
104
106
|
}
|
|
107
|
+
// Limits with a smaller timeframe are restricted by the ones with a larger one
|
|
108
|
+
// e.g: if maxIn is 0 in LG, it should also be 0 in L1 and L0
|
|
109
|
+
for (let i = limits.length - 1; i > 0; i--) {
|
|
110
|
+
limits[i - 1].maxIn = Math.min(limits[i - 1].maxIn, limits[i].maxIn);
|
|
111
|
+
limits[i - 1].maxOut = Math.min(limits[i - 1].maxOut, limits[i].maxOut);
|
|
112
|
+
}
|
|
105
113
|
return limits;
|
|
106
114
|
});
|
|
107
115
|
}
|
package/dist/cjs/mento.d.ts
CHANGED
|
@@ -138,15 +138,15 @@ export declare class Mento {
|
|
|
138
138
|
*/
|
|
139
139
|
getTradingLimits(exchangeId: string): Promise<TradingLimit[]>;
|
|
140
140
|
/**
|
|
141
|
-
* Returns the trading limits
|
|
141
|
+
* Returns the trading limits configurations for a given exchange id
|
|
142
142
|
* @param exchangeId the id of the exchange
|
|
143
143
|
* @returns the trading limits configuration
|
|
144
144
|
*/
|
|
145
|
-
getTradingLimitConfig(exchangeId: string): Promise<TradingLimitsConfig>;
|
|
145
|
+
getTradingLimitConfig(exchangeId: string): Promise<TradingLimitsConfig[]>;
|
|
146
146
|
/**
|
|
147
147
|
* Returns the trading limits state for a given exchange id
|
|
148
148
|
* @param exchangeId the id of the exchange
|
|
149
149
|
* @returns the trading limits state
|
|
150
150
|
*/
|
|
151
|
-
getTradingLimitState(exchangeId: string): Promise<TradingLimitsState>;
|
|
151
|
+
getTradingLimitState(exchangeId: string): Promise<TradingLimitsState[]>;
|
|
152
152
|
}
|
package/dist/cjs/mento.js
CHANGED
|
@@ -277,12 +277,13 @@ class Mento {
|
|
|
277
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
278
|
const exchange = yield this.getExchangeById(exchangeId);
|
|
279
279
|
const broker = mento_core_ts_1.Broker__factory.connect(this.broker.address, this.signerOrProvider);
|
|
280
|
-
const
|
|
281
|
-
|
|
280
|
+
const asset0Limits = yield (0, limits_1.getLimits)(broker, exchangeId, exchange.assets[0]);
|
|
281
|
+
const asset1Limits = yield (0, limits_1.getLimits)(broker, exchangeId, exchange.assets[1]);
|
|
282
|
+
return asset0Limits.concat(asset1Limits);
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
/**
|
|
285
|
-
* Returns the trading limits
|
|
286
|
+
* Returns the trading limits configurations for a given exchange id
|
|
286
287
|
* @param exchangeId the id of the exchange
|
|
287
288
|
* @returns the trading limits configuration
|
|
288
289
|
*/
|
|
@@ -290,8 +291,15 @@ class Mento {
|
|
|
290
291
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
292
|
const exchange = yield this.getExchangeById(exchangeId);
|
|
292
293
|
const broker = mento_core_ts_1.Broker__factory.connect(this.broker.address, this.signerOrProvider);
|
|
293
|
-
const
|
|
294
|
-
|
|
294
|
+
const cfgs = [];
|
|
295
|
+
for (const asset of exchange.assets) {
|
|
296
|
+
const limitCfg = yield (0, limits_1.getLimitsConfig)(broker, exchangeId, asset);
|
|
297
|
+
const isLimitConfigured = limitCfg.flags > 0;
|
|
298
|
+
if (isLimitConfigured) {
|
|
299
|
+
cfgs.push(limitCfg);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return cfgs;
|
|
295
303
|
});
|
|
296
304
|
}
|
|
297
305
|
/**
|
|
@@ -301,10 +309,9 @@ class Mento {
|
|
|
301
309
|
*/
|
|
302
310
|
getTradingLimitState(exchangeId) {
|
|
303
311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
304
|
-
const exchange = yield this.getExchangeById(exchangeId);
|
|
305
312
|
const broker = mento_core_ts_1.Broker__factory.connect(this.broker.address, this.signerOrProvider);
|
|
306
|
-
const
|
|
307
|
-
return (0, limits_1.getLimitsState)(broker, exchangeId,
|
|
313
|
+
const configuredLimitCfgs = yield this.getTradingLimitConfig(exchangeId);
|
|
314
|
+
return yield Promise.all(configuredLimitCfgs.map((cfg) => __awaiter(this, void 0, void 0, function* () { return yield (0, limits_1.getLimitsState)(broker, exchangeId, cfg.asset); })));
|
|
308
315
|
});
|
|
309
316
|
}
|
|
310
317
|
}
|
|
@@ -45,13 +45,13 @@ export const addresses = {
|
|
|
45
45
|
SortedOracles: '0xFdd8bD58115FfBf04e47411c1d228eCC45E93075',
|
|
46
46
|
},
|
|
47
47
|
[ChainId.BAKLAVA]: {
|
|
48
|
-
GovernanceFactory: '
|
|
49
|
-
Airgrab: '
|
|
50
|
-
Emission: '
|
|
51
|
-
MentoGovernor: '
|
|
52
|
-
MentoToken: '
|
|
53
|
-
TimelockController: '
|
|
54
|
-
Locking: '
|
|
48
|
+
GovernanceFactory: '0xe23A28a92B95c743fC0F09c16a6b2E6D59F234Fa',
|
|
49
|
+
Airgrab: '0xNotDeployed',
|
|
50
|
+
Emission: '0xNotDeployed',
|
|
51
|
+
MentoGovernor: '0xf1873597aA9757f57BA8Ed84a3EDb2E3217EF09f',
|
|
52
|
+
MentoToken: '0x8942330eCB5A6c808aac3Aec3C6aab6D8CF436FE',
|
|
53
|
+
TimelockController: '0x8c045769087F9de69B70949ED7fC23c14Db71e20',
|
|
54
|
+
Locking: '0x1E15b108c51a0cAEAFf1a0E6f27A853Bde1AA2e6',
|
|
55
55
|
Broker: '0x6723749339e320E1EFcd9f1B0D997ecb45587208',
|
|
56
56
|
BiPoolManager: '0xFF9a3da00F42839CD6D33AD7adf50bCc97B41411',
|
|
57
57
|
BreakerBox: '0x5Ea5A5F694F10de979BEeC7b8041E9f931F54bc7',
|
package/dist/esm/limits.js
CHANGED
|
@@ -21,6 +21,7 @@ export function getLimitsConfig(broker, exchangeId, asset) {
|
|
|
21
21
|
const limitId = getLimitId(exchangeId, asset);
|
|
22
22
|
const cfg = yield broker.tradingLimitsConfig(limitId);
|
|
23
23
|
return {
|
|
24
|
+
asset,
|
|
24
25
|
timestep0: cfg['timestep0'],
|
|
25
26
|
timestep1: cfg['timestep1'],
|
|
26
27
|
limit0: cfg['limit0'],
|
|
@@ -50,6 +51,7 @@ export function getLimitsState(broker, exchangeId, asset) {
|
|
|
50
51
|
const isL0Outdated = isL0Enabled && nowEpoch > state['lastUpdated0'] + cfg.timestep0;
|
|
51
52
|
const isL1Outdated = isL1Enabled && nowEpoch > state['lastUpdated1'] + cfg.timestep1;
|
|
52
53
|
return {
|
|
54
|
+
asset,
|
|
53
55
|
lastUpdated0: isL0Outdated ? nowEpoch : state['lastUpdated0'],
|
|
54
56
|
lastUpdated1: isL1Outdated ? nowEpoch : state['lastUpdated1'],
|
|
55
57
|
netflow0: isL0Outdated ? 0 : state['netflow0'],
|
|
@@ -97,6 +99,12 @@ export function getLimits(broker, exchangeId, asset) {
|
|
|
97
99
|
until: timestampIn2030,
|
|
98
100
|
});
|
|
99
101
|
}
|
|
102
|
+
// Limits with a smaller timeframe are restricted by the ones with a larger one
|
|
103
|
+
// e.g: if maxIn is 0 in LG, it should also be 0 in L1 and L0
|
|
104
|
+
for (let i = limits.length - 1; i > 0; i--) {
|
|
105
|
+
limits[i - 1].maxIn = Math.min(limits[i - 1].maxIn, limits[i].maxIn);
|
|
106
|
+
limits[i - 1].maxOut = Math.min(limits[i - 1].maxOut, limits[i].maxOut);
|
|
107
|
+
}
|
|
100
108
|
return limits;
|
|
101
109
|
});
|
|
102
110
|
}
|
package/dist/esm/mento.d.ts
CHANGED
|
@@ -138,15 +138,15 @@ export declare class Mento {
|
|
|
138
138
|
*/
|
|
139
139
|
getTradingLimits(exchangeId: string): Promise<TradingLimit[]>;
|
|
140
140
|
/**
|
|
141
|
-
* Returns the trading limits
|
|
141
|
+
* Returns the trading limits configurations for a given exchange id
|
|
142
142
|
* @param exchangeId the id of the exchange
|
|
143
143
|
* @returns the trading limits configuration
|
|
144
144
|
*/
|
|
145
|
-
getTradingLimitConfig(exchangeId: string): Promise<TradingLimitsConfig>;
|
|
145
|
+
getTradingLimitConfig(exchangeId: string): Promise<TradingLimitsConfig[]>;
|
|
146
146
|
/**
|
|
147
147
|
* Returns the trading limits state for a given exchange id
|
|
148
148
|
* @param exchangeId the id of the exchange
|
|
149
149
|
* @returns the trading limits state
|
|
150
150
|
*/
|
|
151
|
-
getTradingLimitState(exchangeId: string): Promise<TradingLimitsState>;
|
|
151
|
+
getTradingLimitState(exchangeId: string): Promise<TradingLimitsState[]>;
|
|
152
152
|
}
|
package/dist/esm/mento.js
CHANGED
|
@@ -274,12 +274,13 @@ export class Mento {
|
|
|
274
274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
275
275
|
const exchange = yield this.getExchangeById(exchangeId);
|
|
276
276
|
const broker = Broker__factory.connect(this.broker.address, this.signerOrProvider);
|
|
277
|
-
const
|
|
278
|
-
|
|
277
|
+
const asset0Limits = yield getLimits(broker, exchangeId, exchange.assets[0]);
|
|
278
|
+
const asset1Limits = yield getLimits(broker, exchangeId, exchange.assets[1]);
|
|
279
|
+
return asset0Limits.concat(asset1Limits);
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
/**
|
|
282
|
-
* Returns the trading limits
|
|
283
|
+
* Returns the trading limits configurations for a given exchange id
|
|
283
284
|
* @param exchangeId the id of the exchange
|
|
284
285
|
* @returns the trading limits configuration
|
|
285
286
|
*/
|
|
@@ -287,8 +288,15 @@ export class Mento {
|
|
|
287
288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
289
|
const exchange = yield this.getExchangeById(exchangeId);
|
|
289
290
|
const broker = Broker__factory.connect(this.broker.address, this.signerOrProvider);
|
|
290
|
-
const
|
|
291
|
-
|
|
291
|
+
const cfgs = [];
|
|
292
|
+
for (const asset of exchange.assets) {
|
|
293
|
+
const limitCfg = yield getLimitsConfig(broker, exchangeId, asset);
|
|
294
|
+
const isLimitConfigured = limitCfg.flags > 0;
|
|
295
|
+
if (isLimitConfigured) {
|
|
296
|
+
cfgs.push(limitCfg);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return cfgs;
|
|
292
300
|
});
|
|
293
301
|
}
|
|
294
302
|
/**
|
|
@@ -298,10 +306,9 @@ export class Mento {
|
|
|
298
306
|
*/
|
|
299
307
|
getTradingLimitState(exchangeId) {
|
|
300
308
|
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
-
const exchange = yield this.getExchangeById(exchangeId);
|
|
302
309
|
const broker = Broker__factory.connect(this.broker.address, this.signerOrProvider);
|
|
303
|
-
const
|
|
304
|
-
return getLimitsState(broker, exchangeId,
|
|
310
|
+
const configuredLimitCfgs = yield this.getTradingLimitConfig(exchangeId);
|
|
311
|
+
return yield Promise.all(configuredLimitCfgs.map((cfg) => __awaiter(this, void 0, void 0, function* () { return yield getLimitsState(broker, exchangeId, cfg.asset); })));
|
|
305
312
|
});
|
|
306
313
|
}
|
|
307
314
|
}
|