diff --git a/code/openbook/adding-liquidity/adding-liquidity.en.ts b/code/openbook/adding-liquidity/adding-liquidity.en.ts new file mode 100644 index 000000000..212cd4389 --- /dev/null +++ b/code/openbook/adding-liquidity/adding-liquidity.en.ts @@ -0,0 +1,7 @@ +// Example TypeScript code for adding liquidity on OpenBook +const liquidity = await OpenBook.addLiquidity({ + pool: "BTC/USDC", + amountA: 10, + amountB: 10000, +}); +console.log("Liquidity added:", liquidity); diff --git a/code/openbook/adding-liquidity/adding-liquidity.preview.en.ts b/code/openbook/adding-liquidity/adding-liquidity.preview.en.ts new file mode 100644 index 000000000..97b08e365 --- /dev/null +++ b/code/openbook/adding-liquidity/adding-liquidity.preview.en.ts @@ -0,0 +1,5 @@ +const liquidity = await OpenBook.addLiquidity({ + pool: "BTC/USDC", + amountA: 10, + amountB: 10000, +}); diff --git a/code/openbook/connecting-solana/connecting-solana.en.ts b/code/openbook/connecting-solana/connecting-solana.en.ts new file mode 100644 index 000000000..f0f7b87e6 --- /dev/null +++ b/code/openbook/connecting-solana/connecting-solana.en.ts @@ -0,0 +1,4 @@ +import { Connection } from "@solana/web3.js"; + +const connection = new Connection("https://api.mainnet-beta.solana.com"); +console.log("Connected to Solana"); diff --git a/code/openbook/connecting-solana/connecting-solana.preview.en.ts b/code/openbook/connecting-solana/connecting-solana.preview.en.ts new file mode 100644 index 000000000..36527a4ba --- /dev/null +++ b/code/openbook/connecting-solana/connecting-solana.preview.en.ts @@ -0,0 +1 @@ +const connection = new Connection("https://api.mainnet-beta.solana.com"); diff --git a/code/openbook/executing-trades/executing-trades.en.ts b/code/openbook/executing-trades/executing-trades.en.ts new file mode 100644 index 000000000..e3da8973c --- /dev/null +++ b/code/openbook/executing-trades/executing-trades.en.ts @@ -0,0 +1,5 @@ +import { OpenBook } from "openbook-library"; // Replace with the correct import + +// Example TypeScript code for executing a trade on OpenBook +const trade = await OpenBook.executeTrade(order); +console.log("Trade executed:", trade); diff --git a/code/openbook/executing-trades/executing-trades.preview.en.ts b/code/openbook/executing-trades/executing-trades.preview.en.ts new file mode 100644 index 000000000..a1bde6766 --- /dev/null +++ b/code/openbook/executing-trades/executing-trades.preview.en.ts @@ -0,0 +1 @@ +const trade = await OpenBook.executeTrade(order); diff --git a/code/openbook/placing-order/placing-order.en.ts b/code/openbook/placing-order/placing-order.en.ts new file mode 100644 index 000000000..7d3270ec6 --- /dev/null +++ b/code/openbook/placing-order/placing-order.en.ts @@ -0,0 +1,10 @@ +import { OpenBook } from "openbook-library"; // Replace with the correct import + +// Example TypeScript code for placing an order on OpenBook +const order = await OpenBook.placeOrder({ + market: "BTC/USDC", + side: "buy", + price: 45000, + quantity: 0.1, +}); +console.log("Order placed:", order); diff --git a/code/openbook/placing-order/placing-order.preview.en.ts b/code/openbook/placing-order/placing-order.preview.en.ts new file mode 100644 index 000000000..fc52921d9 --- /dev/null +++ b/code/openbook/placing-order/placing-order.preview.en.ts @@ -0,0 +1,6 @@ +const order = await OpenBook.placeOrder({ + market: "BTC/USDC", + side: "buy", + price: 45000, + quantity: 0.1, +}); diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index ee2172ce4..2cd3b5804 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -109,7 +109,8 @@ export default defineUserConfig({ text: "Integrations", children: [ "/integrations", - "/integrations/serum.md", + //"/integrations/serum.md", + "/integrations/openbook.md", "/integrations/pyth.md", "/integrations/switchboard.md", "/integrations/mango.md", diff --git a/docs/integrations/openbook.md b/docs/integrations/openbook.md new file mode 100644 index 000000000..b09206f8f --- /dev/null +++ b/docs/integrations/openbook.md @@ -0,0 +1,168 @@ +--- +title: OpenBook +head: + - - meta + - name: title + content: Solana Cookbook | Building on OpenBook + - - meta + - name: og:title + content: Solana Cookbook | Building on OpenBook + - - meta + - name: description + content: OpenBook is an innovative DEX on Solana. Learn how to use and build on top of OpenBook. + - - meta + - name: og:description + content: OpenBook is an innovative DEX on Solana. Learn how to use and build on top of OpenBook. + - - meta + - name: og:image + content: https://solanacookbook.com/cookbook-sharing-card.png + - - meta + - name: og:image:alt + content: Solana splash card + - - meta + - name: twitter:card + content: summary + - - meta + - name: twitter:site + content: "@solanacookbook" + - - meta + - name: twitter:image + content: "https://solanacookbook.com/cookbook-sharing-card.png" + - - meta + - name: robots + content: index,follow,noodp + - - meta + - name: googlebot + content: index,follow +--- + +# OpenBook + +OpenBook is a decentralized exchange (DEX) built on Solana. You can use OpenBook to trade various tokens, provide liquidity, and access decentralized finance (DeFi) services on the Solana blockchain. + +## Prerequisites + +Before diving into OpenBook integration, ensure you have the following: + +- A Solana wallet. +- SOL tokens for transaction fees. +- OpenBook tokens for trading. + +## Getting Started + +### Connecting to Solana + +To begin, you need to connect your Solana wallet to the Solana blockchain. Ensure your wallet is properly configured. + + + + + + + + + + + + +### Depositing Funds + +Deposit the tokens you intend to trade into your Solana wallet. + +## Trading on OpenBook + +### Selecting a Market + +Choose the market and trading pair you want to trade. OpenBook offers a variety of markets; make sure to select the one that suits your trading needs. + +### Placing an Order +Place a buy or sell order with the desired price and quantity. Below is an example in TypeScript: + + + + + + + + + + + + +### Executing Trades + +Confirm and execute the trade using the following TypeScript code: + + + + + + + + + + + + +## Providing Liquidity + +If you wish to provide liquidity to OpenBook's liquidity pools, follow these steps: + +### Selecting a Liquidity Pool + +Choose a liquidity pool that you want to contribute assets to. + +### Adding Liquidity + +Deposit equal amounts of two tokens into the selected pool. Here's an example in TypeScript: + + + + + + + + + + + + +## Building on OpenBook + +Developers can extend the functionality of OpenBook by accessing the OpenBook API and documentation on the [OpenBook Developer Portal](https://openbook.dev/). + +## Conclusion + +OpenBook offers a decentralized and efficient way to trade and participate in DeFi on the Solana blockchain. Explore the platform, try out trading, or contribute to its ecosystem as a developer. \ No newline at end of file