@drift-labs/sdk 2.13.0-beta.2 → 2.14.0-beta.0
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/lib/accounts/bulkAccountLoader.d.ts +1 -0
- package/lib/accounts/bulkAccountLoader.js +3 -3
- package/lib/accounts/fetch.js +2 -2
- package/lib/accounts/pollingDriftClientAccountSubscriber.js +7 -7
- package/lib/accounts/pollingTokenAccountSubscriber.js +2 -2
- package/lib/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
- package/lib/accounts/types.d.ts +1 -0
- package/lib/accounts/webSocketAccountSubscriber.js +1 -1
- package/lib/accounts/webSocketDriftClientAccountSubscriber.js +3 -3
- package/lib/addresses/marketAddresses.js +1 -1
- package/lib/addresses/pda.js +5 -1
- package/lib/adminClient.js +61 -57
- package/lib/dlob/DLOB.js +67 -67
- package/lib/dlob/DLOBNode.js +7 -7
- package/lib/dlob/NodeList.js +2 -2
- package/lib/driftClient.d.ts +33 -33
- package/lib/driftClient.js +120 -116
- package/lib/events/eventSubscriber.js +2 -2
- package/lib/events/pollingLogProvider.js +1 -1
- package/lib/events/types.d.ts +1 -0
- package/lib/examples/loadDlob.js +2 -2
- package/lib/examples/makeTradeExample.js +9 -9
- package/lib/factory/bigNum.js +9 -9
- package/lib/factory/oracleClient.js +2 -2
- package/lib/idl/drift.json +1 -1
- package/lib/index.js +5 -1
- package/lib/math/amm.js +23 -23
- package/lib/math/auction.js +6 -6
- package/lib/math/exchangeStatus.js +2 -2
- package/lib/math/funding.d.ts +1 -1
- package/lib/math/funding.js +8 -8
- package/lib/math/margin.js +5 -5
- package/lib/math/market.js +13 -13
- package/lib/math/oracles.js +1 -1
- package/lib/math/orders.js +23 -23
- package/lib/math/position.js +5 -5
- package/lib/math/repeg.js +1 -1
- package/lib/math/spotBalance.js +9 -9
- package/lib/math/spotPosition.js +3 -3
- package/lib/math/trade.js +42 -42
- package/lib/oracles/oracleClientCache.js +1 -1
- package/lib/oracles/pythClient.js +1 -1
- package/lib/token/index.js +1 -1
- package/lib/tokenFaucet.js +5 -1
- package/lib/tx/retryTxSender.js +1 -1
- package/lib/user.d.ts +8 -9
- package/lib/user.js +153 -158
- package/lib/userMap/userMap.js +1 -1
- package/lib/userMap/userStatsMap.js +3 -3
- package/lib/userStats.js +2 -2
- package/package.json +3 -3
- package/src/driftClient.ts +209 -68
- package/src/events/types.ts +15 -0
- package/src/idl/drift.json +1 -1
- package/src/math/funding.ts +7 -8
- package/src/math/spotBalance.ts +14 -7
- package/src/token/index.ts +1 -1
- package/src/user.ts +187 -184
- package/src/assert/assert.js +0 -9
- package/src/token/index.js +0 -38
- package/src/tx/types.js +0 -2
- package/src/tx/utils.js +0 -17
- package/src/util/computeUnits.js +0 -27
- package/src/util/getTokenAddress.js +0 -9
- package/src/util/promiseTimeout.js +0 -14
- package/src/util/tps.js +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-labs/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0-beta.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"author": "crispheaney",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@project-serum/serum": "^0.13.38",
|
|
38
38
|
"@pythnetwork/client": "2.5.3",
|
|
39
39
|
"@solana/spl-token": "^0.1.6",
|
|
40
|
-
"@solana/web3.js": "1.
|
|
40
|
+
"@solana/web3.js": "1.73.2",
|
|
41
41
|
"strict-event-emitter-types": "^2.0.0",
|
|
42
42
|
"uuid": "^8.3.2"
|
|
43
43
|
},
|
|
@@ -59,4 +59,4 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=12"
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
}
|
package/src/driftClient.ts
CHANGED
|
@@ -682,7 +682,10 @@ export class DriftClient {
|
|
|
682
682
|
);
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
-
public async deleteUser(
|
|
685
|
+
public async deleteUser(
|
|
686
|
+
subAccountId = 0,
|
|
687
|
+
txParams?: TxParams
|
|
688
|
+
): Promise<TransactionSignature> {
|
|
686
689
|
const userAccountPublicKey = getUserAccountPublicKeySync(
|
|
687
690
|
this.program.programId,
|
|
688
691
|
this.wallet.publicKey,
|
|
@@ -698,7 +701,11 @@ export class DriftClient {
|
|
|
698
701
|
},
|
|
699
702
|
});
|
|
700
703
|
|
|
701
|
-
const { txSig } = await this.sendTransaction(
|
|
704
|
+
const { txSig } = await this.sendTransaction(
|
|
705
|
+
wrapInTx(ix, txParams?.computeUnits, txParams?.computeUnitsPrice),
|
|
706
|
+
[],
|
|
707
|
+
this.opts
|
|
708
|
+
);
|
|
702
709
|
|
|
703
710
|
await this.users.get(subAccountId)?.unsubscribe();
|
|
704
711
|
this.users.delete(subAccountId);
|
|
@@ -1474,7 +1481,8 @@ export class DriftClient {
|
|
|
1474
1481
|
amount: BN,
|
|
1475
1482
|
marketIndex: number,
|
|
1476
1483
|
fromSubAccountId: number,
|
|
1477
|
-
toSubAccountId: number
|
|
1484
|
+
toSubAccountId: number,
|
|
1485
|
+
txParams?: TxParams
|
|
1478
1486
|
): Promise<TransactionSignature> {
|
|
1479
1487
|
const { txSig, slot } = await this.sendTransaction(
|
|
1480
1488
|
wrapInTx(
|
|
@@ -1483,7 +1491,9 @@ export class DriftClient {
|
|
|
1483
1491
|
marketIndex,
|
|
1484
1492
|
fromSubAccountId,
|
|
1485
1493
|
toSubAccountId
|
|
1486
|
-
)
|
|
1494
|
+
),
|
|
1495
|
+
txParams?.computeUnits,
|
|
1496
|
+
txParams?.computeUnitsPrice
|
|
1487
1497
|
),
|
|
1488
1498
|
[],
|
|
1489
1499
|
this.opts
|
|
@@ -1552,10 +1562,15 @@ export class DriftClient {
|
|
|
1552
1562
|
}
|
|
1553
1563
|
|
|
1554
1564
|
public async updateSpotMarketCumulativeInterest(
|
|
1555
|
-
marketIndex: number
|
|
1565
|
+
marketIndex: number,
|
|
1566
|
+
txParams?: TxParams
|
|
1556
1567
|
): Promise<TransactionSignature> {
|
|
1557
1568
|
const { txSig } = await this.sendTransaction(
|
|
1558
|
-
wrapInTx(
|
|
1569
|
+
wrapInTx(
|
|
1570
|
+
await this.updateSpotMarketCumulativeInterestIx(marketIndex),
|
|
1571
|
+
txParams?.computeUnits,
|
|
1572
|
+
txParams?.computeUnitsPrice
|
|
1573
|
+
),
|
|
1559
1574
|
[],
|
|
1560
1575
|
this.opts
|
|
1561
1576
|
);
|
|
@@ -1577,10 +1592,15 @@ export class DriftClient {
|
|
|
1577
1592
|
|
|
1578
1593
|
public async settleLP(
|
|
1579
1594
|
settleeUserAccountPublicKey: PublicKey,
|
|
1580
|
-
marketIndex: number
|
|
1595
|
+
marketIndex: number,
|
|
1596
|
+
txParams?: TxParams
|
|
1581
1597
|
): Promise<TransactionSignature> {
|
|
1582
1598
|
const { txSig } = await this.sendTransaction(
|
|
1583
|
-
wrapInTx(
|
|
1599
|
+
wrapInTx(
|
|
1600
|
+
await this.settleLPIx(settleeUserAccountPublicKey, marketIndex),
|
|
1601
|
+
txParams?.computeUnits,
|
|
1602
|
+
txParams?.computeUnitsPrice
|
|
1603
|
+
),
|
|
1584
1604
|
[],
|
|
1585
1605
|
this.opts
|
|
1586
1606
|
);
|
|
@@ -1611,10 +1631,15 @@ export class DriftClient {
|
|
|
1611
1631
|
|
|
1612
1632
|
public async removePerpLpShares(
|
|
1613
1633
|
marketIndex: number,
|
|
1614
|
-
sharesToBurn?: BN
|
|
1634
|
+
sharesToBurn?: BN,
|
|
1635
|
+
txParams?: TxParams
|
|
1615
1636
|
): Promise<TransactionSignature> {
|
|
1616
1637
|
const { txSig } = await this.sendTransaction(
|
|
1617
|
-
wrapInTx(
|
|
1638
|
+
wrapInTx(
|
|
1639
|
+
await this.getRemovePerpLpSharesIx(marketIndex, sharesToBurn),
|
|
1640
|
+
txParams?.computeUnits,
|
|
1641
|
+
txParams?.computeUnitsPrice
|
|
1642
|
+
),
|
|
1618
1643
|
[],
|
|
1619
1644
|
this.opts
|
|
1620
1645
|
);
|
|
@@ -1624,7 +1649,8 @@ export class DriftClient {
|
|
|
1624
1649
|
public async removePerpLpSharesInExpiringMarket(
|
|
1625
1650
|
marketIndex: number,
|
|
1626
1651
|
userAccountPublicKey: PublicKey,
|
|
1627
|
-
sharesToBurn?: BN
|
|
1652
|
+
sharesToBurn?: BN,
|
|
1653
|
+
txParams?: TxParams
|
|
1628
1654
|
): Promise<TransactionSignature> {
|
|
1629
1655
|
const { txSig } = await this.sendTransaction(
|
|
1630
1656
|
wrapInTx(
|
|
@@ -1632,7 +1658,9 @@ export class DriftClient {
|
|
|
1632
1658
|
marketIndex,
|
|
1633
1659
|
userAccountPublicKey,
|
|
1634
1660
|
sharesToBurn
|
|
1635
|
-
)
|
|
1661
|
+
),
|
|
1662
|
+
txParams?.computeUnits,
|
|
1663
|
+
txParams?.computeUnitsPrice
|
|
1636
1664
|
),
|
|
1637
1665
|
[],
|
|
1638
1666
|
this.opts
|
|
@@ -1713,10 +1741,15 @@ export class DriftClient {
|
|
|
1713
1741
|
|
|
1714
1742
|
public async addPerpLpShares(
|
|
1715
1743
|
amount: BN,
|
|
1716
|
-
marketIndex: number
|
|
1744
|
+
marketIndex: number,
|
|
1745
|
+
txParams?: TxParams
|
|
1717
1746
|
): Promise<TransactionSignature> {
|
|
1718
1747
|
const { txSig, slot } = await this.sendTransaction(
|
|
1719
|
-
wrapInTx(
|
|
1748
|
+
wrapInTx(
|
|
1749
|
+
await this.getAddPerpLpSharesIx(amount, marketIndex),
|
|
1750
|
+
txParams?.computeUnits,
|
|
1751
|
+
txParams?.computeUnitsPrice
|
|
1752
|
+
),
|
|
1720
1753
|
[],
|
|
1721
1754
|
this.opts
|
|
1722
1755
|
);
|
|
@@ -1783,12 +1816,17 @@ export class DriftClient {
|
|
|
1783
1816
|
orderParams: OptionalOrderParams,
|
|
1784
1817
|
userAccountPublicKey: PublicKey,
|
|
1785
1818
|
userAccount: UserAccount,
|
|
1786
|
-
makerInfo?: MakerInfo
|
|
1819
|
+
makerInfo?: MakerInfo,
|
|
1820
|
+
txParams?: TxParams
|
|
1787
1821
|
): Promise<{ txSig: TransactionSignature; signedFillTx: Transaction }> {
|
|
1788
1822
|
const marketIndex = orderParams.marketIndex;
|
|
1789
1823
|
const orderId = userAccount.nextOrderId;
|
|
1790
1824
|
|
|
1791
|
-
const marketOrderTx = wrapInTx(
|
|
1825
|
+
const marketOrderTx = wrapInTx(
|
|
1826
|
+
await this.getPlacePerpOrderIx(orderParams),
|
|
1827
|
+
txParams?.computeUnits,
|
|
1828
|
+
txParams?.computeUnitsPrice
|
|
1829
|
+
);
|
|
1792
1830
|
const fillTx = wrapInTx(
|
|
1793
1831
|
await this.getFillPerpOrderIx(
|
|
1794
1832
|
userAccountPublicKey,
|
|
@@ -1798,7 +1836,9 @@ export class DriftClient {
|
|
|
1798
1836
|
marketIndex,
|
|
1799
1837
|
},
|
|
1800
1838
|
makerInfo
|
|
1801
|
-
)
|
|
1839
|
+
),
|
|
1840
|
+
txParams?.computeUnits,
|
|
1841
|
+
txParams?.computeUnitsPrice
|
|
1802
1842
|
);
|
|
1803
1843
|
|
|
1804
1844
|
// Apply the latest blockhash to the txs so that we can sign before sending them
|
|
@@ -1827,10 +1867,15 @@ export class DriftClient {
|
|
|
1827
1867
|
}
|
|
1828
1868
|
|
|
1829
1869
|
public async placePerpOrder(
|
|
1830
|
-
orderParams: OptionalOrderParams
|
|
1870
|
+
orderParams: OptionalOrderParams,
|
|
1871
|
+
txParams?: TxParams
|
|
1831
1872
|
): Promise<TransactionSignature> {
|
|
1832
1873
|
const { txSig, slot } = await this.sendTransaction(
|
|
1833
|
-
wrapInTx(
|
|
1874
|
+
wrapInTx(
|
|
1875
|
+
await this.getPlacePerpOrderIx(orderParams),
|
|
1876
|
+
txParams?.computeUnits,
|
|
1877
|
+
txParams?.computeUnitsPrice
|
|
1878
|
+
),
|
|
1834
1879
|
[],
|
|
1835
1880
|
this.opts
|
|
1836
1881
|
);
|
|
@@ -1871,10 +1916,15 @@ export class DriftClient {
|
|
|
1871
1916
|
}
|
|
1872
1917
|
|
|
1873
1918
|
public async updateAMMs(
|
|
1874
|
-
marketIndexes: number[]
|
|
1919
|
+
marketIndexes: number[],
|
|
1920
|
+
txParams?: TxParams
|
|
1875
1921
|
): Promise<TransactionSignature> {
|
|
1876
1922
|
const { txSig } = await this.sendTransaction(
|
|
1877
|
-
wrapInTx(
|
|
1923
|
+
wrapInTx(
|
|
1924
|
+
await this.getUpdateAMMsIx(marketIndexes),
|
|
1925
|
+
txParams?.computeUnits,
|
|
1926
|
+
txParams?.computeUnitsPrice
|
|
1927
|
+
),
|
|
1878
1928
|
[],
|
|
1879
1929
|
this.opts
|
|
1880
1930
|
);
|
|
@@ -1916,10 +1966,15 @@ export class DriftClient {
|
|
|
1916
1966
|
}
|
|
1917
1967
|
|
|
1918
1968
|
public async settleExpiredMarket(
|
|
1919
|
-
marketIndex: number
|
|
1969
|
+
marketIndex: number,
|
|
1970
|
+
txParams?: TxParams
|
|
1920
1971
|
): Promise<TransactionSignature> {
|
|
1921
1972
|
const { txSig } = await this.sendTransaction(
|
|
1922
|
-
wrapInTx(
|
|
1973
|
+
wrapInTx(
|
|
1974
|
+
await this.getSettleExpiredMarketIx(marketIndex),
|
|
1975
|
+
txParams?.computeUnits,
|
|
1976
|
+
txParams?.computeUnitsPrice
|
|
1977
|
+
),
|
|
1923
1978
|
[],
|
|
1924
1979
|
this.opts
|
|
1925
1980
|
);
|
|
@@ -1964,7 +2019,8 @@ export class DriftClient {
|
|
|
1964
2019
|
}
|
|
1965
2020
|
|
|
1966
2021
|
public async settleExpiredMarketPoolsToRevenuePool(
|
|
1967
|
-
perpMarketIndex: number
|
|
2022
|
+
perpMarketIndex: number,
|
|
2023
|
+
txParams?: TxParams
|
|
1968
2024
|
): Promise<TransactionSignature> {
|
|
1969
2025
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1970
2026
|
this.program.programId,
|
|
@@ -1986,14 +2042,25 @@ export class DriftClient {
|
|
|
1986
2042
|
},
|
|
1987
2043
|
});
|
|
1988
2044
|
|
|
1989
|
-
const { txSig } = await this.sendTransaction(
|
|
2045
|
+
const { txSig } = await this.sendTransaction(
|
|
2046
|
+
wrapInTx(ix, txParams?.computeUnits, txParams?.computeUnitsPrice),
|
|
2047
|
+
[],
|
|
2048
|
+
this.opts
|
|
2049
|
+
);
|
|
1990
2050
|
|
|
1991
2051
|
return txSig;
|
|
1992
2052
|
}
|
|
1993
2053
|
|
|
1994
|
-
public async cancelOrder(
|
|
2054
|
+
public async cancelOrder(
|
|
2055
|
+
orderId?: number,
|
|
2056
|
+
txParams?: TxParams
|
|
2057
|
+
): Promise<TransactionSignature> {
|
|
1995
2058
|
const { txSig } = await this.sendTransaction(
|
|
1996
|
-
wrapInTx(
|
|
2059
|
+
wrapInTx(
|
|
2060
|
+
await this.getCancelOrderIx(orderId),
|
|
2061
|
+
txParams?.computeUnits,
|
|
2062
|
+
txParams?.computeUnitsPrice
|
|
2063
|
+
),
|
|
1997
2064
|
[],
|
|
1998
2065
|
this.opts
|
|
1999
2066
|
);
|
|
@@ -2021,10 +2088,15 @@ export class DriftClient {
|
|
|
2021
2088
|
}
|
|
2022
2089
|
|
|
2023
2090
|
public async cancelOrderByUserId(
|
|
2024
|
-
userOrderId: number
|
|
2091
|
+
userOrderId: number,
|
|
2092
|
+
txParams?: TxParams
|
|
2025
2093
|
): Promise<TransactionSignature> {
|
|
2026
2094
|
const { txSig } = await this.sendTransaction(
|
|
2027
|
-
wrapInTx(
|
|
2095
|
+
wrapInTx(
|
|
2096
|
+
await this.getCancelOrderByUserIdIx(userOrderId),
|
|
2097
|
+
txParams?.computeUnits,
|
|
2098
|
+
txParams?.computeUnitsPrice
|
|
2099
|
+
),
|
|
2028
2100
|
[],
|
|
2029
2101
|
this.opts
|
|
2030
2102
|
);
|
|
@@ -2058,11 +2130,14 @@ export class DriftClient {
|
|
|
2058
2130
|
public async cancelOrders(
|
|
2059
2131
|
marketType?: MarketType,
|
|
2060
2132
|
marketIndex?: number,
|
|
2061
|
-
direction?: PositionDirection
|
|
2133
|
+
direction?: PositionDirection,
|
|
2134
|
+
txParams?: TxParams
|
|
2062
2135
|
): Promise<TransactionSignature> {
|
|
2063
2136
|
const { txSig } = await this.sendTransaction(
|
|
2064
2137
|
wrapInTx(
|
|
2065
|
-
await this.getCancelOrdersIx(marketType, marketIndex, direction)
|
|
2138
|
+
await this.getCancelOrdersIx(marketType, marketIndex, direction),
|
|
2139
|
+
txParams?.computeUnits,
|
|
2140
|
+
txParams?.computeUnitsPrice
|
|
2066
2141
|
),
|
|
2067
2142
|
[],
|
|
2068
2143
|
this.opts
|
|
@@ -2114,7 +2189,8 @@ export class DriftClient {
|
|
|
2114
2189
|
user: UserAccount,
|
|
2115
2190
|
order?: Pick<Order, 'marketIndex' | 'orderId'>,
|
|
2116
2191
|
makerInfo?: MakerInfo,
|
|
2117
|
-
referrerInfo?: ReferrerInfo
|
|
2192
|
+
referrerInfo?: ReferrerInfo,
|
|
2193
|
+
txParams?: TxParams
|
|
2118
2194
|
): Promise<TransactionSignature> {
|
|
2119
2195
|
const { txSig } = await this.sendTransaction(
|
|
2120
2196
|
wrapInTx(
|
|
@@ -2124,7 +2200,9 @@ export class DriftClient {
|
|
|
2124
2200
|
order,
|
|
2125
2201
|
makerInfo,
|
|
2126
2202
|
referrerInfo
|
|
2127
|
-
)
|
|
2203
|
+
),
|
|
2204
|
+
txParams?.computeUnits,
|
|
2205
|
+
txParams?.computeUnitsPrice
|
|
2128
2206
|
),
|
|
2129
2207
|
[],
|
|
2130
2208
|
this.opts
|
|
@@ -2205,10 +2283,15 @@ export class DriftClient {
|
|
|
2205
2283
|
}
|
|
2206
2284
|
|
|
2207
2285
|
public async placeSpotOrder(
|
|
2208
|
-
orderParams: OptionalOrderParams
|
|
2286
|
+
orderParams: OptionalOrderParams,
|
|
2287
|
+
txParams?: TxParams
|
|
2209
2288
|
): Promise<TransactionSignature> {
|
|
2210
2289
|
const { txSig, slot } = await this.sendTransaction(
|
|
2211
|
-
wrapInTx(
|
|
2290
|
+
wrapInTx(
|
|
2291
|
+
await this.getPlaceSpotOrderIx(orderParams),
|
|
2292
|
+
txParams?.computeUnits,
|
|
2293
|
+
txParams?.computeUnitsPrice
|
|
2294
|
+
),
|
|
2212
2295
|
[],
|
|
2213
2296
|
this.opts
|
|
2214
2297
|
);
|
|
@@ -2474,10 +2557,15 @@ export class DriftClient {
|
|
|
2474
2557
|
public async triggerOrder(
|
|
2475
2558
|
userAccountPublicKey: PublicKey,
|
|
2476
2559
|
user: UserAccount,
|
|
2477
|
-
order: Order
|
|
2560
|
+
order: Order,
|
|
2561
|
+
txParams?: TxParams
|
|
2478
2562
|
): Promise<TransactionSignature> {
|
|
2479
2563
|
const { txSig } = await this.sendTransaction(
|
|
2480
|
-
wrapInTx(
|
|
2564
|
+
wrapInTx(
|
|
2565
|
+
await this.getTriggerOrderIx(userAccountPublicKey, user, order),
|
|
2566
|
+
txParams?.computeUnits,
|
|
2567
|
+
txParams?.computeUnitsPrice
|
|
2568
|
+
),
|
|
2481
2569
|
[],
|
|
2482
2570
|
this.opts
|
|
2483
2571
|
);
|
|
@@ -2522,10 +2610,15 @@ export class DriftClient {
|
|
|
2522
2610
|
|
|
2523
2611
|
public async forceCancelOrders(
|
|
2524
2612
|
userAccountPublicKey: PublicKey,
|
|
2525
|
-
user: UserAccount
|
|
2613
|
+
user: UserAccount,
|
|
2614
|
+
txParams?: TxParams
|
|
2526
2615
|
): Promise<TransactionSignature> {
|
|
2527
2616
|
const { txSig } = await this.txSender.send(
|
|
2528
|
-
wrapInTx(
|
|
2617
|
+
wrapInTx(
|
|
2618
|
+
await this.getForceCancelOrdersIx(userAccountPublicKey, user),
|
|
2619
|
+
txParams?.computeUnits,
|
|
2620
|
+
txParams?.computeUnitsPrice
|
|
2621
|
+
),
|
|
2529
2622
|
[],
|
|
2530
2623
|
this.opts
|
|
2531
2624
|
);
|
|
@@ -2557,7 +2650,8 @@ export class DriftClient {
|
|
|
2557
2650
|
public async placeAndTakePerpOrder(
|
|
2558
2651
|
orderParams: OptionalOrderParams,
|
|
2559
2652
|
makerInfo?: MakerInfo,
|
|
2560
|
-
referrerInfo?: ReferrerInfo
|
|
2653
|
+
referrerInfo?: ReferrerInfo,
|
|
2654
|
+
txParams?: TxParams
|
|
2561
2655
|
): Promise<TransactionSignature> {
|
|
2562
2656
|
const { txSig, slot } = await this.sendTransaction(
|
|
2563
2657
|
wrapInTx(
|
|
@@ -2565,7 +2659,9 @@ export class DriftClient {
|
|
|
2565
2659
|
orderParams,
|
|
2566
2660
|
makerInfo,
|
|
2567
2661
|
referrerInfo
|
|
2568
|
-
)
|
|
2662
|
+
),
|
|
2663
|
+
txParams?.computeUnits,
|
|
2664
|
+
txParams?.computeUnitsPrice
|
|
2569
2665
|
),
|
|
2570
2666
|
[],
|
|
2571
2667
|
this.opts
|
|
@@ -2639,7 +2735,8 @@ export class DriftClient {
|
|
|
2639
2735
|
public async placeAndMakePerpOrder(
|
|
2640
2736
|
orderParams: OptionalOrderParams,
|
|
2641
2737
|
takerInfo: TakerInfo,
|
|
2642
|
-
referrerInfo?: ReferrerInfo
|
|
2738
|
+
referrerInfo?: ReferrerInfo,
|
|
2739
|
+
txParams?: TxParams
|
|
2643
2740
|
): Promise<TransactionSignature> {
|
|
2644
2741
|
const { txSig, slot } = await this.sendTransaction(
|
|
2645
2742
|
wrapInTx(
|
|
@@ -2647,7 +2744,9 @@ export class DriftClient {
|
|
|
2647
2744
|
orderParams,
|
|
2648
2745
|
takerInfo,
|
|
2649
2746
|
referrerInfo
|
|
2650
|
-
)
|
|
2747
|
+
),
|
|
2748
|
+
txParams?.computeUnits,
|
|
2749
|
+
txParams?.computeUnitsPrice
|
|
2651
2750
|
),
|
|
2652
2751
|
[],
|
|
2653
2752
|
this.opts
|
|
@@ -2807,7 +2906,8 @@ export class DriftClient {
|
|
|
2807
2906
|
orderParams: OptionalOrderParams,
|
|
2808
2907
|
takerInfo: TakerInfo,
|
|
2809
2908
|
fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
|
|
2810
|
-
referrerInfo?: ReferrerInfo
|
|
2909
|
+
referrerInfo?: ReferrerInfo,
|
|
2910
|
+
txParams?: TxParams
|
|
2811
2911
|
): Promise<TransactionSignature> {
|
|
2812
2912
|
const { txSig, slot } = await this.sendTransaction(
|
|
2813
2913
|
wrapInTx(
|
|
@@ -2816,7 +2916,9 @@ export class DriftClient {
|
|
|
2816
2916
|
takerInfo,
|
|
2817
2917
|
fulfillmentConfig,
|
|
2818
2918
|
referrerInfo
|
|
2819
|
-
)
|
|
2919
|
+
),
|
|
2920
|
+
txParams?.computeUnits,
|
|
2921
|
+
txParams?.computeUnitsPrice
|
|
2820
2922
|
),
|
|
2821
2923
|
[],
|
|
2822
2924
|
this.opts
|
|
@@ -2994,7 +3096,7 @@ export class DriftClient {
|
|
|
2994
3096
|
`No open order with user order id ${userOrderId.toString()}`
|
|
2995
3097
|
);
|
|
2996
3098
|
}
|
|
2997
|
-
const cancelOrderIx = await this.
|
|
3099
|
+
const cancelOrderIx = await this.getCancelOrderByUserIdIx(userOrderId);
|
|
2998
3100
|
|
|
2999
3101
|
const newOrderParams: OptionalOrderParams = {
|
|
3000
3102
|
orderType: openOrder.orderType,
|
|
@@ -3065,7 +3167,8 @@ export class DriftClient {
|
|
|
3065
3167
|
public async settlePNL(
|
|
3066
3168
|
settleeUserAccountPublicKey: PublicKey,
|
|
3067
3169
|
settleeUserAccount: UserAccount,
|
|
3068
|
-
marketIndex: number
|
|
3170
|
+
marketIndex: number,
|
|
3171
|
+
txParams?: TxParams
|
|
3069
3172
|
): Promise<TransactionSignature> {
|
|
3070
3173
|
const { txSig } = await this.sendTransaction(
|
|
3071
3174
|
wrapInTx(
|
|
@@ -3073,7 +3176,9 @@ export class DriftClient {
|
|
|
3073
3176
|
settleeUserAccountPublicKey,
|
|
3074
3177
|
settleeUserAccount,
|
|
3075
3178
|
marketIndex
|
|
3076
|
-
)
|
|
3179
|
+
),
|
|
3180
|
+
txParams?.computeUnits,
|
|
3181
|
+
txParams?.computeUnitsPrice
|
|
3077
3182
|
),
|
|
3078
3183
|
[],
|
|
3079
3184
|
this.opts
|
|
@@ -3108,7 +3213,8 @@ export class DriftClient {
|
|
|
3108
3213
|
userAccount: UserAccount,
|
|
3109
3214
|
marketIndex: number,
|
|
3110
3215
|
maxBaseAssetAmount: BN,
|
|
3111
|
-
limitPrice?: BN
|
|
3216
|
+
limitPrice?: BN,
|
|
3217
|
+
txParams?: TxParams
|
|
3112
3218
|
): Promise<TransactionSignature> {
|
|
3113
3219
|
const { txSig, slot } = await this.sendTransaction(
|
|
3114
3220
|
wrapInTx(
|
|
@@ -3118,7 +3224,9 @@ export class DriftClient {
|
|
|
3118
3224
|
marketIndex,
|
|
3119
3225
|
maxBaseAssetAmount,
|
|
3120
3226
|
limitPrice
|
|
3121
|
-
)
|
|
3227
|
+
),
|
|
3228
|
+
txParams?.computeUnits,
|
|
3229
|
+
txParams?.computeUnitsPrice
|
|
3122
3230
|
),
|
|
3123
3231
|
[],
|
|
3124
3232
|
this.opts
|
|
@@ -3172,7 +3280,8 @@ export class DriftClient {
|
|
|
3172
3280
|
assetMarketIndex: number,
|
|
3173
3281
|
liabilityMarketIndex: number,
|
|
3174
3282
|
maxLiabilityTransfer: BN,
|
|
3175
|
-
limitPrice?: BN
|
|
3283
|
+
limitPrice?: BN,
|
|
3284
|
+
txParams?: TxParams
|
|
3176
3285
|
): Promise<TransactionSignature> {
|
|
3177
3286
|
const { txSig, slot } = await this.sendTransaction(
|
|
3178
3287
|
wrapInTx(
|
|
@@ -3183,7 +3292,9 @@ export class DriftClient {
|
|
|
3183
3292
|
liabilityMarketIndex,
|
|
3184
3293
|
maxLiabilityTransfer,
|
|
3185
3294
|
limitPrice
|
|
3186
|
-
)
|
|
3295
|
+
),
|
|
3296
|
+
txParams?.computeUnits,
|
|
3297
|
+
txParams?.computeUnitsPrice
|
|
3187
3298
|
),
|
|
3188
3299
|
[],
|
|
3189
3300
|
this.opts
|
|
@@ -3240,7 +3351,8 @@ export class DriftClient {
|
|
|
3240
3351
|
perpMarketIndex: number,
|
|
3241
3352
|
liabilityMarketIndex: number,
|
|
3242
3353
|
maxLiabilityTransfer: BN,
|
|
3243
|
-
limitPrice?: BN
|
|
3354
|
+
limitPrice?: BN,
|
|
3355
|
+
txParams?: TxParams
|
|
3244
3356
|
): Promise<TransactionSignature> {
|
|
3245
3357
|
const { txSig, slot } = await this.sendTransaction(
|
|
3246
3358
|
wrapInTx(
|
|
@@ -3251,7 +3363,9 @@ export class DriftClient {
|
|
|
3251
3363
|
liabilityMarketIndex,
|
|
3252
3364
|
maxLiabilityTransfer,
|
|
3253
3365
|
limitPrice
|
|
3254
|
-
)
|
|
3366
|
+
),
|
|
3367
|
+
txParams?.computeUnits,
|
|
3368
|
+
txParams?.computeUnitsPrice
|
|
3255
3369
|
),
|
|
3256
3370
|
[],
|
|
3257
3371
|
this.opts
|
|
@@ -3308,7 +3422,8 @@ export class DriftClient {
|
|
|
3308
3422
|
perpMarketIndex: number,
|
|
3309
3423
|
assetMarketIndex: number,
|
|
3310
3424
|
maxPnlTransfer: BN,
|
|
3311
|
-
limitPrice?: BN
|
|
3425
|
+
limitPrice?: BN,
|
|
3426
|
+
txParams?: TxParams
|
|
3312
3427
|
): Promise<TransactionSignature> {
|
|
3313
3428
|
const { txSig, slot } = await this.sendTransaction(
|
|
3314
3429
|
wrapInTx(
|
|
@@ -3319,7 +3434,9 @@ export class DriftClient {
|
|
|
3319
3434
|
assetMarketIndex,
|
|
3320
3435
|
maxPnlTransfer,
|
|
3321
3436
|
limitPrice
|
|
3322
|
-
)
|
|
3437
|
+
),
|
|
3438
|
+
txParams?.computeUnits,
|
|
3439
|
+
txParams?.computeUnitsPrice
|
|
3323
3440
|
),
|
|
3324
3441
|
[],
|
|
3325
3442
|
this.opts
|
|
@@ -3373,7 +3490,8 @@ export class DriftClient {
|
|
|
3373
3490
|
public async resolvePerpBankruptcy(
|
|
3374
3491
|
userAccountPublicKey: PublicKey,
|
|
3375
3492
|
userAccount: UserAccount,
|
|
3376
|
-
marketIndex: number
|
|
3493
|
+
marketIndex: number,
|
|
3494
|
+
txParams?: TxParams
|
|
3377
3495
|
): Promise<TransactionSignature> {
|
|
3378
3496
|
const { txSig } = await this.sendTransaction(
|
|
3379
3497
|
wrapInTx(
|
|
@@ -3381,7 +3499,9 @@ export class DriftClient {
|
|
|
3381
3499
|
userAccountPublicKey,
|
|
3382
3500
|
userAccount,
|
|
3383
3501
|
marketIndex
|
|
3384
|
-
)
|
|
3502
|
+
),
|
|
3503
|
+
txParams?.computeUnits,
|
|
3504
|
+
txParams?.computeUnitsPrice
|
|
3385
3505
|
),
|
|
3386
3506
|
[],
|
|
3387
3507
|
this.opts
|
|
@@ -3434,7 +3554,8 @@ export class DriftClient {
|
|
|
3434
3554
|
public async resolveSpotBankruptcy(
|
|
3435
3555
|
userAccountPublicKey: PublicKey,
|
|
3436
3556
|
userAccount: UserAccount,
|
|
3437
|
-
marketIndex: number
|
|
3557
|
+
marketIndex: number,
|
|
3558
|
+
txParams?: TxParams
|
|
3438
3559
|
): Promise<TransactionSignature> {
|
|
3439
3560
|
const { txSig } = await this.sendTransaction(
|
|
3440
3561
|
wrapInTx(
|
|
@@ -3442,7 +3563,9 @@ export class DriftClient {
|
|
|
3442
3563
|
userAccountPublicKey,
|
|
3443
3564
|
userAccount,
|
|
3444
3565
|
marketIndex
|
|
3445
|
-
)
|
|
3566
|
+
),
|
|
3567
|
+
txParams?.computeUnits,
|
|
3568
|
+
txParams?.computeUnitsPrice
|
|
3446
3569
|
),
|
|
3447
3570
|
[],
|
|
3448
3571
|
this.opts
|
|
@@ -3489,10 +3612,15 @@ export class DriftClient {
|
|
|
3489
3612
|
|
|
3490
3613
|
public async updateFundingRate(
|
|
3491
3614
|
perpMarketIndex: number,
|
|
3492
|
-
oracle: PublicKey
|
|
3615
|
+
oracle: PublicKey,
|
|
3616
|
+
txParams?: TxParams
|
|
3493
3617
|
): Promise<TransactionSignature> {
|
|
3494
3618
|
const { txSig } = await this.sendTransaction(
|
|
3495
|
-
wrapInTx(
|
|
3619
|
+
wrapInTx(
|
|
3620
|
+
await this.getUpdateFundingRateIx(perpMarketIndex, oracle),
|
|
3621
|
+
txParams?.computeUnits,
|
|
3622
|
+
txParams?.computeUnitsPrice
|
|
3623
|
+
),
|
|
3496
3624
|
[],
|
|
3497
3625
|
this.opts
|
|
3498
3626
|
);
|
|
@@ -3517,10 +3645,15 @@ export class DriftClient {
|
|
|
3517
3645
|
}
|
|
3518
3646
|
|
|
3519
3647
|
public async settleFundingPayment(
|
|
3520
|
-
userAccountPublicKey: PublicKey
|
|
3648
|
+
userAccountPublicKey: PublicKey,
|
|
3649
|
+
txParams?: TxParams
|
|
3521
3650
|
): Promise<TransactionSignature> {
|
|
3522
3651
|
const { txSig } = await this.sendTransaction(
|
|
3523
|
-
wrapInTx(
|
|
3652
|
+
wrapInTx(
|
|
3653
|
+
await this.getSettleFundingPaymentIx(userAccountPublicKey),
|
|
3654
|
+
txParams?.computeUnits,
|
|
3655
|
+
txParams?.computeUnitsPrice
|
|
3656
|
+
),
|
|
3524
3657
|
[],
|
|
3525
3658
|
this.opts
|
|
3526
3659
|
);
|
|
@@ -3574,10 +3707,15 @@ export class DriftClient {
|
|
|
3574
3707
|
}
|
|
3575
3708
|
|
|
3576
3709
|
public async initializeInsuranceFundStake(
|
|
3577
|
-
marketIndex: number
|
|
3710
|
+
marketIndex: number,
|
|
3711
|
+
txParams?: TxParams
|
|
3578
3712
|
): Promise<TransactionSignature> {
|
|
3579
3713
|
const { txSig } = await this.sendTransaction(
|
|
3580
|
-
wrapInTx(
|
|
3714
|
+
wrapInTx(
|
|
3715
|
+
await this.getInitializeInsuranceFundStakeIx(marketIndex),
|
|
3716
|
+
txParams?.computeUnits,
|
|
3717
|
+
txParams?.computeUnitsPrice
|
|
3718
|
+
),
|
|
3581
3719
|
[],
|
|
3582
3720
|
this.opts
|
|
3583
3721
|
);
|
|
@@ -3796,11 +3934,14 @@ export class DriftClient {
|
|
|
3796
3934
|
|
|
3797
3935
|
public async resolvePerpPnlDeficit(
|
|
3798
3936
|
spotMarketIndex: number,
|
|
3799
|
-
perpMarketIndex: number
|
|
3937
|
+
perpMarketIndex: number,
|
|
3938
|
+
txParams?: TxParams
|
|
3800
3939
|
): Promise<TransactionSignature> {
|
|
3801
3940
|
const { txSig } = await this.sendTransaction(
|
|
3802
3941
|
wrapInTx(
|
|
3803
|
-
await this.getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex)
|
|
3942
|
+
await this.getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex),
|
|
3943
|
+
txParams?.computeUnits,
|
|
3944
|
+
txParams?.computeUnitsPrice
|
|
3804
3945
|
),
|
|
3805
3946
|
[],
|
|
3806
3947
|
this.opts
|
package/src/events/types.ts
CHANGED
|
@@ -87,6 +87,21 @@ export type EventMap = {
|
|
|
87
87
|
|
|
88
88
|
export type EventType = keyof EventMap;
|
|
89
89
|
|
|
90
|
+
export type DriftEvent =
|
|
91
|
+
| Event<DepositRecord>
|
|
92
|
+
| Event<FundingPaymentRecord>
|
|
93
|
+
| Event<LiquidationRecord>
|
|
94
|
+
| Event<FundingRateRecord>
|
|
95
|
+
| Event<OrderRecord>
|
|
96
|
+
| Event<OrderActionRecord>
|
|
97
|
+
| Event<SettlePnlRecord>
|
|
98
|
+
| Event<NewUserRecord>
|
|
99
|
+
| Event<LPRecord>
|
|
100
|
+
| Event<InsuranceFundRecord>
|
|
101
|
+
| Event<SpotInterestRecord>
|
|
102
|
+
| Event<InsuranceFundStakeRecord>
|
|
103
|
+
| Event<CurveRecord>;
|
|
104
|
+
|
|
90
105
|
export interface EventSubscriberEvents {
|
|
91
106
|
newEvent: (event: WrappedEvent<EventType>) => void;
|
|
92
107
|
}
|
package/src/idl/drift.json
CHANGED