Algodex Documentation
  • Algodex Documentation
  • Algodex
    • Algodex FAQ
    • Trading Guide
    • Trading Bot Guide
    • Token Listing Guide
  • Algodex Mailbox
    • Mailbox FAQ
    • Mailbox User Guide
  • Rewards Program
    • ALGX Liquidity Rewards Program
    • Community Leadership
    • ALGX Tokenomics
  • Developer Tools
    • Algodex SDK v2
      • Tutorial : Placing Orders
      • Tutorial: Order book
      • Tutorial: Closing Orders
    • Algodex API v1
  • Archives
    • Algodex Whitepaper v1
    • ALGX Airdrop Plan
    • Testnet Liquidity Rewards
  • App Links
    • Algodex
    • Algodex Mailbox
    • Rewards
    • Support
  • social media links
    • REDDIT
    • TWITTER
    • DISCORD
    • TELEGRAM
    • GITHUB
Powered by GitBook
On this page
  • Steps
  • Order Executions
  • Maker Order
  • What is a Maker Order?
  • Condition
  • Walkthrough
  • Taker Order
  • What is a Taker Order?
  • Condition
  • Walkthrough
  • Maker/Taker Order
  • Advanced
  1. Developer Tools
  2. Algodex SDK v2

Tutorial : Placing Orders

PreviousAlgodex SDK v2NextTutorial: Order book

Last updated 2 years ago

You can think of as a toolbox: it's got everything you need to tackle order execution.

Steps

  1. Create a new instance of the .

  2. Set a default using .

  3. Generate an compatible object.

  4. Pass in the object to .

Order Executions

If you are unsure of which execution type to choose input execution:'both' and we'll handle the rest!

Details:

The object has an execution key that determines how the SDK will handle the . Each execution will interact with the in different ways. Algodex supports the following executions: , , .

Maker Order

A Maker Order will always be placed into the . They can be either Buy or Sell order types.

What is a Maker Order?

A Maker Order is an order that does not execute instantly. A maker order has no active takers, therefore it "makes" its own order to be fulfilled at a later date.

Condition

When a user places an order, if no one immediately agrees to the terms of the order, the order is considered a Maker Order.

Walkthrough

  1. The order is now visible to other users of Algodex and will be fulfilled when another user agrees to "take" the order.

Buy Order [JavaScript]

//Buy Example:
const res = await api.placeOrder({
'asset': {
  'id': 15322902,
  'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 3.22, // Limit price for the asset
'amount': 1, // Amount willing to purchase (The total amount sent will be price * amount)
'execution': 'maker',
'type': 'buy',
});

Sell Order [JavaScript]

// Sell Example:
const res = await api.placeOrder({
  'asset': {
    'id': 15322902,
    'decimals': 6,
  },
  'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
  'price': 80000, // Limit price for the asset to sell
  'amount': 1, // Amount of the asset for sale
  'execution': 'maker',
  'type': 'sell',
});

Taker Order

What is a Taker Order?

Condition

There must be at least one existing order in the order book that fulfills the user's criteria. Therefore, the user "takes" from an existing order.

Walkthrough

The user submitted order changes the state of the Order book in 1 of 3 ways:

  1. The user does not "take" the entire order. The remainder of the order remains open.

  2. The user takes the entire order removing it from the order book.

  3. The user takes multiple orders, removing them from the order book.

Buy Order [JavaScript]

// Buy Example
const res = await api.placeOrder({
  'asset': {
    'id': 15322902,
    'decimals': 6,
  },
  'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
  'price': 3.22,
  'amount': 1,
  'execution': 'taker',
  'type': 'buy',
});

Sell Order [JavaScript]

// Sell Example
const res = await api.placeOrder({
  'asset': {
    'id': 15322902,
    'decimals': 6,
  },
  'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
  'price': 80000,
  'amount': 1,
  'execution': 'taker',
  'type': 'sell',
});

Maker/Taker Order

Buy Order [JavaScript]

  const res = await api.placeOrder({
    'asset': {
      'id': 15322902,
      'decimals': 6,
    },
    'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
    'price': 3.22,
    'amount': 1,
    'execution': 'both',
    'type': 'buy',
  });

Sell Order [JavaScript]

  const res = await api.placeOrder({
    'asset': {
      'id': 15322902,
      'decimals': 6,
    },
    'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
    'price': 80000,
    'amount': 1,
    'execution': 'both',
    'type': 'sell',
  });

Advanced

There are multiple ways to place an order using our SDK.

Some users find it clunky to lug around a toolbox if they only need one or two tools.

There are no existing orders in the that fulfill the user's criteria so they decide to "make" their own order.

The users submitted order is added to the .

A Taker Order will always execute existing orders in the . They can be either Buy or Sell order types.

A Taker Order is an order that executes instantly. A taker order closes or modifies an existing order in the .

Maker/Taker will first check the for existing orders that match the current order.

If you are curious about the internal processes of placing an order and how they relate to the different execution types, the is a great place to start.

If that sounds like you, we recommend checking out the & modules to get a better sense of what methods fit your use case.

Algodex Order book
Algodex Order book
Order book
Algodex Order book
Order book
Structure Module
Buy
Sell
AlgodexApi#placeOrder
AlgodexApi
Wallet
AlgodexApi#setWallet
Order
Order
AlgodexApi#placeOrder
Order
Order
Order book
Order book
Maker
Taker
Both