@3rd-eye-labs/dexter-v2 1.0.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 +32 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +261 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.js +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
## Installation
|
|
3
|
+
##### NPM
|
|
4
|
+
`$ npm install @third-eye-labs/arc`
|
|
5
|
+
|
|
6
|
+
##### PNPM
|
|
7
|
+
`$ pnpm install @third-eye-labs/arc`
|
|
8
|
+
|
|
9
|
+
##### Yarn
|
|
10
|
+
`$ yarn add @third-eye-labs/arc`
|
|
11
|
+
|
|
12
|
+
## Using
|
|
13
|
+
|
|
14
|
+
##### Arc Instance
|
|
15
|
+
Arc supports using CIP-30 wallets, and wallets by seed phrase. Each have their own required config, however here is how you can load a wallet by seed phrase :
|
|
16
|
+
```
|
|
17
|
+
const arc = await LoadArc({
|
|
18
|
+
// Custom Iris instance, ignore if using default
|
|
19
|
+
irisHost: 'http://localhost:8000',
|
|
20
|
+
wallet: {
|
|
21
|
+
// Can use Blockfrost, or Kupo + Ogmios
|
|
22
|
+
connection: {
|
|
23
|
+
url: 'https://cardano-mainnet.blockfrost.io';
|
|
24
|
+
projectId: 'project_id';
|
|
25
|
+
},
|
|
26
|
+
seedPhrase: ['word1', 'word2', ...],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Tests
|
|
32
|
+
`$ pnpm run test`
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var F=(a,r)=>{for(var e in r)h(a,e,{get:r[e],enumerable:!0})},W=(a,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of _(r))!I.call(a,n)&&n!==e&&h(a,n,{get:()=>r[n],enumerable:!(s=C(r,n))||s.enumerable});return a};var O=a=>W(h({},"__esModule",{value:!0}),a);var A={};F(A,{AddressType:()=>x,Dexter:()=>B,IWallet:()=>l,Indigo:()=>p,LoadArc:()=>k,MinswapV1:()=>m,MinswapV2:()=>o,SwapBuilder:()=>t,Transaction:()=>y,TransactionStatus:()=>v,Wallet:()=>u});module.exports=O(A);var t=class{};var m=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var o=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var p=class{};var l=class{};var u=class extends l{isWalletLoaded;constructor(){super()}address(){return""}createTransaction(){}loadWallet(r){return Promise.resolve(void 0)}loadWalletFromSeedPhrase(r,e){return Promise.resolve(void 0)}paymentsForTransaction(r,e){return Promise.resolve(void 0)}publicKeyHash(){return""}signTransaction(r){return Promise.resolve(void 0)}stakingKeyHash(){return""}submitTransaction(r){return Promise.resolve("")}};var T=require("@indigo-labs/iris-sdk");var d=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var c=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var P=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var w=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var S=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var b=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var g=class{};var f=class{};var B=class{_config;_wallet;_irisApi;constructor(r){this._config=r,this._irisApi=new T.IrisApiService(r.irisHost??"https://iris.indigoprotocol.io")}get wallet(){return this._wallet}get iris(){return this._irisApi}get minswapV1(){return new m}get minswapV2(){return new o}get muesliswap(){return new d}get splash(){return new c}get sundaeSwapV1(){return new P}get sundaeSwapV3(){return new w}get wingRidersV1(){return new S}get wingRidersV2(){return new b}get indigo(){return new p}get liqwid(){return new g}get bodega(){return new f}withWallet(r){this._wallet=r}},k=async a=>{let r=new B(a);if(a.wallet){let e=new u;await("seedPhrase"in a.wallet?e.loadWalletFromSeedPhrase(a.wallet.seedPhrase,a.wallet.connection):e.loadWallet(a.wallet.cip30)),r.withWallet(e)}return r};var v=(i=>(i[i.Building=0]="Building",i[i.Signing=1]="Signing",i[i.Submitting=2]="Submitting",i[i.Submitted=3]="Submitted",i[i.Errored=4]="Errored",i))(v||{}),x=(s=>(s[s.Contract=0]="Contract",s[s.Base=1]="Base",s[s.Enterprise=2]="Enterprise",s))(x||{});var y=class{providerData={};error=void 0;_hash;_isSigned=!1;_payments=[];_wallet;_currentStatus=0;_listeners=[];constructor(r){this._wallet=r}get hash(){return this._hash}get isSigned(){return this._isSigned}get payments(){return this._payments}get status(){return this._currentStatus}set status(r){this._currentStatus=r,this._listeners.forEach(e=>{e(this)})}payToAddresses(r){return this._wallet.paymentsForTransaction(this,r).then(()=>(this._payments=r,this))}sign(){if(this._isSigned)throw new Error("Transaction was already signed.");return this._wallet.signTransaction(this).then(()=>(this._isSigned=!0,this))}submit(){if(!this._isSigned)throw new Error("Must sign transaction before submitting.");if(this._hash)throw new Error("Transaction was already submitted.");return this._wallet.submitTransaction(this).then(r=>(this._hash=r,this))}onBuilding(r){return this.addListener(e=>{e.status===0&&r(e)}),this}onSigning(r){return this.addListener(e=>{e.status===1&&r(e)}),this}onSubmitting(r){return this.addListener(e=>{e.status===2&&r(e)}),this}onSubmitted(r){return this.addListener(e=>{e.status===3&&r(e)}),this}onError(r){return this.addListener(e=>{e.status===4&&r(e)}),this}onFinally(r){return this.addListener(e=>{(e.status===3||e.status===4)&&r(e)}),this}addListener(r){this._listeners.push(r)}};0&&(module.exports={AddressType,Dexter,IWallet,Indigo,LoadArc,MinswapV1,MinswapV2,SwapBuilder,Transaction,TransactionStatus,Wallet});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { Token, LiquidityPool, IrisApiService } from '@indigo-labs/iris-sdk';
|
|
2
|
+
import { UTxO } from '@lucid-evolution/lucid';
|
|
3
|
+
|
|
4
|
+
declare enum TransactionStatus {
|
|
5
|
+
Building = 0,
|
|
6
|
+
Signing = 1,
|
|
7
|
+
Submitting = 2,
|
|
8
|
+
Submitted = 3,
|
|
9
|
+
Errored = 4
|
|
10
|
+
}
|
|
11
|
+
declare enum AddressType {
|
|
12
|
+
Contract = 0,
|
|
13
|
+
Base = 1,
|
|
14
|
+
Enterprise = 2
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ArcConfig = {
|
|
18
|
+
irisHost?: string;
|
|
19
|
+
wallet?: {
|
|
20
|
+
connection: BlockfrostConfig | KupmiosConfig;
|
|
21
|
+
accountIndex?: number;
|
|
22
|
+
seedPhrase: string[];
|
|
23
|
+
} | {
|
|
24
|
+
accountIndex?: number;
|
|
25
|
+
cip30: Cip30Api;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
type AssetBalance = {
|
|
29
|
+
asset: Token;
|
|
30
|
+
quantity: bigint;
|
|
31
|
+
};
|
|
32
|
+
type SwapFee = {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
value: bigint;
|
|
37
|
+
isReturned: boolean;
|
|
38
|
+
};
|
|
39
|
+
type Payment = {
|
|
40
|
+
address: {
|
|
41
|
+
value: string;
|
|
42
|
+
type: AddressType;
|
|
43
|
+
};
|
|
44
|
+
assetBalances: AssetBalance[];
|
|
45
|
+
spendUtxos?: UTxO[];
|
|
46
|
+
datum?: string;
|
|
47
|
+
isInlineDatum: boolean;
|
|
48
|
+
};
|
|
49
|
+
type SwapBuilderParameters = {
|
|
50
|
+
liquidityPool: LiquidityPool;
|
|
51
|
+
inToken: Token;
|
|
52
|
+
inAmount: bigint;
|
|
53
|
+
spendUtxos?: UTxO[];
|
|
54
|
+
} | {
|
|
55
|
+
liquidityPool: LiquidityPool;
|
|
56
|
+
outToken: Token;
|
|
57
|
+
outAmount: bigint;
|
|
58
|
+
spendUtxos?: UTxO[];
|
|
59
|
+
};
|
|
60
|
+
interface BlockfrostConfig {
|
|
61
|
+
url: string;
|
|
62
|
+
projectId: string;
|
|
63
|
+
}
|
|
64
|
+
interface KupoConfig {
|
|
65
|
+
url: string;
|
|
66
|
+
}
|
|
67
|
+
interface KupmiosConfig {
|
|
68
|
+
kupoUrl: string;
|
|
69
|
+
ogmiosUrl: string;
|
|
70
|
+
}
|
|
71
|
+
type TransactionError = {
|
|
72
|
+
step: TransactionStatus;
|
|
73
|
+
reason: string;
|
|
74
|
+
reasonRaw: string;
|
|
75
|
+
};
|
|
76
|
+
type Cip30Api = {
|
|
77
|
+
getNetworkId(): Promise<number>;
|
|
78
|
+
getUtxos(): Promise<string[] | undefined>;
|
|
79
|
+
getBalance(): Promise<string>;
|
|
80
|
+
getUsedAddresses(): Promise<string[]>;
|
|
81
|
+
getUnusedAddresses(): Promise<string[]>;
|
|
82
|
+
getChangeAddress(): Promise<string>;
|
|
83
|
+
getRewardAddresses(): Promise<string[]>;
|
|
84
|
+
signTx(tx: string, partialSign: boolean): Promise<string>;
|
|
85
|
+
signData(address: string, payload: string): Promise<{
|
|
86
|
+
signature: string;
|
|
87
|
+
key: string;
|
|
88
|
+
}>;
|
|
89
|
+
submitTx(tx: string): Promise<string>;
|
|
90
|
+
getCollateral(): Promise<string[]>;
|
|
91
|
+
experimental: {
|
|
92
|
+
getCollateral(): Promise<string[]>;
|
|
93
|
+
on(eventName: string, callback: (...args: unknown[]) => void): void;
|
|
94
|
+
off(eventName: string, callback: (...args: unknown[]) => void): void;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
declare abstract class SwapBuilder {
|
|
99
|
+
abstract estimatedGive(params: SwapBuilderParameters): bigint;
|
|
100
|
+
abstract estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
101
|
+
abstract priceImpactPercent(params: SwapBuilderParameters): number;
|
|
102
|
+
abstract fees(params: SwapBuilderParameters): SwapFee[];
|
|
103
|
+
abstract buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
104
|
+
abstract buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare class MinswapV1 extends SwapBuilder {
|
|
108
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
109
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
110
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
111
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
112
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
113
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare class MinswapV2 extends SwapBuilder {
|
|
117
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
118
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
119
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
120
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
121
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
122
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class Indigo {
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface TransactionCallback {
|
|
129
|
+
(transaction: Transaction): void;
|
|
130
|
+
}
|
|
131
|
+
declare class Transaction {
|
|
132
|
+
providerData: any;
|
|
133
|
+
error: TransactionError | undefined;
|
|
134
|
+
private _hash;
|
|
135
|
+
private _isSigned;
|
|
136
|
+
private _payments;
|
|
137
|
+
private _wallet;
|
|
138
|
+
private _currentStatus;
|
|
139
|
+
private _listeners;
|
|
140
|
+
constructor(wallet: IWallet);
|
|
141
|
+
get hash(): string;
|
|
142
|
+
get isSigned(): boolean;
|
|
143
|
+
get payments(): Payment[];
|
|
144
|
+
get status(): TransactionStatus;
|
|
145
|
+
set status(status: TransactionStatus);
|
|
146
|
+
payToAddresses(payments: Payment[]): Promise<Transaction>;
|
|
147
|
+
sign(): Promise<Transaction>;
|
|
148
|
+
submit(): Promise<Transaction>;
|
|
149
|
+
onBuilding(callback: TransactionCallback): Transaction;
|
|
150
|
+
onSigning(callback: TransactionCallback): Transaction;
|
|
151
|
+
onSubmitting(callback: TransactionCallback): Transaction;
|
|
152
|
+
onSubmitted(callback: TransactionCallback): Transaction;
|
|
153
|
+
onError(callback: TransactionCallback): Transaction;
|
|
154
|
+
onFinally(callback: TransactionCallback): Transaction;
|
|
155
|
+
private addListener;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare abstract class IWallet {
|
|
159
|
+
abstract isWalletLoaded: boolean;
|
|
160
|
+
abstract address(): string;
|
|
161
|
+
abstract publicKeyHash(): string;
|
|
162
|
+
abstract stakingKeyHash(): string;
|
|
163
|
+
abstract loadWallet(walletApi: Cip30Api, config: any): Promise<IWallet>;
|
|
164
|
+
abstract loadWalletFromSeedPhrase(seedPhrase: string[], config: BlockfrostConfig | KupmiosConfig): Promise<IWallet>;
|
|
165
|
+
abstract createTransaction(): Transaction;
|
|
166
|
+
abstract paymentsForTransaction(transaction: Transaction, payToAddresses: Payment[]): Promise<Transaction>;
|
|
167
|
+
abstract signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
168
|
+
abstract submitTransaction(transaction: Transaction): Promise<string>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare class Muesliswap extends SwapBuilder {
|
|
172
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
173
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
174
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
175
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
176
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
177
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare class Splash extends SwapBuilder {
|
|
181
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
182
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
183
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
184
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
185
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
186
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class SundaeSwapV1 extends SwapBuilder {
|
|
190
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
191
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
192
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
193
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
194
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
195
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare class SundaeSwapV3 extends SwapBuilder {
|
|
199
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
200
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
201
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
202
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
203
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
204
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare class WingRidersV1 extends SwapBuilder {
|
|
208
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
209
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
210
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
211
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
212
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
213
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare class WingRidersV2 extends SwapBuilder {
|
|
217
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
218
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
219
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
220
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
221
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
222
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
declare class Dexter {
|
|
226
|
+
protected _config: ArcConfig;
|
|
227
|
+
protected _wallet: IWallet;
|
|
228
|
+
protected _irisApi: IrisApiService;
|
|
229
|
+
constructor(config: ArcConfig);
|
|
230
|
+
get wallet(): IWallet;
|
|
231
|
+
get iris(): Indigo;
|
|
232
|
+
get minswapV1(): MinswapV1;
|
|
233
|
+
get minswapV2(): MinswapV2;
|
|
234
|
+
get muesliswap(): Muesliswap;
|
|
235
|
+
get splash(): Splash;
|
|
236
|
+
get sundaeSwapV1(): SundaeSwapV1;
|
|
237
|
+
get sundaeSwapV3(): SundaeSwapV3;
|
|
238
|
+
get wingRidersV1(): WingRidersV1;
|
|
239
|
+
get wingRidersV2(): WingRidersV2;
|
|
240
|
+
get indigo(): Indigo;
|
|
241
|
+
get liqwid(): Indigo;
|
|
242
|
+
get bodega(): Indigo;
|
|
243
|
+
withWallet(wallet: IWallet): void;
|
|
244
|
+
}
|
|
245
|
+
declare const LoadArc: (config: ArcConfig) => Promise<Dexter>;
|
|
246
|
+
|
|
247
|
+
declare class Wallet extends IWallet {
|
|
248
|
+
isWalletLoaded: boolean;
|
|
249
|
+
constructor();
|
|
250
|
+
address(): string;
|
|
251
|
+
createTransaction(): Transaction;
|
|
252
|
+
loadWallet(walletApi: Cip30Api): Promise<IWallet>;
|
|
253
|
+
loadWalletFromSeedPhrase(seedPhrase: string[], config: BlockfrostConfig | KupmiosConfig): Promise<IWallet>;
|
|
254
|
+
paymentsForTransaction(transaction: Transaction, payToAddresses: Payment[]): Promise<Transaction>;
|
|
255
|
+
publicKeyHash(): string;
|
|
256
|
+
signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
257
|
+
stakingKeyHash(): string;
|
|
258
|
+
submitTransaction(transaction: Transaction): Promise<string>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { AddressType, type ArcConfig, type AssetBalance, type BlockfrostConfig, type Cip30Api, Dexter, IWallet, Indigo, type KupmiosConfig, type KupoConfig, LoadArc, MinswapV1, MinswapV2, type Payment, SwapBuilder, type SwapBuilderParameters, type SwapFee, Transaction, type TransactionError, TransactionStatus, Wallet };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { Token, LiquidityPool, IrisApiService } from '@indigo-labs/iris-sdk';
|
|
2
|
+
import { UTxO } from '@lucid-evolution/lucid';
|
|
3
|
+
|
|
4
|
+
declare enum TransactionStatus {
|
|
5
|
+
Building = 0,
|
|
6
|
+
Signing = 1,
|
|
7
|
+
Submitting = 2,
|
|
8
|
+
Submitted = 3,
|
|
9
|
+
Errored = 4
|
|
10
|
+
}
|
|
11
|
+
declare enum AddressType {
|
|
12
|
+
Contract = 0,
|
|
13
|
+
Base = 1,
|
|
14
|
+
Enterprise = 2
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ArcConfig = {
|
|
18
|
+
irisHost?: string;
|
|
19
|
+
wallet?: {
|
|
20
|
+
connection: BlockfrostConfig | KupmiosConfig;
|
|
21
|
+
accountIndex?: number;
|
|
22
|
+
seedPhrase: string[];
|
|
23
|
+
} | {
|
|
24
|
+
accountIndex?: number;
|
|
25
|
+
cip30: Cip30Api;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
type AssetBalance = {
|
|
29
|
+
asset: Token;
|
|
30
|
+
quantity: bigint;
|
|
31
|
+
};
|
|
32
|
+
type SwapFee = {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
value: bigint;
|
|
37
|
+
isReturned: boolean;
|
|
38
|
+
};
|
|
39
|
+
type Payment = {
|
|
40
|
+
address: {
|
|
41
|
+
value: string;
|
|
42
|
+
type: AddressType;
|
|
43
|
+
};
|
|
44
|
+
assetBalances: AssetBalance[];
|
|
45
|
+
spendUtxos?: UTxO[];
|
|
46
|
+
datum?: string;
|
|
47
|
+
isInlineDatum: boolean;
|
|
48
|
+
};
|
|
49
|
+
type SwapBuilderParameters = {
|
|
50
|
+
liquidityPool: LiquidityPool;
|
|
51
|
+
inToken: Token;
|
|
52
|
+
inAmount: bigint;
|
|
53
|
+
spendUtxos?: UTxO[];
|
|
54
|
+
} | {
|
|
55
|
+
liquidityPool: LiquidityPool;
|
|
56
|
+
outToken: Token;
|
|
57
|
+
outAmount: bigint;
|
|
58
|
+
spendUtxos?: UTxO[];
|
|
59
|
+
};
|
|
60
|
+
interface BlockfrostConfig {
|
|
61
|
+
url: string;
|
|
62
|
+
projectId: string;
|
|
63
|
+
}
|
|
64
|
+
interface KupoConfig {
|
|
65
|
+
url: string;
|
|
66
|
+
}
|
|
67
|
+
interface KupmiosConfig {
|
|
68
|
+
kupoUrl: string;
|
|
69
|
+
ogmiosUrl: string;
|
|
70
|
+
}
|
|
71
|
+
type TransactionError = {
|
|
72
|
+
step: TransactionStatus;
|
|
73
|
+
reason: string;
|
|
74
|
+
reasonRaw: string;
|
|
75
|
+
};
|
|
76
|
+
type Cip30Api = {
|
|
77
|
+
getNetworkId(): Promise<number>;
|
|
78
|
+
getUtxos(): Promise<string[] | undefined>;
|
|
79
|
+
getBalance(): Promise<string>;
|
|
80
|
+
getUsedAddresses(): Promise<string[]>;
|
|
81
|
+
getUnusedAddresses(): Promise<string[]>;
|
|
82
|
+
getChangeAddress(): Promise<string>;
|
|
83
|
+
getRewardAddresses(): Promise<string[]>;
|
|
84
|
+
signTx(tx: string, partialSign: boolean): Promise<string>;
|
|
85
|
+
signData(address: string, payload: string): Promise<{
|
|
86
|
+
signature: string;
|
|
87
|
+
key: string;
|
|
88
|
+
}>;
|
|
89
|
+
submitTx(tx: string): Promise<string>;
|
|
90
|
+
getCollateral(): Promise<string[]>;
|
|
91
|
+
experimental: {
|
|
92
|
+
getCollateral(): Promise<string[]>;
|
|
93
|
+
on(eventName: string, callback: (...args: unknown[]) => void): void;
|
|
94
|
+
off(eventName: string, callback: (...args: unknown[]) => void): void;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
declare abstract class SwapBuilder {
|
|
99
|
+
abstract estimatedGive(params: SwapBuilderParameters): bigint;
|
|
100
|
+
abstract estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
101
|
+
abstract priceImpactPercent(params: SwapBuilderParameters): number;
|
|
102
|
+
abstract fees(params: SwapBuilderParameters): SwapFee[];
|
|
103
|
+
abstract buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
104
|
+
abstract buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare class MinswapV1 extends SwapBuilder {
|
|
108
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
109
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
110
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
111
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
112
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
113
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare class MinswapV2 extends SwapBuilder {
|
|
117
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
118
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
119
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
120
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
121
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
122
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class Indigo {
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface TransactionCallback {
|
|
129
|
+
(transaction: Transaction): void;
|
|
130
|
+
}
|
|
131
|
+
declare class Transaction {
|
|
132
|
+
providerData: any;
|
|
133
|
+
error: TransactionError | undefined;
|
|
134
|
+
private _hash;
|
|
135
|
+
private _isSigned;
|
|
136
|
+
private _payments;
|
|
137
|
+
private _wallet;
|
|
138
|
+
private _currentStatus;
|
|
139
|
+
private _listeners;
|
|
140
|
+
constructor(wallet: IWallet);
|
|
141
|
+
get hash(): string;
|
|
142
|
+
get isSigned(): boolean;
|
|
143
|
+
get payments(): Payment[];
|
|
144
|
+
get status(): TransactionStatus;
|
|
145
|
+
set status(status: TransactionStatus);
|
|
146
|
+
payToAddresses(payments: Payment[]): Promise<Transaction>;
|
|
147
|
+
sign(): Promise<Transaction>;
|
|
148
|
+
submit(): Promise<Transaction>;
|
|
149
|
+
onBuilding(callback: TransactionCallback): Transaction;
|
|
150
|
+
onSigning(callback: TransactionCallback): Transaction;
|
|
151
|
+
onSubmitting(callback: TransactionCallback): Transaction;
|
|
152
|
+
onSubmitted(callback: TransactionCallback): Transaction;
|
|
153
|
+
onError(callback: TransactionCallback): Transaction;
|
|
154
|
+
onFinally(callback: TransactionCallback): Transaction;
|
|
155
|
+
private addListener;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare abstract class IWallet {
|
|
159
|
+
abstract isWalletLoaded: boolean;
|
|
160
|
+
abstract address(): string;
|
|
161
|
+
abstract publicKeyHash(): string;
|
|
162
|
+
abstract stakingKeyHash(): string;
|
|
163
|
+
abstract loadWallet(walletApi: Cip30Api, config: any): Promise<IWallet>;
|
|
164
|
+
abstract loadWalletFromSeedPhrase(seedPhrase: string[], config: BlockfrostConfig | KupmiosConfig): Promise<IWallet>;
|
|
165
|
+
abstract createTransaction(): Transaction;
|
|
166
|
+
abstract paymentsForTransaction(transaction: Transaction, payToAddresses: Payment[]): Promise<Transaction>;
|
|
167
|
+
abstract signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
168
|
+
abstract submitTransaction(transaction: Transaction): Promise<string>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare class Muesliswap extends SwapBuilder {
|
|
172
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
173
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
174
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
175
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
176
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
177
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare class Splash extends SwapBuilder {
|
|
181
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
182
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
183
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
184
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
185
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
186
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class SundaeSwapV1 extends SwapBuilder {
|
|
190
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
191
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
192
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
193
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
194
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
195
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare class SundaeSwapV3 extends SwapBuilder {
|
|
199
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
200
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
201
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
202
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
203
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
204
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare class WingRidersV1 extends SwapBuilder {
|
|
208
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
209
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
210
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
211
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
212
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
213
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare class WingRidersV2 extends SwapBuilder {
|
|
217
|
+
buildCancelSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
218
|
+
buildSwapOrder(params: SwapBuilderParameters): Promise<Payment[]>;
|
|
219
|
+
estimatedGive(params: SwapBuilderParameters): bigint;
|
|
220
|
+
estimatedReceive(params: SwapBuilderParameters): bigint;
|
|
221
|
+
fees(params: SwapBuilderParameters): SwapFee[];
|
|
222
|
+
priceImpactPercent(params: SwapBuilderParameters): number;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
declare class Dexter {
|
|
226
|
+
protected _config: ArcConfig;
|
|
227
|
+
protected _wallet: IWallet;
|
|
228
|
+
protected _irisApi: IrisApiService;
|
|
229
|
+
constructor(config: ArcConfig);
|
|
230
|
+
get wallet(): IWallet;
|
|
231
|
+
get iris(): Indigo;
|
|
232
|
+
get minswapV1(): MinswapV1;
|
|
233
|
+
get minswapV2(): MinswapV2;
|
|
234
|
+
get muesliswap(): Muesliswap;
|
|
235
|
+
get splash(): Splash;
|
|
236
|
+
get sundaeSwapV1(): SundaeSwapV1;
|
|
237
|
+
get sundaeSwapV3(): SundaeSwapV3;
|
|
238
|
+
get wingRidersV1(): WingRidersV1;
|
|
239
|
+
get wingRidersV2(): WingRidersV2;
|
|
240
|
+
get indigo(): Indigo;
|
|
241
|
+
get liqwid(): Indigo;
|
|
242
|
+
get bodega(): Indigo;
|
|
243
|
+
withWallet(wallet: IWallet): void;
|
|
244
|
+
}
|
|
245
|
+
declare const LoadArc: (config: ArcConfig) => Promise<Dexter>;
|
|
246
|
+
|
|
247
|
+
declare class Wallet extends IWallet {
|
|
248
|
+
isWalletLoaded: boolean;
|
|
249
|
+
constructor();
|
|
250
|
+
address(): string;
|
|
251
|
+
createTransaction(): Transaction;
|
|
252
|
+
loadWallet(walletApi: Cip30Api): Promise<IWallet>;
|
|
253
|
+
loadWalletFromSeedPhrase(seedPhrase: string[], config: BlockfrostConfig | KupmiosConfig): Promise<IWallet>;
|
|
254
|
+
paymentsForTransaction(transaction: Transaction, payToAddresses: Payment[]): Promise<Transaction>;
|
|
255
|
+
publicKeyHash(): string;
|
|
256
|
+
signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
257
|
+
stakingKeyHash(): string;
|
|
258
|
+
submitTransaction(transaction: Transaction): Promise<string>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { AddressType, type ArcConfig, type AssetBalance, type BlockfrostConfig, type Cip30Api, Dexter, IWallet, Indigo, type KupmiosConfig, type KupoConfig, LoadArc, MinswapV1, MinswapV2, type Payment, SwapBuilder, type SwapBuilderParameters, type SwapFee, Transaction, type TransactionError, TransactionStatus, Wallet };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=class{};var n=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var m=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var o=class{};var p=class{};var l=class extends p{isWalletLoaded;constructor(){super()}address(){return""}createTransaction(){}loadWallet(r){return Promise.resolve(void 0)}loadWalletFromSeedPhrase(r,e){return Promise.resolve(void 0)}paymentsForTransaction(r,e){return Promise.resolve(void 0)}publicKeyHash(){return""}signTransaction(r){return Promise.resolve(void 0)}stakingKeyHash(){return""}submitTransaction(r){return Promise.resolve("")}};import{IrisApiService as v}from"@indigo-labs/iris-sdk";var u=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var d=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var c=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var P=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var w=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var S=class extends t{buildCancelSwapOrder(r){return Promise.resolve([])}buildSwapOrder(r){return Promise.resolve([])}estimatedGive(r){return 0n}estimatedReceive(r){return 0n}fees(r){return[]}priceImpactPercent(r){return 0}};var b=class{};var g=class{};var f=class{_config;_wallet;_irisApi;constructor(r){this._config=r,this._irisApi=new v(r.irisHost??"https://iris.indigoprotocol.io")}get wallet(){return this._wallet}get iris(){return this._irisApi}get minswapV1(){return new n}get minswapV2(){return new m}get muesliswap(){return new u}get splash(){return new d}get sundaeSwapV1(){return new c}get sundaeSwapV3(){return new P}get wingRidersV1(){return new w}get wingRidersV2(){return new S}get indigo(){return new o}get liqwid(){return new b}get bodega(){return new g}withWallet(r){this._wallet=r}},nr=async a=>{let r=new f(a);if(a.wallet){let e=new l;await("seedPhrase"in a.wallet?e.loadWalletFromSeedPhrase(a.wallet.seedPhrase,a.wallet.connection):e.loadWallet(a.wallet.cip30)),r.withWallet(e)}return r};var B=(i=>(i[i.Building=0]="Building",i[i.Signing=1]="Signing",i[i.Submitting=2]="Submitting",i[i.Submitted=3]="Submitted",i[i.Errored=4]="Errored",i))(B||{}),y=(s=>(s[s.Contract=0]="Contract",s[s.Base=1]="Base",s[s.Enterprise=2]="Enterprise",s))(y||{});var h=class{providerData={};error=void 0;_hash;_isSigned=!1;_payments=[];_wallet;_currentStatus=0;_listeners=[];constructor(r){this._wallet=r}get hash(){return this._hash}get isSigned(){return this._isSigned}get payments(){return this._payments}get status(){return this._currentStatus}set status(r){this._currentStatus=r,this._listeners.forEach(e=>{e(this)})}payToAddresses(r){return this._wallet.paymentsForTransaction(this,r).then(()=>(this._payments=r,this))}sign(){if(this._isSigned)throw new Error("Transaction was already signed.");return this._wallet.signTransaction(this).then(()=>(this._isSigned=!0,this))}submit(){if(!this._isSigned)throw new Error("Must sign transaction before submitting.");if(this._hash)throw new Error("Transaction was already submitted.");return this._wallet.submitTransaction(this).then(r=>(this._hash=r,this))}onBuilding(r){return this.addListener(e=>{e.status===0&&r(e)}),this}onSigning(r){return this.addListener(e=>{e.status===1&&r(e)}),this}onSubmitting(r){return this.addListener(e=>{e.status===2&&r(e)}),this}onSubmitted(r){return this.addListener(e=>{e.status===3&&r(e)}),this}onError(r){return this.addListener(e=>{e.status===4&&r(e)}),this}onFinally(r){return this.addListener(e=>{(e.status===3||e.status===4)&&r(e)}),this}addListener(r){this._listeners.push(r)}};export{y as AddressType,f as Dexter,p as IWallet,o as Indigo,nr as LoadArc,n as MinswapV1,m as MinswapV2,t as SwapBuilder,h as Transaction,B as TransactionStatus,l as Wallet};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@3rd-eye-labs/dexter-v2",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"lint": "npx eslint .",
|
|
13
|
+
"build": "tsup src/index.ts --minify --format esm,cjs --dts --clean",
|
|
14
|
+
"start": "node dist/index.js",
|
|
15
|
+
"dev": "pnpm build && pnpm start",
|
|
16
|
+
"format": "npx prettier --write .",
|
|
17
|
+
"test": "jest"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@eslint/js": "^9.32.0",
|
|
24
|
+
"@types/jest": "^30.0.0",
|
|
25
|
+
"@types/node": "^24.3.0",
|
|
26
|
+
"eslint": "^9.32.0",
|
|
27
|
+
"jest": "^30.2.0",
|
|
28
|
+
"prettier": "^3.6.2",
|
|
29
|
+
"ts-jest": "^29.4.6",
|
|
30
|
+
"ts-node": "^10.9.2",
|
|
31
|
+
"tsup": "^8.3.6",
|
|
32
|
+
"typescript": "^5.9.2",
|
|
33
|
+
"typescript-eslint": "^8.39.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@indigo-labs/iris-sdk": "^1.0.5",
|
|
37
|
+
"@lucid-evolution/lucid": "^0.4.29"
|
|
38
|
+
}
|
|
39
|
+
}
|