Merge branch 'main' into dev
This commit is contained in:
commit
95e8bf2d2c
|
@ -928,6 +928,7 @@ export class MangoAccount {
|
||||||
perpMarket.loadBids(client),
|
perpMarket.loadBids(client),
|
||||||
perpMarket.loadAsks(client),
|
perpMarket.loadAsks(client),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return [...Array.from(bids.items()), ...Array.from(asks.items())].filter(
|
return [...Array.from(bids.items()), ...Array.from(asks.items())].filter(
|
||||||
(order) => order.owner.equals(this.publicKey),
|
(order) => order.owner.equals(this.publicKey),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1133,7 +1133,7 @@ export class MangoClient {
|
||||||
.rpc();
|
.rpc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async serum3PlaceOrder(
|
public async serum3PlaceOrderIx(
|
||||||
group: Group,
|
group: Group,
|
||||||
mangoAccount: MangoAccount,
|
mangoAccount: MangoAccount,
|
||||||
externalMarketPk: PublicKey,
|
externalMarketPk: PublicKey,
|
||||||
|
@ -1144,7 +1144,7 @@ export class MangoClient {
|
||||||
orderType: Serum3OrderType,
|
orderType: Serum3OrderType,
|
||||||
clientOrderId: number,
|
clientOrderId: number,
|
||||||
limit: number,
|
limit: number,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionInstruction> {
|
||||||
const serum3Market = group.serum3MarketsMapByExternal.get(
|
const serum3Market = group.serum3MarketsMapByExternal.get(
|
||||||
externalMarketPk.toBase58(),
|
externalMarketPk.toBase58(),
|
||||||
)!;
|
)!;
|
||||||
|
@ -1237,6 +1237,34 @@ export class MangoClient {
|
||||||
)
|
)
|
||||||
.instruction();
|
.instruction();
|
||||||
|
|
||||||
|
return ix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async serum3PlaceOrder(
|
||||||
|
group: Group,
|
||||||
|
mangoAccount: MangoAccount,
|
||||||
|
externalMarketPk: PublicKey,
|
||||||
|
side: Serum3Side,
|
||||||
|
price: number,
|
||||||
|
size: number,
|
||||||
|
selfTradeBehavior: Serum3SelfTradeBehavior,
|
||||||
|
orderType: Serum3OrderType,
|
||||||
|
clientOrderId: number,
|
||||||
|
limit: number,
|
||||||
|
): Promise<TransactionSignature> {
|
||||||
|
const ix = await this.serum3PlaceOrderIx(
|
||||||
|
group,
|
||||||
|
mangoAccount,
|
||||||
|
externalMarketPk,
|
||||||
|
side,
|
||||||
|
price,
|
||||||
|
size,
|
||||||
|
selfTradeBehavior,
|
||||||
|
orderType,
|
||||||
|
clientOrderId,
|
||||||
|
limit,
|
||||||
|
);
|
||||||
|
|
||||||
return await sendTransaction(
|
return await sendTransaction(
|
||||||
this.program.provider as AnchorProvider,
|
this.program.provider as AnchorProvider,
|
||||||
[ix],
|
[ix],
|
||||||
|
@ -1288,11 +1316,11 @@ export class MangoClient {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async serum3SettleFunds(
|
public async serum3SettleFundsIx(
|
||||||
group: Group,
|
group: Group,
|
||||||
mangoAccount: MangoAccount,
|
mangoAccount: MangoAccount,
|
||||||
externalMarketPk: PublicKey,
|
externalMarketPk: PublicKey,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionInstruction> {
|
||||||
const serum3Market = group.serum3MarketsMapByExternal.get(
|
const serum3Market = group.serum3MarketsMapByExternal.get(
|
||||||
externalMarketPk.toBase58(),
|
externalMarketPk.toBase58(),
|
||||||
)!;
|
)!;
|
||||||
|
@ -1331,6 +1359,20 @@ export class MangoClient {
|
||||||
})
|
})
|
||||||
.instruction();
|
.instruction();
|
||||||
|
|
||||||
|
return ix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async serum3SettleFunds(
|
||||||
|
group: Group,
|
||||||
|
mangoAccount: MangoAccount,
|
||||||
|
externalMarketPk: PublicKey,
|
||||||
|
): Promise<TransactionSignature> {
|
||||||
|
const ix = await this.serum3SettleFundsIx(
|
||||||
|
group,
|
||||||
|
mangoAccount,
|
||||||
|
externalMarketPk,
|
||||||
|
);
|
||||||
|
|
||||||
return await sendTransaction(
|
return await sendTransaction(
|
||||||
this.program.provider as AnchorProvider,
|
this.program.provider as AnchorProvider,
|
||||||
[ix],
|
[ix],
|
||||||
|
@ -1341,13 +1383,13 @@ export class MangoClient {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async serum3CancelOrder(
|
public async serum3CancelOrderIx(
|
||||||
group: Group,
|
group: Group,
|
||||||
mangoAccount: MangoAccount,
|
mangoAccount: MangoAccount,
|
||||||
externalMarketPk: PublicKey,
|
externalMarketPk: PublicKey,
|
||||||
side: Serum3Side,
|
side: Serum3Side,
|
||||||
orderId: BN,
|
orderId: BN,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionInstruction> {
|
||||||
const serum3Market = group.serum3MarketsMapByExternal.get(
|
const serum3Market = group.serum3MarketsMapByExternal.get(
|
||||||
externalMarketPk.toBase58(),
|
externalMarketPk.toBase58(),
|
||||||
)!;
|
)!;
|
||||||
|
@ -1372,9 +1414,30 @@ export class MangoClient {
|
||||||
})
|
})
|
||||||
.instruction();
|
.instruction();
|
||||||
|
|
||||||
|
return ix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async serum3CancelOrder(
|
||||||
|
group: Group,
|
||||||
|
mangoAccount: MangoAccount,
|
||||||
|
externalMarketPk: PublicKey,
|
||||||
|
side: Serum3Side,
|
||||||
|
orderId: BN,
|
||||||
|
): Promise<TransactionSignature> {
|
||||||
|
const ixes = await Promise.all([
|
||||||
|
this.serum3CancelOrderIx(
|
||||||
|
group,
|
||||||
|
mangoAccount,
|
||||||
|
externalMarketPk,
|
||||||
|
side,
|
||||||
|
orderId,
|
||||||
|
),
|
||||||
|
this.serum3SettleFundsIx(group, mangoAccount, externalMarketPk),
|
||||||
|
]);
|
||||||
|
|
||||||
return await sendTransaction(
|
return await sendTransaction(
|
||||||
this.program.provider as AnchorProvider,
|
this.program.provider as AnchorProvider,
|
||||||
[ix],
|
ixes,
|
||||||
group.addressLookupTablesList,
|
group.addressLookupTablesList,
|
||||||
{
|
{
|
||||||
postSendTxCallback: this.postSendTxCallback,
|
postSendTxCallback: this.postSendTxCallback,
|
||||||
|
@ -2628,4 +2691,96 @@ export class MangoClient {
|
||||||
|
|
||||||
return healthRemainingAccounts;
|
return healthRemainingAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async modifyPerpOrder(
|
||||||
|
group: Group,
|
||||||
|
mangoAccount: MangoAccount,
|
||||||
|
perpMarketIndex: PerpMarketIndex,
|
||||||
|
orderId: BN,
|
||||||
|
side: PerpOrderSide,
|
||||||
|
price: number,
|
||||||
|
quantity: number,
|
||||||
|
maxQuoteQuantity?: number,
|
||||||
|
clientOrderId?: number,
|
||||||
|
orderType?: PerpOrderType,
|
||||||
|
reduceOnly?: boolean,
|
||||||
|
expiryTimestamp?: number,
|
||||||
|
limit?: number,
|
||||||
|
): Promise<TransactionSignature> {
|
||||||
|
const transactionInstructions: TransactionInstruction[] = [];
|
||||||
|
const [cancelOrderIx, placeOrderIx] = await Promise.all([
|
||||||
|
this.perpCancelOrderIx(group, mangoAccount, perpMarketIndex, orderId),
|
||||||
|
this.perpPlaceOrderIx(
|
||||||
|
group,
|
||||||
|
mangoAccount,
|
||||||
|
perpMarketIndex,
|
||||||
|
side,
|
||||||
|
price,
|
||||||
|
quantity,
|
||||||
|
maxQuoteQuantity,
|
||||||
|
clientOrderId,
|
||||||
|
orderType,
|
||||||
|
reduceOnly,
|
||||||
|
expiryTimestamp,
|
||||||
|
limit,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
transactionInstructions.push(cancelOrderIx, placeOrderIx);
|
||||||
|
|
||||||
|
return await sendTransaction(
|
||||||
|
this.program.provider as AnchorProvider,
|
||||||
|
transactionInstructions,
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
{
|
||||||
|
postSendTxCallback: this.postSendTxCallback,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async modifySerum3Order(
|
||||||
|
group: Group,
|
||||||
|
orderId: BN,
|
||||||
|
mangoAccount: MangoAccount,
|
||||||
|
externalMarketPk: PublicKey,
|
||||||
|
side: Serum3Side,
|
||||||
|
price: number,
|
||||||
|
size: number,
|
||||||
|
selfTradeBehavior: Serum3SelfTradeBehavior,
|
||||||
|
orderType: Serum3OrderType,
|
||||||
|
clientOrderId: number,
|
||||||
|
limit: number,
|
||||||
|
): Promise<TransactionSignature> {
|
||||||
|
const transactionInstructions: TransactionInstruction[] = [];
|
||||||
|
const [cancelOrderIx, settleIx, placeOrderIx] = await Promise.all([
|
||||||
|
this.serum3CancelOrderIx(
|
||||||
|
group,
|
||||||
|
mangoAccount,
|
||||||
|
externalMarketPk,
|
||||||
|
side,
|
||||||
|
orderId,
|
||||||
|
),
|
||||||
|
this.serum3SettleFundsIx(group, mangoAccount, externalMarketPk),
|
||||||
|
this.serum3PlaceOrderIx(
|
||||||
|
group,
|
||||||
|
mangoAccount,
|
||||||
|
externalMarketPk,
|
||||||
|
side,
|
||||||
|
price,
|
||||||
|
size,
|
||||||
|
selfTradeBehavior,
|
||||||
|
orderType,
|
||||||
|
clientOrderId,
|
||||||
|
limit,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
transactionInstructions.push(cancelOrderIx, settleIx, placeOrderIx);
|
||||||
|
|
||||||
|
return await sendTransaction(
|
||||||
|
this.program.provider as AnchorProvider,
|
||||||
|
transactionInstructions,
|
||||||
|
group.addressLookupTablesList,
|
||||||
|
{
|
||||||
|
postSendTxCallback: this.postSendTxCallback,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue