-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathswap.ts
33 lines (27 loc) · 893 Bytes
/
swap.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { buildContext, createSwap, estimateAmountReceiving } from '@swingby-protocol/sdk';
const addressReceiving = '0x3F4341a0599f63F444B6f1e0c7C5cAf81b5843Cc';
const amountDesired = '1';
const currencyDeposit = 'BTC';
const currencyReceiving = 'WBTC';
(async () => {
const context = await buildContext({ mode: 'test' });
const { feeTotal, feeBridgeFraction, feeMiner, feeCurrency } = await estimateAmountReceiving({
context,
amountDesired,
currencyDeposit,
currencyReceiving,
});
console.log(
`Transacion fee: ${feeTotal} ${feeCurrency} (${
+feeBridgeFraction * 100
}% + ${feeMiner} ${feeCurrency})`,
);
const swap = await createSwap({
context,
amountDesired,
addressReceiving,
currencyDeposit,
currencyReceiving,
});
console.log(`Send ${swap.amountDeposit} (${swap.currencyDeposit}) to ${swap.addressDeposit}`);
})();