@opp-oss/react 1.0.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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/OpenPerpsChart.d.ts +19 -0
- package/dist/OpenPerpsChart.d.ts.map +1 -0
- package/dist/OpenPerpsChart.js +20 -0
- package/dist/OpenPerpsChart.js.map +1 -0
- package/dist/OpenPerpsMarketLauncher.d.ts +10 -0
- package/dist/OpenPerpsMarketLauncher.d.ts.map +1 -0
- package/dist/OpenPerpsMarketLauncher.js +9 -0
- package/dist/OpenPerpsMarketLauncher.js.map +1 -0
- package/dist/OpenPerpsPosition.d.ts +12 -0
- package/dist/OpenPerpsPosition.d.ts.map +1 -0
- package/dist/OpenPerpsPosition.js +43 -0
- package/dist/OpenPerpsPosition.js.map +1 -0
- package/dist/OpenPerpsTrade.d.ts +14 -0
- package/dist/OpenPerpsTrade.d.ts.map +1 -0
- package/dist/OpenPerpsTrade.js +24 -0
- package/dist/OpenPerpsTrade.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/useOpenPerpsTrade.d.ts +19 -0
- package/dist/useOpenPerpsTrade.d.ts.map +1 -0
- package/dist/useOpenPerpsTrade.js +57 -0
- package/dist/useOpenPerpsTrade.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenPerps
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @opp-oss/react
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@opp-oss/react)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
|
|
6
|
+
Drop-in React components and hooks for embedding OpenPerps trading, charts, and
|
|
7
|
+
positions. Built on [`@opp-oss/sdk`](../sdk) and the Solana wallet adapter.
|
|
8
|
+
|
|
9
|
+
The SDK is the primary integration surface; these components are the fast path
|
|
10
|
+
for teams that want ready-made UI. `react`, `@solana/web3.js`, and
|
|
11
|
+
`@solana/wallet-adapter-react` are peer dependencies, so the components use your
|
|
12
|
+
app's existing wallet and connection providers.
|
|
13
|
+
|
|
14
|
+
## Components
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import {
|
|
18
|
+
OpenPerpsTrade,
|
|
19
|
+
OpenPerpsPosition,
|
|
20
|
+
OpenPerpsChart,
|
|
21
|
+
OpenPerpsMarketLauncher,
|
|
22
|
+
} from "@opp-oss/react";
|
|
23
|
+
|
|
24
|
+
<OpenPerpsTrade market={market} counterparty={house} executionPrice={mark} />
|
|
25
|
+
<OpenPerpsPosition market={market} owner={wallet.publicKey} />
|
|
26
|
+
<OpenPerpsChart market={market} candles={candles} />
|
|
27
|
+
<OpenPerpsMarketLauncher intent={creationIntent} onLaunch={createMarket} />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The host app provides the market config, the resolved House/LP counterparty, the
|
|
31
|
+
execution price (from the keeper/on-chain mark, never a client chart price), and
|
|
32
|
+
chart candles. The components ship no CSS; style them through `className` or the
|
|
33
|
+
default `openperps-*` class names.
|
|
34
|
+
|
|
35
|
+
## Headless
|
|
36
|
+
|
|
37
|
+
Skip the UI and drive a trade with the hook:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { useOpenPerpsTrade } from "@opp-oss/react";
|
|
41
|
+
|
|
42
|
+
const { placeTrade, pending, error } = useOpenPerpsTrade({ market, counterparty });
|
|
43
|
+
|
|
44
|
+
await placeTrade({ side: "long", size: "1000000", executionPrice: mark });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`placeTrade` resolves the intent (counterparty, limit, slippage, reduce-only
|
|
48
|
+
guards), builds the `PlaceOrder` transaction, signs it with the connected
|
|
49
|
+
wallet, and confirms it.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { OpenPerpsMarketConfig } from "@opp-oss/sdk";
|
|
3
|
+
export type Candle = {
|
|
4
|
+
time: number;
|
|
5
|
+
open: number;
|
|
6
|
+
high: number;
|
|
7
|
+
low: number;
|
|
8
|
+
close: number;
|
|
9
|
+
volume?: number;
|
|
10
|
+
};
|
|
11
|
+
export type OpenPerpsChartProps = {
|
|
12
|
+
market: OpenPerpsMarketConfig;
|
|
13
|
+
candles: Candle[];
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function OpenPerpsChart({ candles, width, height, className, }: OpenPerpsChartProps): ReactElement;
|
|
19
|
+
//# sourceMappingURL=OpenPerpsChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsChart.d.ts","sourceRoot":"","sources":["../src/OpenPerpsChart.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,KAAW,EACX,MAAY,EACZ,SAAS,GACV,EAAE,mBAAmB,GAAG,YAAY,CAgCpC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function OpenPerpsChart({ candles, width = 320, height = 120, className, }) {
|
|
3
|
+
const closes = candles.map((c) => c.close);
|
|
4
|
+
let path = "";
|
|
5
|
+
if (closes.length >= 2) {
|
|
6
|
+
const min = Math.min(...closes);
|
|
7
|
+
const max = Math.max(...closes);
|
|
8
|
+
const span = max - min || 1;
|
|
9
|
+
const stepX = width / (closes.length - 1);
|
|
10
|
+
path = closes
|
|
11
|
+
.map((v, i) => {
|
|
12
|
+
const x = i * stepX;
|
|
13
|
+
const y = height - ((v - min) / span) * height;
|
|
14
|
+
return `${i === 0 ? "M" : "L"}${x.toFixed(2)},${y.toFixed(2)}`;
|
|
15
|
+
})
|
|
16
|
+
.join(" ");
|
|
17
|
+
}
|
|
18
|
+
return (_jsx("svg", { className: className ?? "openperps-chart", width: width, height: height, viewBox: `0 0 ${width} ${height}`, role: "img", "aria-label": "price chart", children: path ? (_jsx("path", { d: path, fill: "none", stroke: "currentColor", strokeWidth: 2 })) : null }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=OpenPerpsChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsChart.js","sourceRoot":"","sources":["../src/OpenPerpsChart.tsx"],"names":[],"mappings":";AAyBA,MAAM,UAAU,cAAc,CAAC,EAC7B,OAAO,EACP,KAAK,GAAG,GAAG,EACX,MAAM,GAAG,GAAG,EACZ,SAAS,GACW;IACpB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAE3C,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QAChC,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;QAC5B,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC1C,IAAI,GAAG,MAAM;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACZ,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;YAC/C,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED,OAAO,CACL,cACE,SAAS,EAAE,SAAS,IAAI,iBAAiB,EACzC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,KAAK,IAAI,MAAM,EAAE,EACjC,IAAI,EAAC,KAAK,gBACC,aAAa,YAEvB,IAAI,CAAC,CAAC,CAAC,CACN,eAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAE,CAAC,GAAI,CACpE,CAAC,CAAC,CAAC,IAAI,GACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { type OpenPerpsMarketCreationIntent } from "@opp-oss/sdk";
|
|
3
|
+
export type OpenPerpsMarketLauncherProps = {
|
|
4
|
+
intent: OpenPerpsMarketCreationIntent;
|
|
5
|
+
includeMockPool?: boolean;
|
|
6
|
+
onLaunch?: (intent: OpenPerpsMarketCreationIntent) => void;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function OpenPerpsMarketLauncher({ intent, includeMockPool, onLaunch, className, }: OpenPerpsMarketLauncherProps): ReactElement;
|
|
10
|
+
//# sourceMappingURL=OpenPerpsMarketLauncher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsMarketLauncher.d.ts","sourceRoot":"","sources":["../src/OpenPerpsMarketLauncher.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAAE,6BAA6B,CAAC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,6BAA6B,KAAK,IAAI,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,eAAe,EACf,QAAQ,EACR,SAAS,GACV,EAAE,4BAA4B,GAAG,YAAY,CAqB7C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { planMarketCreation, } from "@opp-oss/sdk";
|
|
3
|
+
export function OpenPerpsMarketLauncher({ intent, includeMockPool, onLaunch, className, }) {
|
|
4
|
+
const plan = planMarketCreation(intent, {
|
|
5
|
+
includeMockPool: includeMockPool ?? false,
|
|
6
|
+
});
|
|
7
|
+
return (_jsxs("div", { className: className ?? "openperps-launcher", children: [_jsx("ol", { className: "openperps-launcher-steps", children: plan.steps.map((step, i) => (_jsx("li", { children: step.kind }, `${step.kind}-${i}`))) }), _jsxs("button", { className: "openperps-launcher-create", type: "button", onClick: () => onLaunch?.(intent), children: ["Create ", intent.symbol] })] }));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=OpenPerpsMarketLauncher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsMarketLauncher.js","sourceRoot":"","sources":["../src/OpenPerpsMarketLauncher.tsx"],"names":[],"mappings":";AAKA,OAAO,EACL,kBAAkB,GAEnB,MAAM,cAAc,CAAC;AAStB,MAAM,UAAU,uBAAuB,CAAC,EACtC,MAAM,EACN,eAAe,EACf,QAAQ,EACR,SAAS,GACoB;IAC7B,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,EAAE;QACtC,eAAe,EAAE,eAAe,IAAI,KAAK;KAC1C,CAAC,CAAC;IAEH,OAAO,CACL,eAAK,SAAS,EAAE,SAAS,IAAI,oBAAoB,aAC/C,aAAI,SAAS,EAAC,0BAA0B,YACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC3B,uBAA+B,IAAI,CAAC,IAAI,IAA/B,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,CAAkB,CAC/C,CAAC,GACC,EACL,kBACE,SAAS,EAAC,2BAA2B,EACrC,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,wBAEzB,MAAM,CAAC,MAAM,IACd,IACL,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { type OpenPerpsMarketConfig } from "@opp-oss/sdk";
|
|
4
|
+
export type OpenPerpsPositionProps = {
|
|
5
|
+
market: OpenPerpsMarketConfig;
|
|
6
|
+
owner: PublicKey;
|
|
7
|
+
pollMs?: number;
|
|
8
|
+
formatAmount?: (atoms: bigint) => string;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function OpenPerpsPosition({ market, owner, pollMs, formatAmount, className, }: OpenPerpsPositionProps): ReactElement;
|
|
12
|
+
//# sourceMappingURL=OpenPerpsPosition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsPosition.d.ts","sourceRoot":"","sources":["../src/OpenPerpsPosition.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,GACV,EAAE,sBAAsB,GAAG,YAAY,CAoDvC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/// Show a wallet's position summary in a market: capital, realized pnl, and open
|
|
3
|
+
/// position count, decoded from the portfolio account. Polls on its own.
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { PublicKey } from "@solana/web3.js";
|
|
6
|
+
import { useConnection } from "@solana/wallet-adapter-react";
|
|
7
|
+
import { decodePortfolioSummary, portfolioPda, } from "@opp-oss/sdk";
|
|
8
|
+
export function OpenPerpsPosition({ market, owner, pollMs, formatAmount, className, }) {
|
|
9
|
+
const { connection } = useConnection();
|
|
10
|
+
const [summary, setSummary] = useState(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
let active = true;
|
|
13
|
+
const programId = new PublicKey(market.programId);
|
|
14
|
+
const marketAccount = new PublicKey(market.market);
|
|
15
|
+
const [portfolio] = portfolioPda(programId, owner, marketAccount);
|
|
16
|
+
const tick = () => {
|
|
17
|
+
connection
|
|
18
|
+
.getAccountInfo(portfolio)
|
|
19
|
+
.then((info) => {
|
|
20
|
+
if (!active)
|
|
21
|
+
return;
|
|
22
|
+
if (!info) {
|
|
23
|
+
setSummary(null);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const u = new Uint8Array(info.data.buffer, info.data.byteOffset, info.data.byteLength);
|
|
27
|
+
setSummary(decodePortfolioSummary(u));
|
|
28
|
+
})
|
|
29
|
+
.catch(() => {
|
|
30
|
+
/* transient RPC error; keep the last good summary */
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
tick();
|
|
34
|
+
const id = setInterval(tick, pollMs ?? 5000);
|
|
35
|
+
return () => {
|
|
36
|
+
active = false;
|
|
37
|
+
clearInterval(id);
|
|
38
|
+
};
|
|
39
|
+
}, [connection, market.programId, market.market, owner, pollMs]);
|
|
40
|
+
const fmt = formatAmount ?? ((a) => a.toString());
|
|
41
|
+
return (_jsx("div", { className: className ?? "openperps-position", children: summary ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "openperps-position-capital", children: fmt(summary.capital) }), _jsx("span", { className: "openperps-position-pnl", children: fmt(summary.pnl) }), _jsx("span", { className: "openperps-position-count", children: summary.positions.length })] })) : (_jsx("span", { className: "openperps-position-empty", children: "no position" })) }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=OpenPerpsPosition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsPosition.js","sourceRoot":"","sources":["../src/OpenPerpsPosition.tsx"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,yEAAyE;AAEzE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAqB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,sBAAsB,EACtB,YAAY,GAGb,MAAM,cAAc,CAAC;AAWtB,MAAM,UAAU,iBAAiB,CAAC,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Aa,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,YAAY,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE1D,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,IAAI,oBAAoB,YAC9C,OAAO,CAAC,CAAC,CAAC,CACT,8BACE,eAAM,SAAS,EAAC,4BAA4B,YAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,GAAQ,EAC1E,eAAM,SAAS,EAAC,wBAAwB,YAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAQ,EAClE,eAAM,SAAS,EAAC,0BAA0B,YAAE,OAAO,CAAC,SAAS,CAAC,MAAM,GAAQ,IAC3E,CACJ,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,0BAA0B,4BAAmB,CAC9D,GACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { Commitment } from "@solana/web3.js";
|
|
3
|
+
import type { OpenPerpsMarketConfig, TradeCounterparty } from "@opp-oss/sdk";
|
|
4
|
+
export type OpenPerpsTradeProps = {
|
|
5
|
+
market: OpenPerpsMarketConfig;
|
|
6
|
+
counterparty: TradeCounterparty;
|
|
7
|
+
executionPrice: bigint;
|
|
8
|
+
defaultSize?: string;
|
|
9
|
+
commitment?: Commitment;
|
|
10
|
+
onFilled?: (signature: string) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function OpenPerpsTrade({ market, counterparty, executionPrice, defaultSize, commitment, onFilled, className, }: OpenPerpsTradeProps): ReactElement;
|
|
14
|
+
//# sourceMappingURL=OpenPerpsTrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsTrade.d.ts","sourceRoot":"","sources":["../src/OpenPerpsTrade.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG7E,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,YAAY,EAAE,iBAAiB,CAAC;IAEhC,cAAc,EAAE,MAAM,CAAC;IAEvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,GACV,EAAE,mBAAmB,GAAG,YAAY,CAkDpC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/// A minimal, unstyled Long/Short widget built on `useOpenPerpsTrade`. The host
|
|
3
|
+
/// app supplies the market config, the resolved counterparty, and the current
|
|
4
|
+
/// execution price (from the keeper/on-chain mark). Styling is left to the host
|
|
5
|
+
/// via `className`; the default class names carry no built-in CSS.
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { useOpenPerpsTrade } from "./useOpenPerpsTrade.js";
|
|
8
|
+
export function OpenPerpsTrade({ market, counterparty, executionPrice, defaultSize, commitment, onFilled, className, }) {
|
|
9
|
+
const { placeTrade, pending, error } = useOpenPerpsTrade({
|
|
10
|
+
market,
|
|
11
|
+
counterparty,
|
|
12
|
+
commitment,
|
|
13
|
+
});
|
|
14
|
+
const [size, setSize] = useState(
|
|
15
|
+
// BigInt, not `10 ** n`, so a large `sizeDecimals` keeps integer precision
|
|
16
|
+
// instead of overflowing Number's 2^53 safe-integer range.
|
|
17
|
+
defaultSize ?? (10n ** BigInt(market.sizeDecimals)).toString());
|
|
18
|
+
const submit = async (side) => {
|
|
19
|
+
const signature = await placeTrade({ side, size, executionPrice });
|
|
20
|
+
onFilled?.(signature);
|
|
21
|
+
};
|
|
22
|
+
return (_jsxs("div", { className: className ?? "openperps-trade", children: [_jsx("input", { className: "openperps-trade-size", type: "text", inputMode: "numeric", value: size, disabled: pending, onChange: (e) => setSize(e.target.value.replace(/[^0-9]/g, "")) }), _jsx("button", { className: "openperps-trade-long", type: "button", disabled: pending || size.length === 0, onClick: () => void submit("long"), children: "Long" }), _jsx("button", { className: "openperps-trade-short", type: "button", disabled: pending || size.length === 0, onClick: () => void submit("short"), children: "Short" }), error ? (_jsx("p", { className: "openperps-trade-error", role: "alert", children: error })) : null] }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=OpenPerpsTrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenPerpsTrade.js","sourceRoot":"","sources":["../src/OpenPerpsTrade.tsx"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAChF,mEAAmE;AAEnE,OAAO,EAAE,QAAQ,EAAqB,MAAM,OAAO,CAAC;AAGpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAc3D,MAAM,UAAU,cAAc,CAAC,EAC7B,MAAM,EACN,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,GACW;IACpB,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC;QACvD,MAAM;QACN,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,EAAC,OAAO,YAC9C,KAAK,GACJ,CACL,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { useOpenPerpsTrade } from "./useOpenPerpsTrade.js";
|
|
2
|
+
export type { PlaceTradeInput, UseOpenPerpsTradeResult, } from "./useOpenPerpsTrade.js";
|
|
3
|
+
export { OpenPerpsTrade } from "./OpenPerpsTrade.js";
|
|
4
|
+
export type { OpenPerpsTradeProps } from "./OpenPerpsTrade.js";
|
|
5
|
+
export { OpenPerpsPosition } from "./OpenPerpsPosition.js";
|
|
6
|
+
export type { OpenPerpsPositionProps } from "./OpenPerpsPosition.js";
|
|
7
|
+
export { OpenPerpsChart } from "./OpenPerpsChart.js";
|
|
8
|
+
export type { Candle, OpenPerpsChartProps } from "./OpenPerpsChart.js";
|
|
9
|
+
export { OpenPerpsMarketLauncher } from "./OpenPerpsMarketLauncher.js";
|
|
10
|
+
export type { OpenPerpsMarketLauncherProps } from "./OpenPerpsMarketLauncher.js";
|
|
11
|
+
export { buildTradeFromIntent, planMarketCreation, resolveTradeIntent, portfolioPda, type OpenPerpsMarketConfig, type OpenPerpsTradeIntent, type OpenPerpsTradeSide, type OpenPerpsMarketCreationIntent, type TradeCounterparty, } from "@opp-oss/sdk";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACV,eAAe,EACf,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,YAAY,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAGlF,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { useOpenPerpsTrade } from "./useOpenPerpsTrade.js";
|
|
2
|
+
export { OpenPerpsTrade } from "./OpenPerpsTrade.js";
|
|
3
|
+
export { OpenPerpsPosition } from "./OpenPerpsPosition.js";
|
|
4
|
+
export { OpenPerpsChart } from "./OpenPerpsChart.js";
|
|
5
|
+
export { OpenPerpsMarketLauncher } from "./OpenPerpsMarketLauncher.js";
|
|
6
|
+
// Re-export the SDK pieces an embedder needs alongside the components.
|
|
7
|
+
export { buildTradeFromIntent, planMarketCreation, resolveTradeIntent, portfolioPda, } from "@opp-oss/sdk";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAM3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAGtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA+B,CAAC;AAGxE,uEAAuE;AACvE,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GAMb,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Commitment } from "@solana/web3.js";
|
|
2
|
+
import { type OpenPerpsMarketConfig, type OpenPerpsTradeSide, type TradeCounterparty } from "@opp-oss/sdk";
|
|
3
|
+
export type PlaceTradeInput = {
|
|
4
|
+
side: OpenPerpsTradeSide;
|
|
5
|
+
size: string;
|
|
6
|
+
executionPrice: bigint;
|
|
7
|
+
feeBps?: bigint;
|
|
8
|
+
};
|
|
9
|
+
export type UseOpenPerpsTradeResult = {
|
|
10
|
+
placeTrade: (input: PlaceTradeInput) => Promise<string>;
|
|
11
|
+
pending: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
};
|
|
14
|
+
export declare function useOpenPerpsTrade(args: {
|
|
15
|
+
market: OpenPerpsMarketConfig;
|
|
16
|
+
counterparty: TradeCounterparty;
|
|
17
|
+
commitment?: Commitment;
|
|
18
|
+
}): UseOpenPerpsTradeResult;
|
|
19
|
+
//# sourceMappingURL=useOpenPerpsTrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOpenPerpsTrade.d.ts","sourceRoot":"","sources":["../src/useOpenPerpsTrade.ts"],"names":[],"mappings":"AAMA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,kBAAkB,CAAC;IAEzB,IAAI,EAAE,MAAM,CAAC;IAEb,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,YAAY,EAAE,iBAAiB,CAAC;IAChC,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,GAAG,uBAAuB,CAsD1B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// Headless trade hook. Wraps the SDK's `buildTradeFromIntent` with the app's
|
|
2
|
+
/// wallet adapter: build, sign, confirm. Returns `placeTrade` plus pending and
|
|
3
|
+
/// error state. The host app supplies the resolved counterparty and the
|
|
4
|
+
/// execution price (from the keeper/on-chain mark, never a client chart price).
|
|
5
|
+
import { useCallback, useState } from "react";
|
|
6
|
+
import { Transaction } from "@solana/web3.js";
|
|
7
|
+
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
|
|
8
|
+
import { buildTradeFromIntent, } from "@opp-oss/sdk";
|
|
9
|
+
export function useOpenPerpsTrade(args) {
|
|
10
|
+
const { market, counterparty } = args;
|
|
11
|
+
const commitment = args.commitment ?? "confirmed";
|
|
12
|
+
const { connection } = useConnection();
|
|
13
|
+
const wallet = useWallet();
|
|
14
|
+
const [pending, setPending] = useState(false);
|
|
15
|
+
const [error, setError] = useState(null);
|
|
16
|
+
const placeTrade = useCallback(async (input) => {
|
|
17
|
+
setPending(true);
|
|
18
|
+
setError(null);
|
|
19
|
+
try {
|
|
20
|
+
// Inside the try so a disconnected wallet sets `error` (and clears
|
|
21
|
+
// `pending` via finally) instead of throwing past the error state.
|
|
22
|
+
if (!wallet.publicKey || !wallet.sendTransaction) {
|
|
23
|
+
throw new Error("Wallet is not connected.");
|
|
24
|
+
}
|
|
25
|
+
const built = buildTradeFromIntent({
|
|
26
|
+
intent: {
|
|
27
|
+
schemaVersion: 1,
|
|
28
|
+
marketId: market.id,
|
|
29
|
+
side: input.side,
|
|
30
|
+
size: input.size,
|
|
31
|
+
},
|
|
32
|
+
market,
|
|
33
|
+
counterparty,
|
|
34
|
+
executionPrice: input.executionPrice,
|
|
35
|
+
owner: wallet.publicKey,
|
|
36
|
+
feeBps: input.feeBps,
|
|
37
|
+
});
|
|
38
|
+
const tx = new Transaction().add(...built.instructions);
|
|
39
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash(commitment);
|
|
40
|
+
tx.recentBlockhash = blockhash;
|
|
41
|
+
tx.feePayer = wallet.publicKey;
|
|
42
|
+
const signature = await wallet.sendTransaction(tx, connection);
|
|
43
|
+
await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight }, commitment);
|
|
44
|
+
return signature;
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
48
|
+
setError(message);
|
|
49
|
+
throw e;
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setPending(false);
|
|
53
|
+
}
|
|
54
|
+
}, [connection, wallet, market, counterparty, commitment]);
|
|
55
|
+
return { placeTrade, pending, error };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=useOpenPerpsTrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOpenPerpsTrade.js","sourceRoot":"","sources":["../src/useOpenPerpsTrade.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+EAA+E;AAC/E,wEAAwE;AACxE,gFAAgF;AAEhF,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL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AAC;YACxD,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GACvC,MAAM,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;YAClD,EAAE,CAAC,eAAe,GAAG,SAAS,CAAC;YAC/B,EAAE,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC;YAC/B,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;YAC/D,MAAM,UAAU,CAAC,kBAAkB,CACjC,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,EAC9C,UAAU,CACX,CAAC;YACF,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3D,QAAQ,CAAC,OAAO,CAAC,CAAC;YAClB,MAAM,CAAC,CAAC;QACV,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,EACD,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,CACvD,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opp-oss/react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Drop-in React components and hooks for embedding OpenPerps trading, charts, and positions.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "itsbenjiidunn",
|
|
7
|
+
"homepage": "https://github.com/itsbenjiidunn/openperps-oss/tree/main/packages/react#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/itsbenjiidunn/openperps-oss.git",
|
|
11
|
+
"directory": "packages/react"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/itsbenjiidunn/openperps-oss/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"solana",
|
|
18
|
+
"perpetuals",
|
|
19
|
+
"perps",
|
|
20
|
+
"defi",
|
|
21
|
+
"trading",
|
|
22
|
+
"react",
|
|
23
|
+
"components",
|
|
24
|
+
"hooks"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"default": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/rewrite-dts-extensions.mjs dist",
|
|
49
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@solana/wallet-adapter-react": "^0.15.0",
|
|
55
|
+
"@solana/web3.js": "^1.95.0",
|
|
56
|
+
"react": ">=18"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@opp-oss/sdk": "^1.0.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@solana/wallet-adapter-base": "^0.9.23",
|
|
63
|
+
"@solana/wallet-adapter-react": "^0.15.35",
|
|
64
|
+
"@solana/web3.js": "^1.95.0",
|
|
65
|
+
"@types/react": "^18.3.0",
|
|
66
|
+
"react": "^18.3.1",
|
|
67
|
+
"typescript": "^5.6.0"
|
|
68
|
+
}
|
|
69
|
+
}
|