@depthhq/maker-sdk 0.1.10 → 0.1.12
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/node.js +8 -3
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -466,7 +466,7 @@ class MakerBot {
|
|
|
466
466
|
await this.store.save(this.state);
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
if (ready && (!this.position || (this.inventoryVersion ?? this.position.version) !== currentVersion)) {
|
|
469
|
+
if (ready && (!this.position || this.position.status !== "ready" || this.position.position === undefined || (this.inventoryVersion ?? this.position.version) !== currentVersion)) {
|
|
470
470
|
const prior = this.position;
|
|
471
471
|
this.position = await this.maker.position.summary({ timeoutMs: 180000 });
|
|
472
472
|
const fresh = await this.maker.read("MarketAccount", this.maker.marketAccount(), "finalized");
|
|
@@ -681,12 +681,15 @@ class MakerBot {
|
|
|
681
681
|
const account = await this.maker.read("MarketAccount", this.maker.marketAccount());
|
|
682
682
|
if (!("ready" in account.status) || market.pendingOrders)
|
|
683
683
|
return this.snapshot("pending", "settlement in progress");
|
|
684
|
-
if (!this.position || this.position.version !== BigInt(account.version.toString())) {
|
|
684
|
+
if (!this.position || this.position.status !== "ready" || this.position.version !== BigInt(account.version.toString())) {
|
|
685
685
|
this.position = await this.maker.position.summary({
|
|
686
686
|
timeoutMs: 180000
|
|
687
687
|
});
|
|
688
688
|
if (this.position.status !== "ready" || this.position.version !== BigInt(account.version.toString()))
|
|
689
689
|
return this.snapshot("pending", "maker view changed");
|
|
690
|
+
this.inventoryVersion = this.position.version;
|
|
691
|
+
this.dirty = false;
|
|
692
|
+
return this.snapshot("pending", "maker view refreshed");
|
|
690
693
|
}
|
|
691
694
|
this.inventoryVersion = this.position.version;
|
|
692
695
|
this.dirty = false;
|
|
@@ -708,7 +711,9 @@ class MakerBot {
|
|
|
708
711
|
}
|
|
709
712
|
const prior = this.maker.quote.get(new PublicKey(replacement.prior));
|
|
710
713
|
const previous = await prior.status();
|
|
711
|
-
|
|
714
|
+
const size = this.position.position;
|
|
715
|
+
const exposure = ((size < 0n ? -size : size) * BigInt(market.oraclePriceE8.toString()) + 99999999999n) / 100000000000n;
|
|
716
|
+
if (!terminal.has(previous.status) && ["validated", "waiting", "reserving"].includes(snapshot.status) && market.activeQuoteCount < 4 && exposure + previous.maxCapacity + snapshot.maxCapacity <= this.policy.maxInventoryNotional && BigInt(market.quotedNotional.toString()) + snapshot.maxCapacity <= BigInt(market.config.maxMarketNotional.toString())) {
|
|
712
717
|
await this.quoteWrite(next);
|
|
713
718
|
return this.snapshot("pending", "activating successor quote");
|
|
714
719
|
}
|