diff --git a/docs/docs/how-to/swap/create-swap.md b/docs/docs/how-to/swap/create-swap.md new file mode 100644 index 0000000000..3df07ad7f0 --- /dev/null +++ b/docs/docs/how-to/swap/create-swap.md @@ -0,0 +1,48 @@ +--- +title: Create Swap +tags: + - how-to + - swap + - nft + - token +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import DeepLink from '../../_admonitions/_deep_link.md' + + + + To create a swap order, you must call [`create`](../../reference-api/classes/SwapOtrDataset.md#create) on `dataset(Dataset.SWAP)`. + [`create`](../../reference-api/classes/SwapOtrDataset.md#create) takes an object of type [`SwapCreateTangleRequest`](../../reference-api/interfaces/SwapCreateTangleRequest.md) as parameter, in which you can specify the recipient, native tokens, NFTs and base token you are interested in. + + ```tsx file=../../../../packages/sdk/examples/swap/otr/create.ts#L21-L27 + ``` + + + + + To create a swap order, you must call [`create`](../../reference-api/classes/SwapDataset.md#create) on `dataset(Dataset.SWAP)`. + [`create`](../../reference-api/classes/SwapDataset.md#create) takes an object of type [`SwapCreateRequest`](../../reference-api/interfaces/SwapCreateRequest.md) as parameter, in which you can specify the recipient, native tokens, NFTs and base token you are interested in. + + ```tsx file=../../../../packages/sdk/examples/swap/https/create.ts#L14-L29 + ``` + + afterwards you need to fund a specific address: + + ```tsx file=../../../../packages/sdk/examples/swap/https/create.ts#L31 + ``` + + and set the order as funded: + + ```tsx file=../../../../packages/sdk/examples/swap/https/create.ts#L35-L46 + ``` + + + + +:::info setFunded + +With `setFunded`, you can specify if you, as the bidder, are giving your final bid or keeping it open. + +::: diff --git a/docs/sidebars.js b/docs/sidebars.js index ba385a6d23..42c8ce53da 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -66,6 +66,11 @@ const sidebars = { 'how-to/nft/transfer', ], }, + { + 'Swap': [ + 'how-to/swap/create-swap', + ] + }, { 'Stamp API': [ 'how-to/stamp/create-stamp', diff --git a/packages/sdk/examples/swap/https/create.ts b/packages/sdk/examples/swap/https/create.ts index 6e16894294..7b10b243fb 100644 --- a/packages/sdk/examples/swap/https/create.ts +++ b/packages/sdk/examples/swap/https/create.ts @@ -28,7 +28,8 @@ async function main() { }, }); - console.log('Send bids to swap order address', response.payload.targetAddress); + const targetAddress = response.payload.targetAddress; + console.log('Send bids to swap order address', targetAddress); console.log('Once bids are sent mark the swap as funded.'); await https(origin)