@atomiqlabs/sdk 4.0.0 → 5.0.0-dev.0
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/README.md +35 -11
- package/dist/SmartChainAssets.d.ts +20 -0
- package/dist/SmartChainAssets.js +20 -0
- package/package.json +3 -3
- package/src/SmartChainAssets.ts +20 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Example SDK integration in NodeJS available [here](https://github.com/atomiqlabs
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
```
|
|
9
|
-
npm install @atomiqlabs/sdk
|
|
9
|
+
npm install @atomiqlabs/sdk@dev
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Installing chain-specific connectors
|
|
@@ -14,8 +14,9 @@ npm install @atomiqlabs/sdk
|
|
|
14
14
|
You can install only the chain-specific connectors that your project requires
|
|
15
15
|
|
|
16
16
|
```
|
|
17
|
-
npm install @atomiqlabs/chain-solana
|
|
18
|
-
npm install @atomiqlabs/chain-starknet
|
|
17
|
+
npm install @atomiqlabs/chain-solana@dev
|
|
18
|
+
npm install @atomiqlabs/chain-starknet@dev
|
|
19
|
+
npm install @atomiqlabs/chain-evm@dev
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
## How to use?
|
|
@@ -26,7 +27,7 @@ npm install @atomiqlabs/chain-starknet
|
|
|
26
27
|
- Swaps:
|
|
27
28
|
- [Smart Chain -> BTC L1](#swap-smart-chain---bitcoin-on-chain)
|
|
28
29
|
- [BTC L1 -> Solana (Old swap protocol)](#swap-bitcoin-on-chain---solana)
|
|
29
|
-
- [BTC L1 -> Starknet (New swap protocol)](#swap-bitcoin-on-chain---starknet)
|
|
30
|
+
- [BTC L1 -> Starknet/EVM (New swap protocol)](#swap-bitcoin-on-chain---starknet-evm)
|
|
30
31
|
- [Smart Chain -> BTC Lightning network L2](#swap-smart-chain---bitcoin-lightning-network)
|
|
31
32
|
- [Smart Chain -> BTC Lightning network L2 (LNURL-pay)](#swap-smart-chain---bitcoin-lightning-network-1)
|
|
32
33
|
- [BTC Lightning network L2 -> Smart Chain](#swap-bitcoin-lightning-network---smart-chain)
|
|
@@ -48,7 +49,8 @@ Set Solana & Starknet RPC URL to use
|
|
|
48
49
|
|
|
49
50
|
```typescript
|
|
50
51
|
const solanaRpc = "https://api.mainnet-beta.solana.com";
|
|
51
|
-
const starknetRpc = "https://starknet-mainnet.public.blastapi.io/rpc/
|
|
52
|
+
const starknetRpc = "https://starknet-mainnet.public.blastapi.io/rpc/v0_8";
|
|
53
|
+
const citreaRpc = "https://rpc.testnet.citrea.xyz";
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
Create swapper factory, here we can pick and choose which chains we want to have supported in the SDK, ensure the "as const" keyword is used such that the typescript compiler can properly infer the types.
|
|
@@ -56,9 +58,10 @@ Create swapper factory, here we can pick and choose which chains we want to have
|
|
|
56
58
|
```typescript
|
|
57
59
|
import {SolanaInitializer, SolanaInitializerType} from "@atomiqlabs/chain-solana";
|
|
58
60
|
import {StarknetInitializer, StarknetInitializerType} from "@atomiqlabs/chain-starknet";
|
|
61
|
+
import {CitreaInitializer, CitreaInitializerType} from "@atomiqlabs/chain-evm";
|
|
59
62
|
import {SwapperFactory} from "@atomiqlabs/sdk";
|
|
60
63
|
|
|
61
|
-
const Factory = new SwapperFactory<[SolanaInitializerType, StarknetInitializerType]>([SolanaInitializer, StarknetInitializer] as const);
|
|
64
|
+
const Factory = new SwapperFactory<[SolanaInitializerType, StarknetInitializerType, CitreaInitializerType]>([SolanaInitializer, StarknetInitializer, CitreaInitializer] as const);
|
|
62
65
|
const Tokens = Factory.Tokens; //Get the supported tokens for all the specified chains.
|
|
63
66
|
```
|
|
64
67
|
|
|
@@ -75,7 +78,10 @@ const swapper = Factory.newSwapper({
|
|
|
75
78
|
rpcUrl: solanaRpc //You can also pass Connection object here
|
|
76
79
|
},
|
|
77
80
|
STARKNET: {
|
|
78
|
-
rpcUrl: starknetRpc //You can also pass Provider object here
|
|
81
|
+
rpcUrl: starknetRpc //You can also pass Provider object here
|
|
82
|
+
},
|
|
83
|
+
CITREA: {
|
|
84
|
+
rpcUrl: citreaRpc, //You can also pass JsonApiProvider object here
|
|
79
85
|
}
|
|
80
86
|
},
|
|
81
87
|
bitcoinNetwork: BitcoinNetwork.TESTNET //or BitcoinNetwork.MAINNET, BitcoinNetwork.TESTNET4 - this also sets the network to use for Solana (solana devnet for bitcoin testnet) & Starknet (sepolia for bitcoin testnet)
|
|
@@ -105,6 +111,9 @@ const swapper = Factory.newSwapper({
|
|
|
105
111
|
},
|
|
106
112
|
STARKNET: {
|
|
107
113
|
rpcUrl: starknetRpc //You can also pass Provider object here
|
|
114
|
+
},
|
|
115
|
+
CITREA: {
|
|
116
|
+
rpcUrl: citreaRpc, //You can also pass JsonApiProvider object here
|
|
108
117
|
}
|
|
109
118
|
},
|
|
110
119
|
bitcoinNetwork: BitcoinNetwork.TESTNET, //or BitcoinNetwork.MAINNET - this also sets the network to use for Solana (solana devnet for bitcoin testnet) & Starknet (sepolia for bitcoin testnet)
|
|
@@ -144,11 +153,19 @@ const solanaSigner = new SolanaSigner(new SolanaKeypairWallet(Keypair.fromSecret
|
|
|
144
153
|
```
|
|
145
154
|
|
|
146
155
|
```typescript
|
|
147
|
-
import {
|
|
156
|
+
import {StarknetSigner, StarknetKeypairWallet} from "@atomiqlabs/chain-starknet";
|
|
148
157
|
//Creating Starknet signer from private key
|
|
149
158
|
const starknetSigner = new StarknetSigner(new StarknetKeypairWallet(starknetRpc, starknetKey));
|
|
150
159
|
```
|
|
151
160
|
|
|
161
|
+
```typescript
|
|
162
|
+
import {BaseWallet, SigningKey} from "ethers";
|
|
163
|
+
import {EVMSigner} from "@atomiqlabs/chain-evm";
|
|
164
|
+
//Creating EVM signer from private key
|
|
165
|
+
const wallet = new BaseWallet(new SigningKey(evmKey));
|
|
166
|
+
const evmWallet = new EVMSigner(wallet, wallet.address);
|
|
167
|
+
```
|
|
168
|
+
|
|
152
169
|
### Initialization
|
|
153
170
|
|
|
154
171
|
Initialize the swapper
|
|
@@ -371,9 +388,9 @@ try {
|
|
|
371
388
|
- Swap funds are claimed to the user's wallet
|
|
372
389
|
|
|
373
390
|
|
|
374
|
-
#### Swap Bitcoin on-chain -> Starknet
|
|
391
|
+
#### Swap Bitcoin on-chain -> Starknet/EVM
|
|
375
392
|
|
|
376
|
-
NOTE: Starknet uses a new swap protocol for Bitcoin on-chain ->
|
|
393
|
+
NOTE: Starknet & EVM uses a new swap protocol for Bitcoin on-chain -> Smart chain swaps, the flow here is different from the one for Solana!
|
|
377
394
|
|
|
378
395
|
Getting swap quote
|
|
379
396
|
|
|
@@ -774,7 +791,7 @@ const swap = await swapper.swap(
|
|
|
774
791
|
_amount,
|
|
775
792
|
_exactIn, //Whether we define an input or output amount
|
|
776
793
|
_lnurl, //Source LNURL for the swap
|
|
777
|
-
signer.getAddress() //Destination address
|
|
794
|
+
signer.getAddress(), //Destination address
|
|
778
795
|
);
|
|
779
796
|
|
|
780
797
|
//Get the amount required to pay and fee
|
|
@@ -1042,6 +1059,13 @@ for(let tx of txns) {
|
|
|
1042
1059
|
if(tx.type==="DEPLOY_ACCOUNT") await starknetSigner.account.deployAccount(tx.tx, tx.details);
|
|
1043
1060
|
}
|
|
1044
1061
|
await swap.waitTillCommited(); //Or other relevant waitTillClaimed, waitTillRefunded
|
|
1062
|
+
|
|
1063
|
+
//Example for EVM
|
|
1064
|
+
const txns = await swap.txsCommit(); //Also works with txsClaim, txsRefund, txCommitAndClaim
|
|
1065
|
+
for(let tx of txns) {
|
|
1066
|
+
await evmSigner.account.sendTransaction(tx);
|
|
1067
|
+
}
|
|
1068
|
+
await swap.waitTillCommited(); //Or other relevant waitTillClaimed, waitTillRefunded
|
|
1045
1069
|
```
|
|
1046
1070
|
|
|
1047
1071
|
### Additional swapper options
|
|
@@ -69,5 +69,25 @@ export declare const SmartChainAssets: {
|
|
|
69
69
|
};
|
|
70
70
|
readonly name: "Starknet";
|
|
71
71
|
};
|
|
72
|
+
readonly CBTC: {
|
|
73
|
+
readonly pricing: {
|
|
74
|
+
readonly binancePair: "$fixed-100000000";
|
|
75
|
+
readonly okxPair: "$fixed-100000000";
|
|
76
|
+
readonly coinGeckoCoinId: "$fixed-100000000";
|
|
77
|
+
readonly coinPaprikaCoinId: "$fixed-100000000";
|
|
78
|
+
readonly krakenPair: "$fixed-100000000";
|
|
79
|
+
};
|
|
80
|
+
readonly name: "Citrea BTC";
|
|
81
|
+
};
|
|
82
|
+
readonly BBTC: {
|
|
83
|
+
readonly pricing: {
|
|
84
|
+
readonly binancePair: "$fixed-100000000";
|
|
85
|
+
readonly okxPair: "$fixed-100000000";
|
|
86
|
+
readonly coinGeckoCoinId: "$fixed-100000000";
|
|
87
|
+
readonly coinPaprikaCoinId: "$fixed-100000000";
|
|
88
|
+
readonly krakenPair: "$fixed-100000000";
|
|
89
|
+
};
|
|
90
|
+
readonly name: "Botanix BTC";
|
|
91
|
+
};
|
|
72
92
|
};
|
|
73
93
|
export type SmartChainAssetTickers = keyof typeof SmartChainAssets;
|
package/dist/SmartChainAssets.js
CHANGED
|
@@ -71,5 +71,25 @@ exports.SmartChainAssets = {
|
|
|
71
71
|
krakenPair: "STRKUSD;!XXBTZUSD"
|
|
72
72
|
},
|
|
73
73
|
name: "Starknet"
|
|
74
|
+
},
|
|
75
|
+
CBTC: {
|
|
76
|
+
pricing: {
|
|
77
|
+
binancePair: "$fixed-100000000",
|
|
78
|
+
okxPair: "$fixed-100000000",
|
|
79
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
80
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
81
|
+
krakenPair: "$fixed-100000000"
|
|
82
|
+
},
|
|
83
|
+
name: "Citrea BTC"
|
|
84
|
+
},
|
|
85
|
+
BBTC: {
|
|
86
|
+
pricing: {
|
|
87
|
+
binancePair: "$fixed-100000000",
|
|
88
|
+
okxPair: "$fixed-100000000",
|
|
89
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
90
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
91
|
+
krakenPair: "$fixed-100000000"
|
|
92
|
+
},
|
|
93
|
+
name: "Botanix BTC"
|
|
74
94
|
}
|
|
75
95
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomiqlabs/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-dev.0",
|
|
4
4
|
"description": "atomiq labs SDK for cross-chain swaps between smart chains and bitcoin",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types:": "./dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"author": "adambor",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atomiqlabs/base": "^
|
|
25
|
-
"@atomiqlabs/sdk-lib": "^
|
|
24
|
+
"@atomiqlabs/base": "^10.0.0-dev.1",
|
|
25
|
+
"@atomiqlabs/sdk-lib": "^14.0.0-dev.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "22.13.5",
|
package/src/SmartChainAssets.ts
CHANGED
|
@@ -70,6 +70,26 @@ export const SmartChainAssets = {
|
|
|
70
70
|
krakenPair: "STRKUSD;!XXBTZUSD"
|
|
71
71
|
},
|
|
72
72
|
name: "Starknet"
|
|
73
|
+
},
|
|
74
|
+
CBTC: {
|
|
75
|
+
pricing: {
|
|
76
|
+
binancePair: "$fixed-100000000",
|
|
77
|
+
okxPair: "$fixed-100000000",
|
|
78
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
79
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
80
|
+
krakenPair: "$fixed-100000000"
|
|
81
|
+
},
|
|
82
|
+
name: "Citrea BTC"
|
|
83
|
+
},
|
|
84
|
+
BBTC: {
|
|
85
|
+
pricing: {
|
|
86
|
+
binancePair: "$fixed-100000000",
|
|
87
|
+
okxPair: "$fixed-100000000",
|
|
88
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
89
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
90
|
+
krakenPair: "$fixed-100000000"
|
|
91
|
+
},
|
|
92
|
+
name: "Botanix BTC"
|
|
73
93
|
}
|
|
74
94
|
} as const;
|
|
75
95
|
|