Skip to content

Commit

Permalink
Merge pull request #8 from clober-dex/feat/return-values
Browse files Browse the repository at this point in the history
Feat/return values
  • Loading branch information
graykode authored Apr 15, 2024
2 parents 68df9d6 + 27dd48a commit d2a517d
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 101 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clober/v2-sdk",
"version": "0.0.4",
"version": "0.0.5",
"description": "🛠 An SDK for building applications on top of Clober V2",
"files": [
"dist"
Expand Down
3 changes: 1 addition & 2 deletions src/apis/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { CONTRACT_ADDRESSES } from '../constants/addresses'
import { cachedPublicClients } from '../constants/client'
import { BOOK_VIEWER_ABI } from '../abis/core/book-viewer-abi'
import { fetchIsOpened } from '../utils/open'

import { fetchCurrency } from './currency'
import { fetchCurrency } from '../utils/currency'

const getBook = async (
chainId: CHAIN_IDS,
Expand Down
11 changes: 7 additions & 4 deletions src/apis/open-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { formatUnits, getAddress, isAddressEqual } from 'viem'

import { CHAIN_IDS } from '../constants/chain'
import { getMarketId } from '../utils/market'
import { Currency } from '../model/currency'
import type { Currency } from '../model/currency'
import { quoteToBase } from '../utils/decimals'
import { formatPrice } from '../utils/prices'
import { invertPrice, toPrice } from '../utils/tick'
import { OpenOrder, OpenOrderDto } from '../model/open-order'
import type { OpenOrder, OpenOrderDto } from '../model/open-order'
import { fetchCurrency } from '../utils/currency'

import { fetchCurrency } from './currency'
import { fetchSubgraph } from './subgraph'

const getOpenOrder = async (chainId: CHAIN_IDS, orderId: string) => {
Expand Down Expand Up @@ -139,6 +139,9 @@ const toOpenOrder = (
currency: outputCurrency,
value: formatUnits(claimable, outputCurrency.decimals),
},
cancelable: rawAmount > rawFilledAmount,
cancelable: {
currency: outputCurrency,
value: formatUnits(amount - filled, base.decimals),
},
}
}
Loading

0 comments on commit d2a517d

Please sign in to comment.