@gardenfi/core 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/src/lib/garden.d.ts +22 -3
- package/dist/src/lib/garden.types.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("ethers"),c=require("@gardenfi/orderbook"),u=require("@catalogfi/utils"),g=async(e,t,r,s)=>{const i=r[e],a=r[t];if(!a)throw new Error(`No ${e} wallet found`);if(!i)throw new Error(`No ${t} wallet found`);let d;if(w(e)){const o=h.sha256(u.with0x(Buffer.from("catalog.js"+s+await a.getAddress()).toString("hex"))).slice(2);d=await i.sign(o)}else{const o=h.sha256(u.with0x(Buffer.from("catalog.js"+s+await i.getAddress()).toString("hex"))).slice(2);d=await a.sign(o)}return u.trim0x(h.sha256(u.with0x(d)))},w=e=>e==="bitcoin"||e==="bitcoin_testnet"||e==="bitcoin_regtest",m={WALLET_NOT_FOUND:e=>`${e?"from":"to"} wallet not found`,CHAIN_WALLET_NOT_FOUND:e=>`no ${e} wallet found`},p={NO_ACTION:"no actions can be performed in this state",NO_SECRET:"secret not found in order",INVALID_ACTION:(e,t)=>`can not ${e} on status: ${t}`};class _{constructor(t,r){this.order=t,this.wallets=r}get action(){return c.parseStatus(this.order)}get status(){return+`${this.order.status}${this.order.initiatorAtomicSwap.swapStatus}${this.order.followerAtomicSwap.swapStatus}`}async next(){switch(v[this.action]){case"Initiate":return await this.init();case"Redeem":return await this.redeem();case"Refund":return await this.refund();default:return L}}async init(){switch(this.action){case c.Actions.UserCanInitiate:{const t=this.wallets[this.order.initiatorAtomicSwap.chain];if(!t)throw new Error(`No ${this.order.initiatorAtomicSwap.chain} wallet found`);return{user:"initiator",action:"Initiate",output:await(await l(t,this.order,"native",this.order.initiatorAtomicSwap.asset)).init()}}case c.Actions.CounterpartyCanInitiate:{const t=this.wallets[this.order.followerAtomicSwap.chain];if(!t)throw new Error(`No ${this.order.followerAtomicSwap.chain} wallet`);return{user:"redeemer",action:"Initiate",output:await(await l(t,this.order,"foreign",this.order.followerAtomicSwap.asset)).init()}}default:throw new Error(p.INVALID_ACTION("init",this.status))}}async redeem(){const t=this.getWallet(this.order.followerAtomicSwap.chain),r=this.getWallet(this.order.initiatorAtomicSwap.chain);switch(this.action){case c.Actions.UserCanRedeem:{const s=await l(t,this.order,"foreign",this.order.followerAtomicSwap.asset),i=await g(this.order.initiatorAtomicSwap.chain,this.order.followerAtomicSwap.chain,this.wallets,this.order.secretNonce);return{user:"initiator",action:"Redeem",output:await s.redeem(i,this.order.userBtcWalletAddress)}}case c.Actions.CounterpartyCanRedeem:{if(!this.order.secret)throw new Error("Secret not found in order");return{user:"redeemer",action:"Redeem",output:await(await l(r,this.order,"native",this.order.initiatorAtomicSwap.asset)).redeem(this.order.secret)}}default:throw new Error(p.INVALID_ACTION("redeem",this.status))}}async refund(){const t=this.getWallet(this.order.initiatorAtomicSwap.chain),r=this.getWallet(this.order.followerAtomicSwap.chain);if(this.order.initiatorAtomicSwap.swapStatus===3)return{user:"initiator",action:"Refund",output:await(await l(t,this.order,"native",this.order.initiatorAtomicSwap.asset)).refund(this.order.userBtcWalletAddress)};if(this.order.followerAtomicSwap.swapStatus===3)return{user:"redeemer",action:"Refund",output:await(await l(r,this.order,"foreign",this.order.followerAtomicSwap.asset)).refund(this.order.userBtcWalletAddress)};throw new Error(p.INVALID_ACTION("refund",this.status))}id(){throw new Error("Method not implemented.")}getWallet(t){const r=this.wallets[t];if(!r)throw new Error(`No ${t} wallet found`);return r}}const l=async(e,t,r,s)=>{const i=r==="native"?t.initiatorAtomicSwap:t.followerAtomicSwap;return e.newSwap({recipientAddress:i.redeemerAddress,refundAddress:i.initiatorAddress,initiatorAddress:i.initiatorAddress,chain:c.chainToId[i.chain],expiryBlocks:+i.timelock,secretHash:t.secretHash,amount:+i.amount,contractAddress:s})};var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("ethers"),c=require("@gardenfi/orderbook"),u=require("@catalogfi/utils"),g=async(e,t,r,s)=>{const i=r[e],a=r[t];if(!a)throw new Error(`No ${e} wallet found`);if(!i)throw new Error(`No ${t} wallet found`);let d;if(w(e)){const o=h.sha256(u.with0x(Buffer.from("catalog.js"+s+await a.getAddress()).toString("hex"))).slice(2);d=await i.sign(o)}else{const o=h.sha256(u.with0x(Buffer.from("catalog.js"+s+await i.getAddress()).toString("hex"))).slice(2);d=await a.sign(o)}return u.trim0x(h.sha256(u.with0x(d)))},w=e=>e==="bitcoin"||e==="bitcoin_testnet"||e==="bitcoin_regtest",m={WALLET_NOT_FOUND:e=>`${e?"from":"to"} wallet not found`,CHAIN_WALLET_NOT_FOUND:e=>`no ${e} wallet found`},p={NO_ACTION:"no actions can be performed in this state",NO_SECRET:"secret not found in order",INVALID_ACTION:(e,t)=>`can not ${e} on status: ${t}`};class _{constructor(t,r){this.order=t,this.wallets=r}get action(){return c.parseStatus(this.order)}get status(){return+`${this.order.status}${this.order.initiatorAtomicSwap.swapStatus}${this.order.followerAtomicSwap.swapStatus}`}async next(){switch(v[this.action]){case"Initiate":return await this.init();case"Redeem":return await this.redeem();case"Refund":return await this.refund();default:return L}}async init(){switch(this.action){case c.Actions.UserCanInitiate:{const t=this.wallets[this.order.initiatorAtomicSwap.chain];if(!t)throw new Error(`No ${this.order.initiatorAtomicSwap.chain} wallet found`);return{user:"initiator",action:"Initiate",output:await(await l(t,this.order,"native",this.order.initiatorAtomicSwap.asset)).init()}}case c.Actions.CounterpartyCanInitiate:{const t=this.wallets[this.order.followerAtomicSwap.chain];if(!t)throw new Error(`No ${this.order.followerAtomicSwap.chain} wallet`);return{user:"redeemer",action:"Initiate",output:await(await l(t,this.order,"foreign",this.order.followerAtomicSwap.asset)).init()}}default:throw new Error(p.INVALID_ACTION("init",this.status))}}async redeem(){const t=this.getWallet(this.order.followerAtomicSwap.chain),r=this.getWallet(this.order.initiatorAtomicSwap.chain);switch(this.action){case c.Actions.UserCanRedeem:{const s=await l(t,this.order,"foreign",this.order.followerAtomicSwap.asset),i=await g(this.order.initiatorAtomicSwap.chain,this.order.followerAtomicSwap.chain,this.wallets,this.order.secretNonce);return{user:"initiator",action:"Redeem",output:await s.redeem(i,this.order.userBtcWalletAddress)}}case c.Actions.CounterpartyCanRedeem:{if(!this.order.secret)throw new Error("Secret not found in order");return{user:"redeemer",action:"Redeem",output:await(await l(r,this.order,"native",this.order.initiatorAtomicSwap.asset)).redeem(this.order.secret)}}default:throw new Error(p.INVALID_ACTION("redeem",this.status))}}async refund(){const t=this.getWallet(this.order.initiatorAtomicSwap.chain),r=this.getWallet(this.order.followerAtomicSwap.chain);if(this.order.initiatorAtomicSwap.swapStatus===3)return{user:"initiator",action:"Refund",output:await(await l(t,this.order,"native",this.order.initiatorAtomicSwap.asset)).refund(this.order.userBtcWalletAddress)};if(this.order.followerAtomicSwap.swapStatus===3)return{user:"redeemer",action:"Refund",output:await(await l(r,this.order,"foreign",this.order.followerAtomicSwap.asset)).refund(this.order.userBtcWalletAddress)};throw new Error(p.INVALID_ACTION("refund",this.status))}id(){throw new Error("Method not implemented.")}getWallet(t){const r=this.wallets[t];if(!r)throw new Error(`No ${t} wallet found`);return r}}const l=async(e,t,r,s)=>{const i=r==="native"?t.initiatorAtomicSwap:t.followerAtomicSwap;return e.newSwap({recipientAddress:i.redeemerAddress,refundAddress:i.initiatorAddress,initiatorAddress:i.initiatorAddress,chain:c.chainToId[i.chain],expiryBlocks:+i.timelock,secretHash:t.secretHash,amount:+i.amount,contractAddress:s})};var N=(e=>(e.INITIATOR="initiator",e.REDEEMER="redeemer",e))(N||{}),I=(e=>(e.Init="Initiate",e.Redeem="Redeem",e.Refund="Refund",e.None="None",e))(I||{});const v={[c.Actions.UserCanInitiate]:"Initiate",[c.Actions.CounterpartyCanInitiate]:"Initiate",[c.Actions.UserCanRedeem]:"Redeem",[c.Actions.CounterpartyCanRedeem]:"Redeem",[c.Actions.UserCanRefund]:"Refund",[c.Actions.CounterpartyCanRefund]:"Refund",[c.Actions.NoAction]:"None"},L={user:"initiator",action:"None",output:""};class U{constructor(t){if(t)this.extensionId=t.id;else if($())this.extensionId=S("chrome");else if(E())this.extensionId=S("window");else throw new Error("Catalog wallet extension not found")}send(t,r){return new Promise((s,i)=>{const a={url:"",favicon:""},d=window.location.href.split("://")[1].replace(/\/$/,"");a.url=d;let o=document.querySelector("link[rel='icon']");if(o||(o=document.querySelector("link[rel='shortcut icon']")),o||(o=document.querySelector("link[rel='apple-touch-icon']")),o||(o=document.querySelector("meta[property='og:image']")),o)a.favicon=o instanceof HTMLMetaElement?o.content:o.href;else{const n=new URL(window.location.href);a.favicon=`${n.protocol}//${n.hostname}/favicon.ico`}chrome.runtime.sendMessage(this.extensionId,{method:t,params:r,metadata:a},n=>chrome.runtime.lastError?i(chrome.runtime.lastError):typeof n=="object"&&n&&"error"in n?i(n.error):s(n))})}}const E=()=>{try{const e=window;return e&&e.catalog&&e.catalog.id}catch{return!1}},S=e=>{if(e==="chrome")return chrome.runtime.id;if(e==="window")return window.catalog.id;throw new Error("Invalid medium to get wallet id")},$=()=>{try{return chrome&&!!chrome.runtime&&!!chrome.runtime.id}catch{return!1}},O={createOrderAndSwap:"createOrderAndSwap"};class x{constructor(t,r){this.orderbook=t,this.wallets=r}subscribeOrders(t,r){this.orderbook.subscribeOrders(t,r)}unsubscribeOrders(){return this.orderbook.unsubscribeOrders()}async swap(t,r,s,i,a){if(E()){const T=await new U().send(O.createOrderAndSwap,{from:t,to:r,amt:s,receiveAmount:i,opts:a});return Number(T)}const d=this.wallets[t.chain],o=this.wallets[r.chain];if(!d)throw new Error(m.WALLET_NOT_FOUND(!0));if(!o)throw new Error(m.WALLET_NOT_FOUND(!1));D(t.chain,r.chain),(a&&!a.btcUserAddress||!a)&&(a=a||{},a.btcUserAddress=await this.wallets[w(t.chain)?t.chain:r.chain].getAddress());const n=w(t.chain),A=n?o:d,f=n?d:o,W=await A.getAddress(),b=await this.orderbook.getOrders(W),R=n?await f.getAddress():await A.getAddress(),C=n?await A.getAddress():await f.getAddress(),y=await g(t.chain,r.chain,this.wallets,b.length+1);return this.orderbook.createOrder({fromAsset:t,toAsset:r,sendAmount:s.toString(),receiveAmount:i.toString(),receiveAddress:C,sendAddress:R,secretHash:h.sha256(u.with0x(y)),btcInputAddress:a.btcUserAddress??await f.getAddress()})}getSwap(t){return new _(t,this.wallets)}calculateReceiveAmt(t,r,s){return Promise.resolve(s-s*.03)}}const D=(e,t)=>{if(w(e)===w(t))throw new Error(w(e)?m.CHAIN_WALLET_NOT_FOUND("Bitcoin"):m.CHAIN_WALLET_NOT_FOUND("EVM"))};exports.GardenJS=x;exports.SwapperActions=I;exports.SwapperRole=N;exports.catalogWalletActions=O;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sha256 as
|
|
1
|
+
import{sha256 as l}from"ethers";import{Actions as c,parseStatus as L,chainToId as v}from"@gardenfi/orderbook";import{with0x as u,trim0x as U}from"@catalogfi/utils";const S=async(e,t,r,a)=>{const i=r[e],s=r[t];if(!s)throw new Error(`No ${e} wallet found`);if(!i)throw new Error(`No ${t} wallet found`);let d;if(w(e)){const o=l(u(Buffer.from("catalog.js"+a+await s.getAddress()).toString("hex"))).slice(2);d=await i.sign(o)}else{const o=l(u(Buffer.from("catalog.js"+a+await i.getAddress()).toString("hex"))).slice(2);d=await s.sign(o)}return U(l(u(d)))},w=e=>e==="bitcoin"||e==="bitcoin_testnet"||e==="bitcoin_regtest",m={WALLET_NOT_FOUND:e=>`${e?"from":"to"} wallet not found`,CHAIN_WALLET_NOT_FOUND:e=>`no ${e} wallet found`},p={NO_ACTION:"no actions can be performed in this state",NO_SECRET:"secret not found in order",INVALID_ACTION:(e,t)=>`can not ${e} on status: ${t}`};class W{constructor(t,r){this.order=t,this.wallets=r}get action(){return L(this.order)}get status(){return+`${this.order.status}${this.order.initiatorAtomicSwap.swapStatus}${this.order.followerAtomicSwap.swapStatus}`}async next(){switch($[this.action]){case"Initiate":return await this.init();case"Redeem":return await this.redeem();case"Refund":return await this.refund();default:return x}}async init(){switch(this.action){case c.UserCanInitiate:{const t=this.wallets[this.order.initiatorAtomicSwap.chain];if(!t)throw new Error(`No ${this.order.initiatorAtomicSwap.chain} wallet found`);return{user:"initiator",action:"Initiate",output:await(await h(t,this.order,"native",this.order.initiatorAtomicSwap.asset)).init()}}case c.CounterpartyCanInitiate:{const t=this.wallets[this.order.followerAtomicSwap.chain];if(!t)throw new Error(`No ${this.order.followerAtomicSwap.chain} wallet`);return{user:"redeemer",action:"Initiate",output:await(await h(t,this.order,"foreign",this.order.followerAtomicSwap.asset)).init()}}default:throw new Error(p.INVALID_ACTION("init",this.status))}}async redeem(){const t=this.getWallet(this.order.followerAtomicSwap.chain),r=this.getWallet(this.order.initiatorAtomicSwap.chain);switch(this.action){case c.UserCanRedeem:{const a=await h(t,this.order,"foreign",this.order.followerAtomicSwap.asset),i=await S(this.order.initiatorAtomicSwap.chain,this.order.followerAtomicSwap.chain,this.wallets,this.order.secretNonce);return{user:"initiator",action:"Redeem",output:await a.redeem(i,this.order.userBtcWalletAddress)}}case c.CounterpartyCanRedeem:{if(!this.order.secret)throw new Error("Secret not found in order");return{user:"redeemer",action:"Redeem",output:await(await h(r,this.order,"native",this.order.initiatorAtomicSwap.asset)).redeem(this.order.secret)}}default:throw new Error(p.INVALID_ACTION("redeem",this.status))}}async refund(){const t=this.getWallet(this.order.initiatorAtomicSwap.chain),r=this.getWallet(this.order.followerAtomicSwap.chain);if(this.order.initiatorAtomicSwap.swapStatus===3)return{user:"initiator",action:"Refund",output:await(await h(t,this.order,"native",this.order.initiatorAtomicSwap.asset)).refund(this.order.userBtcWalletAddress)};if(this.order.followerAtomicSwap.swapStatus===3)return{user:"redeemer",action:"Refund",output:await(await h(r,this.order,"foreign",this.order.followerAtomicSwap.asset)).refund(this.order.userBtcWalletAddress)};throw new Error(p.INVALID_ACTION("refund",this.status))}id(){throw new Error("Method not implemented.")}getWallet(t){const r=this.wallets[t];if(!r)throw new Error(`No ${t} wallet found`);return r}}const h=async(e,t,r,a)=>{const i=r==="native"?t.initiatorAtomicSwap:t.followerAtomicSwap;return e.newSwap({recipientAddress:i.redeemerAddress,refundAddress:i.initiatorAddress,initiatorAddress:i.initiatorAddress,chain:v[i.chain],expiryBlocks:+i.timelock,secretHash:t.secretHash,amount:+i.amount,contractAddress:a})};var g=(e=>(e.INITIATOR="initiator",e.REDEEMER="redeemer",e))(g||{}),N=(e=>(e.Init="Initiate",e.Redeem="Redeem",e.Refund="Refund",e.None="None",e))(N||{});const $={[c.UserCanInitiate]:"Initiate",[c.CounterpartyCanInitiate]:"Initiate",[c.UserCanRedeem]:"Redeem",[c.CounterpartyCanRedeem]:"Redeem",[c.UserCanRefund]:"Refund",[c.CounterpartyCanRefund]:"Refund",[c.NoAction]:"None"},x={user:"initiator",action:"None",output:""};class D{constructor(t){if(t)this.extensionId=t.id;else if(k())this.extensionId=E("chrome");else if(I())this.extensionId=E("window");else throw new Error("Catalog wallet extension not found")}send(t,r){return new Promise((a,i)=>{const s={url:"",favicon:""},d=window.location.href.split("://")[1].replace(/\/$/,"");s.url=d;let o=document.querySelector("link[rel='icon']");if(o||(o=document.querySelector("link[rel='shortcut icon']")),o||(o=document.querySelector("link[rel='apple-touch-icon']")),o||(o=document.querySelector("meta[property='og:image']")),o)s.favicon=o instanceof HTMLMetaElement?o.content:o.href;else{const n=new URL(window.location.href);s.favicon=`${n.protocol}//${n.hostname}/favicon.ico`}chrome.runtime.sendMessage(this.extensionId,{method:t,params:r,metadata:s},n=>chrome.runtime.lastError?i(chrome.runtime.lastError):typeof n=="object"&&n&&"error"in n?i(n.error):a(n))})}}const I=()=>{try{const e=window;return e&&e.catalog&&e.catalog.id}catch{return!1}},E=e=>{if(e==="chrome")return chrome.runtime.id;if(e==="window")return window.catalog.id;throw new Error("Invalid medium to get wallet id")},k=()=>{try{return chrome&&!!chrome.runtime&&!!chrome.runtime.id}catch{return!1}},O={createOrderAndSwap:"createOrderAndSwap"};class B{constructor(t,r){this.orderbook=t,this.wallets=r}subscribeOrders(t,r){this.orderbook.subscribeOrders(t,r)}unsubscribeOrders(){return this.orderbook.unsubscribeOrders()}async swap(t,r,a,i,s){if(I()){const y=await new D().send(O.createOrderAndSwap,{from:t,to:r,amt:a,receiveAmount:i,opts:s});return Number(y)}const d=this.wallets[t.chain],o=this.wallets[r.chain];if(!d)throw new Error(m.WALLET_NOT_FOUND(!0));if(!o)throw new Error(m.WALLET_NOT_FOUND(!1));H(t.chain,r.chain),(s&&!s.btcUserAddress||!s)&&(s=s||{},s.btcUserAddress=await this.wallets[w(t.chain)?t.chain:r.chain].getAddress());const n=w(t.chain),f=n?o:d,A=n?d:o,R=await f.getAddress(),C=await this.orderbook.getOrders(R),b=n?await A.getAddress():await f.getAddress(),_=n?await f.getAddress():await A.getAddress(),T=await S(t.chain,r.chain,this.wallets,C.length+1);return this.orderbook.createOrder({fromAsset:t,toAsset:r,sendAmount:a.toString(),receiveAmount:i.toString(),receiveAddress:_,sendAddress:b,secretHash:l(u(T)),btcInputAddress:s.btcUserAddress??await A.getAddress()})}getSwap(t){return new W(t,this.wallets)}calculateReceiveAmt(t,r,a){return Promise.resolve(a-a*.03)}}const H=(e,t)=>{if(w(e)===w(t))throw new Error(w(e)?m.CHAIN_WALLET_NOT_FOUND("Bitcoin"):m.CHAIN_WALLET_NOT_FOUND("EVM"))};export{B as GardenJS,N as SwapperActions,g as SwapperRole,O as catalogWalletActions};
|
package/dist/src/lib/garden.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { ISwapper } from './swapper';
|
|
|
3
3
|
import { IGardenJS, Wallets } from './garden.types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* GardenJS is the core component of the Garden SDK. It allows you to create orders,
|
|
7
|
+
* subscribe to order updates, and perform initiates, redeems, and refunds on swaps.
|
|
8
|
+
*
|
|
9
|
+
* Visit the [GardenJS documentation](https://docs.garden.finance/developers/sdk/) for more information.
|
|
8
10
|
*/
|
|
9
11
|
export declare class GardenJS implements IGardenJS {
|
|
10
12
|
private readonly orderbook;
|
|
@@ -19,9 +21,26 @@ export declare class GardenJS implements IGardenJS {
|
|
|
19
21
|
constructor(orderbook: IOrderbook, wallets: Partial<Wallets>);
|
|
20
22
|
subscribeOrders(address: string, callback: (orders: Orders) => void): void;
|
|
21
23
|
unsubscribeOrders(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a swap order in the orderbook backend. Checkout `Assets` from @gardenfi/orderbook for the available assets
|
|
26
|
+
* @param from from asset (e.g. Assets.ethereum.WBTC)
|
|
27
|
+
* @param to to asset (e.g. Assets.bitcoin.BTC)
|
|
28
|
+
* @param amt send amount
|
|
29
|
+
* @param receiveAmount receive amount
|
|
30
|
+
* @param opts if the swap destination is bitcoin, you can provide a btcInputAddress to redeem funds to.
|
|
31
|
+
* @returns order id
|
|
32
|
+
*
|
|
33
|
+
* Note: localnet assets require `merry` running, else it will throw an error saying unsupported asset.
|
|
34
|
+
*/
|
|
22
35
|
swap(from: Asset, to: Asset, amt: number, receiveAmount: number, opts?: {
|
|
23
|
-
|
|
36
|
+
btcUserAddress?: string;
|
|
24
37
|
}): Promise<number>;
|
|
38
|
+
/**
|
|
39
|
+
* Given an order, returns a Swapper instance to progress the swap (init, redeem, refund)
|
|
40
|
+
*/
|
|
25
41
|
getSwap(order: Order): ISwapper;
|
|
42
|
+
/**
|
|
43
|
+
* Calculates the receive amount for the given send amount
|
|
44
|
+
*/
|
|
26
45
|
calculateReceiveAmt(from: Asset, to: Asset, sendAmt: number): Promise<number>;
|
|
27
46
|
}
|
|
@@ -13,11 +13,11 @@ export interface IGardenJS {
|
|
|
13
13
|
* @param {number} amt - The amount you want to swap in it's lowest denomination
|
|
14
14
|
* @param {number} receiveAmount - The amount you want to receive in it's lowest denomination
|
|
15
15
|
* @param {Object} [opts] - Additional options for creating an order
|
|
16
|
-
* @param {string} [opts.
|
|
16
|
+
* @param {string} [opts.btcUserAddress] - If specified, BTC will be sent to this address
|
|
17
17
|
* @returns {Promise<number>} The order ID
|
|
18
18
|
*/
|
|
19
19
|
swap(from: Asset, to: Asset, amt: number, receiveAmount: number, opts?: {
|
|
20
|
-
|
|
20
|
+
btcUserAddress?: string;
|
|
21
21
|
}): Promise<number>;
|
|
22
22
|
/**
|
|
23
23
|
* Calculates the amount you receive. Currently deducts 0.3% of the amount you send.
|