UNPKG

@bancor/carbon-sdk

Version:

The SDK is a READ-ONLY tool, intended to facilitate working with Carbon contracts. It's a convenient wrapper around our matching algorithm, allowing programs and users get a ready to use transaction data that will allow them to manage strategies and fulfi

2 lines (1 loc) 459 B
"use strict";const r=(r,e)=>r.localeCompare(e),e=r=>{if(2!==r.length)throw new Error(`Invalid number of tokens: expected 2, got ${r.length}`);if(r[0]===r[1])throw new Error(`Cannot create key for identical tokens: ${r[0]}`);return r.join("_")};exports.fromPairKey=r=>{const e=r.split("_");return[e[0],e[1]]},exports.isOrderTradable=function(r){return r.y>0n&&(r.A>0n||r.B>0n)},exports.toDirectionKey=(r,t)=>e([r,t]),exports.toPairKey=(t,o)=>e([t,o].sort(r));