@baseline-markets/sdk 1.0.1 → 1.1.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/dist/index.cjs +427 -1819
- package/dist/index.d.cts +88 -4
- package/dist/index.d.ts +88 -4
- package/dist/index.js +427 -1821
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
1
|
+
import { Address, Hex, PublicClient, WalletClient, Call, toHex } from 'viem';
|
|
2
|
+
export { mercuryAbis as abis } from '@baseline/contracts/abis';
|
|
2
3
|
|
|
3
|
-
type
|
|
4
|
+
type LaunchMode = 'zrp' | 'standard';
|
|
5
|
+
type BaseLaunchInput = {
|
|
6
|
+
name: string;
|
|
7
|
+
symbol: string;
|
|
8
|
+
reserve: Address;
|
|
9
|
+
totalSupply: bigint;
|
|
10
|
+
initialPoolBTokens: bigint;
|
|
11
|
+
creator: Address;
|
|
12
|
+
creatorFeePct: bigint;
|
|
13
|
+
mode?: LaunchMode;
|
|
14
|
+
initialPoolReserves?: bigint;
|
|
15
|
+
feeRecipient?: Address;
|
|
16
|
+
swapFeePct?: bigint;
|
|
17
|
+
salt?: Hex | null;
|
|
18
|
+
reserveDecimals?: number;
|
|
19
|
+
};
|
|
20
|
+
type LaunchInput = BaseLaunchInput;
|
|
21
|
+
|
|
22
|
+
type CreatePoolParams = {
|
|
4
23
|
bToken: Address;
|
|
5
24
|
initialPoolBTokens: bigint;
|
|
6
25
|
reserve: Address;
|
|
@@ -16,6 +35,17 @@ type CreateParams = {
|
|
|
16
35
|
initialCollateral: bigint;
|
|
17
36
|
initialDebt: bigint;
|
|
18
37
|
};
|
|
38
|
+
type CreatePoolFromInvariantParams = {
|
|
39
|
+
bToken: Address;
|
|
40
|
+
initialPoolBTokens: bigint;
|
|
41
|
+
reserve: Address;
|
|
42
|
+
initialInvariant: bigint;
|
|
43
|
+
creator: Address;
|
|
44
|
+
feeRecipient: Address;
|
|
45
|
+
creatorFeePct: bigint;
|
|
46
|
+
swapFeePct: bigint;
|
|
47
|
+
createHook: boolean;
|
|
48
|
+
};
|
|
19
49
|
type PoolKey = {
|
|
20
50
|
currency0: Address;
|
|
21
51
|
currency1: Address;
|
|
@@ -83,12 +113,47 @@ type SDKConfig = {
|
|
|
83
113
|
defaultUseNative?: boolean;
|
|
84
114
|
wrappedNative?: Address;
|
|
85
115
|
};
|
|
116
|
+
type BTokenInfoStatus = 'not_deployed' | 'contract_only' | 'baseline_uninitialized' | 'initialized';
|
|
117
|
+
type BTokenMakerInfo = {
|
|
118
|
+
initialized: boolean;
|
|
119
|
+
blvPrice: bigint;
|
|
120
|
+
swapFee: bigint;
|
|
121
|
+
maxCirc: bigint;
|
|
122
|
+
maxReserves: bigint;
|
|
123
|
+
convexityExp: bigint;
|
|
124
|
+
lastInvariant: bigint;
|
|
125
|
+
};
|
|
126
|
+
type BTokenInfo = {
|
|
127
|
+
chainId: number;
|
|
128
|
+
relay: Address;
|
|
129
|
+
bToken: Address;
|
|
130
|
+
status: BTokenInfoStatus;
|
|
131
|
+
bytecode: boolean;
|
|
132
|
+
name?: string;
|
|
133
|
+
symbol?: string;
|
|
134
|
+
decimals?: number;
|
|
135
|
+
totalSupply?: bigint;
|
|
136
|
+
reserve?: Address;
|
|
137
|
+
reserveDecimals?: number;
|
|
138
|
+
creator?: Address;
|
|
139
|
+
poolFeeRecipient?: Address;
|
|
140
|
+
creatorFeePct?: bigint;
|
|
141
|
+
swapFee?: bigint;
|
|
142
|
+
totalBTokens?: bigint;
|
|
143
|
+
totalReserves?: bigint;
|
|
144
|
+
maker?: BTokenMakerInfo;
|
|
145
|
+
};
|
|
86
146
|
|
|
87
147
|
declare class BaselineSDK {
|
|
88
148
|
readonly publicClient: PublicClient;
|
|
89
149
|
readonly walletClient?: WalletClient;
|
|
90
150
|
readonly config?: SDKConfig;
|
|
91
151
|
private readonly readFactory;
|
|
152
|
+
readonly calls: {
|
|
153
|
+
launch: (input: LaunchInput, opts?: {
|
|
154
|
+
account?: Address;
|
|
155
|
+
}) => Promise<Call[]>;
|
|
156
|
+
};
|
|
92
157
|
private getAccount;
|
|
93
158
|
private requireWallet;
|
|
94
159
|
constructor(publicClient: PublicClient<any, any>, walletClient?: WalletClient<any, any, any>, config?: SDKConfig);
|
|
@@ -100,9 +165,20 @@ declare class BaselineSDK {
|
|
|
100
165
|
hash: Hex;
|
|
101
166
|
bToken: Address;
|
|
102
167
|
}>;
|
|
103
|
-
createPool(params:
|
|
168
|
+
createPool(params: CreatePoolParams, opts?: TxOpts): Promise<{
|
|
169
|
+
hash: Hex;
|
|
170
|
+
}>;
|
|
171
|
+
createPoolFromInvariant(params: CreatePoolFromInvariantParams, opts?: TxOpts): Promise<{
|
|
104
172
|
hash: Hex;
|
|
105
173
|
}>;
|
|
174
|
+
precomputeBTokenAddress(input: {
|
|
175
|
+
name: string;
|
|
176
|
+
symbol: string;
|
|
177
|
+
totalSupply: bigint;
|
|
178
|
+
salt: Hex;
|
|
179
|
+
deployer: Address;
|
|
180
|
+
}): Promise<Address>;
|
|
181
|
+
private launchCalls;
|
|
106
182
|
quoteBuyExactIn(bToken: Address, reservesIn: bigint): Promise<{
|
|
107
183
|
tokensOut: bigint;
|
|
108
184
|
fee: bigint;
|
|
@@ -188,6 +264,7 @@ declare class BaselineSDK {
|
|
|
188
264
|
ensureApproval(token: Address, spender: Address, required: bigint, opts?: TxOpts & {
|
|
189
265
|
policy?: 'infinite' | 'exact';
|
|
190
266
|
}): Promise<void>;
|
|
267
|
+
getBTokenInfo(bToken: Address): Promise<BTokenInfo>;
|
|
191
268
|
getReserve(bToken: Address): Promise<Address>;
|
|
192
269
|
activePrice(bToken: Address): Promise<bigint>;
|
|
193
270
|
quoteLeverage(bToken: Address, collateralIn: bigint, leverageFactor: bigint): Promise<{
|
|
@@ -198,6 +275,13 @@ declare class BaselineSDK {
|
|
|
198
275
|
}>;
|
|
199
276
|
}
|
|
200
277
|
|
|
278
|
+
type SerializedCall = {
|
|
279
|
+
to: Call['to'];
|
|
280
|
+
data?: Call['data'];
|
|
281
|
+
value: ReturnType<typeof toHex>;
|
|
282
|
+
};
|
|
283
|
+
declare function serializeCalls(calls: Call[]): SerializedCall[];
|
|
284
|
+
|
|
201
285
|
/**
|
|
202
286
|
* Coarse-grained category for an SDKError. Consumers should branch on this
|
|
203
287
|
* instead of sniffing the message string or unwrapping `cause`.
|
|
@@ -220,4 +304,4 @@ declare class SDKError extends Error {
|
|
|
220
304
|
|
|
221
305
|
declare const supportedChainIds: number[];
|
|
222
306
|
|
|
223
|
-
export { type ApprovalOpts, type ApprovalPolicy, BaselineSDK, type
|
|
307
|
+
export { type ApprovalOpts, type ApprovalPolicy, type BTokenInfo, type BTokenInfoStatus, type BTokenMakerInfo, BaselineSDK, type CreatePoolFromInvariantParams, type CreatePoolParams, type CreditAccount, type DeleverageResult, type LaunchInput, type LaunchMode, type LeverageResult, type NativeOpts, type PoolKey, type QuoteBuyBToken, type QuoteBuyReserves, type QuoteSellBToken, type QuoteSellReserves, type SDKConfig, SDKError, type SerializedCall, type StakedAccount, type SwapOpts, type TxOpts, serializeCalls, supportedChainIds };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
1
|
+
import { Address, Hex, PublicClient, WalletClient, Call, toHex } from 'viem';
|
|
2
|
+
export { mercuryAbis as abis } from '@baseline/contracts/abis';
|
|
2
3
|
|
|
3
|
-
type
|
|
4
|
+
type LaunchMode = 'zrp' | 'standard';
|
|
5
|
+
type BaseLaunchInput = {
|
|
6
|
+
name: string;
|
|
7
|
+
symbol: string;
|
|
8
|
+
reserve: Address;
|
|
9
|
+
totalSupply: bigint;
|
|
10
|
+
initialPoolBTokens: bigint;
|
|
11
|
+
creator: Address;
|
|
12
|
+
creatorFeePct: bigint;
|
|
13
|
+
mode?: LaunchMode;
|
|
14
|
+
initialPoolReserves?: bigint;
|
|
15
|
+
feeRecipient?: Address;
|
|
16
|
+
swapFeePct?: bigint;
|
|
17
|
+
salt?: Hex | null;
|
|
18
|
+
reserveDecimals?: number;
|
|
19
|
+
};
|
|
20
|
+
type LaunchInput = BaseLaunchInput;
|
|
21
|
+
|
|
22
|
+
type CreatePoolParams = {
|
|
4
23
|
bToken: Address;
|
|
5
24
|
initialPoolBTokens: bigint;
|
|
6
25
|
reserve: Address;
|
|
@@ -16,6 +35,17 @@ type CreateParams = {
|
|
|
16
35
|
initialCollateral: bigint;
|
|
17
36
|
initialDebt: bigint;
|
|
18
37
|
};
|
|
38
|
+
type CreatePoolFromInvariantParams = {
|
|
39
|
+
bToken: Address;
|
|
40
|
+
initialPoolBTokens: bigint;
|
|
41
|
+
reserve: Address;
|
|
42
|
+
initialInvariant: bigint;
|
|
43
|
+
creator: Address;
|
|
44
|
+
feeRecipient: Address;
|
|
45
|
+
creatorFeePct: bigint;
|
|
46
|
+
swapFeePct: bigint;
|
|
47
|
+
createHook: boolean;
|
|
48
|
+
};
|
|
19
49
|
type PoolKey = {
|
|
20
50
|
currency0: Address;
|
|
21
51
|
currency1: Address;
|
|
@@ -83,12 +113,47 @@ type SDKConfig = {
|
|
|
83
113
|
defaultUseNative?: boolean;
|
|
84
114
|
wrappedNative?: Address;
|
|
85
115
|
};
|
|
116
|
+
type BTokenInfoStatus = 'not_deployed' | 'contract_only' | 'baseline_uninitialized' | 'initialized';
|
|
117
|
+
type BTokenMakerInfo = {
|
|
118
|
+
initialized: boolean;
|
|
119
|
+
blvPrice: bigint;
|
|
120
|
+
swapFee: bigint;
|
|
121
|
+
maxCirc: bigint;
|
|
122
|
+
maxReserves: bigint;
|
|
123
|
+
convexityExp: bigint;
|
|
124
|
+
lastInvariant: bigint;
|
|
125
|
+
};
|
|
126
|
+
type BTokenInfo = {
|
|
127
|
+
chainId: number;
|
|
128
|
+
relay: Address;
|
|
129
|
+
bToken: Address;
|
|
130
|
+
status: BTokenInfoStatus;
|
|
131
|
+
bytecode: boolean;
|
|
132
|
+
name?: string;
|
|
133
|
+
symbol?: string;
|
|
134
|
+
decimals?: number;
|
|
135
|
+
totalSupply?: bigint;
|
|
136
|
+
reserve?: Address;
|
|
137
|
+
reserveDecimals?: number;
|
|
138
|
+
creator?: Address;
|
|
139
|
+
poolFeeRecipient?: Address;
|
|
140
|
+
creatorFeePct?: bigint;
|
|
141
|
+
swapFee?: bigint;
|
|
142
|
+
totalBTokens?: bigint;
|
|
143
|
+
totalReserves?: bigint;
|
|
144
|
+
maker?: BTokenMakerInfo;
|
|
145
|
+
};
|
|
86
146
|
|
|
87
147
|
declare class BaselineSDK {
|
|
88
148
|
readonly publicClient: PublicClient;
|
|
89
149
|
readonly walletClient?: WalletClient;
|
|
90
150
|
readonly config?: SDKConfig;
|
|
91
151
|
private readonly readFactory;
|
|
152
|
+
readonly calls: {
|
|
153
|
+
launch: (input: LaunchInput, opts?: {
|
|
154
|
+
account?: Address;
|
|
155
|
+
}) => Promise<Call[]>;
|
|
156
|
+
};
|
|
92
157
|
private getAccount;
|
|
93
158
|
private requireWallet;
|
|
94
159
|
constructor(publicClient: PublicClient<any, any>, walletClient?: WalletClient<any, any, any>, config?: SDKConfig);
|
|
@@ -100,9 +165,20 @@ declare class BaselineSDK {
|
|
|
100
165
|
hash: Hex;
|
|
101
166
|
bToken: Address;
|
|
102
167
|
}>;
|
|
103
|
-
createPool(params:
|
|
168
|
+
createPool(params: CreatePoolParams, opts?: TxOpts): Promise<{
|
|
169
|
+
hash: Hex;
|
|
170
|
+
}>;
|
|
171
|
+
createPoolFromInvariant(params: CreatePoolFromInvariantParams, opts?: TxOpts): Promise<{
|
|
104
172
|
hash: Hex;
|
|
105
173
|
}>;
|
|
174
|
+
precomputeBTokenAddress(input: {
|
|
175
|
+
name: string;
|
|
176
|
+
symbol: string;
|
|
177
|
+
totalSupply: bigint;
|
|
178
|
+
salt: Hex;
|
|
179
|
+
deployer: Address;
|
|
180
|
+
}): Promise<Address>;
|
|
181
|
+
private launchCalls;
|
|
106
182
|
quoteBuyExactIn(bToken: Address, reservesIn: bigint): Promise<{
|
|
107
183
|
tokensOut: bigint;
|
|
108
184
|
fee: bigint;
|
|
@@ -188,6 +264,7 @@ declare class BaselineSDK {
|
|
|
188
264
|
ensureApproval(token: Address, spender: Address, required: bigint, opts?: TxOpts & {
|
|
189
265
|
policy?: 'infinite' | 'exact';
|
|
190
266
|
}): Promise<void>;
|
|
267
|
+
getBTokenInfo(bToken: Address): Promise<BTokenInfo>;
|
|
191
268
|
getReserve(bToken: Address): Promise<Address>;
|
|
192
269
|
activePrice(bToken: Address): Promise<bigint>;
|
|
193
270
|
quoteLeverage(bToken: Address, collateralIn: bigint, leverageFactor: bigint): Promise<{
|
|
@@ -198,6 +275,13 @@ declare class BaselineSDK {
|
|
|
198
275
|
}>;
|
|
199
276
|
}
|
|
200
277
|
|
|
278
|
+
type SerializedCall = {
|
|
279
|
+
to: Call['to'];
|
|
280
|
+
data?: Call['data'];
|
|
281
|
+
value: ReturnType<typeof toHex>;
|
|
282
|
+
};
|
|
283
|
+
declare function serializeCalls(calls: Call[]): SerializedCall[];
|
|
284
|
+
|
|
201
285
|
/**
|
|
202
286
|
* Coarse-grained category for an SDKError. Consumers should branch on this
|
|
203
287
|
* instead of sniffing the message string or unwrapping `cause`.
|
|
@@ -220,4 +304,4 @@ declare class SDKError extends Error {
|
|
|
220
304
|
|
|
221
305
|
declare const supportedChainIds: number[];
|
|
222
306
|
|
|
223
|
-
export { type ApprovalOpts, type ApprovalPolicy, BaselineSDK, type
|
|
307
|
+
export { type ApprovalOpts, type ApprovalPolicy, type BTokenInfo, type BTokenInfoStatus, type BTokenMakerInfo, BaselineSDK, type CreatePoolFromInvariantParams, type CreatePoolParams, type CreditAccount, type DeleverageResult, type LaunchInput, type LaunchMode, type LeverageResult, type NativeOpts, type PoolKey, type QuoteBuyBToken, type QuoteBuyReserves, type QuoteSellBToken, type QuoteSellReserves, type SDKConfig, SDKError, type SerializedCall, type StakedAccount, type SwapOpts, type TxOpts, serializeCalls, supportedChainIds };
|