@owney/sdk 0.5.3 → 0.6.0-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/index.cjs +45 -9
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +45 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38,7 +38,7 @@ var P_SUPPORTED_CHAINS = {
|
|
|
38
38
|
chainIds: [8453, 42161],
|
|
39
39
|
chains: ["BASE", "ARBITRUM"]
|
|
40
40
|
};
|
|
41
|
-
var SUPPORTED_TOKENS = ["USDC", "USDT"];
|
|
41
|
+
var SUPPORTED_TOKENS = ["USDC", "USDT", "WETH"];
|
|
42
42
|
var SUPPORTED_CHAIN_IDS = P_SUPPORTED_CHAINS.chainIds;
|
|
43
43
|
var SUPPORTED_CHAINS = P_SUPPORTED_CHAINS.chains;
|
|
44
44
|
var SupportedAssets = [
|
|
@@ -59,6 +59,18 @@ var SupportedAssets = [
|
|
|
59
59
|
symbol: "USDT",
|
|
60
60
|
chainId: 42161,
|
|
61
61
|
decimals: 6
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
address: `0x4200000000000000000000000000000000000006`,
|
|
65
|
+
symbol: "WETH",
|
|
66
|
+
chainId: 8453,
|
|
67
|
+
decimals: 18
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
address: `0x82aF49447D8a07e3bd95BD0d56f35241523fBab1`,
|
|
71
|
+
symbol: "WETH",
|
|
72
|
+
chainId: 42161,
|
|
73
|
+
decimals: 18
|
|
62
74
|
}
|
|
63
75
|
];
|
|
64
76
|
|
|
@@ -491,6 +503,10 @@ var DEFAULT_ZYFAI_RPC_URLS = {
|
|
|
491
503
|
8453: "https://base-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
|
|
492
504
|
42161: "https://arb-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V"
|
|
493
505
|
};
|
|
506
|
+
var WETH_ADDRESS_BY_CHAIN = {
|
|
507
|
+
8453: "0x4200000000000000000000000000000000000006",
|
|
508
|
+
42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
|
|
509
|
+
};
|
|
494
510
|
var ZyfaiAgent = class {
|
|
495
511
|
id = "zyfai";
|
|
496
512
|
supportedChainIds = [8453, 42161];
|
|
@@ -498,12 +514,18 @@ var ZyfaiAgent = class {
|
|
|
498
514
|
{
|
|
499
515
|
chainId: 8453,
|
|
500
516
|
chain: "BASE",
|
|
501
|
-
assets: [
|
|
517
|
+
assets: [
|
|
518
|
+
{ symbol: "USDC", minDepositAmount: "1500000" },
|
|
519
|
+
{ symbol: "WETH", minDepositAmount: "500000000000000" }
|
|
520
|
+
]
|
|
502
521
|
},
|
|
503
522
|
{
|
|
504
523
|
chainId: 42161,
|
|
505
524
|
chain: "ARBITRUM",
|
|
506
|
-
assets: [
|
|
525
|
+
assets: [
|
|
526
|
+
{ symbol: "USDC", minDepositAmount: "1500000" },
|
|
527
|
+
{ symbol: "WETH", minDepositAmount: "500000000000000" }
|
|
528
|
+
]
|
|
507
529
|
}
|
|
508
530
|
];
|
|
509
531
|
sdk;
|
|
@@ -669,7 +691,7 @@ var ZyfaiAgent = class {
|
|
|
669
691
|
throw error;
|
|
670
692
|
}
|
|
671
693
|
}
|
|
672
|
-
async deposit(state, chainId, amount, depositCallback) {
|
|
694
|
+
async deposit(state, chainId, amount, asset, depositCallback) {
|
|
673
695
|
try {
|
|
674
696
|
await this.connectFull(state, chainId);
|
|
675
697
|
const validChainId = isValidChainId(chainId);
|
|
@@ -683,13 +705,15 @@ var ZyfaiAgent = class {
|
|
|
683
705
|
validChainId,
|
|
684
706
|
amount
|
|
685
707
|
);
|
|
686
|
-
|
|
708
|
+
const tokenAddress = asset === "WETH" ? WETH_ADDRESS_BY_CHAIN[validChainId] : void 0;
|
|
709
|
+
await (tokenAddress ? this.sdk.logDeposit(validChainId, txHash, amount, tokenAddress) : this.sdk.logDeposit(validChainId, txHash, amount));
|
|
687
710
|
return { txHash, smartWallet: wallet.address, amount };
|
|
688
711
|
}
|
|
689
712
|
const raw = await this.sdk.depositFunds(
|
|
690
713
|
this.getAddress(),
|
|
691
714
|
validChainId,
|
|
692
|
-
amount
|
|
715
|
+
amount,
|
|
716
|
+
asset
|
|
693
717
|
);
|
|
694
718
|
return mapDeposit(raw);
|
|
695
719
|
} catch (error) {
|
|
@@ -1414,7 +1438,7 @@ var OwneySDK = class {
|
|
|
1414
1438
|
}
|
|
1415
1439
|
const state = this.requireState();
|
|
1416
1440
|
const chainId = this.requireChainId();
|
|
1417
|
-
const effectiveCallback = depositCallback ?? this.getDefaultSponsoredCallback();
|
|
1441
|
+
const effectiveCallback = depositCallback ?? (asset === "WETH" ? void 0 : this.getDefaultSponsoredCallback());
|
|
1418
1442
|
if (agentId) {
|
|
1419
1443
|
if (this.isAgentDisabled(agentId)) {
|
|
1420
1444
|
throw new OwneyError(
|
|
@@ -1429,7 +1453,13 @@ var OwneySDK = class {
|
|
|
1429
1453
|
return withFailureReporting(
|
|
1430
1454
|
this.apiKey,
|
|
1431
1455
|
agent.id,
|
|
1432
|
-
() => agent.deposit(
|
|
1456
|
+
() => agent.deposit(
|
|
1457
|
+
state,
|
|
1458
|
+
chainId,
|
|
1459
|
+
amount,
|
|
1460
|
+
asset,
|
|
1461
|
+
effectiveCallback
|
|
1462
|
+
)
|
|
1433
1463
|
);
|
|
1434
1464
|
}
|
|
1435
1465
|
const totalAmount = BigInt(amount);
|
|
@@ -1463,7 +1493,13 @@ var OwneySDK = class {
|
|
|
1463
1493
|
agentResults[agent.id] = await withFailureReporting(
|
|
1464
1494
|
this.apiKey,
|
|
1465
1495
|
agent.id,
|
|
1466
|
-
() => agent.deposit(
|
|
1496
|
+
() => agent.deposit(
|
|
1497
|
+
state,
|
|
1498
|
+
chainId,
|
|
1499
|
+
agentAmount,
|
|
1500
|
+
asset,
|
|
1501
|
+
effectiveCallback
|
|
1502
|
+
)
|
|
1467
1503
|
);
|
|
1468
1504
|
}
|
|
1469
1505
|
return { agentResults };
|
package/dist/index.d.cts
CHANGED
|
@@ -14,7 +14,7 @@ interface ConnectionState {
|
|
|
14
14
|
walletAddress: `0x${string}`;
|
|
15
15
|
chainId: number | null;
|
|
16
16
|
}
|
|
17
|
-
declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT"];
|
|
17
|
+
declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT", "WETH"];
|
|
18
18
|
declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161];
|
|
19
19
|
declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM"];
|
|
20
20
|
type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
@@ -175,7 +175,7 @@ interface IAgent {
|
|
|
175
175
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
176
176
|
disconnect(): Promise<void>;
|
|
177
177
|
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
178
|
-
deposit(state: ConnectionState, chainId: number, amount: string, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
178
|
+
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
179
179
|
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
180
180
|
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
181
181
|
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface ConnectionState {
|
|
|
14
14
|
walletAddress: `0x${string}`;
|
|
15
15
|
chainId: number | null;
|
|
16
16
|
}
|
|
17
|
-
declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT"];
|
|
17
|
+
declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT", "WETH"];
|
|
18
18
|
declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161];
|
|
19
19
|
declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM"];
|
|
20
20
|
type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
@@ -175,7 +175,7 @@ interface IAgent {
|
|
|
175
175
|
readonly supportedAssets: readonly AgentSupportedAssets[];
|
|
176
176
|
disconnect(): Promise<void>;
|
|
177
177
|
activateAgent(state: ConnectionState, chainId: number): Promise<void>;
|
|
178
|
-
deposit(state: ConnectionState, chainId: number, amount: string, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
178
|
+
deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
|
|
179
179
|
withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
|
|
180
180
|
getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
|
|
181
181
|
getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var P_SUPPORTED_CHAINS = {
|
|
|
6
6
|
chainIds: [8453, 42161],
|
|
7
7
|
chains: ["BASE", "ARBITRUM"]
|
|
8
8
|
};
|
|
9
|
-
var SUPPORTED_TOKENS = ["USDC", "USDT"];
|
|
9
|
+
var SUPPORTED_TOKENS = ["USDC", "USDT", "WETH"];
|
|
10
10
|
var SUPPORTED_CHAIN_IDS = P_SUPPORTED_CHAINS.chainIds;
|
|
11
11
|
var SUPPORTED_CHAINS = P_SUPPORTED_CHAINS.chains;
|
|
12
12
|
var SupportedAssets = [
|
|
@@ -27,6 +27,18 @@ var SupportedAssets = [
|
|
|
27
27
|
symbol: "USDT",
|
|
28
28
|
chainId: 42161,
|
|
29
29
|
decimals: 6
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
address: `0x4200000000000000000000000000000000000006`,
|
|
33
|
+
symbol: "WETH",
|
|
34
|
+
chainId: 8453,
|
|
35
|
+
decimals: 18
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
address: `0x82aF49447D8a07e3bd95BD0d56f35241523fBab1`,
|
|
39
|
+
symbol: "WETH",
|
|
40
|
+
chainId: 42161,
|
|
41
|
+
decimals: 18
|
|
30
42
|
}
|
|
31
43
|
];
|
|
32
44
|
|
|
@@ -459,6 +471,10 @@ var DEFAULT_ZYFAI_RPC_URLS = {
|
|
|
459
471
|
8453: "https://base-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
|
|
460
472
|
42161: "https://arb-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V"
|
|
461
473
|
};
|
|
474
|
+
var WETH_ADDRESS_BY_CHAIN = {
|
|
475
|
+
8453: "0x4200000000000000000000000000000000000006",
|
|
476
|
+
42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
|
|
477
|
+
};
|
|
462
478
|
var ZyfaiAgent = class {
|
|
463
479
|
id = "zyfai";
|
|
464
480
|
supportedChainIds = [8453, 42161];
|
|
@@ -466,12 +482,18 @@ var ZyfaiAgent = class {
|
|
|
466
482
|
{
|
|
467
483
|
chainId: 8453,
|
|
468
484
|
chain: "BASE",
|
|
469
|
-
assets: [
|
|
485
|
+
assets: [
|
|
486
|
+
{ symbol: "USDC", minDepositAmount: "1500000" },
|
|
487
|
+
{ symbol: "WETH", minDepositAmount: "500000000000000" }
|
|
488
|
+
]
|
|
470
489
|
},
|
|
471
490
|
{
|
|
472
491
|
chainId: 42161,
|
|
473
492
|
chain: "ARBITRUM",
|
|
474
|
-
assets: [
|
|
493
|
+
assets: [
|
|
494
|
+
{ symbol: "USDC", minDepositAmount: "1500000" },
|
|
495
|
+
{ symbol: "WETH", minDepositAmount: "500000000000000" }
|
|
496
|
+
]
|
|
475
497
|
}
|
|
476
498
|
];
|
|
477
499
|
sdk;
|
|
@@ -637,7 +659,7 @@ var ZyfaiAgent = class {
|
|
|
637
659
|
throw error;
|
|
638
660
|
}
|
|
639
661
|
}
|
|
640
|
-
async deposit(state, chainId, amount, depositCallback) {
|
|
662
|
+
async deposit(state, chainId, amount, asset, depositCallback) {
|
|
641
663
|
try {
|
|
642
664
|
await this.connectFull(state, chainId);
|
|
643
665
|
const validChainId = isValidChainId(chainId);
|
|
@@ -651,13 +673,15 @@ var ZyfaiAgent = class {
|
|
|
651
673
|
validChainId,
|
|
652
674
|
amount
|
|
653
675
|
);
|
|
654
|
-
|
|
676
|
+
const tokenAddress = asset === "WETH" ? WETH_ADDRESS_BY_CHAIN[validChainId] : void 0;
|
|
677
|
+
await (tokenAddress ? this.sdk.logDeposit(validChainId, txHash, amount, tokenAddress) : this.sdk.logDeposit(validChainId, txHash, amount));
|
|
655
678
|
return { txHash, smartWallet: wallet.address, amount };
|
|
656
679
|
}
|
|
657
680
|
const raw = await this.sdk.depositFunds(
|
|
658
681
|
this.getAddress(),
|
|
659
682
|
validChainId,
|
|
660
|
-
amount
|
|
683
|
+
amount,
|
|
684
|
+
asset
|
|
661
685
|
);
|
|
662
686
|
return mapDeposit(raw);
|
|
663
687
|
} catch (error) {
|
|
@@ -1386,7 +1410,7 @@ var OwneySDK = class {
|
|
|
1386
1410
|
}
|
|
1387
1411
|
const state = this.requireState();
|
|
1388
1412
|
const chainId = this.requireChainId();
|
|
1389
|
-
const effectiveCallback = depositCallback ?? this.getDefaultSponsoredCallback();
|
|
1413
|
+
const effectiveCallback = depositCallback ?? (asset === "WETH" ? void 0 : this.getDefaultSponsoredCallback());
|
|
1390
1414
|
if (agentId) {
|
|
1391
1415
|
if (this.isAgentDisabled(agentId)) {
|
|
1392
1416
|
throw new OwneyError(
|
|
@@ -1401,7 +1425,13 @@ var OwneySDK = class {
|
|
|
1401
1425
|
return withFailureReporting(
|
|
1402
1426
|
this.apiKey,
|
|
1403
1427
|
agent.id,
|
|
1404
|
-
() => agent.deposit(
|
|
1428
|
+
() => agent.deposit(
|
|
1429
|
+
state,
|
|
1430
|
+
chainId,
|
|
1431
|
+
amount,
|
|
1432
|
+
asset,
|
|
1433
|
+
effectiveCallback
|
|
1434
|
+
)
|
|
1405
1435
|
);
|
|
1406
1436
|
}
|
|
1407
1437
|
const totalAmount = BigInt(amount);
|
|
@@ -1435,7 +1465,13 @@ var OwneySDK = class {
|
|
|
1435
1465
|
agentResults[agent.id] = await withFailureReporting(
|
|
1436
1466
|
this.apiKey,
|
|
1437
1467
|
agent.id,
|
|
1438
|
-
() => agent.deposit(
|
|
1468
|
+
() => agent.deposit(
|
|
1469
|
+
state,
|
|
1470
|
+
chainId,
|
|
1471
|
+
agentAmount,
|
|
1472
|
+
asset,
|
|
1473
|
+
effectiveCallback
|
|
1474
|
+
)
|
|
1439
1475
|
);
|
|
1440
1476
|
}
|
|
1441
1477
|
return { agentResults };
|