### Develop All Apps and Packages (Shell) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/README.md Navigate into the project directory and use pnpm to start the development servers or processes for all applications and packages in the Turborepo monorepo. ```sh cd my-turborepo pnpm dev ``` -------------------------------- ### Installing Splash Protocol SDK with npm Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Command to install the Splash Protocol SDK package using the npm package manager. ```npm npm install @splashprotocol/sdk ``` -------------------------------- ### Creating and Submitting Market Orders (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Demonstrates creating spot orders without specifying a price, which simulates a market order in the Splash Protocol SDK. Includes examples for buying SPLASH with ADA and selling SPLASH for ADA, followed by submitting the first order. ```typescript // Order buys splash for 5 ada usign actual price import {AssetInfo} from "@splashprotocol/core"; const splashAssetId = 'ececc92aeaaac1f5b665f567b01baec8bc2771804b4c21716a87a4e3.53504c415348'; const marketOrder = await builder .newTx({ input: Currency.ada(5000000n), outputAsset: AssetInfo.fromAssetId(splashAssetId) }) .spotOrder() .complete() // Order sells 5 splash usign actual price const marketOrder2 = await builder .newTx({ input: Currency.new( 5000000n, AssetInfo.fromAssetId(splashAssetId) ), outputAsset: AssetInfo.ada }) .spotOrder() .complete() // Submit order to chain const txId = await marketOrder.signAndSubmit(); ``` -------------------------------- ### Initializing Splash Protocol SDK and Wallet (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Demonstrates how to initialize the SplashApi, SplashExplorer, and SplashBuilder instances, and configure the builder to use a HotWallet derived from a seed phrase. This setup is suitable for both Node.js and browser environments (if WASM is supported). ```typescript const splashApi = SplashApi({ network: 'mainnet' }); const splashExplorer = SplashExplorer.new('mainnet'); const builder = SplashBuilder(splashApi, splashExplorer); builder.selectWallet(() => HotWallet.fromSeed('seed phrase', splashExplorer), ); ``` -------------------------------- ### Installing Splash Protocol SDK with yarn Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Command to add the Splash Protocol SDK package as a dependency using the yarn package manager. ```yarn yarn add @splashprotocol/sdk ``` -------------------------------- ### Initialize Turborepo Project (Shell) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/README.md Use the `create-turbo` CLI to initialize a new Turborepo monorepo project with the latest starter template. ```sh npx create-turbo@latest ``` -------------------------------- ### Build All Apps and Packages (Shell) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/README.md Navigate into the project directory and use pnpm to build all applications and packages defined within the Turborepo monorepo. ```sh cd my-turborepo pnpm build ``` -------------------------------- ### Creating and Submitting a Limit Order (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Shows how to use the `builder` to create a new transaction for a spot order with a specified limit price, input currency (ADA), and output asset (SPLASH), then signs and submits the transaction to the chain. ```typescript // Order buys splash for 5 ada usign 0.18 price const splashAssetId = 'ececc92aeaaac1f5b665f567b01baec8bc2771804b4c21716a87a4e3.53504c415348'; const limitOrder = await builder .newTx({ price: Price.new({ value: '0.18', base: AssetInfo.fromAssetId(splashAssetId), quote: AssetInfo.ada }), input: Currency.ada(5000000n), outputAsset: AssetInfo.fromAssetId(splashAssetId) }) .spotOrder() .complete() // Submit order to chain const txId = await limitOrder.signAndSubmit(); ``` -------------------------------- ### Authenticate Turborepo CLI with Vercel (Shell) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/README.md Navigate into the project directory and use the `turbo login` command to authenticate the Turborepo CLI with your Vercel account, enabling features like Remote Caching. ```sh cd my-turborepo npx turbo login ``` -------------------------------- ### Creating Market Order with Custom Slippage (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Illustrates how to create a spot order simulating a market order (by omitting price) and explicitly setting a custom slippage percentage using the `slippage` property in the configuration. ```typescript const splashAssetId = 'ececc92aeaaac1f5b665f567b01baec8bc2771804b4c21716a87a4e3.53504c415348'; // Order buys splash for 5 ada usign actual price with slippage 90% const marketOrder = await builder .newTx() .spotOrder({ slippage: 90, input: Currency.ada(5000000n), outputAsset: AssetInfo.fromAssetId(splashAssetId) }) .complete() ``` -------------------------------- ### Defining Spot Order Configuration Interface (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Defines the TypeScript interface `SpotOrderConfig` which specifies the required and optional properties for configuring a spot trade order, including input/output assets, price, maximum partial fills, and slippage. ```typescript export interface SpotOrderConfig { readonly input: Currency; // Input asset for a trade readonly outputAsset: AssetInfo; // Output asset that you aim to receive after the trade is executed readonly price?: Price; // The price of the base asset in a quote asset readonly maxStepCount?: bigint; // This is needed to specify how many times your order can be partially filled on-chain. After reaching this number of fill the order will be ignored by the execution engine readonly slippage?: number; } ``` -------------------------------- ### Link Turborepo to Remote Cache (Shell) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/README.md From the root of the Turborepo, use the `turbo link` command to link the project to a Remote Cache, typically hosted on Vercel, allowing cache sharing. ```sh npx turbo link ``` -------------------------------- ### Fetching Order Book for a Pair (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Demonstrates how to use the `getOrderBook` method from the `builder.api` instance to retrieve the order book data for a specified trading pair, identified by its base and quote assets. ```typescript const splashAssetId = 'ececc92aeaaac1f5b665f567b01baec8bc2771804b4c21716a87a4e3.53504c415348'; const splashAdaOb = await builder.api.getOrderBook({ base: AssetInfo.fromAssetId(splashAssetId), quote: AssetInfo.ada }); ``` -------------------------------- ### Creating Multiple Spot Orders in One Transaction (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md This snippet shows how to create multiple spot orders within a single Cardano transaction using the SDK's transaction builder. It chains multiple `spotOrder` calls, each specifying an ADA input amount and the desired output asset (SPLASH). The transaction is then completed, signed, and submitted. ```TypeScript const splashSubject = 'ececc92aeaaac1f5b665f567b01baec8bc2771804b4c21716a87a4e353504c415348'; const multipleOrders = await builder .newTx() .spotOrder({ input: Currency.ada(5000000n), outputAsset: AssetInfo.fromSubject(splashSubject) }) .spotOrder({ input: Currency.ada(6000000n), outputAsset: AssetInfo.fromSubject(splashSubject) }) .spotOrder({ input: Currency.ada(7000000n), outputAsset: AssetInfo.fromSubject(splashSubject) }) .complete(); const txId = await multipleOrders.signAndSubmit() ``` -------------------------------- ### Creating AssetInfo from Subject (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Shows how to use the `AssetInfo.fromSubject` static method from the `@splashprotocol/core` library to create an `AssetInfo` object using a subject string identifier instead of an asset ID. ```typescript import {AssetInfo} from "@splashprotocol/core"; const splashSubject = 'ececc92aeaaac1f5b665f567b01baec8bc2771804b4c21716a87a4e353504c415348'; const splash = AssetInfo.fromSubject(splashSubject); ``` -------------------------------- ### Estimating Price from Order Book (TypeScript) Source: https://github.com/splashprotocol/protocol-sdk/blob/main/packages/sdk/README.md Shows how to use the `selectEstimatedPrice` utility function with an order book, input currency amount, and price type ('average') to calculate an estimated execution price for a potential trade based on the current order book data. ```typescript const splashSubject = 'ececc92aeaaac1f5b665f567b01baec8bc2771804b4c21716a87a4e353504c415348'; const splashAdaOb = await builder.api.getOrderBook({ base: AssetInfo.fromSubject(splashSubject), quote: AssetInfo.ada }); // it returns estimated price for of splash for 10 ADA input const estimatedPrice = selectEstimatedPrice({ orderBook: splashAdaOb, input: Currency.ada(10000000n), priceType: 'average' }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.