@lightconexyz/lightcone-sdk 0.2.3 → 0.2.4
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/README.md +25 -14
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/client.js +3 -7
- package/dist/auth/client.js.map +1 -1
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/client.d.ts +17 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -10
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +14 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +10 -0
- package/dist/context.js.map +1 -0
- package/dist/domain/admin/client.d.ts +15 -5
- package/dist/domain/admin/client.d.ts.map +1 -1
- package/dist/domain/admin/client.js +39 -0
- package/dist/domain/admin/client.js.map +1 -1
- package/dist/domain/index.d.ts +0 -1
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +1 -2
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/market/client.d.ts +11 -5
- package/dist/domain/market/client.d.ts.map +1 -1
- package/dist/domain/market/client.js +76 -0
- package/dist/domain/market/client.js.map +1 -1
- package/dist/domain/order/client.d.ts +21 -5
- package/dist/domain/order/client.d.ts.map +1 -1
- package/dist/domain/order/client.js +89 -0
- package/dist/domain/order/client.js.map +1 -1
- package/dist/domain/order/index.d.ts +8 -2
- package/dist/domain/order/index.d.ts.map +1 -1
- package/dist/domain/order/index.js +23 -0
- package/dist/domain/order/index.js.map +1 -1
- package/dist/domain/orderbook/client.d.ts +7 -12
- package/dist/domain/orderbook/client.d.ts.map +1 -1
- package/dist/domain/orderbook/client.js +24 -4
- package/dist/domain/orderbook/client.js.map +1 -1
- package/dist/domain/orderbook/state.d.ts +2 -0
- package/dist/domain/orderbook/state.d.ts.map +1 -1
- package/dist/domain/orderbook/state.js +25 -2
- package/dist/domain/orderbook/state.js.map +1 -1
- package/dist/domain/position/client.d.ts +11 -5
- package/dist/domain/position/client.d.ts.map +1 -1
- package/dist/domain/position/client.js +38 -0
- package/dist/domain/position/client.js.map +1 -1
- package/dist/domain/position/index.d.ts +4 -1
- package/dist/domain/position/index.d.ts.map +1 -1
- package/dist/domain/position/index.js +20 -0
- package/dist/domain/position/index.js.map +1 -1
- package/dist/domain/position/wire.d.ts +6 -0
- package/dist/domain/position/wire.d.ts.map +1 -1
- package/dist/domain/position/wire.js.map +1 -1
- package/dist/domain/price_history/client.d.ts +14 -1
- package/dist/domain/price_history/client.d.ts.map +1 -1
- package/dist/domain/price_history/client.js +53 -0
- package/dist/domain/price_history/client.js.map +1 -1
- package/dist/domain/price_history/index.d.ts +4 -0
- package/dist/domain/price_history/index.d.ts.map +1 -1
- package/dist/domain/price_history/index.js.map +1 -1
- package/dist/domain/price_history/state.d.ts +16 -0
- package/dist/domain/price_history/state.d.ts.map +1 -1
- package/dist/domain/price_history/state.js +42 -1
- package/dist/domain/price_history/state.js.map +1 -1
- package/dist/domain/price_history/wire.d.ts +34 -0
- package/dist/domain/price_history/wire.d.ts.map +1 -1
- package/dist/domain/price_history/wire.js.map +1 -1
- package/dist/http/client.d.ts.map +1 -1
- package/dist/http/client.js +17 -36
- package/dist/http/client.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/prelude.d.ts +5 -6
- package/dist/prelude.d.ts.map +1 -1
- package/dist/prelude.js +4 -5
- package/dist/prelude.js.map +1 -1
- package/dist/privy/client.d.ts +1 -0
- package/dist/privy/client.d.ts.map +1 -1
- package/dist/privy/client.js +10 -0
- package/dist/privy/client.js.map +1 -1
- package/dist/program/accounts.d.ts +2 -1
- package/dist/program/accounts.d.ts.map +1 -1
- package/dist/program/accounts.js +2 -1
- package/dist/program/accounts.js.map +1 -1
- package/dist/program/index.d.ts +1 -2
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/index.js +8 -6
- package/dist/program/index.js.map +1 -1
- package/dist/program/instructions.d.ts +1 -1
- package/dist/program/instructions.d.ts.map +1 -1
- package/dist/program/instructions.js +3 -3
- package/dist/program/instructions.js.map +1 -1
- package/dist/program/orders.d.ts +13 -1
- package/dist/program/orders.d.ts.map +1 -1
- package/dist/program/orders.js +53 -3
- package/dist/program/orders.js.map +1 -1
- package/dist/rpc.d.ts +19 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +51 -0
- package/dist/rpc.js.map +1 -0
- package/dist/shared/fmt/decimal.d.ts +1 -1
- package/dist/shared/fmt/decimal.d.ts.map +1 -1
- package/dist/shared/fmt/decimal.js +2 -2
- package/dist/shared/fmt/decimal.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +2 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/scaling.d.ts.map +1 -1
- package/dist/shared/scaling.js +7 -3
- package/dist/shared/scaling.js.map +1 -1
- package/dist/shared/types.d.ts +1 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +9 -1
- package/dist/shared/types.js.map +1 -1
- package/dist/ws/client.browser.d.ts +2 -0
- package/dist/ws/client.browser.d.ts.map +1 -1
- package/dist/ws/client.browser.js +43 -6
- package/dist/ws/client.browser.js.map +1 -1
- package/dist/ws/client.node.d.ts +2 -0
- package/dist/ws/client.node.d.ts.map +1 -1
- package/dist/ws/client.node.js +43 -6
- package/dist/ws/client.node.js.map +1 -1
- package/dist/ws/index.d.ts +1 -2
- package/dist/ws/index.d.ts.map +1 -1
- package/dist/ws/index.js.map +1 -1
- package/dist/ws/types.d.ts +2 -0
- package/dist/ws/types.d.ts.map +1 -1
- package/dist/ws/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/domain/deposit_price/client.d.ts +0 -21
- package/dist/domain/deposit_price/client.d.ts.map +0 -1
- package/dist/domain/deposit_price/client.js +0 -68
- package/dist/domain/deposit_price/client.js.map +0 -1
- package/dist/domain/deposit_price/index.d.ts +0 -9
- package/dist/domain/deposit_price/index.d.ts.map +0 -1
- package/dist/domain/deposit_price/index.js +0 -20
- package/dist/domain/deposit_price/index.js.map +0 -1
- package/dist/domain/deposit_price/state.d.ts +0 -17
- package/dist/domain/deposit_price/state.d.ts.map +0 -1
- package/dist/domain/deposit_price/state.js +0 -45
- package/dist/domain/deposit_price/state.js.map +0 -1
- package/dist/domain/deposit_price/wire.d.ts +0 -36
- package/dist/domain/deposit_price/wire.d.ts.map +0 -1
- package/dist/domain/deposit_price/wire.js +0 -3
- package/dist/domain/deposit_price/wire.js.map +0 -1
- package/dist/program/client.d.ts +0 -96
- package/dist/program/client.d.ts.map +0 -1
- package/dist/program/client.js +0 -372
- package/dist/program/client.js.map +0 -1
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DepositPriceState = void 0;
|
|
4
|
-
class DepositPriceState {
|
|
5
|
-
candles;
|
|
6
|
-
latestPrice;
|
|
7
|
-
constructor() {
|
|
8
|
-
this.candles = new Map();
|
|
9
|
-
this.latestPrice = new Map();
|
|
10
|
-
}
|
|
11
|
-
applySnapshot(depositAsset, resolution, prices) {
|
|
12
|
-
this.candles.set(keyFor(depositAsset, resolution), prices);
|
|
13
|
-
}
|
|
14
|
-
applyCandleUpdate(depositAsset, resolution, candle) {
|
|
15
|
-
const key = keyFor(depositAsset, resolution);
|
|
16
|
-
const existing = this.candles.get(key) ?? [];
|
|
17
|
-
const last = existing.at(-1);
|
|
18
|
-
if (last && last.t === candle.t) {
|
|
19
|
-
last.c = candle.c;
|
|
20
|
-
last.tc = candle.tc;
|
|
21
|
-
this.candles.set(key, existing);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
existing.push(candle);
|
|
25
|
-
this.candles.set(key, existing);
|
|
26
|
-
}
|
|
27
|
-
applyPriceTick(depositAsset, price, eventTime) {
|
|
28
|
-
this.latestPrice.set(depositAsset, { price, eventTime });
|
|
29
|
-
}
|
|
30
|
-
getCandles(depositAsset, resolution) {
|
|
31
|
-
return this.candles.get(keyFor(depositAsset, resolution));
|
|
32
|
-
}
|
|
33
|
-
getLatestPrice(depositAsset) {
|
|
34
|
-
return this.latestPrice.get(depositAsset);
|
|
35
|
-
}
|
|
36
|
-
clear() {
|
|
37
|
-
this.candles.clear();
|
|
38
|
-
this.latestPrice.clear();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.DepositPriceState = DepositPriceState;
|
|
42
|
-
function keyFor(depositAsset, resolution) {
|
|
43
|
-
return `${depositAsset}:${resolution}`;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/domain/deposit_price/state.ts"],"names":[],"mappings":";;;AAGA,MAAa,iBAAiB;IACX,OAAO,CAAoC;IAC3C,WAAW,CAAoD;IAEhF;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;IAC/B,CAAC;IAED,aAAa,CAAC,YAAoB,EAAE,UAAsB,EAAE,MAA4B;QACtF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,iBAAiB,CAAC,YAAoB,EAAE,UAAsB,EAAE,MAA0B;QACxF,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAE7C,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAClB,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAChC,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,cAAc,CAAC,YAAoB,EAAE,KAAa,EAAE,SAAiB;QACnE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,UAAU,CAAC,YAAoB,EAAE,UAAsB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,cAAc,CAAC,YAAoB;QACjC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AA7CD,8CA6CC;AAED,SAAS,MAAM,CAAC,YAAoB,EAAE,UAAsB;IAC1D,OAAO,GAAG,YAAY,IAAI,UAAU,EAAE,CAAC;AACzC,CAAC","sourcesContent":["import type { Resolution } from \"../../shared\";\nimport type { DepositTokenCandle } from \"./wire\";\n\nexport class DepositPriceState {\n private readonly candles: Map<string, DepositTokenCandle[]>;\n private readonly latestPrice: Map<string, { price: string; eventTime: number }>;\n\n constructor() {\n this.candles = new Map();\n this.latestPrice = new Map();\n }\n\n applySnapshot(depositAsset: string, resolution: Resolution, prices: DepositTokenCandle[]): void {\n this.candles.set(keyFor(depositAsset, resolution), prices);\n }\n\n applyCandleUpdate(depositAsset: string, resolution: Resolution, candle: DepositTokenCandle): void {\n const key = keyFor(depositAsset, resolution);\n const existing = this.candles.get(key) ?? [];\n\n const last = existing.at(-1);\n if (last && last.t === candle.t) {\n last.c = candle.c;\n last.tc = candle.tc;\n this.candles.set(key, existing);\n return;\n }\n\n existing.push(candle);\n this.candles.set(key, existing);\n }\n\n applyPriceTick(depositAsset: string, price: string, eventTime: number): void {\n this.latestPrice.set(depositAsset, { price, eventTime });\n }\n\n getCandles(depositAsset: string, resolution: Resolution): readonly DepositTokenCandle[] | undefined {\n return this.candles.get(keyFor(depositAsset, resolution));\n }\n\n getLatestPrice(depositAsset: string): { price: string; eventTime: number } | undefined {\n return this.latestPrice.get(depositAsset);\n }\n\n clear(): void {\n this.candles.clear();\n this.latestPrice.clear();\n }\n}\n\nfunction keyFor(depositAsset: string, resolution: Resolution): string {\n return `${depositAsset}:${resolution}`;\n}\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Resolution } from "../../shared";
|
|
2
|
-
export interface DepositTokenCandle {
|
|
3
|
-
t: number;
|
|
4
|
-
tc: number;
|
|
5
|
-
c: string;
|
|
6
|
-
}
|
|
7
|
-
export interface DepositPriceSnapshot {
|
|
8
|
-
event_type: "snapshot";
|
|
9
|
-
deposit_asset: string;
|
|
10
|
-
resolution: Resolution;
|
|
11
|
-
prices: DepositTokenCandle[];
|
|
12
|
-
}
|
|
13
|
-
export interface DepositPriceTick {
|
|
14
|
-
event_type: "price";
|
|
15
|
-
deposit_asset: string;
|
|
16
|
-
price: string;
|
|
17
|
-
event_time: number;
|
|
18
|
-
}
|
|
19
|
-
export interface DepositPriceCandleUpdate {
|
|
20
|
-
event_type: "candle";
|
|
21
|
-
deposit_asset: string;
|
|
22
|
-
resolution: Resolution;
|
|
23
|
-
t: number;
|
|
24
|
-
tc: number;
|
|
25
|
-
c: string;
|
|
26
|
-
}
|
|
27
|
-
export type DepositPrice = DepositPriceSnapshot | DepositPriceTick | DepositPriceCandleUpdate;
|
|
28
|
-
export interface DepositTokenPriceHistoryResponse {
|
|
29
|
-
deposit_asset: string;
|
|
30
|
-
binance_symbol: string;
|
|
31
|
-
resolution: Resolution;
|
|
32
|
-
prices: DepositTokenCandle[];
|
|
33
|
-
next_cursor: number | null;
|
|
34
|
-
has_more: boolean;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/domain/deposit_price/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,QAAQ,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,MAAM,YAAY,GACpB,oBAAoB,GACpB,gBAAgB,GAChB,wBAAwB,CAAC;AAE7B,MAAM,WAAW,gCAAgC;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../src/domain/deposit_price/wire.ts"],"names":[],"mappings":"","sourcesContent":["import type { Resolution } from \"../../shared\";\n\nexport interface DepositTokenCandle {\n t: number;\n tc: number;\n c: string;\n}\n\nexport interface DepositPriceSnapshot {\n event_type: \"snapshot\";\n deposit_asset: string;\n resolution: Resolution;\n prices: DepositTokenCandle[];\n}\n\nexport interface DepositPriceTick {\n event_type: \"price\";\n deposit_asset: string;\n price: string;\n event_time: number;\n}\n\nexport interface DepositPriceCandleUpdate {\n event_type: \"candle\";\n deposit_asset: string;\n resolution: Resolution;\n t: number;\n tc: number;\n c: string;\n}\n\nexport type DepositPrice =\n | DepositPriceSnapshot\n | DepositPriceTick\n | DepositPriceCandleUpdate;\n\nexport interface DepositTokenPriceHistoryResponse {\n deposit_asset: string;\n binance_symbol: string;\n resolution: Resolution;\n prices: DepositTokenCandle[];\n next_cursor: number | null;\n has_more: boolean;\n}\n"]}
|
package/dist/program/client.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Connection, PublicKey, Keypair } from "@solana/web3.js";
|
|
2
|
-
import { Exchange, Market, Position, OrderStatus, Orderbook, GlobalDepositToken, BuildResult, InitializeParams, CreateMarketParams, AddDepositMintParams, MintCompleteSetParams, MergeCompleteSetParams, SettleMarketParams, RedeemWinningsParams, WithdrawFromPositionParams, ActivateMarketParams, MatchOrdersMultiParams, SetAuthorityParams, CreateOrderbookParams, WhitelistDepositTokenParams, DepositToGlobalParams, GlobalToMarketDepositParams, InitPositionTokensParams, ExtendPositionTokensParams, DepositAndSwapParams, SignedOrder, BidOrderParams, AskOrderParams, InitializeAccounts, CreateMarketAccounts, AddDepositMintAccounts, MintCompleteSetAccounts, MergeCompleteSetAccounts, CancelOrderAccounts, IncrementNonceAccounts, SettleMarketAccounts, RedeemWinningsAccounts, ActivateMarketAccounts, MatchOrdersMultiAccounts } from "./types";
|
|
3
|
-
import * as pda from "./pda";
|
|
4
|
-
/**
|
|
5
|
-
* LightconePinocchioClient - SDK for interacting with the Lightcone Pinocchio program
|
|
6
|
-
*/
|
|
7
|
-
export declare class LightconePinocchioClient {
|
|
8
|
-
readonly connection: Connection;
|
|
9
|
-
readonly programId: PublicKey;
|
|
10
|
-
readonly pda: typeof pda;
|
|
11
|
-
constructor(connection: Connection, programId?: PublicKey);
|
|
12
|
-
static new(rpcUrl: string): LightconePinocchioClient;
|
|
13
|
-
static withProgramId(rpcUrl: string, programId: PublicKey): LightconePinocchioClient;
|
|
14
|
-
static fromConnection(connection: Connection): LightconePinocchioClient;
|
|
15
|
-
getExchange(): Promise<Exchange>;
|
|
16
|
-
getMarket(marketId: bigint): Promise<Market>;
|
|
17
|
-
getMarketByPubkey(market: PublicKey): Promise<Market>;
|
|
18
|
-
getPosition(owner: PublicKey, market: PublicKey): Promise<Position | null>;
|
|
19
|
-
getOrderStatus(orderHash: Buffer): Promise<OrderStatus | null>;
|
|
20
|
-
getUserNonce(user: PublicKey): Promise<bigint>;
|
|
21
|
-
getCurrentNonce(user: PublicKey): Promise<number>;
|
|
22
|
-
getNextNonce(user: PublicKey): Promise<number>;
|
|
23
|
-
getNextMarketId(): Promise<bigint>;
|
|
24
|
-
getOrderbook(mintA: PublicKey, mintB: PublicKey): Promise<Orderbook>;
|
|
25
|
-
getGlobalDepositToken(mint: PublicKey): Promise<GlobalDepositToken>;
|
|
26
|
-
getLatestBlockhash(): Promise<Readonly<{
|
|
27
|
-
blockhash: import("@solana/web3.js").Blockhash;
|
|
28
|
-
lastValidBlockHeight: number;
|
|
29
|
-
}>>;
|
|
30
|
-
private createBuildResult;
|
|
31
|
-
initialize(params: InitializeParams): Promise<BuildResult<InitializeAccounts>>;
|
|
32
|
-
createMarket(params: CreateMarketParams): Promise<BuildResult<CreateMarketAccounts>>;
|
|
33
|
-
addDepositMint(params: AddDepositMintParams, market: PublicKey, numOutcomes: number): Promise<BuildResult<AddDepositMintAccounts>>;
|
|
34
|
-
mintCompleteSet(params: MintCompleteSetParams, numOutcomes: number): Promise<BuildResult<MintCompleteSetAccounts>>;
|
|
35
|
-
mergeCompleteSet(params: MergeCompleteSetParams, numOutcomes: number): Promise<BuildResult<MergeCompleteSetAccounts>>;
|
|
36
|
-
cancelOrder(maker: PublicKey, order: SignedOrder): Promise<BuildResult<CancelOrderAccounts>>;
|
|
37
|
-
incrementNonce(user: PublicKey): Promise<BuildResult<IncrementNonceAccounts>>;
|
|
38
|
-
settleMarket(params: SettleMarketParams): Promise<BuildResult<SettleMarketAccounts>>;
|
|
39
|
-
redeemWinnings(params: RedeemWinningsParams, winningOutcome: number): Promise<BuildResult<RedeemWinningsAccounts>>;
|
|
40
|
-
setPaused(authority: PublicKey, paused: boolean): Promise<BuildResult<{
|
|
41
|
-
exchange: PublicKey;
|
|
42
|
-
}>>;
|
|
43
|
-
setOperator(authority: PublicKey, newOperator: PublicKey): Promise<BuildResult<{
|
|
44
|
-
exchange: PublicKey;
|
|
45
|
-
}>>;
|
|
46
|
-
withdrawFromPosition(params: WithdrawFromPositionParams, isToken2022: boolean): Promise<BuildResult<{
|
|
47
|
-
position: PublicKey;
|
|
48
|
-
}>>;
|
|
49
|
-
activateMarket(params: ActivateMarketParams): Promise<BuildResult<ActivateMarketAccounts>>;
|
|
50
|
-
matchOrdersMulti(params: MatchOrdersMultiParams): Promise<BuildResult<MatchOrdersMultiAccounts>>;
|
|
51
|
-
setAuthority(params: SetAuthorityParams): Promise<BuildResult<{
|
|
52
|
-
exchange: PublicKey;
|
|
53
|
-
}>>;
|
|
54
|
-
createOrderbook(params: CreateOrderbookParams): Promise<BuildResult<{
|
|
55
|
-
orderbook: PublicKey;
|
|
56
|
-
}>>;
|
|
57
|
-
whitelistDepositToken(params: WhitelistDepositTokenParams): Promise<BuildResult<{
|
|
58
|
-
globalDepositToken: PublicKey;
|
|
59
|
-
}>>;
|
|
60
|
-
depositToGlobal(params: DepositToGlobalParams): Promise<BuildResult<{
|
|
61
|
-
userGlobalDeposit: PublicKey;
|
|
62
|
-
}>>;
|
|
63
|
-
globalToMarketDeposit(params: GlobalToMarketDepositParams, numOutcomes: number): Promise<BuildResult<{
|
|
64
|
-
position: PublicKey;
|
|
65
|
-
userGlobalDeposit: PublicKey;
|
|
66
|
-
}>>;
|
|
67
|
-
initPositionTokens(params: InitPositionTokensParams, numOutcomes: number): Promise<BuildResult<{
|
|
68
|
-
position: PublicKey;
|
|
69
|
-
lookupTable: PublicKey;
|
|
70
|
-
}>>;
|
|
71
|
-
extendPositionTokens(params: ExtendPositionTokensParams, numOutcomes: number): Promise<BuildResult<{
|
|
72
|
-
position: PublicKey;
|
|
73
|
-
lookupTable: PublicKey;
|
|
74
|
-
}>>;
|
|
75
|
-
depositAndSwap(params: DepositAndSwapParams): Promise<BuildResult<{
|
|
76
|
-
takerPosition: PublicKey;
|
|
77
|
-
}>>;
|
|
78
|
-
createBidOrder(params: BidOrderParams): Omit<SignedOrder, "signature">;
|
|
79
|
-
createAskOrder(params: AskOrderParams): Omit<SignedOrder, "signature">;
|
|
80
|
-
createSignedBidOrder(params: BidOrderParams, signer: Keypair): SignedOrder;
|
|
81
|
-
createSignedAskOrder(params: AskOrderParams, signer: Keypair): SignedOrder;
|
|
82
|
-
hashOrder(order: SignedOrder): Buffer;
|
|
83
|
-
signOrder(order: SignedOrder, signer: Keypair): Buffer;
|
|
84
|
-
signFullOrder(order: Omit<SignedOrder, "signature">, signer: Keypair): SignedOrder;
|
|
85
|
-
deriveConditionId(oracle: PublicKey, questionId: Buffer, numOutcomes: number): Buffer;
|
|
86
|
-
getConditionalMints(market: PublicKey, depositMint: PublicKey, numOutcomes: number): PublicKey[];
|
|
87
|
-
getExchangePda(): PublicKey;
|
|
88
|
-
getMarketPda(marketId: bigint): PublicKey;
|
|
89
|
-
getPositionPda(owner: PublicKey, market: PublicKey): PublicKey;
|
|
90
|
-
getOrderStatusPda(orderHash: Buffer): PublicKey;
|
|
91
|
-
getUserNoncePda(user: PublicKey): PublicKey;
|
|
92
|
-
getOrderbookPda(mintA: PublicKey, mintB: PublicKey): PublicKey;
|
|
93
|
-
getGlobalDepositTokenPda(mint: PublicKey): PublicKey;
|
|
94
|
-
getUserGlobalDepositPda(user: PublicKey, mint: PublicKey): PublicKey;
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/program/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAET,OAAO,EACR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,qBAAqB,EACrB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAC1B,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,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AC,IAAI,EAAE,SAAS,GAAG,SAAS;IAI3C,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS;IAI9D,wBAAwB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS;IAIpD,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS;CAGrE"}
|
package/dist/program/client.js
DELETED
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.LightconePinocchioClient = void 0;
|
|
37
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
38
|
-
const constants_1 = require("./constants");
|
|
39
|
-
const pda = __importStar(require("./pda"));
|
|
40
|
-
const accounts_1 = require("./accounts");
|
|
41
|
-
const instructions_1 = require("./instructions");
|
|
42
|
-
const orders_1 = require("./orders");
|
|
43
|
-
const utils_1 = require("./utils");
|
|
44
|
-
/**
|
|
45
|
-
* LightconePinocchioClient - SDK for interacting with the Lightcone Pinocchio program
|
|
46
|
-
*/
|
|
47
|
-
class LightconePinocchioClient {
|
|
48
|
-
connection;
|
|
49
|
-
programId;
|
|
50
|
-
pda = pda;
|
|
51
|
-
constructor(connection, programId = constants_1.PROGRAM_ID) {
|
|
52
|
-
this.connection = connection;
|
|
53
|
-
this.programId = programId;
|
|
54
|
-
}
|
|
55
|
-
static new(rpcUrl) {
|
|
56
|
-
return new LightconePinocchioClient(new web3_js_1.Connection(rpcUrl), constants_1.PROGRAM_ID);
|
|
57
|
-
}
|
|
58
|
-
static withProgramId(rpcUrl, programId) {
|
|
59
|
-
return new LightconePinocchioClient(new web3_js_1.Connection(rpcUrl), programId);
|
|
60
|
-
}
|
|
61
|
-
static fromConnection(connection) {
|
|
62
|
-
return new LightconePinocchioClient(connection, constants_1.PROGRAM_ID);
|
|
63
|
-
}
|
|
64
|
-
// ============================================================================
|
|
65
|
-
// ACCOUNT FETCHERS
|
|
66
|
-
// ============================================================================
|
|
67
|
-
async getExchange() {
|
|
68
|
-
const [exchangePda] = pda.getExchangePda(this.programId);
|
|
69
|
-
const accountInfo = await this.connection.getAccountInfo(exchangePda);
|
|
70
|
-
if (!accountInfo) {
|
|
71
|
-
throw new Error("Exchange account not found. Protocol not initialized.");
|
|
72
|
-
}
|
|
73
|
-
return (0, accounts_1.deserializeExchange)(accountInfo.data);
|
|
74
|
-
}
|
|
75
|
-
async getMarket(marketId) {
|
|
76
|
-
const [marketPda] = pda.getMarketPda(marketId, this.programId);
|
|
77
|
-
const accountInfo = await this.connection.getAccountInfo(marketPda);
|
|
78
|
-
if (!accountInfo) {
|
|
79
|
-
throw new Error(`Market ${marketId} not found`);
|
|
80
|
-
}
|
|
81
|
-
return (0, accounts_1.deserializeMarket)(accountInfo.data);
|
|
82
|
-
}
|
|
83
|
-
async getMarketByPubkey(market) {
|
|
84
|
-
const accountInfo = await this.connection.getAccountInfo(market);
|
|
85
|
-
if (!accountInfo) {
|
|
86
|
-
throw new Error(`Market not found at ${market.toBase58()}`);
|
|
87
|
-
}
|
|
88
|
-
return (0, accounts_1.deserializeMarket)(accountInfo.data);
|
|
89
|
-
}
|
|
90
|
-
async getPosition(owner, market) {
|
|
91
|
-
const [positionPda] = pda.getPositionPda(owner, market, this.programId);
|
|
92
|
-
const accountInfo = await this.connection.getAccountInfo(positionPda);
|
|
93
|
-
if (!accountInfo) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
return (0, accounts_1.deserializePosition)(accountInfo.data);
|
|
97
|
-
}
|
|
98
|
-
async getOrderStatus(orderHash) {
|
|
99
|
-
const [orderStatusPda] = pda.getOrderStatusPda(orderHash, this.programId);
|
|
100
|
-
const accountInfo = await this.connection.getAccountInfo(orderStatusPda);
|
|
101
|
-
if (!accountInfo) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
return (0, accounts_1.deserializeOrderStatus)(accountInfo.data);
|
|
105
|
-
}
|
|
106
|
-
async getUserNonce(user) {
|
|
107
|
-
const [userNoncePda] = pda.getUserNoncePda(user, this.programId);
|
|
108
|
-
const accountInfo = await this.connection.getAccountInfo(userNoncePda);
|
|
109
|
-
if (!accountInfo) {
|
|
110
|
-
return 0n;
|
|
111
|
-
}
|
|
112
|
-
const nonce = (0, accounts_1.deserializeUserNonce)(accountInfo.data);
|
|
113
|
-
return nonce.nonce;
|
|
114
|
-
}
|
|
115
|
-
async getCurrentNonce(user) {
|
|
116
|
-
const nonce = await this.getUserNonce(user);
|
|
117
|
-
if (nonce > 0xffffffffn) {
|
|
118
|
-
throw new Error(`Nonce exceeds u32 range: ${nonce}`);
|
|
119
|
-
}
|
|
120
|
-
return Number(nonce);
|
|
121
|
-
}
|
|
122
|
-
async getNextNonce(user) {
|
|
123
|
-
return this.getCurrentNonce(user);
|
|
124
|
-
}
|
|
125
|
-
async getNextMarketId() {
|
|
126
|
-
const exchange = await this.getExchange();
|
|
127
|
-
return exchange.marketCount;
|
|
128
|
-
}
|
|
129
|
-
async getOrderbook(mintA, mintB) {
|
|
130
|
-
const [orderbookPda] = pda.getOrderbookPda(mintA, mintB, this.programId);
|
|
131
|
-
const accountInfo = await this.connection.getAccountInfo(orderbookPda);
|
|
132
|
-
if (!accountInfo) {
|
|
133
|
-
throw new Error(`Orderbook not found for ${mintA.toBase58()} / ${mintB.toBase58()}`);
|
|
134
|
-
}
|
|
135
|
-
return (0, accounts_1.deserializeOrderbook)(accountInfo.data);
|
|
136
|
-
}
|
|
137
|
-
async getGlobalDepositToken(mint) {
|
|
138
|
-
const [globalDepositTokenPda] = pda.getGlobalDepositTokenPda(mint, this.programId);
|
|
139
|
-
const accountInfo = await this.connection.getAccountInfo(globalDepositTokenPda);
|
|
140
|
-
if (!accountInfo) {
|
|
141
|
-
throw new Error(`GlobalDepositToken not found for mint ${mint.toBase58()}`);
|
|
142
|
-
}
|
|
143
|
-
return (0, accounts_1.deserializeGlobalDepositToken)(accountInfo.data);
|
|
144
|
-
}
|
|
145
|
-
async getLatestBlockhash() {
|
|
146
|
-
return this.connection.getLatestBlockhash();
|
|
147
|
-
}
|
|
148
|
-
// ============================================================================
|
|
149
|
-
// TRANSACTION BUILDERS
|
|
150
|
-
// ============================================================================
|
|
151
|
-
async createBuildResult(feePayer, accounts, ...instructions) {
|
|
152
|
-
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash();
|
|
153
|
-
const transaction = new web3_js_1.Transaction({
|
|
154
|
-
feePayer,
|
|
155
|
-
blockhash,
|
|
156
|
-
lastValidBlockHeight,
|
|
157
|
-
});
|
|
158
|
-
for (const ix of instructions) {
|
|
159
|
-
transaction.add(ix);
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
transaction,
|
|
163
|
-
accounts,
|
|
164
|
-
serialize: () => transaction
|
|
165
|
-
.serialize({ requireAllSignatures: false, verifySignatures: false })
|
|
166
|
-
.toString("base64"),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
async initialize(params) {
|
|
170
|
-
const [exchange] = pda.getExchangePda(this.programId);
|
|
171
|
-
const ix = (0, instructions_1.buildInitializeIx)(params, this.programId);
|
|
172
|
-
return this.createBuildResult(params.authority, { exchange }, ix);
|
|
173
|
-
}
|
|
174
|
-
async createMarket(params) {
|
|
175
|
-
const marketId = await this.getNextMarketId();
|
|
176
|
-
const [exchange] = pda.getExchangePda(this.programId);
|
|
177
|
-
const [market] = pda.getMarketPda(marketId, this.programId);
|
|
178
|
-
const ix = (0, instructions_1.buildCreateMarketIx)(params, marketId, this.programId);
|
|
179
|
-
return this.createBuildResult(params.authority, { exchange, market }, ix);
|
|
180
|
-
}
|
|
181
|
-
async addDepositMint(params, market, numOutcomes) {
|
|
182
|
-
const [vault] = pda.getVaultPda(params.depositMint, market, this.programId);
|
|
183
|
-
const [mintAuthority] = pda.getMintAuthorityPda(market, this.programId);
|
|
184
|
-
const conditionalMints = pda
|
|
185
|
-
.getAllConditionalMintPdas(market, params.depositMint, numOutcomes, this.programId)
|
|
186
|
-
.map(([mint]) => mint);
|
|
187
|
-
const ix = (0, instructions_1.buildAddDepositMintIx)(params, market, numOutcomes, this.programId);
|
|
188
|
-
return this.createBuildResult(params.authority, { market, vault, mintAuthority, conditionalMints }, ix);
|
|
189
|
-
}
|
|
190
|
-
async mintCompleteSet(params, numOutcomes) {
|
|
191
|
-
const [vault] = pda.getVaultPda(params.depositMint, params.market, this.programId);
|
|
192
|
-
const [position] = pda.getPositionPda(params.user, params.market, this.programId);
|
|
193
|
-
const conditionalMints = pda
|
|
194
|
-
.getAllConditionalMintPdas(params.market, params.depositMint, numOutcomes, this.programId)
|
|
195
|
-
.map(([mint]) => mint);
|
|
196
|
-
const ix = (0, instructions_1.buildMintCompleteSetIx)(params, numOutcomes, this.programId);
|
|
197
|
-
return this.createBuildResult(params.user, { position, vault, conditionalMints }, ix);
|
|
198
|
-
}
|
|
199
|
-
async mergeCompleteSet(params, numOutcomes) {
|
|
200
|
-
const [vault] = pda.getVaultPda(params.depositMint, params.market, this.programId);
|
|
201
|
-
const [position] = pda.getPositionPda(params.user, params.market, this.programId);
|
|
202
|
-
const conditionalMints = pda
|
|
203
|
-
.getAllConditionalMintPdas(params.market, params.depositMint, numOutcomes, this.programId)
|
|
204
|
-
.map(([mint]) => mint);
|
|
205
|
-
const ix = (0, instructions_1.buildMergeCompleteSetIx)(params, numOutcomes, this.programId);
|
|
206
|
-
return this.createBuildResult(params.user, { position, vault, conditionalMints }, ix);
|
|
207
|
-
}
|
|
208
|
-
async cancelOrder(maker, order) {
|
|
209
|
-
const orderHash = (0, orders_1.hashOrder)(order);
|
|
210
|
-
const [orderStatus] = pda.getOrderStatusPda(orderHash, this.programId);
|
|
211
|
-
const ix = (0, instructions_1.buildCancelOrderIx)(maker, order, this.programId);
|
|
212
|
-
return this.createBuildResult(maker, { orderStatus }, ix);
|
|
213
|
-
}
|
|
214
|
-
async incrementNonce(user) {
|
|
215
|
-
const [userNonce] = pda.getUserNoncePda(user, this.programId);
|
|
216
|
-
const ix = (0, instructions_1.buildIncrementNonceIx)(user, this.programId);
|
|
217
|
-
return this.createBuildResult(user, { userNonce }, ix);
|
|
218
|
-
}
|
|
219
|
-
async settleMarket(params) {
|
|
220
|
-
const [exchange] = pda.getExchangePda(this.programId);
|
|
221
|
-
const [market] = pda.getMarketPda(params.marketId, this.programId);
|
|
222
|
-
const ix = (0, instructions_1.buildSettleMarketIx)(params, this.programId);
|
|
223
|
-
return this.createBuildResult(params.oracle, { exchange, market }, ix);
|
|
224
|
-
}
|
|
225
|
-
async redeemWinnings(params, winningOutcome) {
|
|
226
|
-
const [vault] = pda.getVaultPda(params.depositMint, params.market, this.programId);
|
|
227
|
-
const [position] = pda.getPositionPda(params.user, params.market, this.programId);
|
|
228
|
-
const [winningMint] = pda.getConditionalMintPda(params.market, params.depositMint, winningOutcome, this.programId);
|
|
229
|
-
const ix = (0, instructions_1.buildRedeemWinningsIx)(params, winningOutcome, this.programId);
|
|
230
|
-
return this.createBuildResult(params.user, { position, vault, winningMint }, ix);
|
|
231
|
-
}
|
|
232
|
-
async setPaused(authority, paused) {
|
|
233
|
-
const [exchange] = pda.getExchangePda(this.programId);
|
|
234
|
-
const ix = (0, instructions_1.buildSetPausedIx)(authority, paused, this.programId);
|
|
235
|
-
return this.createBuildResult(authority, { exchange }, ix);
|
|
236
|
-
}
|
|
237
|
-
async setOperator(authority, newOperator) {
|
|
238
|
-
const [exchange] = pda.getExchangePda(this.programId);
|
|
239
|
-
const ix = (0, instructions_1.buildSetOperatorIx)(authority, newOperator, this.programId);
|
|
240
|
-
return this.createBuildResult(authority, { exchange }, ix);
|
|
241
|
-
}
|
|
242
|
-
async withdrawFromPosition(params, isToken2022) {
|
|
243
|
-
const [position] = pda.getPositionPda(params.user, params.market, this.programId);
|
|
244
|
-
const ix = (0, instructions_1.buildWithdrawFromPositionIx)(params, isToken2022, this.programId);
|
|
245
|
-
return this.createBuildResult(params.user, { position }, ix);
|
|
246
|
-
}
|
|
247
|
-
async activateMarket(params) {
|
|
248
|
-
const [exchange] = pda.getExchangePda(this.programId);
|
|
249
|
-
const [market] = pda.getMarketPda(params.marketId, this.programId);
|
|
250
|
-
const ix = (0, instructions_1.buildActivateMarketIx)(params, this.programId);
|
|
251
|
-
return this.createBuildResult(params.authority, { exchange, market }, ix);
|
|
252
|
-
}
|
|
253
|
-
async matchOrdersMulti(params) {
|
|
254
|
-
const takerOrderHash = (0, orders_1.hashOrder)(params.takerOrder);
|
|
255
|
-
const [takerOrderStatus] = pda.getOrderStatusPda(takerOrderHash, this.programId);
|
|
256
|
-
const [takerPosition] = pda.getPositionPda(params.takerOrder.maker, params.market, this.programId);
|
|
257
|
-
const makerOrderStatuses = [];
|
|
258
|
-
const makerPositions = [];
|
|
259
|
-
for (const makerOrder of params.makerOrders) {
|
|
260
|
-
const makerOrderHash = (0, orders_1.hashOrder)(makerOrder);
|
|
261
|
-
const [makerOrderStatus] = pda.getOrderStatusPda(makerOrderHash, this.programId);
|
|
262
|
-
const [makerPosition] = pda.getPositionPda(makerOrder.maker, params.market, this.programId);
|
|
263
|
-
makerOrderStatuses.push(makerOrderStatus);
|
|
264
|
-
makerPositions.push(makerPosition);
|
|
265
|
-
}
|
|
266
|
-
const ix = (0, instructions_1.buildMatchOrdersMultiIx)(params, this.programId);
|
|
267
|
-
return this.createBuildResult(params.operator, { takerOrderStatus, takerPosition, makerOrderStatuses, makerPositions }, ix);
|
|
268
|
-
}
|
|
269
|
-
async setAuthority(params) {
|
|
270
|
-
const [exchange] = pda.getExchangePda(this.programId);
|
|
271
|
-
const ix = (0, instructions_1.buildSetAuthorityIx)(params, this.programId);
|
|
272
|
-
return this.createBuildResult(params.currentAuthority, { exchange }, ix);
|
|
273
|
-
}
|
|
274
|
-
async createOrderbook(params) {
|
|
275
|
-
const [orderbook] = pda.getOrderbookPda(params.mintA, params.mintB, this.programId);
|
|
276
|
-
const ix = (0, instructions_1.buildCreateOrderbookIx)(params, this.programId);
|
|
277
|
-
return this.createBuildResult(params.authority, { orderbook }, ix);
|
|
278
|
-
}
|
|
279
|
-
async whitelistDepositToken(params) {
|
|
280
|
-
const [globalDepositToken] = pda.getGlobalDepositTokenPda(params.mint, this.programId);
|
|
281
|
-
const ix = (0, instructions_1.buildWhitelistDepositTokenIx)(params, this.programId);
|
|
282
|
-
return this.createBuildResult(params.authority, { globalDepositToken }, ix);
|
|
283
|
-
}
|
|
284
|
-
async depositToGlobal(params) {
|
|
285
|
-
const [userGlobalDeposit] = pda.getUserGlobalDepositPda(params.user, params.mint, this.programId);
|
|
286
|
-
const ix = (0, instructions_1.buildDepositToGlobalIx)(params, this.programId);
|
|
287
|
-
return this.createBuildResult(params.user, { userGlobalDeposit }, ix);
|
|
288
|
-
}
|
|
289
|
-
async globalToMarketDeposit(params, numOutcomes) {
|
|
290
|
-
const [position] = pda.getPositionPda(params.user, params.market, this.programId);
|
|
291
|
-
const [userGlobalDeposit] = pda.getUserGlobalDepositPda(params.user, params.depositMint, this.programId);
|
|
292
|
-
const ix = (0, instructions_1.buildGlobalToMarketDepositIx)(params, numOutcomes, this.programId);
|
|
293
|
-
return this.createBuildResult(params.user, { position, userGlobalDeposit }, ix);
|
|
294
|
-
}
|
|
295
|
-
async initPositionTokens(params, numOutcomes) {
|
|
296
|
-
const [position] = pda.getPositionPda(params.user, params.market, this.programId);
|
|
297
|
-
const [lookupTable] = pda.getPositionAltPda(position, params.recentSlot);
|
|
298
|
-
const ix = (0, instructions_1.buildInitPositionTokensIx)(params, numOutcomes, this.programId);
|
|
299
|
-
return this.createBuildResult(params.payer, { position, lookupTable }, ix);
|
|
300
|
-
}
|
|
301
|
-
async extendPositionTokens(params, numOutcomes) {
|
|
302
|
-
const [position] = pda.getPositionPda(params.user, params.market, this.programId);
|
|
303
|
-
const ix = (0, instructions_1.buildExtendPositionTokensIx)(params, numOutcomes, this.programId);
|
|
304
|
-
return this.createBuildResult(params.payer, { position, lookupTable: params.lookupTable }, ix);
|
|
305
|
-
}
|
|
306
|
-
async depositAndSwap(params) {
|
|
307
|
-
const [takerPosition] = pda.getPositionPda(params.takerOrder.maker, params.market, this.programId);
|
|
308
|
-
const ix = (0, instructions_1.buildDepositAndSwapIx)(params, this.programId);
|
|
309
|
-
return this.createBuildResult(params.operator, { takerPosition }, ix);
|
|
310
|
-
}
|
|
311
|
-
// ============================================================================
|
|
312
|
-
// ORDER HELPERS
|
|
313
|
-
// ============================================================================
|
|
314
|
-
createBidOrder(params) {
|
|
315
|
-
return (0, orders_1.createBidOrder)(params);
|
|
316
|
-
}
|
|
317
|
-
createAskOrder(params) {
|
|
318
|
-
return (0, orders_1.createAskOrder)(params);
|
|
319
|
-
}
|
|
320
|
-
createSignedBidOrder(params, signer) {
|
|
321
|
-
return (0, orders_1.createSignedBidOrder)(params, signer);
|
|
322
|
-
}
|
|
323
|
-
createSignedAskOrder(params, signer) {
|
|
324
|
-
return (0, orders_1.createSignedAskOrder)(params, signer);
|
|
325
|
-
}
|
|
326
|
-
hashOrder(order) {
|
|
327
|
-
return (0, orders_1.hashOrder)(order);
|
|
328
|
-
}
|
|
329
|
-
signOrder(order, signer) {
|
|
330
|
-
return (0, orders_1.signOrder)(order, signer);
|
|
331
|
-
}
|
|
332
|
-
signFullOrder(order, signer) {
|
|
333
|
-
return (0, orders_1.signOrderFull)(order, signer);
|
|
334
|
-
}
|
|
335
|
-
// ============================================================================
|
|
336
|
-
// UTILITY METHODS
|
|
337
|
-
// ============================================================================
|
|
338
|
-
deriveConditionId(oracle, questionId, numOutcomes) {
|
|
339
|
-
return (0, utils_1.deriveConditionId)(oracle, questionId, numOutcomes);
|
|
340
|
-
}
|
|
341
|
-
getConditionalMints(market, depositMint, numOutcomes) {
|
|
342
|
-
return pda
|
|
343
|
-
.getAllConditionalMintPdas(market, depositMint, numOutcomes, this.programId)
|
|
344
|
-
.map(([mint]) => mint);
|
|
345
|
-
}
|
|
346
|
-
getExchangePda() {
|
|
347
|
-
return pda.getExchangePda(this.programId)[0];
|
|
348
|
-
}
|
|
349
|
-
getMarketPda(marketId) {
|
|
350
|
-
return pda.getMarketPda(marketId, this.programId)[0];
|
|
351
|
-
}
|
|
352
|
-
getPositionPda(owner, market) {
|
|
353
|
-
return pda.getPositionPda(owner, market, this.programId)[0];
|
|
354
|
-
}
|
|
355
|
-
getOrderStatusPda(orderHash) {
|
|
356
|
-
return pda.getOrderStatusPda(orderHash, this.programId)[0];
|
|
357
|
-
}
|
|
358
|
-
getUserNoncePda(user) {
|
|
359
|
-
return pda.getUserNoncePda(user, this.programId)[0];
|
|
360
|
-
}
|
|
361
|
-
getOrderbookPda(mintA, mintB) {
|
|
362
|
-
return pda.getOrderbookPda(mintA, mintB, this.programId)[0];
|
|
363
|
-
}
|
|
364
|
-
getGlobalDepositTokenPda(mint) {
|
|
365
|
-
return pda.getGlobalDepositTokenPda(mint, this.programId)[0];
|
|
366
|
-
}
|
|
367
|
-
getUserGlobalDepositPda(user, mint) {
|
|
368
|
-
return pda.getUserGlobalDepositPda(user, mint, this.programId)[0];
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
exports.LightconePinocchioClient = LightconePinocchioClient;
|
|
372
|
-
//# sourceMappingURL=client.js.map
|