@baseline-markets/sdk 1.0.2 → 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 +426 -1819
- package/dist/index.d.cts +87 -4
- package/dist/index.d.ts +87 -4
- package/dist/index.js +427 -1821
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
1
|
+
import { Address, Hex, PublicClient, WalletClient, Call, toHex } from 'viem';
|
|
2
2
|
export { mercuryAbis as abis } from '@baseline/contracts/abis';
|
|
3
3
|
|
|
4
|
-
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 = {
|
|
5
23
|
bToken: Address;
|
|
6
24
|
initialPoolBTokens: bigint;
|
|
7
25
|
reserve: Address;
|
|
@@ -17,6 +35,17 @@ type CreateParams = {
|
|
|
17
35
|
initialCollateral: bigint;
|
|
18
36
|
initialDebt: bigint;
|
|
19
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
|
+
};
|
|
20
49
|
type PoolKey = {
|
|
21
50
|
currency0: Address;
|
|
22
51
|
currency1: Address;
|
|
@@ -84,12 +113,47 @@ type SDKConfig = {
|
|
|
84
113
|
defaultUseNative?: boolean;
|
|
85
114
|
wrappedNative?: Address;
|
|
86
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
|
+
};
|
|
87
146
|
|
|
88
147
|
declare class BaselineSDK {
|
|
89
148
|
readonly publicClient: PublicClient;
|
|
90
149
|
readonly walletClient?: WalletClient;
|
|
91
150
|
readonly config?: SDKConfig;
|
|
92
151
|
private readonly readFactory;
|
|
152
|
+
readonly calls: {
|
|
153
|
+
launch: (input: LaunchInput, opts?: {
|
|
154
|
+
account?: Address;
|
|
155
|
+
}) => Promise<Call[]>;
|
|
156
|
+
};
|
|
93
157
|
private getAccount;
|
|
94
158
|
private requireWallet;
|
|
95
159
|
constructor(publicClient: PublicClient<any, any>, walletClient?: WalletClient<any, any, any>, config?: SDKConfig);
|
|
@@ -101,9 +165,20 @@ declare class BaselineSDK {
|
|
|
101
165
|
hash: Hex;
|
|
102
166
|
bToken: Address;
|
|
103
167
|
}>;
|
|
104
|
-
createPool(params:
|
|
168
|
+
createPool(params: CreatePoolParams, opts?: TxOpts): Promise<{
|
|
169
|
+
hash: Hex;
|
|
170
|
+
}>;
|
|
171
|
+
createPoolFromInvariant(params: CreatePoolFromInvariantParams, opts?: TxOpts): Promise<{
|
|
105
172
|
hash: Hex;
|
|
106
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;
|
|
107
182
|
quoteBuyExactIn(bToken: Address, reservesIn: bigint): Promise<{
|
|
108
183
|
tokensOut: bigint;
|
|
109
184
|
fee: bigint;
|
|
@@ -189,6 +264,7 @@ declare class BaselineSDK {
|
|
|
189
264
|
ensureApproval(token: Address, spender: Address, required: bigint, opts?: TxOpts & {
|
|
190
265
|
policy?: 'infinite' | 'exact';
|
|
191
266
|
}): Promise<void>;
|
|
267
|
+
getBTokenInfo(bToken: Address): Promise<BTokenInfo>;
|
|
192
268
|
getReserve(bToken: Address): Promise<Address>;
|
|
193
269
|
activePrice(bToken: Address): Promise<bigint>;
|
|
194
270
|
quoteLeverage(bToken: Address, collateralIn: bigint, leverageFactor: bigint): Promise<{
|
|
@@ -199,6 +275,13 @@ declare class BaselineSDK {
|
|
|
199
275
|
}>;
|
|
200
276
|
}
|
|
201
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
|
+
|
|
202
285
|
/**
|
|
203
286
|
* Coarse-grained category for an SDKError. Consumers should branch on this
|
|
204
287
|
* instead of sniffing the message string or unwrapping `cause`.
|
|
@@ -221,4 +304,4 @@ declare class SDKError extends Error {
|
|
|
221
304
|
|
|
222
305
|
declare const supportedChainIds: number[];
|
|
223
306
|
|
|
224
|
-
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,7 +1,25 @@
|
|
|
1
|
-
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
1
|
+
import { Address, Hex, PublicClient, WalletClient, Call, toHex } from 'viem';
|
|
2
2
|
export { mercuryAbis as abis } from '@baseline/contracts/abis';
|
|
3
3
|
|
|
4
|
-
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 = {
|
|
5
23
|
bToken: Address;
|
|
6
24
|
initialPoolBTokens: bigint;
|
|
7
25
|
reserve: Address;
|
|
@@ -17,6 +35,17 @@ type CreateParams = {
|
|
|
17
35
|
initialCollateral: bigint;
|
|
18
36
|
initialDebt: bigint;
|
|
19
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
|
+
};
|
|
20
49
|
type PoolKey = {
|
|
21
50
|
currency0: Address;
|
|
22
51
|
currency1: Address;
|
|
@@ -84,12 +113,47 @@ type SDKConfig = {
|
|
|
84
113
|
defaultUseNative?: boolean;
|
|
85
114
|
wrappedNative?: Address;
|
|
86
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
|
+
};
|
|
87
146
|
|
|
88
147
|
declare class BaselineSDK {
|
|
89
148
|
readonly publicClient: PublicClient;
|
|
90
149
|
readonly walletClient?: WalletClient;
|
|
91
150
|
readonly config?: SDKConfig;
|
|
92
151
|
private readonly readFactory;
|
|
152
|
+
readonly calls: {
|
|
153
|
+
launch: (input: LaunchInput, opts?: {
|
|
154
|
+
account?: Address;
|
|
155
|
+
}) => Promise<Call[]>;
|
|
156
|
+
};
|
|
93
157
|
private getAccount;
|
|
94
158
|
private requireWallet;
|
|
95
159
|
constructor(publicClient: PublicClient<any, any>, walletClient?: WalletClient<any, any, any>, config?: SDKConfig);
|
|
@@ -101,9 +165,20 @@ declare class BaselineSDK {
|
|
|
101
165
|
hash: Hex;
|
|
102
166
|
bToken: Address;
|
|
103
167
|
}>;
|
|
104
|
-
createPool(params:
|
|
168
|
+
createPool(params: CreatePoolParams, opts?: TxOpts): Promise<{
|
|
169
|
+
hash: Hex;
|
|
170
|
+
}>;
|
|
171
|
+
createPoolFromInvariant(params: CreatePoolFromInvariantParams, opts?: TxOpts): Promise<{
|
|
105
172
|
hash: Hex;
|
|
106
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;
|
|
107
182
|
quoteBuyExactIn(bToken: Address, reservesIn: bigint): Promise<{
|
|
108
183
|
tokensOut: bigint;
|
|
109
184
|
fee: bigint;
|
|
@@ -189,6 +264,7 @@ declare class BaselineSDK {
|
|
|
189
264
|
ensureApproval(token: Address, spender: Address, required: bigint, opts?: TxOpts & {
|
|
190
265
|
policy?: 'infinite' | 'exact';
|
|
191
266
|
}): Promise<void>;
|
|
267
|
+
getBTokenInfo(bToken: Address): Promise<BTokenInfo>;
|
|
192
268
|
getReserve(bToken: Address): Promise<Address>;
|
|
193
269
|
activePrice(bToken: Address): Promise<bigint>;
|
|
194
270
|
quoteLeverage(bToken: Address, collateralIn: bigint, leverageFactor: bigint): Promise<{
|
|
@@ -199,6 +275,13 @@ declare class BaselineSDK {
|
|
|
199
275
|
}>;
|
|
200
276
|
}
|
|
201
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
|
+
|
|
202
285
|
/**
|
|
203
286
|
* Coarse-grained category for an SDKError. Consumers should branch on this
|
|
204
287
|
* instead of sniffing the message string or unwrapping `cause`.
|
|
@@ -221,4 +304,4 @@ declare class SDKError extends Error {
|
|
|
221
304
|
|
|
222
305
|
declare const supportedChainIds: number[];
|
|
223
306
|
|
|
224
|
-
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 };
|