@owney/sdk 0.7.22-beta.0 → 0.7.22-beta.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/dist/{chunk-W3FYRJLJ.js → chunk-3HL52KM7.js} +63 -34
- package/dist/{chunk-5LU2SHO7.js → chunk-AURO3C3R.js} +18 -10
- package/dist/index.cjs +116 -68
- package/dist/index.js +2 -2
- package/dist/{surfliquid.agent-XDJ672GM.js → surfliquid.agent-AE7RZ66F.js} +5 -5
- package/dist/{surfliquid.smart-account-DWV5B3D5.js → surfliquid.smart-account-C535356J.js} +16 -4
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-5LU2SHO7.js";
|
|
2
|
+
buildPermitTypedData
|
|
3
|
+
} from "./chunk-AURO3C3R.js";
|
|
5
4
|
|
|
6
5
|
// src/agents/surfliquid/surfliquid.constants.ts
|
|
7
6
|
var SURFLIQUID_CHAIN_ID = 8453;
|
|
8
7
|
var SURFLIQUID_CHAIN_NAME = "BASE";
|
|
9
8
|
var SURFLIQUID_USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
9
|
+
var SURFLIQUID_PERMIT_CAP = 10000000000n;
|
|
10
|
+
var SURFLIQUID_PERMIT_TTL_SECONDS = 3600n;
|
|
10
11
|
var SURFLIQUID_MIN_DEPOSIT = "0";
|
|
11
12
|
var SURFLIQUID_SUPPORTED_ASSETS = [
|
|
12
13
|
{
|
|
@@ -49,10 +50,16 @@ var SURFLIQUID_VAULT_ABI = parseAbi([
|
|
|
49
50
|
var USDC_ABI = parseAbi([
|
|
50
51
|
"function approve(address spender, uint256 amount)",
|
|
51
52
|
"function transfer(address to, uint256 amount)",
|
|
53
|
+
"function transferFrom(address from, address to, uint256 value)",
|
|
52
54
|
"function balanceOf(address account) view returns (uint256)",
|
|
53
|
-
"function
|
|
55
|
+
"function allowance(address owner, address spender) view returns (uint256)",
|
|
56
|
+
"function nonces(address owner) view returns (uint256)",
|
|
57
|
+
"function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)"
|
|
54
58
|
]);
|
|
55
59
|
|
|
60
|
+
// src/agents/surfliquid/surfliquid.sponsorship.ts
|
|
61
|
+
import { parseSignature } from "viem";
|
|
62
|
+
|
|
56
63
|
// src/agents/surfliquid/surfliquid.calls.ts
|
|
57
64
|
import { encodeFunctionData } from "viem";
|
|
58
65
|
var call = (to, abi, functionName, args) => ({
|
|
@@ -60,12 +67,12 @@ var call = (to, abi, functionName, args) => ({
|
|
|
60
67
|
data: encodeFunctionData({ abi, functionName, args })
|
|
61
68
|
});
|
|
62
69
|
function buildDepositCalls(input) {
|
|
63
|
-
const { smartAccount, vault, amount,
|
|
64
|
-
if (
|
|
65
|
-
throw new Error("
|
|
70
|
+
const { smartAccount, owner, vault, amount, permit, deploySalt } = input;
|
|
71
|
+
if (permit && permit.owner.toLowerCase() !== owner.toLowerCase()) {
|
|
72
|
+
throw new Error("Permit must be signed by the smart account's owner");
|
|
66
73
|
}
|
|
67
|
-
if (
|
|
68
|
-
throw new Error("
|
|
74
|
+
if (permit && permit.value < amount) {
|
|
75
|
+
throw new Error("Permit allowance is worth less than the deposit");
|
|
69
76
|
}
|
|
70
77
|
if (!input.hasInitialDeposit && !input.morphoVault) {
|
|
71
78
|
throw new Error("A first deposit needs a target morpho vault");
|
|
@@ -79,16 +86,21 @@ function buildDepositCalls(input) {
|
|
|
79
86
|
])
|
|
80
87
|
);
|
|
81
88
|
}
|
|
89
|
+
if (permit) {
|
|
90
|
+
calls.push(
|
|
91
|
+
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "permit", [
|
|
92
|
+
permit.owner,
|
|
93
|
+
smartAccount,
|
|
94
|
+
permit.value,
|
|
95
|
+
permit.deadline,
|
|
96
|
+
permit.v,
|
|
97
|
+
permit.r,
|
|
98
|
+
permit.s
|
|
99
|
+
])
|
|
100
|
+
);
|
|
101
|
+
}
|
|
82
102
|
calls.push(
|
|
83
|
-
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "
|
|
84
|
-
authorization.from,
|
|
85
|
-
authorization.to,
|
|
86
|
-
authorization.value,
|
|
87
|
-
authorization.validAfter,
|
|
88
|
-
authorization.validBefore,
|
|
89
|
-
authorization.nonce,
|
|
90
|
-
authorization.signature
|
|
91
|
-
]),
|
|
103
|
+
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "transferFrom", [owner, smartAccount, amount]),
|
|
92
104
|
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "approve", [vault, amount]),
|
|
93
105
|
input.hasInitialDeposit ? call(vault, SURFLIQUID_VAULT_ABI, "userDeposit", [SURFLIQUID_USDC_ADDRESS, amount]) : call(vault, SURFLIQUID_VAULT_ABI, "initialDeposit", [
|
|
94
106
|
SURFLIQUID_USDC_ADDRESS,
|
|
@@ -111,7 +123,6 @@ function buildSweepCalls(input) {
|
|
|
111
123
|
}
|
|
112
124
|
|
|
113
125
|
// src/agents/surfliquid/surfliquid.sponsorship.ts
|
|
114
|
-
var AUTHORIZATION_TTL_SECONDS = 3600n;
|
|
115
126
|
var SubmittedError = class extends Error {
|
|
116
127
|
constructor(message, userOpHash) {
|
|
117
128
|
super(message);
|
|
@@ -160,22 +171,23 @@ async function pickMorphoVault(api) {
|
|
|
160
171
|
}
|
|
161
172
|
return candidate.vaultAddress;
|
|
162
173
|
}
|
|
163
|
-
async function
|
|
164
|
-
const {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
174
|
+
async function permitIfShort(input) {
|
|
175
|
+
const { chain, wallet, amount } = input;
|
|
176
|
+
const allowance = await chain.readAllowance(wallet.ownerAddress, wallet.smartAccountAddress);
|
|
177
|
+
if (allowance >= amount) return void 0;
|
|
178
|
+
const [{ tokenName, tokenVersion }, nonce] = await Promise.all([
|
|
179
|
+
chain.readTokenMeta(),
|
|
180
|
+
chain.readPermitNonce(wallet.ownerAddress)
|
|
181
|
+
]);
|
|
169
182
|
const message = {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
value: amount,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
nonce: randomAuthNonce()
|
|
183
|
+
owner: wallet.ownerAddress,
|
|
184
|
+
spender: wallet.smartAccountAddress,
|
|
185
|
+
value: amount > SURFLIQUID_PERMIT_CAP ? amount : SURFLIQUID_PERMIT_CAP,
|
|
186
|
+
nonce,
|
|
187
|
+
deadline: BigInt(Math.floor(Date.now() / 1e3)) + SURFLIQUID_PERMIT_TTL_SECONDS
|
|
176
188
|
};
|
|
177
|
-
const signature = await wallet.
|
|
178
|
-
|
|
189
|
+
const signature = await wallet.signPermit(
|
|
190
|
+
buildPermitTypedData({
|
|
179
191
|
token: SURFLIQUID_USDC_ADDRESS,
|
|
180
192
|
chainId: SURFLIQUID_CHAIN_ID,
|
|
181
193
|
tokenName,
|
|
@@ -183,12 +195,29 @@ async function depositSponsored(input) {
|
|
|
183
195
|
message
|
|
184
196
|
})
|
|
185
197
|
);
|
|
198
|
+
const { r, s, v, yParity } = parseSignature(signature);
|
|
199
|
+
return {
|
|
200
|
+
owner: message.owner,
|
|
201
|
+
value: message.value,
|
|
202
|
+
deadline: message.deadline,
|
|
203
|
+
v: Number(v ?? BigInt(yParity + 27)),
|
|
204
|
+
r,
|
|
205
|
+
s
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
async function depositSponsored(input) {
|
|
209
|
+
const { api, chain, wallet, amount } = input;
|
|
210
|
+
const { vault, deploySalt, registerAfterDeposit } = await resolveVault(input);
|
|
211
|
+
const hasInitialDeposit = deploySalt ? false : await chain.hasInitialDeposit(vault, SURFLIQUID_USDC_ADDRESS);
|
|
212
|
+
const morphoVault = hasInitialDeposit ? void 0 : await pickMorphoVault(api);
|
|
213
|
+
const permit = await permitIfShort({ chain, wallet, amount });
|
|
186
214
|
const txHash = await wallet.sendCalls(
|
|
187
215
|
buildDepositCalls({
|
|
188
216
|
smartAccount: wallet.smartAccountAddress,
|
|
217
|
+
owner: wallet.ownerAddress,
|
|
189
218
|
vault,
|
|
190
219
|
amount,
|
|
191
|
-
|
|
220
|
+
permit,
|
|
192
221
|
hasInitialDeposit,
|
|
193
222
|
morphoVault,
|
|
194
223
|
deploySalt
|
|
@@ -21,14 +21,6 @@ function buildTransferWithAuthorizationTypedData(input) {
|
|
|
21
21
|
message: input.message
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function buildReceiveWithAuthorizationTypedData(input) {
|
|
25
|
-
const transfer = buildTransferWithAuthorizationTypedData(input);
|
|
26
|
-
return {
|
|
27
|
-
...transfer,
|
|
28
|
-
types: { ReceiveWithAuthorization: transfer.types.TransferWithAuthorization },
|
|
29
|
-
primaryType: "ReceiveWithAuthorization"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
24
|
async function readTokenMeta(publicClient, token) {
|
|
33
25
|
const [tokenName, tokenVersion] = await Promise.all([
|
|
34
26
|
publicClient.readContract({ address: token, abi: ERC20_META_ABI, functionName: "name" }),
|
|
@@ -41,10 +33,26 @@ function randomAuthNonce() {
|
|
|
41
33
|
globalThis.crypto.getRandomValues(bytes);
|
|
42
34
|
return bytesToHex(bytes);
|
|
43
35
|
}
|
|
36
|
+
function buildPermitTypedData(input) {
|
|
37
|
+
return {
|
|
38
|
+
domain: { name: input.tokenName, version: input.tokenVersion, chainId: input.chainId, verifyingContract: input.token },
|
|
39
|
+
types: {
|
|
40
|
+
Permit: [
|
|
41
|
+
{ name: "owner", type: "address" },
|
|
42
|
+
{ name: "spender", type: "address" },
|
|
43
|
+
{ name: "value", type: "uint256" },
|
|
44
|
+
{ name: "nonce", type: "uint256" },
|
|
45
|
+
{ name: "deadline", type: "uint256" }
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
primaryType: "Permit",
|
|
49
|
+
message: input.message
|
|
50
|
+
};
|
|
51
|
+
}
|
|
44
52
|
|
|
45
53
|
export {
|
|
46
54
|
buildTransferWithAuthorizationTypedData,
|
|
47
|
-
buildReceiveWithAuthorizationTypedData,
|
|
48
55
|
readTokenMeta,
|
|
49
|
-
randomAuthNonce
|
|
56
|
+
randomAuthNonce,
|
|
57
|
+
buildPermitTypedData
|
|
50
58
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -193,14 +193,6 @@ function buildTransferWithAuthorizationTypedData(input) {
|
|
|
193
193
|
message: input.message
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
-
function buildReceiveWithAuthorizationTypedData(input) {
|
|
197
|
-
const transfer = buildTransferWithAuthorizationTypedData(input);
|
|
198
|
-
return {
|
|
199
|
-
...transfer,
|
|
200
|
-
types: { ReceiveWithAuthorization: transfer.types.TransferWithAuthorization },
|
|
201
|
-
primaryType: "ReceiveWithAuthorization"
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
196
|
async function readTokenMeta(publicClient, token) {
|
|
205
197
|
const [tokenName, tokenVersion] = await Promise.all([
|
|
206
198
|
publicClient.readContract({ address: token, abi: ERC20_META_ABI, functionName: "name" }),
|
|
@@ -213,6 +205,22 @@ function randomAuthNonce() {
|
|
|
213
205
|
globalThis.crypto.getRandomValues(bytes);
|
|
214
206
|
return (0, import_viem3.bytesToHex)(bytes);
|
|
215
207
|
}
|
|
208
|
+
function buildPermitTypedData(input) {
|
|
209
|
+
return {
|
|
210
|
+
domain: { name: input.tokenName, version: input.tokenVersion, chainId: input.chainId, verifyingContract: input.token },
|
|
211
|
+
types: {
|
|
212
|
+
Permit: [
|
|
213
|
+
{ name: "owner", type: "address" },
|
|
214
|
+
{ name: "spender", type: "address" },
|
|
215
|
+
{ name: "value", type: "uint256" },
|
|
216
|
+
{ name: "nonce", type: "uint256" },
|
|
217
|
+
{ name: "deadline", type: "uint256" }
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
primaryType: "Permit",
|
|
221
|
+
message: input.message
|
|
222
|
+
};
|
|
223
|
+
}
|
|
216
224
|
var import_viem3, ERC20_META_ABI;
|
|
217
225
|
var init_transfer_auth = __esm({
|
|
218
226
|
"src/lib/transfer-auth.ts"() {
|
|
@@ -226,13 +234,15 @@ var init_transfer_auth = __esm({
|
|
|
226
234
|
});
|
|
227
235
|
|
|
228
236
|
// src/agents/surfliquid/surfliquid.constants.ts
|
|
229
|
-
var SURFLIQUID_CHAIN_ID, SURFLIQUID_CHAIN_NAME, SURFLIQUID_USDC_ADDRESS, SURFLIQUID_MIN_DEPOSIT, SURFLIQUID_SUPPORTED_ASSETS, SURFLIQUID_ACTION_MAP;
|
|
237
|
+
var SURFLIQUID_CHAIN_ID, SURFLIQUID_CHAIN_NAME, SURFLIQUID_USDC_ADDRESS, SURFLIQUID_PERMIT_CAP, SURFLIQUID_PERMIT_TTL_SECONDS, SURFLIQUID_MIN_DEPOSIT, SURFLIQUID_SUPPORTED_ASSETS, SURFLIQUID_ACTION_MAP;
|
|
230
238
|
var init_surfliquid_constants = __esm({
|
|
231
239
|
"src/agents/surfliquid/surfliquid.constants.ts"() {
|
|
232
240
|
"use strict";
|
|
233
241
|
SURFLIQUID_CHAIN_ID = 8453;
|
|
234
242
|
SURFLIQUID_CHAIN_NAME = "BASE";
|
|
235
243
|
SURFLIQUID_USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
244
|
+
SURFLIQUID_PERMIT_CAP = 10000000000n;
|
|
245
|
+
SURFLIQUID_PERMIT_TTL_SECONDS = 3600n;
|
|
236
246
|
SURFLIQUID_MIN_DEPOSIT = "0";
|
|
237
247
|
SURFLIQUID_SUPPORTED_ASSETS = [
|
|
238
248
|
{
|
|
@@ -645,20 +655,23 @@ var init_surfliquid_contracts = __esm({
|
|
|
645
655
|
USDC_ABI = (0, import_viem6.parseAbi)([
|
|
646
656
|
"function approve(address spender, uint256 amount)",
|
|
647
657
|
"function transfer(address to, uint256 amount)",
|
|
658
|
+
"function transferFrom(address from, address to, uint256 value)",
|
|
648
659
|
"function balanceOf(address account) view returns (uint256)",
|
|
649
|
-
"function
|
|
660
|
+
"function allowance(address owner, address spender) view returns (uint256)",
|
|
661
|
+
"function nonces(address owner) view returns (uint256)",
|
|
662
|
+
"function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)"
|
|
650
663
|
]);
|
|
651
664
|
}
|
|
652
665
|
});
|
|
653
666
|
|
|
654
667
|
// src/agents/surfliquid/surfliquid.calls.ts
|
|
655
668
|
function buildDepositCalls(input) {
|
|
656
|
-
const { smartAccount, vault, amount,
|
|
657
|
-
if (
|
|
658
|
-
throw new Error("
|
|
669
|
+
const { smartAccount, owner, vault, amount, permit, deploySalt } = input;
|
|
670
|
+
if (permit && permit.owner.toLowerCase() !== owner.toLowerCase()) {
|
|
671
|
+
throw new Error("Permit must be signed by the smart account's owner");
|
|
659
672
|
}
|
|
660
|
-
if (
|
|
661
|
-
throw new Error("
|
|
673
|
+
if (permit && permit.value < amount) {
|
|
674
|
+
throw new Error("Permit allowance is worth less than the deposit");
|
|
662
675
|
}
|
|
663
676
|
if (!input.hasInitialDeposit && !input.morphoVault) {
|
|
664
677
|
throw new Error("A first deposit needs a target morpho vault");
|
|
@@ -672,16 +685,21 @@ function buildDepositCalls(input) {
|
|
|
672
685
|
])
|
|
673
686
|
);
|
|
674
687
|
}
|
|
688
|
+
if (permit) {
|
|
689
|
+
calls.push(
|
|
690
|
+
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "permit", [
|
|
691
|
+
permit.owner,
|
|
692
|
+
smartAccount,
|
|
693
|
+
permit.value,
|
|
694
|
+
permit.deadline,
|
|
695
|
+
permit.v,
|
|
696
|
+
permit.r,
|
|
697
|
+
permit.s
|
|
698
|
+
])
|
|
699
|
+
);
|
|
700
|
+
}
|
|
675
701
|
calls.push(
|
|
676
|
-
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "
|
|
677
|
-
authorization.from,
|
|
678
|
-
authorization.to,
|
|
679
|
-
authorization.value,
|
|
680
|
-
authorization.validAfter,
|
|
681
|
-
authorization.validBefore,
|
|
682
|
-
authorization.nonce,
|
|
683
|
-
authorization.signature
|
|
684
|
-
]),
|
|
702
|
+
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "transferFrom", [owner, smartAccount, amount]),
|
|
685
703
|
call(SURFLIQUID_USDC_ADDRESS, USDC_ABI, "approve", [vault, amount]),
|
|
686
704
|
input.hasInitialDeposit ? call(vault, SURFLIQUID_VAULT_ABI, "userDeposit", [SURFLIQUID_USDC_ADDRESS, amount]) : call(vault, SURFLIQUID_VAULT_ABI, "initialDeposit", [
|
|
687
705
|
SURFLIQUID_USDC_ADDRESS,
|
|
@@ -751,22 +769,23 @@ async function pickMorphoVault(api) {
|
|
|
751
769
|
}
|
|
752
770
|
return candidate.vaultAddress;
|
|
753
771
|
}
|
|
754
|
-
async function
|
|
755
|
-
const {
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
const
|
|
759
|
-
|
|
772
|
+
async function permitIfShort(input) {
|
|
773
|
+
const { chain, wallet, amount } = input;
|
|
774
|
+
const allowance = await chain.readAllowance(wallet.ownerAddress, wallet.smartAccountAddress);
|
|
775
|
+
if (allowance >= amount) return void 0;
|
|
776
|
+
const [{ tokenName, tokenVersion }, nonce] = await Promise.all([
|
|
777
|
+
chain.readTokenMeta(),
|
|
778
|
+
chain.readPermitNonce(wallet.ownerAddress)
|
|
779
|
+
]);
|
|
760
780
|
const message = {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
value: amount,
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
nonce: randomAuthNonce()
|
|
781
|
+
owner: wallet.ownerAddress,
|
|
782
|
+
spender: wallet.smartAccountAddress,
|
|
783
|
+
value: amount > SURFLIQUID_PERMIT_CAP ? amount : SURFLIQUID_PERMIT_CAP,
|
|
784
|
+
nonce,
|
|
785
|
+
deadline: BigInt(Math.floor(Date.now() / 1e3)) + SURFLIQUID_PERMIT_TTL_SECONDS
|
|
767
786
|
};
|
|
768
|
-
const signature = await wallet.
|
|
769
|
-
|
|
787
|
+
const signature = await wallet.signPermit(
|
|
788
|
+
buildPermitTypedData({
|
|
770
789
|
token: SURFLIQUID_USDC_ADDRESS,
|
|
771
790
|
chainId: SURFLIQUID_CHAIN_ID,
|
|
772
791
|
tokenName,
|
|
@@ -774,12 +793,29 @@ async function depositSponsored(input) {
|
|
|
774
793
|
message
|
|
775
794
|
})
|
|
776
795
|
);
|
|
796
|
+
const { r, s, v, yParity } = (0, import_viem8.parseSignature)(signature);
|
|
797
|
+
return {
|
|
798
|
+
owner: message.owner,
|
|
799
|
+
value: message.value,
|
|
800
|
+
deadline: message.deadline,
|
|
801
|
+
v: Number(v ?? BigInt(yParity + 27)),
|
|
802
|
+
r,
|
|
803
|
+
s
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
async function depositSponsored(input) {
|
|
807
|
+
const { api, chain, wallet, amount } = input;
|
|
808
|
+
const { vault, deploySalt, registerAfterDeposit } = await resolveVault(input);
|
|
809
|
+
const hasInitialDeposit = deploySalt ? false : await chain.hasInitialDeposit(vault, SURFLIQUID_USDC_ADDRESS);
|
|
810
|
+
const morphoVault = hasInitialDeposit ? void 0 : await pickMorphoVault(api);
|
|
811
|
+
const permit = await permitIfShort({ chain, wallet, amount });
|
|
777
812
|
const txHash = await wallet.sendCalls(
|
|
778
813
|
buildDepositCalls({
|
|
779
814
|
smartAccount: wallet.smartAccountAddress,
|
|
815
|
+
owner: wallet.ownerAddress,
|
|
780
816
|
vault,
|
|
781
817
|
amount,
|
|
782
|
-
|
|
818
|
+
permit,
|
|
783
819
|
hasInitialDeposit,
|
|
784
820
|
morphoVault,
|
|
785
821
|
deploySalt
|
|
@@ -827,14 +863,14 @@ async function withdrawSponsored(input) {
|
|
|
827
863
|
);
|
|
828
864
|
}
|
|
829
865
|
}
|
|
830
|
-
var
|
|
866
|
+
var import_viem8, SubmittedError, VaultNotSponsorableError;
|
|
831
867
|
var init_surfliquid_sponsorship = __esm({
|
|
832
868
|
"src/agents/surfliquid/surfliquid.sponsorship.ts"() {
|
|
833
869
|
"use strict";
|
|
870
|
+
import_viem8 = require("viem");
|
|
834
871
|
init_transfer_auth();
|
|
835
872
|
init_surfliquid_constants();
|
|
836
873
|
init_surfliquid_calls();
|
|
837
|
-
AUTHORIZATION_TTL_SECONDS = 3600n;
|
|
838
874
|
SubmittedError = class extends Error {
|
|
839
875
|
constructor(message, userOpHash) {
|
|
840
876
|
super(message);
|
|
@@ -946,7 +982,7 @@ __export(surfliquid_smart_account_exports, {
|
|
|
946
982
|
pinAccount: () => pinAccount
|
|
947
983
|
});
|
|
948
984
|
function publicClientFor(rpcUrl) {
|
|
949
|
-
return (0,
|
|
985
|
+
return (0, import_viem9.createPublicClient)({ chain: import_chains2.base, transport: (0, import_viem9.http)(rpcUrl) });
|
|
950
986
|
}
|
|
951
987
|
function createSponsoredChain(rpcUrl) {
|
|
952
988
|
const client = publicClientFor(rpcUrl);
|
|
@@ -976,7 +1012,19 @@ function createSponsoredChain(rpcUrl) {
|
|
|
976
1012
|
}),
|
|
977
1013
|
// Cast: viem's OP-stack tx union does not match the generic PublicClient
|
|
978
1014
|
// the helper is typed against, though every method it uses is present.
|
|
979
|
-
readTokenMeta: () => readTokenMeta(client, SURFLIQUID_USDC_ADDRESS)
|
|
1015
|
+
readTokenMeta: () => readTokenMeta(client, SURFLIQUID_USDC_ADDRESS),
|
|
1016
|
+
readAllowance: (owner, spender) => client.readContract({
|
|
1017
|
+
address: SURFLIQUID_USDC_ADDRESS,
|
|
1018
|
+
abi: USDC_ABI,
|
|
1019
|
+
functionName: "allowance",
|
|
1020
|
+
args: [owner, spender]
|
|
1021
|
+
}),
|
|
1022
|
+
readPermitNonce: (owner) => client.readContract({
|
|
1023
|
+
address: SURFLIQUID_USDC_ADDRESS,
|
|
1024
|
+
abi: USDC_ABI,
|
|
1025
|
+
functionName: "nonces",
|
|
1026
|
+
args: [owner]
|
|
1027
|
+
})
|
|
980
1028
|
};
|
|
981
1029
|
}
|
|
982
1030
|
function pinAccount(provider, address) {
|
|
@@ -992,7 +1040,7 @@ async function createSponsoredWallet(input) {
|
|
|
992
1040
|
owner: pinAccount(input.provider, input.ownerAddress),
|
|
993
1041
|
entryPoint
|
|
994
1042
|
});
|
|
995
|
-
const bundlerTransport = (0,
|
|
1043
|
+
const bundlerTransport = (0, import_viem9.http)(sponsorProxyUrl(input.routingApiBaseUrl), {
|
|
996
1044
|
fetchOptions: { headers: { "x-owney-api-key": input.apiKey } }
|
|
997
1045
|
});
|
|
998
1046
|
const pimlico = (0, import_pimlico.createPimlicoClient)({ transport: bundlerTransport, entryPoint });
|
|
@@ -1005,16 +1053,16 @@ async function createSponsoredWallet(input) {
|
|
|
1005
1053
|
estimateFeesPerGas: async () => (await pimlico.getUserOperationGasPrice()).fast
|
|
1006
1054
|
}
|
|
1007
1055
|
});
|
|
1008
|
-
const walletClient = (0,
|
|
1056
|
+
const walletClient = (0, import_viem9.createWalletClient)({
|
|
1009
1057
|
account: input.ownerAddress,
|
|
1010
1058
|
chain: import_chains2.base,
|
|
1011
|
-
transport: (0,
|
|
1059
|
+
transport: (0, import_viem9.custom)(input.provider)
|
|
1012
1060
|
});
|
|
1013
1061
|
return {
|
|
1014
1062
|
smartAccountAddress: account.address,
|
|
1015
1063
|
ownerAddress: input.ownerAddress,
|
|
1016
1064
|
// The EOA signs, not the smart account: USDC verifies ECDSA from the token holder.
|
|
1017
|
-
|
|
1065
|
+
signPermit: (typedData) => walletClient.signTypedData({
|
|
1018
1066
|
account: input.ownerAddress,
|
|
1019
1067
|
domain: typedData.domain,
|
|
1020
1068
|
types: typedData.types,
|
|
@@ -1037,14 +1085,14 @@ async function createSponsoredWallet(input) {
|
|
|
1037
1085
|
}
|
|
1038
1086
|
};
|
|
1039
1087
|
}
|
|
1040
|
-
var import_permissionless, import_accounts, import_pimlico,
|
|
1088
|
+
var import_permissionless, import_accounts, import_pimlico, import_viem9, import_account_abstraction, import_chains2, sponsorProxyUrl;
|
|
1041
1089
|
var init_surfliquid_smart_account = __esm({
|
|
1042
1090
|
"src/agents/surfliquid/surfliquid.smart-account.ts"() {
|
|
1043
1091
|
"use strict";
|
|
1044
1092
|
import_permissionless = require("permissionless");
|
|
1045
1093
|
import_accounts = require("permissionless/accounts");
|
|
1046
1094
|
import_pimlico = require("permissionless/clients/pimlico");
|
|
1047
|
-
|
|
1095
|
+
import_viem9 = require("viem");
|
|
1048
1096
|
import_account_abstraction = require("viem/account-abstraction");
|
|
1049
1097
|
import_chains2 = require("viem/chains");
|
|
1050
1098
|
init_transfer_auth();
|
|
@@ -1075,11 +1123,11 @@ function toOwneyError(error) {
|
|
|
1075
1123
|
}
|
|
1076
1124
|
return new OwneyError("SPONSORSHIP_UNAVAILABLE", message, void 0, AGENT_ID2);
|
|
1077
1125
|
}
|
|
1078
|
-
var
|
|
1126
|
+
var import_viem10, import_chains3, AGENT_ID2, WALLET_REJECTED_CODE, DISCOVERY_WALLET2, HISTORY_DEFAULT_LIMIT, APY_WINDOW_KEY2, SurfLiquidAgent;
|
|
1079
1127
|
var init_surfliquid_agent = __esm({
|
|
1080
1128
|
"src/agents/surfliquid/surfliquid.agent.ts"() {
|
|
1081
1129
|
"use strict";
|
|
1082
|
-
|
|
1130
|
+
import_viem10 = require("viem");
|
|
1083
1131
|
import_chains3 = require("viem/chains");
|
|
1084
1132
|
init_errors();
|
|
1085
1133
|
init_surfliquid_constants();
|
|
@@ -1133,10 +1181,10 @@ var init_surfliquid_agent = __esm({
|
|
|
1133
1181
|
if (this.connectPromise) return this.connectPromise;
|
|
1134
1182
|
this.connectPromise = (async () => {
|
|
1135
1183
|
const message = await broker.nonce();
|
|
1136
|
-
const walletClient = (0,
|
|
1184
|
+
const walletClient = (0, import_viem10.createWalletClient)({
|
|
1137
1185
|
account: state.walletAddress,
|
|
1138
1186
|
chain: import_chains3.base,
|
|
1139
|
-
transport: (0,
|
|
1187
|
+
transport: (0, import_viem10.custom)(state.provider)
|
|
1140
1188
|
});
|
|
1141
1189
|
const signature = await walletClient.signMessage({ account: state.walletAddress, message });
|
|
1142
1190
|
await broker.login(message, signature);
|
|
@@ -3481,7 +3529,7 @@ function aggregateApyByChainAndAsset(agentApys, agentBalances) {
|
|
|
3481
3529
|
}
|
|
3482
3530
|
|
|
3483
3531
|
// src/client.ts
|
|
3484
|
-
var
|
|
3532
|
+
var import_viem11 = require("viem");
|
|
3485
3533
|
var import_chains4 = require("viem/chains");
|
|
3486
3534
|
|
|
3487
3535
|
// src/lib/sponsored-deposit.ts
|
|
@@ -4160,14 +4208,14 @@ var OwneySDK = class {
|
|
|
4160
4208
|
// Casts work around viem's chain-narrowed Client vs the generic
|
|
4161
4209
|
// PublicClient/WalletClient param types — structurally identical at
|
|
4162
4210
|
// runtime, but the two share a name TS treats as unrelated.
|
|
4163
|
-
getPublicClient: (cid) => (0,
|
|
4211
|
+
getPublicClient: (cid) => (0, import_viem11.createPublicClient)({
|
|
4164
4212
|
chain: VIEM_CHAIN2[cid],
|
|
4165
|
-
transport: (0,
|
|
4213
|
+
transport: (0, import_viem11.custom)(provider)
|
|
4166
4214
|
}),
|
|
4167
|
-
getWalletClient: (cid) => (0,
|
|
4215
|
+
getWalletClient: (cid) => (0, import_viem11.createWalletClient)({
|
|
4168
4216
|
account: owner,
|
|
4169
4217
|
chain: VIEM_CHAIN2[cid],
|
|
4170
|
-
transport: (0,
|
|
4218
|
+
transport: (0, import_viem11.custom)(provider)
|
|
4171
4219
|
})
|
|
4172
4220
|
});
|
|
4173
4221
|
if (!onApproved) this.cachedSponsoredCallback = callback;
|
|
@@ -4213,14 +4261,14 @@ var OwneySDK = class {
|
|
|
4213
4261
|
// Casts work around viem's chain-narrowed Client vs the generic
|
|
4214
4262
|
// PublicClient/WalletClient param types — structurally identical at
|
|
4215
4263
|
// runtime, but the two share a name TS treats as unrelated.
|
|
4216
|
-
getPublicClient: (cid) => (0,
|
|
4264
|
+
getPublicClient: (cid) => (0, import_viem11.createPublicClient)({
|
|
4217
4265
|
chain: VIEM_CHAIN2[cid],
|
|
4218
|
-
transport: (0,
|
|
4266
|
+
transport: (0, import_viem11.custom)(provider)
|
|
4219
4267
|
}),
|
|
4220
|
-
getWalletClient: (cid) => (0,
|
|
4268
|
+
getWalletClient: (cid) => (0, import_viem11.createWalletClient)({
|
|
4221
4269
|
account: owner,
|
|
4222
4270
|
chain: VIEM_CHAIN2[cid],
|
|
4223
|
-
transport: (0,
|
|
4271
|
+
transport: (0, import_viem11.custom)(provider)
|
|
4224
4272
|
})
|
|
4225
4273
|
});
|
|
4226
4274
|
if (!onApproved) this.cachedWethSponsoredCallback = callback;
|
|
@@ -5314,10 +5362,10 @@ var OwneySDK = class {
|
|
|
5314
5362
|
);
|
|
5315
5363
|
}
|
|
5316
5364
|
const provider = this.requireConnectedProvider();
|
|
5317
|
-
const wallet = (0,
|
|
5365
|
+
const wallet = (0, import_viem11.createWalletClient)({
|
|
5318
5366
|
account: state.walletAddress,
|
|
5319
5367
|
chain: VIEM_CHAIN2[chainId],
|
|
5320
|
-
transport: (0,
|
|
5368
|
+
transport: (0, import_viem11.custom)(provider)
|
|
5321
5369
|
});
|
|
5322
5370
|
const hash = await wallet.writeContract({
|
|
5323
5371
|
address: token,
|
|
@@ -5327,9 +5375,9 @@ var OwneySDK = class {
|
|
|
5327
5375
|
account: state.walletAddress,
|
|
5328
5376
|
chain: VIEM_CHAIN2[chainId]
|
|
5329
5377
|
});
|
|
5330
|
-
const publicClient = (0,
|
|
5378
|
+
const publicClient = (0, import_viem11.createPublicClient)({
|
|
5331
5379
|
chain: VIEM_CHAIN2[chainId],
|
|
5332
|
-
transport: (0,
|
|
5380
|
+
transport: (0, import_viem11.custom)(provider)
|
|
5333
5381
|
});
|
|
5334
5382
|
const receipt = await publicClient.waitForTransactionReceipt({
|
|
5335
5383
|
hash,
|
|
@@ -5445,7 +5493,7 @@ init_errors();
|
|
|
5445
5493
|
init_debug();
|
|
5446
5494
|
|
|
5447
5495
|
// src/agents/zyfai/zyfai.siwx.ts
|
|
5448
|
-
var
|
|
5496
|
+
var import_viem12 = require("viem");
|
|
5449
5497
|
var import_siwe = require("siwe");
|
|
5450
5498
|
var import_sdk2 = require("@zyfai/sdk");
|
|
5451
5499
|
|
|
@@ -5572,7 +5620,7 @@ function buildSIWXConfig(deps) {
|
|
|
5572
5620
|
issuedAt,
|
|
5573
5621
|
toString() {
|
|
5574
5622
|
return new import_siwe.SiweMessage({
|
|
5575
|
-
address: (0,
|
|
5623
|
+
address: (0, import_viem12.getAddress)(accountAddress),
|
|
5576
5624
|
chainId: numericChainId(chainId),
|
|
5577
5625
|
domain,
|
|
5578
5626
|
uri,
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
buildTransferWithAuthorizationTypedData,
|
|
13
13
|
randomAuthNonce,
|
|
14
14
|
readTokenMeta
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-AURO3C3R.js";
|
|
16
16
|
|
|
17
17
|
// src/lib/rate-limit.ts
|
|
18
18
|
function rateLimitDelay(error, now = Date.now()) {
|
|
@@ -3036,7 +3036,7 @@ var OwneySDK = class {
|
|
|
3036
3036
|
}
|
|
3037
3037
|
if (agentId === "surfliquid") {
|
|
3038
3038
|
if (!key2) return null;
|
|
3039
|
-
const { SurfLiquidAgent } = await import("./surfliquid.agent-
|
|
3039
|
+
const { SurfLiquidAgent } = await import("./surfliquid.agent-AE7RZ66F.js");
|
|
3040
3040
|
return new SurfLiquidAgent({
|
|
3041
3041
|
apiKey: this.apiKey,
|
|
3042
3042
|
routingApiBaseUrl: this.routingApiBaseUrl
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
VaultNotSponsorableError,
|
|
12
12
|
depositSponsored,
|
|
13
13
|
withdrawSponsored
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-3HL52KM7.js";
|
|
15
|
+
import "./chunk-AURO3C3R.js";
|
|
16
16
|
|
|
17
17
|
// src/agents/surfliquid/surfliquid.agent.ts
|
|
18
18
|
import { createWalletClient, custom } from "viem";
|
|
@@ -533,7 +533,7 @@ var SurfLiquidAgent = class {
|
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
async sponsoredWallet(state) {
|
|
536
|
-
const { createSponsoredWallet } = await import("./surfliquid.smart-account-
|
|
536
|
+
const { createSponsoredWallet } = await import("./surfliquid.smart-account-C535356J.js");
|
|
537
537
|
return createSponsoredWallet({
|
|
538
538
|
provider: state.provider,
|
|
539
539
|
ownerAddress: state.walletAddress,
|
|
@@ -555,7 +555,7 @@ var SurfLiquidAgent = class {
|
|
|
555
555
|
async deposit(state, _chainId, amount, _asset, _depositCallback) {
|
|
556
556
|
const broker = await this.connect(state);
|
|
557
557
|
const wallet = await this.sponsoredWallet(state);
|
|
558
|
-
const { createSponsoredChain } = await import("./surfliquid.smart-account-
|
|
558
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-C535356J.js");
|
|
559
559
|
try {
|
|
560
560
|
const { txHash, vault } = await this.withSession(
|
|
561
561
|
state,
|
|
@@ -570,7 +570,7 @@ var SurfLiquidAgent = class {
|
|
|
570
570
|
async withdraw(state, _chainId, _token, amount) {
|
|
571
571
|
const broker = await this.connect(state);
|
|
572
572
|
const wallet = await this.sponsoredWallet(state);
|
|
573
|
-
const { createSponsoredChain } = await import("./surfliquid.smart-account-
|
|
573
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-C535356J.js");
|
|
574
574
|
try {
|
|
575
575
|
const result = await this.withSession(
|
|
576
576
|
state,
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
SURFLIQUID_VAULT_ABI,
|
|
7
7
|
SubmittedError,
|
|
8
8
|
USDC_ABI
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3HL52KM7.js";
|
|
10
10
|
import {
|
|
11
11
|
readTokenMeta
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-AURO3C3R.js";
|
|
13
13
|
|
|
14
14
|
// src/agents/surfliquid/surfliquid.smart-account.ts
|
|
15
15
|
import { createSmartAccountClient } from "permissionless";
|
|
@@ -55,7 +55,19 @@ function createSponsoredChain(rpcUrl) {
|
|
|
55
55
|
}),
|
|
56
56
|
// Cast: viem's OP-stack tx union does not match the generic PublicClient
|
|
57
57
|
// the helper is typed against, though every method it uses is present.
|
|
58
|
-
readTokenMeta: () => readTokenMeta(client, SURFLIQUID_USDC_ADDRESS)
|
|
58
|
+
readTokenMeta: () => readTokenMeta(client, SURFLIQUID_USDC_ADDRESS),
|
|
59
|
+
readAllowance: (owner, spender) => client.readContract({
|
|
60
|
+
address: SURFLIQUID_USDC_ADDRESS,
|
|
61
|
+
abi: USDC_ABI,
|
|
62
|
+
functionName: "allowance",
|
|
63
|
+
args: [owner, spender]
|
|
64
|
+
}),
|
|
65
|
+
readPermitNonce: (owner) => client.readContract({
|
|
66
|
+
address: SURFLIQUID_USDC_ADDRESS,
|
|
67
|
+
abi: USDC_ABI,
|
|
68
|
+
functionName: "nonces",
|
|
69
|
+
args: [owner]
|
|
70
|
+
})
|
|
59
71
|
};
|
|
60
72
|
}
|
|
61
73
|
function pinAccount(provider, address) {
|
|
@@ -93,7 +105,7 @@ async function createSponsoredWallet(input) {
|
|
|
93
105
|
smartAccountAddress: account.address,
|
|
94
106
|
ownerAddress: input.ownerAddress,
|
|
95
107
|
// The EOA signs, not the smart account: USDC verifies ECDSA from the token holder.
|
|
96
|
-
|
|
108
|
+
signPermit: (typedData) => walletClient.signTypedData({
|
|
97
109
|
account: input.ownerAddress,
|
|
98
110
|
domain: typedData.domain,
|
|
99
111
|
types: typedData.types,
|