@zyfai/sdk 0.7.1 → 0.9.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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +98 -22
- package/dist/index.mjs +98 -22
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ type Hex = `0x${string}`;
|
|
|
14
14
|
*/
|
|
15
15
|
type Strategy = "conservative" | "aggressive" | "yieldmaxxing";
|
|
16
16
|
/** Public asset symbols supported by the SDK */
|
|
17
|
-
type SupportedAsset = "USDC" | "WETH" | "EURC" | "NVDAc";
|
|
17
|
+
type SupportedAsset = "USDC" | "WETH" | "EURC" | "USDT" | "PYUSD" | "NVDAc";
|
|
18
18
|
/** Optional per-chain RPC URLs for on-chain reads and writes. */
|
|
19
19
|
interface RpcUrlsConfig {
|
|
20
20
|
/** Ethereum mainnet */
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ type Hex = `0x${string}`;
|
|
|
14
14
|
*/
|
|
15
15
|
type Strategy = "conservative" | "aggressive" | "yieldmaxxing";
|
|
16
16
|
/** Public asset symbols supported by the SDK */
|
|
17
|
-
type SupportedAsset = "USDC" | "WETH" | "EURC" | "NVDAc";
|
|
17
|
+
type SupportedAsset = "USDC" | "WETH" | "EURC" | "USDT" | "PYUSD" | "NVDAc";
|
|
18
18
|
/** Optional per-chain RPC URLs for on-chain reads and writes. */
|
|
19
19
|
interface RpcUrlsConfig {
|
|
20
20
|
/** Ethereum mainnet */
|
package/dist/index.js
CHANGED
|
@@ -548,6 +548,33 @@ var ERC20_ABI = [
|
|
|
548
548
|
outputs: [{ name: "", type: "uint256" }]
|
|
549
549
|
}
|
|
550
550
|
];
|
|
551
|
+
var ERC20_TRANSFER_LEGACY_ABI = [
|
|
552
|
+
{
|
|
553
|
+
name: "transfer",
|
|
554
|
+
type: "function",
|
|
555
|
+
stateMutability: "nonpayable",
|
|
556
|
+
inputs: [
|
|
557
|
+
{ name: "to", type: "address" },
|
|
558
|
+
{ name: "amount", type: "uint256" }
|
|
559
|
+
],
|
|
560
|
+
outputs: []
|
|
561
|
+
}
|
|
562
|
+
];
|
|
563
|
+
var ERC20_TRANSFER_WITH_BOOL_ABI = [
|
|
564
|
+
{
|
|
565
|
+
name: "transfer",
|
|
566
|
+
type: "function",
|
|
567
|
+
stateMutability: "nonpayable",
|
|
568
|
+
inputs: [
|
|
569
|
+
{ name: "to", type: "address" },
|
|
570
|
+
{ name: "amount", type: "uint256" }
|
|
571
|
+
],
|
|
572
|
+
outputs: [{ name: "", type: "bool" }]
|
|
573
|
+
}
|
|
574
|
+
];
|
|
575
|
+
function erc20TransferWriteAbi(assetSymbol) {
|
|
576
|
+
return assetSymbol === "USDT" ? ERC20_TRANSFER_LEGACY_ABI : ERC20_TRANSFER_WITH_BOOL_ABI;
|
|
577
|
+
}
|
|
551
578
|
var IDENTITY_REGISTRY_ABI = (0, import_viem.parseAbi)([
|
|
552
579
|
"function register() external returns (uint256 agentId)",
|
|
553
580
|
"function register(string tokenUri) external returns (uint256 agentId)",
|
|
@@ -645,8 +672,12 @@ var MIN_PORTFOLIO_BALANCE = {
|
|
|
645
672
|
1: {
|
|
646
673
|
USDC: 10000n * 10n ** 6n,
|
|
647
674
|
// 10,000 USDC (6 decimals)
|
|
648
|
-
EURC: 10000n * 10n ** 6n
|
|
675
|
+
EURC: 10000n * 10n ** 6n,
|
|
649
676
|
// 10,000 EURC (6 decimals)
|
|
677
|
+
USDT: 10000n * 10n ** 6n,
|
|
678
|
+
// 10,000 USDT (6 decimals)
|
|
679
|
+
PYUSD: 10000n * 10n ** 6n
|
|
680
|
+
// 10,000 PYUSD (6 decimals)
|
|
650
681
|
},
|
|
651
682
|
8453: {
|
|
652
683
|
USDC: 10n * 10n ** 6n,
|
|
@@ -724,6 +755,20 @@ function shouldBypassMinPortfolioCheck(executionApiUrl) {
|
|
|
724
755
|
return isLocalExecutionApiUrl(executionApiUrl) || isStagingExecutionApiUrl(executionApiUrl);
|
|
725
756
|
}
|
|
726
757
|
|
|
758
|
+
// src/config/min-portfolio-exempt.ts
|
|
759
|
+
var MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES = /* @__PURE__ */ new Set([
|
|
760
|
+
"0x2db791f63c8b12bde9a3fe31afa8ad491f47d60f",
|
|
761
|
+
"0xae72cb0f7d604a8ff742d96031104506186638e3"
|
|
762
|
+
]);
|
|
763
|
+
function isMainnetMinPortfolioExempt(chainId, ...addresses) {
|
|
764
|
+
if (chainId !== 1) {
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
return addresses.some(
|
|
768
|
+
(address) => typeof address === "string" && MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES.has(address.toLowerCase())
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
|
|
727
772
|
// src/core/ZyfaiSDK.ts
|
|
728
773
|
var import_accounts2 = require("viem/accounts");
|
|
729
774
|
var import_viem4 = require("viem");
|
|
@@ -746,7 +791,7 @@ var ASSET_CONFIGS = {
|
|
|
746
791
|
displayName: "USDC",
|
|
747
792
|
icon: "/ai-dashboard/usdc-token.png",
|
|
748
793
|
decimals: 6,
|
|
749
|
-
tokenSymbols: ["USDC", "USDC.e", "
|
|
794
|
+
tokenSymbols: ["USDC", "USDC.e", "USDT0"],
|
|
750
795
|
tokenSymbolsByChainId: {
|
|
751
796
|
1: "USDC",
|
|
752
797
|
8453: "USDC",
|
|
@@ -817,6 +862,36 @@ var ASSET_CONFIGS = {
|
|
|
817
862
|
},
|
|
818
863
|
enabled: true
|
|
819
864
|
},
|
|
865
|
+
USDT: {
|
|
866
|
+
symbol: "USDT",
|
|
867
|
+
assetType: "usdt",
|
|
868
|
+
displayName: "USDT",
|
|
869
|
+
icon: "https://etherscan.io/token/images/tethernew_32.svg",
|
|
870
|
+
decimals: 6,
|
|
871
|
+
tokenSymbols: ["USDT"],
|
|
872
|
+
tokenSymbolsByChainId: {
|
|
873
|
+
1: "USDT"
|
|
874
|
+
},
|
|
875
|
+
addresses: {
|
|
876
|
+
1: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
|
877
|
+
},
|
|
878
|
+
enabled: true
|
|
879
|
+
},
|
|
880
|
+
PYUSD: {
|
|
881
|
+
symbol: "PYUSD",
|
|
882
|
+
assetType: "pyusd",
|
|
883
|
+
displayName: "PYUSD",
|
|
884
|
+
icon: "https://etherscan.io/token/images/PYUSD_32.png",
|
|
885
|
+
decimals: 6,
|
|
886
|
+
tokenSymbols: ["PYUSD"],
|
|
887
|
+
tokenSymbolsByChainId: {
|
|
888
|
+
1: "PYUSD"
|
|
889
|
+
},
|
|
890
|
+
addresses: {
|
|
891
|
+
1: "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8"
|
|
892
|
+
},
|
|
893
|
+
enabled: true
|
|
894
|
+
},
|
|
820
895
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
821
896
|
// protocols with delayed withdrawals — see the `yieldmaxxing` strategy.
|
|
822
897
|
NVDAc: {
|
|
@@ -896,6 +971,8 @@ var MANAGED_ASSET_ORDER = [
|
|
|
896
971
|
"USDC",
|
|
897
972
|
"WETH",
|
|
898
973
|
"EURC",
|
|
974
|
+
"USDT",
|
|
975
|
+
"PYUSD",
|
|
899
976
|
"NVDAc"
|
|
900
977
|
];
|
|
901
978
|
function getManagedAssets() {
|
|
@@ -1140,7 +1217,7 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1140
1217
|
|
|
1141
1218
|
// src/utils/strategy.ts
|
|
1142
1219
|
var PUBLIC_STRATEGIES = `"conservative", "aggressive" or "yieldmaxxing"`;
|
|
1143
|
-
var SUPPORTED_ASSETS = `"
|
|
1220
|
+
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1144
1221
|
function toInternalStrategy(publicStrategy) {
|
|
1145
1222
|
switch (publicStrategy) {
|
|
1146
1223
|
case "conservative":
|
|
@@ -1220,20 +1297,12 @@ function removeUnusedFields(obj) {
|
|
|
1220
1297
|
return result;
|
|
1221
1298
|
}
|
|
1222
1299
|
function convertAssetInternally(asset) {
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
if (asset === "WETH") {
|
|
1227
|
-
return "eth";
|
|
1228
|
-
}
|
|
1229
|
-
if (asset === "EURC") {
|
|
1230
|
-
return "eurc";
|
|
1231
|
-
}
|
|
1232
|
-
if (asset === "NVDAc") {
|
|
1233
|
-
return "nvdac";
|
|
1300
|
+
const assetType = ASSET_CONFIGS[asset]?.assetType;
|
|
1301
|
+
if (assetType === "usdc" || assetType === "eth" || assetType === "eurc" || assetType === "usdt" || assetType === "pyusd" || assetType === "nvdac") {
|
|
1302
|
+
return assetType;
|
|
1234
1303
|
}
|
|
1235
1304
|
throw new Error(
|
|
1236
|
-
`Invalid asset: ${asset}. Must be ${SUPPORTED_ASSETS}.`
|
|
1305
|
+
`Invalid asset: ${asset}. Must be one of: ${SUPPORTED_ASSETS}.`
|
|
1237
1306
|
);
|
|
1238
1307
|
}
|
|
1239
1308
|
function convertStrategiesToPublic(array) {
|
|
@@ -3186,7 +3255,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3186
3255
|
throw new Error("Valid amount is required");
|
|
3187
3256
|
}
|
|
3188
3257
|
if (!asset) {
|
|
3189
|
-
throw new Error(
|
|
3258
|
+
throw new Error(
|
|
3259
|
+
"Asset is required (USDC, WETH, EURC, USDT, PYUSD, or NVDAc)"
|
|
3260
|
+
);
|
|
3190
3261
|
}
|
|
3191
3262
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3192
3263
|
throw new Error(
|
|
@@ -3203,8 +3274,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3203
3274
|
)}.`
|
|
3204
3275
|
);
|
|
3205
3276
|
}
|
|
3206
|
-
|
|
3207
|
-
|
|
3277
|
+
const skipMinPortfolio = this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress);
|
|
3278
|
+
let minRequired = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
|
|
3279
|
+
const minUsd = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_USD[chainId]?.[assetSymbol];
|
|
3208
3280
|
const token = getDefaultTokenAddress(chainId, assetSymbol);
|
|
3209
3281
|
const walletClient = this.getWalletClient();
|
|
3210
3282
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
@@ -3246,6 +3318,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3246
3318
|
);
|
|
3247
3319
|
}
|
|
3248
3320
|
}
|
|
3321
|
+
if (minRequired !== void 0 && isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
|
|
3322
|
+
minRequired = void 0;
|
|
3323
|
+
}
|
|
3249
3324
|
if (minRequired !== void 0) {
|
|
3250
3325
|
const safeBalance = currentSafeBalance;
|
|
3251
3326
|
const totalAfterDeposit = safeBalance + amountBigInt;
|
|
@@ -3262,7 +3337,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3262
3337
|
}
|
|
3263
3338
|
const txHash = await walletClient.writeContract({
|
|
3264
3339
|
address: token,
|
|
3265
|
-
abi:
|
|
3340
|
+
abi: erc20TransferWriteAbi(assetSymbol),
|
|
3266
3341
|
functionName: "transfer",
|
|
3267
3342
|
args: [safeAddress, amountBigInt],
|
|
3268
3343
|
chain: chainConfig.chain,
|
|
@@ -3370,7 +3445,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3370
3445
|
chainId,
|
|
3371
3446
|
asset,
|
|
3372
3447
|
amountBigInt,
|
|
3373
|
-
safeAddress
|
|
3448
|
+
safeAddress,
|
|
3449
|
+
userAddress
|
|
3374
3450
|
);
|
|
3375
3451
|
const tokenAddress = getDefaultTokenAddress(
|
|
3376
3452
|
chainId,
|
|
@@ -3389,8 +3465,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3389
3465
|
};
|
|
3390
3466
|
}
|
|
3391
3467
|
/** Apply the same per-asset minimum portfolio rule as sendDeposit. */
|
|
3392
|
-
async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress) {
|
|
3393
|
-
if (this.bypassMinPortfolio) {
|
|
3468
|
+
async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress, userAddress) {
|
|
3469
|
+
if (this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
|
|
3394
3470
|
return;
|
|
3395
3471
|
}
|
|
3396
3472
|
const assetSymbol = resolveAssetSymbol(asset);
|
package/dist/index.mjs
CHANGED
|
@@ -479,6 +479,33 @@ var ERC20_ABI = [
|
|
|
479
479
|
outputs: [{ name: "", type: "uint256" }]
|
|
480
480
|
}
|
|
481
481
|
];
|
|
482
|
+
var ERC20_TRANSFER_LEGACY_ABI = [
|
|
483
|
+
{
|
|
484
|
+
name: "transfer",
|
|
485
|
+
type: "function",
|
|
486
|
+
stateMutability: "nonpayable",
|
|
487
|
+
inputs: [
|
|
488
|
+
{ name: "to", type: "address" },
|
|
489
|
+
{ name: "amount", type: "uint256" }
|
|
490
|
+
],
|
|
491
|
+
outputs: []
|
|
492
|
+
}
|
|
493
|
+
];
|
|
494
|
+
var ERC20_TRANSFER_WITH_BOOL_ABI = [
|
|
495
|
+
{
|
|
496
|
+
name: "transfer",
|
|
497
|
+
type: "function",
|
|
498
|
+
stateMutability: "nonpayable",
|
|
499
|
+
inputs: [
|
|
500
|
+
{ name: "to", type: "address" },
|
|
501
|
+
{ name: "amount", type: "uint256" }
|
|
502
|
+
],
|
|
503
|
+
outputs: [{ name: "", type: "bool" }]
|
|
504
|
+
}
|
|
505
|
+
];
|
|
506
|
+
function erc20TransferWriteAbi(assetSymbol) {
|
|
507
|
+
return assetSymbol === "USDT" ? ERC20_TRANSFER_LEGACY_ABI : ERC20_TRANSFER_WITH_BOOL_ABI;
|
|
508
|
+
}
|
|
482
509
|
var IDENTITY_REGISTRY_ABI = parseAbi([
|
|
483
510
|
"function register() external returns (uint256 agentId)",
|
|
484
511
|
"function register(string tokenUri) external returns (uint256 agentId)",
|
|
@@ -576,8 +603,12 @@ var MIN_PORTFOLIO_BALANCE = {
|
|
|
576
603
|
1: {
|
|
577
604
|
USDC: 10000n * 10n ** 6n,
|
|
578
605
|
// 10,000 USDC (6 decimals)
|
|
579
|
-
EURC: 10000n * 10n ** 6n
|
|
606
|
+
EURC: 10000n * 10n ** 6n,
|
|
580
607
|
// 10,000 EURC (6 decimals)
|
|
608
|
+
USDT: 10000n * 10n ** 6n,
|
|
609
|
+
// 10,000 USDT (6 decimals)
|
|
610
|
+
PYUSD: 10000n * 10n ** 6n
|
|
611
|
+
// 10,000 PYUSD (6 decimals)
|
|
581
612
|
},
|
|
582
613
|
8453: {
|
|
583
614
|
USDC: 10n * 10n ** 6n,
|
|
@@ -655,6 +686,20 @@ function shouldBypassMinPortfolioCheck(executionApiUrl) {
|
|
|
655
686
|
return isLocalExecutionApiUrl(executionApiUrl) || isStagingExecutionApiUrl(executionApiUrl);
|
|
656
687
|
}
|
|
657
688
|
|
|
689
|
+
// src/config/min-portfolio-exempt.ts
|
|
690
|
+
var MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES = /* @__PURE__ */ new Set([
|
|
691
|
+
"0x2db791f63c8b12bde9a3fe31afa8ad491f47d60f",
|
|
692
|
+
"0xae72cb0f7d604a8ff742d96031104506186638e3"
|
|
693
|
+
]);
|
|
694
|
+
function isMainnetMinPortfolioExempt(chainId, ...addresses) {
|
|
695
|
+
if (chainId !== 1) {
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
return addresses.some(
|
|
699
|
+
(address) => typeof address === "string" && MAINNET_MIN_PORTFOLIO_EXEMPT_ADDRESSES.has(address.toLowerCase())
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
|
|
658
703
|
// src/core/ZyfaiSDK.ts
|
|
659
704
|
import { privateKeyToAccount } from "viem/accounts";
|
|
660
705
|
import {
|
|
@@ -683,7 +728,7 @@ var ASSET_CONFIGS = {
|
|
|
683
728
|
displayName: "USDC",
|
|
684
729
|
icon: "/ai-dashboard/usdc-token.png",
|
|
685
730
|
decimals: 6,
|
|
686
|
-
tokenSymbols: ["USDC", "USDC.e", "
|
|
731
|
+
tokenSymbols: ["USDC", "USDC.e", "USDT0"],
|
|
687
732
|
tokenSymbolsByChainId: {
|
|
688
733
|
1: "USDC",
|
|
689
734
|
8453: "USDC",
|
|
@@ -754,6 +799,36 @@ var ASSET_CONFIGS = {
|
|
|
754
799
|
},
|
|
755
800
|
enabled: true
|
|
756
801
|
},
|
|
802
|
+
USDT: {
|
|
803
|
+
symbol: "USDT",
|
|
804
|
+
assetType: "usdt",
|
|
805
|
+
displayName: "USDT",
|
|
806
|
+
icon: "https://etherscan.io/token/images/tethernew_32.svg",
|
|
807
|
+
decimals: 6,
|
|
808
|
+
tokenSymbols: ["USDT"],
|
|
809
|
+
tokenSymbolsByChainId: {
|
|
810
|
+
1: "USDT"
|
|
811
|
+
},
|
|
812
|
+
addresses: {
|
|
813
|
+
1: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
|
814
|
+
},
|
|
815
|
+
enabled: true
|
|
816
|
+
},
|
|
817
|
+
PYUSD: {
|
|
818
|
+
symbol: "PYUSD",
|
|
819
|
+
assetType: "pyusd",
|
|
820
|
+
displayName: "PYUSD",
|
|
821
|
+
icon: "https://etherscan.io/token/images/PYUSD_32.png",
|
|
822
|
+
decimals: 6,
|
|
823
|
+
tokenSymbols: ["PYUSD"],
|
|
824
|
+
tokenSymbolsByChainId: {
|
|
825
|
+
1: "PYUSD"
|
|
826
|
+
},
|
|
827
|
+
addresses: {
|
|
828
|
+
1: "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8"
|
|
829
|
+
},
|
|
830
|
+
enabled: true
|
|
831
|
+
},
|
|
757
832
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
758
833
|
// protocols with delayed withdrawals — see the `yieldmaxxing` strategy.
|
|
759
834
|
NVDAc: {
|
|
@@ -833,6 +908,8 @@ var MANAGED_ASSET_ORDER = [
|
|
|
833
908
|
"USDC",
|
|
834
909
|
"WETH",
|
|
835
910
|
"EURC",
|
|
911
|
+
"USDT",
|
|
912
|
+
"PYUSD",
|
|
836
913
|
"NVDAc"
|
|
837
914
|
];
|
|
838
915
|
function getManagedAssets() {
|
|
@@ -1091,7 +1168,7 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1091
1168
|
|
|
1092
1169
|
// src/utils/strategy.ts
|
|
1093
1170
|
var PUBLIC_STRATEGIES = `"conservative", "aggressive" or "yieldmaxxing"`;
|
|
1094
|
-
var SUPPORTED_ASSETS = `"
|
|
1171
|
+
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1095
1172
|
function toInternalStrategy(publicStrategy) {
|
|
1096
1173
|
switch (publicStrategy) {
|
|
1097
1174
|
case "conservative":
|
|
@@ -1171,20 +1248,12 @@ function removeUnusedFields(obj) {
|
|
|
1171
1248
|
return result;
|
|
1172
1249
|
}
|
|
1173
1250
|
function convertAssetInternally(asset) {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
if (asset === "WETH") {
|
|
1178
|
-
return "eth";
|
|
1179
|
-
}
|
|
1180
|
-
if (asset === "EURC") {
|
|
1181
|
-
return "eurc";
|
|
1182
|
-
}
|
|
1183
|
-
if (asset === "NVDAc") {
|
|
1184
|
-
return "nvdac";
|
|
1251
|
+
const assetType = ASSET_CONFIGS[asset]?.assetType;
|
|
1252
|
+
if (assetType === "usdc" || assetType === "eth" || assetType === "eurc" || assetType === "usdt" || assetType === "pyusd" || assetType === "nvdac") {
|
|
1253
|
+
return assetType;
|
|
1185
1254
|
}
|
|
1186
1255
|
throw new Error(
|
|
1187
|
-
`Invalid asset: ${asset}. Must be ${SUPPORTED_ASSETS}.`
|
|
1256
|
+
`Invalid asset: ${asset}. Must be one of: ${SUPPORTED_ASSETS}.`
|
|
1188
1257
|
);
|
|
1189
1258
|
}
|
|
1190
1259
|
function convertStrategiesToPublic(array) {
|
|
@@ -3137,7 +3206,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3137
3206
|
throw new Error("Valid amount is required");
|
|
3138
3207
|
}
|
|
3139
3208
|
if (!asset) {
|
|
3140
|
-
throw new Error(
|
|
3209
|
+
throw new Error(
|
|
3210
|
+
"Asset is required (USDC, WETH, EURC, USDT, PYUSD, or NVDAc)"
|
|
3211
|
+
);
|
|
3141
3212
|
}
|
|
3142
3213
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3143
3214
|
throw new Error(
|
|
@@ -3154,8 +3225,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3154
3225
|
)}.`
|
|
3155
3226
|
);
|
|
3156
3227
|
}
|
|
3157
|
-
|
|
3158
|
-
|
|
3228
|
+
const skipMinPortfolio = this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress);
|
|
3229
|
+
let minRequired = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_BALANCE[chainId]?.[assetSymbol];
|
|
3230
|
+
const minUsd = skipMinPortfolio ? void 0 : MIN_PORTFOLIO_USD[chainId]?.[assetSymbol];
|
|
3159
3231
|
const token = getDefaultTokenAddress(chainId, assetSymbol);
|
|
3160
3232
|
const walletClient = this.getWalletClient();
|
|
3161
3233
|
const chainConfig = getChainConfig(chainId, this.rpcUrls);
|
|
@@ -3197,6 +3269,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3197
3269
|
);
|
|
3198
3270
|
}
|
|
3199
3271
|
}
|
|
3272
|
+
if (minRequired !== void 0 && isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
|
|
3273
|
+
minRequired = void 0;
|
|
3274
|
+
}
|
|
3200
3275
|
if (minRequired !== void 0) {
|
|
3201
3276
|
const safeBalance = currentSafeBalance;
|
|
3202
3277
|
const totalAfterDeposit = safeBalance + amountBigInt;
|
|
@@ -3213,7 +3288,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3213
3288
|
}
|
|
3214
3289
|
const txHash = await walletClient.writeContract({
|
|
3215
3290
|
address: token,
|
|
3216
|
-
abi:
|
|
3291
|
+
abi: erc20TransferWriteAbi(assetSymbol),
|
|
3217
3292
|
functionName: "transfer",
|
|
3218
3293
|
args: [safeAddress, amountBigInt],
|
|
3219
3294
|
chain: chainConfig.chain,
|
|
@@ -3321,7 +3396,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3321
3396
|
chainId,
|
|
3322
3397
|
asset,
|
|
3323
3398
|
amountBigInt,
|
|
3324
|
-
safeAddress
|
|
3399
|
+
safeAddress,
|
|
3400
|
+
userAddress
|
|
3325
3401
|
);
|
|
3326
3402
|
const tokenAddress = getDefaultTokenAddress(
|
|
3327
3403
|
chainId,
|
|
@@ -3340,8 +3416,8 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3340
3416
|
};
|
|
3341
3417
|
}
|
|
3342
3418
|
/** Apply the same per-asset minimum portfolio rule as sendDeposit. */
|
|
3343
|
-
async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress) {
|
|
3344
|
-
if (this.bypassMinPortfolio) {
|
|
3419
|
+
async enforceMinimumPortfolioBalance(chainId, asset, amount, safeAddress, userAddress) {
|
|
3420
|
+
if (this.bypassMinPortfolio || isMainnetMinPortfolioExempt(chainId, userAddress, safeAddress)) {
|
|
3345
3421
|
return;
|
|
3346
3422
|
}
|
|
3347
3423
|
const assetSymbol = resolveAssetSymbol(asset);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "TypeScript SDK for self-custodial Zyfai yield agents: discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum, Base, and Arbitrum",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|