@clober/v2-sdk 0.0.9 → 0.0.11
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/cjs/abis/core/controller-abi.js +28 -18
- package/dist/cjs/abis/core/controller-abi.js.map +1 -1
- package/dist/cjs/approval.js.map +1 -1
- package/dist/cjs/call.js +145 -84
- package/dist/cjs/call.js.map +1 -1
- package/dist/cjs/signature.js +9 -10
- package/dist/cjs/signature.js.map +1 -1
- package/dist/cjs/type.js.map +1 -1
- package/dist/cjs/utils/build-transaction.js +8 -7
- package/dist/cjs/utils/build-transaction.js.map +1 -1
- package/dist/esm/abis/core/controller-abi.js +28 -18
- package/dist/esm/abis/core/controller-abi.js.map +1 -1
- package/dist/esm/approval.js +3 -12
- package/dist/esm/approval.js.map +1 -1
- package/dist/esm/call.js +165 -109
- package/dist/esm/call.js.map +1 -1
- package/dist/esm/signature.js +11 -24
- package/dist/esm/signature.js.map +1 -1
- package/dist/esm/type.js.map +1 -1
- package/dist/esm/utils/build-transaction.js +8 -7
- package/dist/esm/utils/build-transaction.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/abis/core/controller-abi.d.ts +22 -14
- package/dist/types/abis/core/controller-abi.d.ts.map +1 -1
- package/dist/types/approval.d.ts +3 -12
- package/dist/types/approval.d.ts.map +1 -1
- package/dist/types/call.d.ts +30 -29
- package/dist/types/call.d.ts.map +1 -1
- package/dist/types/signature.d.ts +3 -15
- package/dist/types/signature.d.ts.map +1 -1
- package/dist/types/type.d.ts +6 -0
- package/dist/types/type.d.ts.map +1 -1
- package/dist/types/utils/build-transaction.d.ts +1 -1
- package/dist/types/utils/build-transaction.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -14,14 +14,6 @@ export declare const CONTROLLER_ABI: readonly [{
|
|
|
14
14
|
}];
|
|
15
15
|
readonly name: "AddressEmptyCode";
|
|
16
16
|
readonly type: "error";
|
|
17
|
-
}, {
|
|
18
|
-
readonly inputs: readonly [{
|
|
19
|
-
readonly internalType: "address";
|
|
20
|
-
readonly name: "account";
|
|
21
|
-
readonly type: "address";
|
|
22
|
-
}];
|
|
23
|
-
readonly name: "AddressInsufficientBalance";
|
|
24
|
-
readonly type: "error";
|
|
25
17
|
}, {
|
|
26
18
|
readonly inputs: readonly [];
|
|
27
19
|
readonly name: "ControllerSlippage";
|
|
@@ -36,7 +28,19 @@ export declare const CONTROLLER_ABI: readonly [{
|
|
|
36
28
|
readonly type: "error";
|
|
37
29
|
}, {
|
|
38
30
|
readonly inputs: readonly [];
|
|
39
|
-
readonly name: "
|
|
31
|
+
readonly name: "FailedCall";
|
|
32
|
+
readonly type: "error";
|
|
33
|
+
}, {
|
|
34
|
+
readonly inputs: readonly [{
|
|
35
|
+
readonly internalType: "uint256";
|
|
36
|
+
readonly name: "balance";
|
|
37
|
+
readonly type: "uint256";
|
|
38
|
+
}, {
|
|
39
|
+
readonly internalType: "uint256";
|
|
40
|
+
readonly name: "needed";
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
}];
|
|
43
|
+
readonly name: "InsufficientBalance";
|
|
40
44
|
readonly type: "error";
|
|
41
45
|
}, {
|
|
42
46
|
readonly inputs: readonly [];
|
|
@@ -90,10 +94,6 @@ export declare const CONTROLLER_ABI: readonly [{
|
|
|
90
94
|
}];
|
|
91
95
|
readonly name: "SafeERC20FailedOperation";
|
|
92
96
|
readonly type: "error";
|
|
93
|
-
}, {
|
|
94
|
-
readonly inputs: readonly [];
|
|
95
|
-
readonly name: "ValueTransferFailed";
|
|
96
|
-
readonly type: "error";
|
|
97
97
|
}, {
|
|
98
98
|
readonly inputs: readonly [{
|
|
99
99
|
readonly components: readonly [{
|
|
@@ -340,7 +340,7 @@ export declare const CONTROLLER_ABI: readonly [{
|
|
|
340
340
|
readonly name: "id";
|
|
341
341
|
readonly type: "uint192";
|
|
342
342
|
}];
|
|
343
|
-
readonly name: "
|
|
343
|
+
readonly name: "getHighestPrice";
|
|
344
344
|
readonly outputs: readonly [{
|
|
345
345
|
readonly internalType: "uint256";
|
|
346
346
|
readonly name: "";
|
|
@@ -612,6 +612,10 @@ export declare const CONTROLLER_ABI: readonly [{
|
|
|
612
612
|
readonly internalType: "uint256";
|
|
613
613
|
readonly name: "baseAmount";
|
|
614
614
|
readonly type: "uint256";
|
|
615
|
+
}, {
|
|
616
|
+
readonly internalType: "uint256";
|
|
617
|
+
readonly name: "minQuoteAmount";
|
|
618
|
+
readonly type: "uint256";
|
|
615
619
|
}, {
|
|
616
620
|
readonly internalType: "bytes";
|
|
617
621
|
readonly name: "hookData";
|
|
@@ -681,6 +685,10 @@ export declare const CONTROLLER_ABI: readonly [{
|
|
|
681
685
|
readonly internalType: "uint256";
|
|
682
686
|
readonly name: "quoteAmount";
|
|
683
687
|
readonly type: "uint256";
|
|
688
|
+
}, {
|
|
689
|
+
readonly internalType: "uint256";
|
|
690
|
+
readonly name: "maxBaseAmount";
|
|
691
|
+
readonly type: "uint256";
|
|
684
692
|
}, {
|
|
685
693
|
readonly internalType: "bytes";
|
|
686
694
|
readonly name: "hookData";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-abi.d.ts","sourceRoot":"","sources":["../../../../src/abis/core/controller-abi.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"controller-abi.d.ts","sourceRoot":"","sources":["../../../../src/abis/core/controller-abi.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAk+BjB,CAAA"}
|
package/dist/types/approval.d.ts
CHANGED
|
@@ -12,15 +12,6 @@ import type { DefaultOptions } from './type';
|
|
|
12
12
|
* @returns {Promise<`0x${string}` | undefined>} Promise resolving to the transaction hash. If the account is already approved for all, the promise resolves to `undefined`.
|
|
13
13
|
* @example
|
|
14
14
|
* import { setApprovalOfOpenOrdersForAll } from '@clober/v2-sdk'
|
|
15
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
16
|
-
*
|
|
17
|
-
* const hash = await setApprovalOfOpenOrdersForAll({
|
|
18
|
-
* chainId: 421614,
|
|
19
|
-
* account: privateKeyToAccount('0x...')
|
|
20
|
-
* })
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* import { setApprovalOfOpenOrdersForAll } from '@clober/v2-sdk'
|
|
24
15
|
* import { mnemonicToAccount } from 'viem/accounts'
|
|
25
16
|
*
|
|
26
17
|
* const walletClient = createWalletClient({
|
|
@@ -29,10 +20,10 @@ import type { DefaultOptions } from './type';
|
|
|
29
20
|
* transport: http(),
|
|
30
21
|
* })
|
|
31
22
|
*
|
|
32
|
-
* const hash = await setApprovalOfOpenOrdersForAll(
|
|
33
|
-
* 421614,
|
|
23
|
+
* const hash = await setApprovalOfOpenOrdersForAll({
|
|
24
|
+
* chainId: 421614,
|
|
34
25
|
* walletClient
|
|
35
|
-
* )
|
|
26
|
+
* })
|
|
36
27
|
*/
|
|
37
28
|
export declare const setApprovalOfOpenOrdersForAll: (args: {
|
|
38
29
|
chainId: CHAIN_IDS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAA;AAIxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAuB5C
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAA;AAIxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAuB5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B;aAK7B,SAAS;kBACJ,YAAY;cAChB,cAAc;wCAqB3B,CAAA"}
|
package/dist/types/call.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CHAIN_IDS } from './constants/chain';
|
|
2
|
-
import type { CurrencyFlow, DefaultOptions,
|
|
2
|
+
import type { CurrencyFlow, DefaultOptions, ERC20PermitParam, Transaction } from './type';
|
|
3
3
|
/**
|
|
4
4
|
* Build a transaction to open a market.
|
|
5
5
|
*
|
|
@@ -34,7 +34,7 @@ export declare const openMarket: (args: {
|
|
|
34
34
|
* @param {string} amount The amount of input tokens for the order.
|
|
35
35
|
* @param {string} price The price at which the order should be executed.
|
|
36
36
|
* @param {Object} [options] Optional parameters for the limit order.
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {erc20PermitParam} [options.erc20PermitParam] The permit signature for token approval.
|
|
38
38
|
* @param {boolean} [options.postOnly] A boolean indicating whether the order is only to be made not taken.
|
|
39
39
|
* @param {string} [options.rpcUrl] The RPC URL of the blockchain.
|
|
40
40
|
* @returns {Promise<{ transaction: Transaction, result: { make: CurrencyFlow, take: CurrencyFlow } }>}
|
|
@@ -43,9 +43,9 @@ export declare const openMarket: (args: {
|
|
|
43
43
|
* import { signERC20Permit, limitOrder } from '@clober/v2-sdk'
|
|
44
44
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
45
45
|
*
|
|
46
|
-
* const
|
|
46
|
+
* const erc20PermitParam = await signERC20Permit({
|
|
47
47
|
* chainId: 421614,
|
|
48
|
-
*
|
|
48
|
+
* walletClient,
|
|
49
49
|
* token: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
50
50
|
* amount: '100.123'
|
|
51
51
|
* })
|
|
@@ -57,7 +57,7 @@ export declare const openMarket: (args: {
|
|
|
57
57
|
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
58
58
|
* amount: '100.123', // 100.123 USDC
|
|
59
59
|
* price: '4000.01', // price at 4000.01 (ETH/USDC)
|
|
60
|
-
* options: {
|
|
60
|
+
* options: { erc20PermitParam }
|
|
61
61
|
* })
|
|
62
62
|
*
|
|
63
63
|
* @example
|
|
@@ -80,7 +80,7 @@ export declare const limitOrder: (args: {
|
|
|
80
80
|
amount: string;
|
|
81
81
|
price: string;
|
|
82
82
|
options?: {
|
|
83
|
-
|
|
83
|
+
erc20PermitParam?: ERC20PermitParam;
|
|
84
84
|
postOnly?: boolean;
|
|
85
85
|
} & DefaultOptions;
|
|
86
86
|
}) => Promise<{
|
|
@@ -92,25 +92,29 @@ export declare const limitOrder: (args: {
|
|
|
92
92
|
}>;
|
|
93
93
|
/**
|
|
94
94
|
* Executes a market order on the specified chain for trading tokens.
|
|
95
|
+
* If only `amountIn` is provided, spend the specified amount of input tokens.
|
|
96
|
+
* If `amountIn` and `amountOut` are provided, take the appropriate amount of output tokens with the specified input amount.
|
|
95
97
|
*
|
|
96
98
|
* @param {CHAIN_IDS} chainId The chain ID.
|
|
97
99
|
* @param {`0x${string}`} userAddress The Ethereum address of the user placing the order.
|
|
98
100
|
* @param {`0x${string}`} inputToken The address of the token to be used as input.
|
|
99
101
|
* @param {`0x${string}`} outputToken The address of the token to be received as output.
|
|
100
|
-
* @param {string}
|
|
101
|
-
* @param {
|
|
102
|
-
* @param {
|
|
102
|
+
* @param {string} amountIn The amount of input tokens for the order to spend.
|
|
103
|
+
* @param {string} amountOut The amount of output tokens for the order to take.
|
|
104
|
+
* @param {Object} [options] Optional parameters for the market order.
|
|
105
|
+
* @param {erc20PermitParam} [options.erc20PermitParam] The permit signature for token approval.
|
|
103
106
|
* @param {string} [options.rpcUrl] The RPC URL of the blockchain.
|
|
104
|
-
* @param {
|
|
105
|
-
* if the
|
|
106
|
-
* @returns {Promise<
|
|
107
|
+
* @param {number} [options.slippage] The maximum slippage percentage allowed for the order.
|
|
108
|
+
* if the slippage is not provided, unlimited slippage is allowed.
|
|
109
|
+
* @returns {Promise<{ transaction: Transaction, result: { spend: CurrencyFlow, take: CurrencyFlow } }>}
|
|
110
|
+
* Promise resolving to the transaction object representing the market order with the result of the order.
|
|
107
111
|
* @example
|
|
108
112
|
* import { signERC20Permit, marketOrder } from '@clober/v2-sdk'
|
|
109
113
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
110
114
|
*
|
|
111
|
-
* const
|
|
115
|
+
* const erc20PermitParam = await signERC20Permit({
|
|
112
116
|
* chainId: 421614,
|
|
113
|
-
*
|
|
117
|
+
* walletClient,
|
|
114
118
|
* token: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
115
119
|
* amount: '100.123'
|
|
116
120
|
* })
|
|
@@ -121,31 +125,28 @@ export declare const limitOrder: (args: {
|
|
|
121
125
|
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
122
126
|
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
123
127
|
* amount: '100.123', // 100.123 USDC
|
|
124
|
-
* options: {
|
|
128
|
+
* options: { erc20PermitParam }
|
|
125
129
|
* })
|
|
126
130
|
*
|
|
127
|
-
* @example
|
|
128
|
-
* import { marketOrder } from '@clober/v2-sdk'
|
|
129
|
-
*
|
|
130
|
-
* const transaction = await limitOrder(
|
|
131
|
-
* chainId: 421614,
|
|
132
|
-
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69
|
|
133
|
-
* inputToken: '0x0000000000000000000000000000000000000000',
|
|
134
|
-
* outputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
135
|
-
* options: '0.13', // 0.13 ETH
|
|
136
|
-
* )
|
|
137
131
|
*/
|
|
138
132
|
export declare const marketOrder: (args: {
|
|
139
133
|
chainId: CHAIN_IDS;
|
|
140
134
|
userAddress: `0x${string}`;
|
|
141
135
|
inputToken: `0x${string}`;
|
|
142
136
|
outputToken: `0x${string}`;
|
|
143
|
-
|
|
137
|
+
amountIn: string;
|
|
138
|
+
amountOut?: string;
|
|
144
139
|
options?: {
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
erc20PermitParam?: ERC20PermitParam;
|
|
141
|
+
slippage?: number;
|
|
147
142
|
} & DefaultOptions;
|
|
148
|
-
}) => Promise<
|
|
143
|
+
}) => Promise<{
|
|
144
|
+
transaction: Transaction;
|
|
145
|
+
result: {
|
|
146
|
+
take: CurrencyFlow;
|
|
147
|
+
spend: CurrencyFlow;
|
|
148
|
+
};
|
|
149
|
+
}>;
|
|
149
150
|
/**
|
|
150
151
|
* Claims specified open order for settlement.
|
|
151
152
|
* [IMPORTANT] Set ApprovalForAll before calling this function.
|
package/dist/types/call.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/call.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/call.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,WAAW,EACZ,MAAM,QAAQ,CAAA;AAkBf;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU;aAOV,SAAS;gBACN,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;cAChB,cAAc;sCAqC3B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,UAAU;aAUV,SAAS;iBACL,KAAK,MAAM,EAAE;gBACd,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;YAClB,MAAM;WACP,MAAM;cACH;QACR,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;QACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;KACnB,GAAG,cAAc;;iBAEL,WAAW;YAChB;QACN,IAAI,EAAE,YAAY,CAAA;QAClB,IAAI,EAAE,YAAY,CAAA;KACnB;EAiIJ,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,WAAW;aAUX,SAAS;iBACL,KAAK,MAAM,EAAE;gBACd,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;cAChB,MAAM;gBACJ,MAAM;cACR;QACR,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;QACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,GAAG,cAAc;;iBAEL,WAAW;YAChB;QACN,IAAI,EAAE,YAAY,CAAA;QAClB,KAAK,EAAE,YAAY,CAAA;KACpB;EAkJJ,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU;aAOV,SAAS;iBACL,KAAK,MAAM,EAAE;QACtB,MAAM;cACA,cAAc;;iBACC,WAAW;YAAU,YAAY;EAY7D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,WAAW;aAOX,SAAS;iBACL,KAAK,MAAM,EAAE;SACrB,MAAM,EAAE;cACH,cAAc;;iBACC,WAAW;YAAU,YAAY,EAAE;EA+E/D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,WAAW;aAOX,SAAS;iBACL,KAAK,MAAM,EAAE;QACtB,MAAM;cACA,cAAc;;iBACC,WAAW;YAAU,YAAY;EAY7D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY;aAOZ,SAAS;iBACL,KAAK,MAAM,EAAE;SACrB,MAAM,EAAE;cACH,cAAc;;iBACC,WAAW;YAAU,YAAY,EAAE;EAiF/D,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WalletClient } from 'viem';
|
|
2
2
|
import { CHAIN_IDS } from './constants/chain';
|
|
3
|
-
import { DefaultOptions,
|
|
3
|
+
import { DefaultOptions, ERC20PermitParam } from './type';
|
|
4
4
|
/**
|
|
5
5
|
* @dev This function relates with `viem` dependency
|
|
6
6
|
* Signs an ERC20 permit using EIP-712 encoding.
|
|
@@ -11,21 +11,9 @@ import { DefaultOptions, PermitSignature } from './type';
|
|
|
11
11
|
* @param {string} amount The amount of tokens to permit.
|
|
12
12
|
* @param options
|
|
13
13
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
14
|
-
* @returns {Promise<
|
|
14
|
+
* @returns {Promise<erc20PermitParam | undefined>} The signed permit.
|
|
15
15
|
* @example
|
|
16
16
|
* import { signERC20Permit } from '@clober/v2-sdk'
|
|
17
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
18
|
-
*
|
|
19
|
-
* const { deadline, r, s, v } = await signERC20Permit({
|
|
20
|
-
* chainId: 421614,
|
|
21
|
-
* account: privateKeyToAccount('0x...')
|
|
22
|
-
* token: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
23
|
-
* amount: '1000.123', // spend 1000.123 USDC
|
|
24
|
-
* })
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* import { signERC20Permit } from '@clober/v2-sdk'
|
|
28
|
-
* import { mnemonicToAccount } from 'viem/accounts'
|
|
29
17
|
*
|
|
30
18
|
* const walletClient = createWalletClient({
|
|
31
19
|
* chain: arbitrumSepolia,
|
|
@@ -46,5 +34,5 @@ export declare const signERC20Permit: (args: {
|
|
|
46
34
|
token: `0x${string}`;
|
|
47
35
|
amount: string;
|
|
48
36
|
options?: DefaultOptions;
|
|
49
|
-
}) => Promise<
|
|
37
|
+
}) => Promise<ERC20PermitParam | undefined>;
|
|
50
38
|
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/signature.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,YAAY,EAAE,MAAM,MAAM,CAAA;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAI7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAoDzD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe;aAOf,SAAS;kBACJ,YAAY;WACnB,KAAK,MAAM,EAAE;YACZ,MAAM;cACJ,cAAc;2CA2F3B,CAAA"}
|
package/dist/types/type.d.ts
CHANGED
|
@@ -31,8 +31,14 @@ export type PermitSignature = {
|
|
|
31
31
|
r: `0x${string}`;
|
|
32
32
|
s: `0x${string}`;
|
|
33
33
|
};
|
|
34
|
+
export type ERC20PermitParam = {
|
|
35
|
+
token: `0x${string}`;
|
|
36
|
+
permitAmount: bigint;
|
|
37
|
+
signature: PermitSignature;
|
|
38
|
+
};
|
|
34
39
|
export type DefaultOptions = {
|
|
35
40
|
rpcUrl?: string;
|
|
41
|
+
gasLimit?: bigint;
|
|
36
42
|
};
|
|
37
43
|
export type CurrencyFlow = {
|
|
38
44
|
currency: Currency;
|
package/dist/types/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,EAAE,SAAS,CAAA;IAClB,KAAK,EAAE,QAAQ,CAAA;IACf,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,KAAK,EAAE,CA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ACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,oBAAY,mBAAmB;IAC7B,SAAS,OAAO;IAChB,YAAY,OAAO;IACnB,WAAW,OAAO;IAClB,UAAU,QAAQ;IAClB,cAAc,QAAQ;IACtB,aAAa,QAAQ;IACrB,OAAO,OAAO;IACd,QAAQ,OAAO;IACf,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,MAAM,OAAO;IACb,OAAO,OAAO;CACf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type SimulateContractParameters, type WriteContractParameters } from 'viem';
|
|
2
2
|
import { CHAIN_IDS, type Transaction } from '../type';
|
|
3
|
-
export declare const buildTransaction: (chainId: CHAIN_IDS, args: WriteContractParameters | SimulateContractParameters) => Promise<Transaction>;
|
|
3
|
+
export declare const buildTransaction: (chainId: CHAIN_IDS, args: WriteContractParameters | SimulateContractParameters, gasLimit?: bigint) => Promise<Transaction>;
|
|
4
4
|
//# sourceMappingURL=build-transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-transaction.d.ts","sourceRoot":"","sources":["../../../src/utils/build-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC7B,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAA;AAGrD,eAAO,MAAM,gBAAgB,YAClB,SAAS,QACZ,uBAAuB,GAAG,0BAA0B,
|
|
1
|
+
{"version":3,"file":"build-transaction.d.ts","sourceRoot":"","sources":["../../../src/utils/build-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC7B,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAA;AAGrD,eAAO,MAAM,gBAAgB,YAClB,SAAS,QACZ,uBAAuB,GAAG,0BAA0B,aAC/C,MAAM,KAChB,QAAQ,WAAW,CAoBrB,CAAA"}
|