@drift-labs/sdk 2.43.0-beta.16 → 2.43.0-beta.17
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/VERSION +1 -1
- package/lib/adminClient.d.ts +1 -0
- package/lib/adminClient.js +8 -0
- package/lib/idl/drift.json +21 -0
- package/lib/math/amm.js +2 -1
- package/package.json +1 -1
- package/src/adminClient.ts +14 -0
- package/src/idl/drift.json +21 -0
- package/src/math/amm.ts +2 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.43.0-beta.
|
|
1
|
+
2.43.0-beta.17
|
package/lib/adminClient.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare class AdminClient extends DriftClient {
|
|
|
33
33
|
updateSpotFeeStructure(feeStructure: FeeStructure): Promise<TransactionSignature>;
|
|
34
34
|
updateInitialPctToLiquidate(initialPctToLiquidate: number): Promise<TransactionSignature>;
|
|
35
35
|
updateLiquidationDuration(liquidationDuration: number): Promise<TransactionSignature>;
|
|
36
|
+
updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio: number): Promise<TransactionSignature>;
|
|
36
37
|
updateOracleGuardRails(oracleGuardRails: OracleGuardRails): Promise<TransactionSignature>;
|
|
37
38
|
updateStateSettlementDuration(settlementDuration: number): Promise<TransactionSignature>;
|
|
38
39
|
updateWithdrawGuardThreshold(spotMarketIndex: number, withdrawGuardThreshold: BN): Promise<TransactionSignature>;
|
package/lib/adminClient.js
CHANGED
|
@@ -421,6 +421,14 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
421
421
|
},
|
|
422
422
|
});
|
|
423
423
|
}
|
|
424
|
+
async updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio) {
|
|
425
|
+
return await this.program.rpc.updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio, {
|
|
426
|
+
accounts: {
|
|
427
|
+
admin: this.wallet.publicKey,
|
|
428
|
+
state: await this.getStatePublicKey(),
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
}
|
|
424
432
|
async updateOracleGuardRails(oracleGuardRails) {
|
|
425
433
|
const tx = await this.program.transaction.updateOracleGuardRails(oracleGuardRails, {
|
|
426
434
|
accounts: {
|
package/lib/idl/drift.json
CHANGED
|
@@ -4098,6 +4098,27 @@
|
|
|
4098
4098
|
}
|
|
4099
4099
|
]
|
|
4100
4100
|
},
|
|
4101
|
+
{
|
|
4102
|
+
"name": "updateLiquidationMarginBufferRatio",
|
|
4103
|
+
"accounts": [
|
|
4104
|
+
{
|
|
4105
|
+
"name": "admin",
|
|
4106
|
+
"isMut": false,
|
|
4107
|
+
"isSigner": true
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
"name": "state",
|
|
4111
|
+
"isMut": true,
|
|
4112
|
+
"isSigner": false
|
|
4113
|
+
}
|
|
4114
|
+
],
|
|
4115
|
+
"args": [
|
|
4116
|
+
{
|
|
4117
|
+
"name": "liquidationMarginBufferRatio",
|
|
4118
|
+
"type": "u32"
|
|
4119
|
+
}
|
|
4120
|
+
]
|
|
4121
|
+
},
|
|
4101
4122
|
{
|
|
4102
4123
|
"name": "updateOracleGuardRails",
|
|
4103
4124
|
"accounts": [
|
package/lib/math/amm.js
CHANGED
|
@@ -410,7 +410,8 @@ function calculateSpreadReserves(amm, oraclePriceData, now) {
|
|
|
410
410
|
quoteAssetReserve: amm.quoteAssetReserve,
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
|
-
const
|
|
413
|
+
const spreadFraction = anchor_1.BN.max(new anchor_1.BN(spread / 2), numericConstants_1.ONE);
|
|
414
|
+
const quoteAssetReserveDelta = amm.quoteAssetReserve.div(numericConstants_1.BID_ASK_SPREAD_PRECISION.div(spreadFraction));
|
|
414
415
|
let quoteAssetReserve;
|
|
415
416
|
if ((0, types_1.isVariant)(direction, 'long')) {
|
|
416
417
|
quoteAssetReserve = amm.quoteAssetReserve.add(quoteAssetReserveDelta);
|
package/package.json
CHANGED
package/src/adminClient.ts
CHANGED
|
@@ -787,6 +787,20 @@ export class AdminClient extends DriftClient {
|
|
|
787
787
|
);
|
|
788
788
|
}
|
|
789
789
|
|
|
790
|
+
public async updateLiquidationMarginBufferRatio(
|
|
791
|
+
updateLiquidationMarginBufferRatio: number
|
|
792
|
+
): Promise<TransactionSignature> {
|
|
793
|
+
return await this.program.rpc.updateLiquidationMarginBufferRatio(
|
|
794
|
+
updateLiquidationMarginBufferRatio,
|
|
795
|
+
{
|
|
796
|
+
accounts: {
|
|
797
|
+
admin: this.wallet.publicKey,
|
|
798
|
+
state: await this.getStatePublicKey(),
|
|
799
|
+
},
|
|
800
|
+
}
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
|
|
790
804
|
public async updateOracleGuardRails(
|
|
791
805
|
oracleGuardRails: OracleGuardRails
|
|
792
806
|
): Promise<TransactionSignature> {
|
package/src/idl/drift.json
CHANGED
|
@@ -4098,6 +4098,27 @@
|
|
|
4098
4098
|
}
|
|
4099
4099
|
]
|
|
4100
4100
|
},
|
|
4101
|
+
{
|
|
4102
|
+
"name": "updateLiquidationMarginBufferRatio",
|
|
4103
|
+
"accounts": [
|
|
4104
|
+
{
|
|
4105
|
+
"name": "admin",
|
|
4106
|
+
"isMut": false,
|
|
4107
|
+
"isSigner": true
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
"name": "state",
|
|
4111
|
+
"isMut": true,
|
|
4112
|
+
"isSigner": false
|
|
4113
|
+
}
|
|
4114
|
+
],
|
|
4115
|
+
"args": [
|
|
4116
|
+
{
|
|
4117
|
+
"name": "liquidationMarginBufferRatio",
|
|
4118
|
+
"type": "u32"
|
|
4119
|
+
}
|
|
4120
|
+
]
|
|
4121
|
+
},
|
|
4101
4122
|
{
|
|
4102
4123
|
"name": "updateOracleGuardRails",
|
|
4103
4124
|
"accounts": [
|
package/src/math/amm.ts
CHANGED
|
@@ -760,9 +760,9 @@ export function calculateSpreadReserves(
|
|
|
760
760
|
quoteAssetReserve: amm.quoteAssetReserve,
|
|
761
761
|
};
|
|
762
762
|
}
|
|
763
|
-
|
|
763
|
+
const spreadFraction = BN.max(new BN(spread / 2), ONE);
|
|
764
764
|
const quoteAssetReserveDelta = amm.quoteAssetReserve.div(
|
|
765
|
-
BID_ASK_SPREAD_PRECISION.div(
|
|
765
|
+
BID_ASK_SPREAD_PRECISION.div(spreadFraction)
|
|
766
766
|
);
|
|
767
767
|
|
|
768
768
|
let quoteAssetReserve;
|