@circle-fin/adapter-ethers-v6 1.7.0 → 1.8.1
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/CHANGELOG.md +16 -0
- package/index.cjs +338 -124
- package/index.d.ts +125 -4
- package/index.mjs +338 -124
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1812,12 +1812,14 @@ declare enum PermitType {
|
|
|
1812
1812
|
* The Adapter Contract uses this to pull tokens from the user's wallet
|
|
1813
1813
|
* using permit signatures instead of requiring separate approval transactions.
|
|
1814
1814
|
*
|
|
1815
|
+
* Shared by the `swap.*` and `earn.*` action namespaces because both forward
|
|
1816
|
+
* `tokenInputs` unchanged to the adapter contract's `execute` call.
|
|
1817
|
+
*
|
|
1815
1818
|
* @example
|
|
1816
1819
|
* ```typescript
|
|
1817
1820
|
* const tokenInput: TokenInput = {
|
|
1818
1821
|
* permitType: PermitType.EIP2612,
|
|
1819
1822
|
* token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
|
|
1820
|
-
* from: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
|
|
1821
1823
|
* amount: 1000000n, // 1 USDC
|
|
1822
1824
|
* permitCalldata: '0x...' // Encoded permit(value, deadline, v, r, s)
|
|
1823
1825
|
* }
|
|
@@ -1840,12 +1842,91 @@ interface TokenInput {
|
|
|
1840
1842
|
* ABI-encoded permit calldata.
|
|
1841
1843
|
*
|
|
1842
1844
|
* For EIP-2612: encode(value, deadline, v, r, s)
|
|
1843
|
-
* For Permit2: encode(permit, signature)
|
|
1844
1845
|
*
|
|
1845
1846
|
* @example '0x0000000000000000000000000000000000000000000000000000000000989680...'
|
|
1846
1847
|
*/
|
|
1847
1848
|
permitCalldata: `0x${string}`;
|
|
1848
1849
|
}
|
|
1850
|
+
|
|
1851
|
+
/**
|
|
1852
|
+
* Parameters for executing a service-signed earn operation via the Adapter
|
|
1853
|
+
* smart contract on EVM chains.
|
|
1854
|
+
*
|
|
1855
|
+
* Shared across earn action keys: `earn.deposit`, `earn.withdraw`, and
|
|
1856
|
+
* `earn.claimRewards`. Each operation forwards the same `executeParams`,
|
|
1857
|
+
* `tokenInputs`, and `signature` triple to the adapter contract's `execute`
|
|
1858
|
+
* function. The service signs `executeParams` off-chain; the contract verifies
|
|
1859
|
+
* the signature on-chain.
|
|
1860
|
+
*
|
|
1861
|
+
* @example
|
|
1862
|
+
* ```typescript
|
|
1863
|
+
* import type { ActionPayload } from '@core/adapter'
|
|
1864
|
+
*
|
|
1865
|
+
* const params: ActionPayload<'earn.deposit'> = {
|
|
1866
|
+
* executeParams: { instructions: [], tokens: [], execId: 1n, deadline: 0n, metadata: '0x' },
|
|
1867
|
+
* tokenInputs: [],
|
|
1868
|
+
* signature: '0x...',
|
|
1869
|
+
* }
|
|
1870
|
+
*
|
|
1871
|
+
* const prepared = await adapter.prepareAction('earn.deposit', params, { chain, address })
|
|
1872
|
+
* const txHash = await prepared.execute()
|
|
1873
|
+
* ```
|
|
1874
|
+
*/
|
|
1875
|
+
interface ExecuteEarnEVMParams extends ActionParameters {
|
|
1876
|
+
/**
|
|
1877
|
+
* Execution parameters returned by the earn service.
|
|
1878
|
+
*
|
|
1879
|
+
* Kept as an opaque record so the adapter forwards the service-signed struct
|
|
1880
|
+
* unchanged. The adapter contract ABI decodes it on-chain.
|
|
1881
|
+
*/
|
|
1882
|
+
executeParams: Record<string, unknown>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Token inputs with permit signatures for gasless approvals.
|
|
1885
|
+
*
|
|
1886
|
+
* Populated by the earn provider after it decides how token spending is
|
|
1887
|
+
* authorised. Today deposit uses a separate `token.approve` transaction and
|
|
1888
|
+
* passes `PermitType.NONE`; a future permit-enabled path can populate this
|
|
1889
|
+
* field without a breaking change.
|
|
1890
|
+
*/
|
|
1891
|
+
tokenInputs: TokenInput[];
|
|
1892
|
+
/**
|
|
1893
|
+
* EIP-712 signature from the earn service proxy.
|
|
1894
|
+
*
|
|
1895
|
+
* The adapter contract verifies this signature on-chain. Passed through
|
|
1896
|
+
* unchanged.
|
|
1897
|
+
*/
|
|
1898
|
+
signature: `0x${string}`;
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Parameters for earn execute actions across supported ecosystems.
|
|
1902
|
+
*
|
|
1903
|
+
* EVM-only today; becomes a union when a non-EVM adapter implementation
|
|
1904
|
+
* lands. Action handlers narrow via a property-based type guard, same
|
|
1905
|
+
* pattern as {@link ExecuteSwapParams}.
|
|
1906
|
+
*/
|
|
1907
|
+
type ExecuteEarnParams = ExecuteEarnEVMParams;
|
|
1908
|
+
/**
|
|
1909
|
+
* Action map for earn operations.
|
|
1910
|
+
*
|
|
1911
|
+
* Each action key forwards the same `(executeParams, tokenInputs, signature)`
|
|
1912
|
+
* triple to the adapter contract. Provider-side orchestration performs any
|
|
1913
|
+
* required token approval; this action only prepares the adapter execute call.
|
|
1914
|
+
*/
|
|
1915
|
+
interface EarnActionMap {
|
|
1916
|
+
/**
|
|
1917
|
+
* Execute a service-signed deposit against the adapter contract.
|
|
1918
|
+
*/
|
|
1919
|
+
readonly deposit: ExecuteEarnParams;
|
|
1920
|
+
/**
|
|
1921
|
+
* Execute a service-signed withdraw against the adapter contract.
|
|
1922
|
+
*/
|
|
1923
|
+
readonly withdraw: ExecuteEarnParams;
|
|
1924
|
+
/**
|
|
1925
|
+
* Execute a service-signed claim rewards against the adapter contract.
|
|
1926
|
+
*/
|
|
1927
|
+
readonly claimRewards: ExecuteEarnParams;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1849
1930
|
/**
|
|
1850
1931
|
* Single instruction to execute within the Adapter Contract.
|
|
1851
1932
|
*
|
|
@@ -2027,7 +2108,6 @@ interface ExecuteParams {
|
|
|
2027
2108
|
* const tokenInputs: TokenInput[] = [{
|
|
2028
2109
|
* permitType: PermitType.EIP2612,
|
|
2029
2110
|
* token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
2030
|
-
* from: userAddress,
|
|
2031
2111
|
* amount: 1000000n,
|
|
2032
2112
|
* permitCalldata: '0x...' // Encoded permit signature
|
|
2033
2113
|
* }]
|
|
@@ -2070,7 +2150,6 @@ interface ExecuteSwapEVMParams extends ActionParameters {
|
|
|
2070
2150
|
* [{
|
|
2071
2151
|
* permitType: PermitType.EIP2612,
|
|
2072
2152
|
* token: '0xUSDC',
|
|
2073
|
-
* from: userAddress,
|
|
2074
2153
|
* amount: 1000000n,
|
|
2075
2154
|
* permitCalldata: '0x...'
|
|
2076
2155
|
* }]
|
|
@@ -2806,6 +2885,8 @@ interface ActionMap {
|
|
|
2806
2885
|
readonly usdt: USDTActionMap;
|
|
2807
2886
|
/** Swap operations for DEX aggregator integrations. */
|
|
2808
2887
|
readonly swap: SwapActionMap;
|
|
2888
|
+
/** Earn operations that execute service-signed payloads via the adapter contract. */
|
|
2889
|
+
readonly earn: EarnActionMap;
|
|
2809
2890
|
}
|
|
2810
2891
|
/**
|
|
2811
2892
|
* Determine if a type represents an action parameter object (leaf node).
|
|
@@ -3974,6 +4055,37 @@ declare abstract class EvmAdapter<TAdapterCapabilities extends AdapterCapabiliti
|
|
|
3974
4055
|
* @throws Error when balance retrieval fails.
|
|
3975
4056
|
*/
|
|
3976
4057
|
abstract readNativeBalance(address: string, chain: EVMChainDefinition): Promise<bigint>;
|
|
4058
|
+
/**
|
|
4059
|
+
* Reads the on-chain bytecode for a given address.
|
|
4060
|
+
*
|
|
4061
|
+
* Returns the deployed contract bytecode as a hex string (`0x`-prefixed),
|
|
4062
|
+
* or `'0x'` when the address has no code (i.e. is a plain EOA).
|
|
4063
|
+
* Implementations MUST normalize a "no code" RPC response to `'0x'` so
|
|
4064
|
+
* callers can compare against a single sentinel.
|
|
4065
|
+
*
|
|
4066
|
+
* Useful for detecting smart-contract accounts before attempting an
|
|
4067
|
+
* operation that only supports EOA signing (e.g. Gateway burn intents).
|
|
4068
|
+
*
|
|
4069
|
+
* @param address - The address to read bytecode for.
|
|
4070
|
+
* @param chain - The chain definition to read from.
|
|
4071
|
+
* @returns Promise resolving to `'0x'` for an EOA, or the hex-encoded
|
|
4072
|
+
* deployed bytecode otherwise.
|
|
4073
|
+
* @throws Error when the underlying RPC call fails.
|
|
4074
|
+
*
|
|
4075
|
+
* @example
|
|
4076
|
+
* ```typescript
|
|
4077
|
+
* import { ViemAdapter } from '@circle-fin/adapter-viem-v2'
|
|
4078
|
+
* import { Ethereum } from '@core/chains'
|
|
4079
|
+
*
|
|
4080
|
+
* const adapter = new ViemAdapter({ publicClient, walletClient })
|
|
4081
|
+
* const code = await adapter.readBytecode('0xabc...', Ethereum)
|
|
4082
|
+
*
|
|
4083
|
+
* if (code !== '0x') {
|
|
4084
|
+
* throw new Error('signer has on-chain bytecode')
|
|
4085
|
+
* }
|
|
4086
|
+
* ```
|
|
4087
|
+
*/
|
|
4088
|
+
abstract readBytecode(address: string, chain: EVMChainDefinition): Promise<`0x${string}`>;
|
|
3977
4089
|
/**
|
|
3978
4090
|
* Calculate the total transaction fee including compute cost and buffer for the configured chain.
|
|
3979
4091
|
*
|
|
@@ -4573,6 +4685,15 @@ declare class EthersAdapter<TAdapterCapabilities extends AdapterCapabilities = A
|
|
|
4573
4685
|
* ```
|
|
4574
4686
|
*/
|
|
4575
4687
|
readNativeBalance(address: string, chain: EVMChainDefinition): Promise<bigint>;
|
|
4688
|
+
/**
|
|
4689
|
+
* Reads the on-chain bytecode for a given address via ethers' `getCode`.
|
|
4690
|
+
*
|
|
4691
|
+
* Returns the hex-encoded bytecode when the address is a contract, or
|
|
4692
|
+
* `'0x'` when the address has no code (EOA). Used by Gateway burn-intent
|
|
4693
|
+
* signing to detect smart-contract accounts, which are not supported by
|
|
4694
|
+
* Gateway's ecrecover-based verification path.
|
|
4695
|
+
*/
|
|
4696
|
+
readBytecode(address: string, chain: EVMChainDefinition): Promise<`0x${string}`>;
|
|
4576
4697
|
/**
|
|
4577
4698
|
* Signs EIP-712 typed data using the configured signer with OperationContext.
|
|
4578
4699
|
*
|