@exagent/sdk 0.1.10 → 0.1.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/index.d.mts CHANGED
@@ -526,8 +526,6 @@ interface VaultPosition {
526
526
  pendingWithdrawals: bigint;
527
527
  assetsValue: bigint;
528
528
  userHighWaterMark: bigint;
529
- canWithdraw: boolean;
530
- cooldownRemaining: bigint;
531
529
  }
532
530
  /**
533
531
  * Withdrawal request details
@@ -613,6 +611,21 @@ declare class ExagentVault {
613
611
  * @returns Transaction hash
614
612
  */
615
613
  redeem(shares: bigint, receiver?: Address, owner?: Address): Promise<Hash>;
614
+ /**
615
+ * Redeem all shares safely — charges performance fee first, then redeems remaining balance.
616
+ * Use this instead of redeem(fullBalance) to avoid ERC4626ExceededMaxRedeem revert.
617
+ * @param receiver Address to receive assets
618
+ * @param owner Address whose shares to burn (defaults to caller)
619
+ * @returns Transaction hash
620
+ */
621
+ redeemMax(receiver?: Address, owner?: Address): Promise<Hash>;
622
+ /**
623
+ * Withdraw all assets safely — charges performance fee first, then withdraws remaining balance.
624
+ * @param receiver Address to receive assets
625
+ * @param owner Address whose shares to burn (defaults to caller)
626
+ * @returns Transaction hash
627
+ */
628
+ withdrawMax(receiver?: Address, owner?: Address): Promise<Hash>;
616
629
  /**
617
630
  * Request a queued withdrawal (for large amounts)
618
631
  * @param shares Amount of shares to withdraw
@@ -633,7 +646,8 @@ declare class ExagentVault {
633
646
  */
634
647
  cancelWithdrawal(requestId: bigint): Promise<Hash>;
635
648
  /**
636
- * Emergency withdrawal (bypasses cooldown, forfeits pending rewards)
649
+ * Emergency withdrawal with penalty (50% if vault < 7 days old, 20% otherwise).
650
+ * Penalty stays in the vault for remaining backers.
637
651
  * @returns Transaction hash
638
652
  */
639
653
  emergencyWithdraw(): Promise<Hash>;
package/dist/index.d.ts CHANGED
@@ -526,8 +526,6 @@ interface VaultPosition {
526
526
  pendingWithdrawals: bigint;
527
527
  assetsValue: bigint;
528
528
  userHighWaterMark: bigint;
529
- canWithdraw: boolean;
530
- cooldownRemaining: bigint;
531
529
  }
532
530
  /**
533
531
  * Withdrawal request details
@@ -613,6 +611,21 @@ declare class ExagentVault {
613
611
  * @returns Transaction hash
614
612
  */
615
613
  redeem(shares: bigint, receiver?: Address, owner?: Address): Promise<Hash>;
614
+ /**
615
+ * Redeem all shares safely — charges performance fee first, then redeems remaining balance.
616
+ * Use this instead of redeem(fullBalance) to avoid ERC4626ExceededMaxRedeem revert.
617
+ * @param receiver Address to receive assets
618
+ * @param owner Address whose shares to burn (defaults to caller)
619
+ * @returns Transaction hash
620
+ */
621
+ redeemMax(receiver?: Address, owner?: Address): Promise<Hash>;
622
+ /**
623
+ * Withdraw all assets safely — charges performance fee first, then withdraws remaining balance.
624
+ * @param receiver Address to receive assets
625
+ * @param owner Address whose shares to burn (defaults to caller)
626
+ * @returns Transaction hash
627
+ */
628
+ withdrawMax(receiver?: Address, owner?: Address): Promise<Hash>;
616
629
  /**
617
630
  * Request a queued withdrawal (for large amounts)
618
631
  * @param shares Amount of shares to withdraw
@@ -633,7 +646,8 @@ declare class ExagentVault {
633
646
  */
634
647
  cancelWithdrawal(requestId: bigint): Promise<Hash>;
635
648
  /**
636
- * Emergency withdrawal (bypasses cooldown, forfeits pending rewards)
649
+ * Emergency withdrawal with penalty (50% if vault < 7 days old, 20% otherwise).
650
+ * Penalty stays in the vault for remaining backers.
637
651
  * @returns Transaction hash
638
652
  */
639
653
  emergencyWithdraw(): Promise<Hash>;
package/dist/index.js CHANGED
@@ -850,7 +850,8 @@ var EXAGENT_VAULT_ABI = [
850
850
  { type: "function", name: "withdrawalsPaused", inputs: [], outputs: [{ type: "bool" }], stateMutability: "view" },
851
851
  { type: "function", name: "circuitBreakerActive", inputs: [], outputs: [{ type: "bool" }], stateMutability: "view" },
852
852
  { type: "function", name: "pendingWithdrawals", inputs: [{ name: "user", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "view" },
853
- { type: "function", name: "canWithdraw", inputs: [{ name: "user", type: "address" }], outputs: [{ type: "bool" }, { type: "uint256" }], stateMutability: "view" },
853
+ { type: "function", name: "getPendingWithdrawals", inputs: [{ name: "owner", type: "address" }], outputs: [{ name: "requestIds", type: "uint256[]" }], stateMutability: "view" },
854
+ { type: "function", name: "getClaimableAmount", inputs: [{ name: "requestId", type: "uint256" }], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "view" },
854
855
  { type: "function", name: "getRateLimitStatus", inputs: [], outputs: [{ name: "remaining", type: "uint256" }, { name: "periodEnds", type: "uint256" }], stateMutability: "view" },
855
856
  { type: "function", name: "getWithdrawalQueueLength", inputs: [], outputs: [{ type: "uint256" }], stateMutability: "view" },
856
857
  // Withdrawal Queue
@@ -871,8 +872,11 @@ var EXAGENT_VAULT_ABI = [
871
872
  ],
872
873
  stateMutability: "view"
873
874
  },
874
- // Emergency
875
- { type: "function", name: "emergencyWithdraw", inputs: [], outputs: [], stateMutability: "nonpayable" },
875
+ // V2: Safe "withdraw all"
876
+ { type: "function", name: "redeemMax", inputs: [{ name: "receiver", type: "address" }, { name: "owner", type: "address" }], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "nonpayable" },
877
+ { type: "function", name: "withdrawMax", inputs: [{ name: "receiver", type: "address" }, { name: "owner", type: "address" }], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "nonpayable" },
878
+ // V2: Emergency exit with penalty
879
+ { type: "function", name: "emergencyWithdraw", inputs: [], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "nonpayable" },
876
880
  // Events
877
881
  { type: "event", name: "Deposit", inputs: [{ name: "sender", type: "address", indexed: true }, { name: "owner", type: "address", indexed: true }, { name: "assets", type: "uint256" }, { name: "shares", type: "uint256" }] },
878
882
  { type: "event", name: "Withdraw", inputs: [{ name: "sender", type: "address", indexed: true }, { name: "receiver", type: "address", indexed: true }, { name: "owner", type: "address", indexed: true }, { name: "assets", type: "uint256" }, { name: "shares", type: "uint256" }] },
@@ -965,14 +969,12 @@ var ExagentVault = class {
965
969
  shares,
966
970
  effectiveShares,
967
971
  pendingWithdrawals,
968
- userHighWaterMark,
969
- canWithdrawResult
972
+ userHighWaterMark
970
973
  ] = await Promise.all([
971
974
  this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "balanceOf", args: [user] }),
972
975
  this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "effectiveShares", args: [user] }),
973
976
  this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "pendingWithdrawals", args: [user] }),
974
- this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "userHighWaterMark", args: [user] }),
975
- this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "canWithdraw", args: [user] })
977
+ this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "userHighWaterMark", args: [user] })
976
978
  ]);
977
979
  const assetsValue = await this.publicClient.readContract({
978
980
  address: this.address,
@@ -985,9 +987,7 @@ var ExagentVault = class {
985
987
  effectiveShares,
986
988
  pendingWithdrawals,
987
989
  assetsValue,
988
- userHighWaterMark,
989
- canWithdraw: canWithdrawResult[0],
990
- cooldownRemaining: canWithdrawResult[1]
990
+ userHighWaterMark
991
991
  };
992
992
  }
993
993
  /**
@@ -1143,6 +1143,51 @@ var ExagentVault = class {
1143
1143
  });
1144
1144
  return hash;
1145
1145
  }
1146
+ /**
1147
+ * Redeem all shares safely — charges performance fee first, then redeems remaining balance.
1148
+ * Use this instead of redeem(fullBalance) to avoid ERC4626ExceededMaxRedeem revert.
1149
+ * @param receiver Address to receive assets
1150
+ * @param owner Address whose shares to burn (defaults to caller)
1151
+ * @returns Transaction hash
1152
+ */
1153
+ async redeemMax(receiver, owner) {
1154
+ if (!this.walletClient || !this.account) {
1155
+ throw new Error("Wallet client required for write operations");
1156
+ }
1157
+ const to = receiver ?? this.account.address;
1158
+ const from = owner ?? this.account.address;
1159
+ const hash = await this.walletClient.writeContract({
1160
+ address: this.address,
1161
+ abi: EXAGENT_VAULT_ABI,
1162
+ functionName: "redeemMax",
1163
+ args: [to, from],
1164
+ account: this.account,
1165
+ chain: this.chain
1166
+ });
1167
+ return hash;
1168
+ }
1169
+ /**
1170
+ * Withdraw all assets safely — charges performance fee first, then withdraws remaining balance.
1171
+ * @param receiver Address to receive assets
1172
+ * @param owner Address whose shares to burn (defaults to caller)
1173
+ * @returns Transaction hash
1174
+ */
1175
+ async withdrawMax(receiver, owner) {
1176
+ if (!this.walletClient || !this.account) {
1177
+ throw new Error("Wallet client required for write operations");
1178
+ }
1179
+ const to = receiver ?? this.account.address;
1180
+ const from = owner ?? this.account.address;
1181
+ const hash = await this.walletClient.writeContract({
1182
+ address: this.address,
1183
+ abi: EXAGENT_VAULT_ABI,
1184
+ functionName: "withdrawMax",
1185
+ args: [to, from],
1186
+ account: this.account,
1187
+ chain: this.chain
1188
+ });
1189
+ return hash;
1190
+ }
1146
1191
  /**
1147
1192
  * Request a queued withdrawal (for large amounts)
1148
1193
  * @param shares Amount of shares to withdraw
@@ -1203,7 +1248,8 @@ var ExagentVault = class {
1203
1248
  return hash;
1204
1249
  }
1205
1250
  /**
1206
- * Emergency withdrawal (bypasses cooldown, forfeits pending rewards)
1251
+ * Emergency withdrawal with penalty (50% if vault < 7 days old, 20% otherwise).
1252
+ * Penalty stays in the vault for remaining backers.
1207
1253
  * @returns Transaction hash
1208
1254
  */
1209
1255
  async emergencyWithdraw() {
@@ -2076,7 +2122,7 @@ var CONTRACT_ADDRESSES = {
2076
2122
  exaToken: "0x13403Fb738C97cF7564F279288468c140AaEd05c",
2077
2123
  staking: "0xAF1729D1519A72f7d9b87aa23a305b775e2849DA",
2078
2124
  router: "0x1BCFa13f677fDCf697D8b7d5120f544817F1de1A",
2079
- vaultFactory: "0x1e72379F5B46b73df5EFaC610e0eEaE63d109a41",
2125
+ vaultFactory: "0x5b90C7F9F02F9130a92481360E9aa5Be4fcc9500",
2080
2126
  feeCollector: "0xe66328a964AF93bEF2eDB226D039C35aE6e66De1",
2081
2127
  buyback: "0x39967532b640B2f735548c7a5b46d8D890A0B2f2",
2082
2128
  serviceEscrow: "0x63A4d1dA774422EFC2cc57d71F948231BD812516"
package/dist/index.mjs CHANGED
@@ -815,7 +815,8 @@ var EXAGENT_VAULT_ABI = [
815
815
  { type: "function", name: "withdrawalsPaused", inputs: [], outputs: [{ type: "bool" }], stateMutability: "view" },
816
816
  { type: "function", name: "circuitBreakerActive", inputs: [], outputs: [{ type: "bool" }], stateMutability: "view" },
817
817
  { type: "function", name: "pendingWithdrawals", inputs: [{ name: "user", type: "address" }], outputs: [{ type: "uint256" }], stateMutability: "view" },
818
- { type: "function", name: "canWithdraw", inputs: [{ name: "user", type: "address" }], outputs: [{ type: "bool" }, { type: "uint256" }], stateMutability: "view" },
818
+ { type: "function", name: "getPendingWithdrawals", inputs: [{ name: "owner", type: "address" }], outputs: [{ name: "requestIds", type: "uint256[]" }], stateMutability: "view" },
819
+ { type: "function", name: "getClaimableAmount", inputs: [{ name: "requestId", type: "uint256" }], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "view" },
819
820
  { type: "function", name: "getRateLimitStatus", inputs: [], outputs: [{ name: "remaining", type: "uint256" }, { name: "periodEnds", type: "uint256" }], stateMutability: "view" },
820
821
  { type: "function", name: "getWithdrawalQueueLength", inputs: [], outputs: [{ type: "uint256" }], stateMutability: "view" },
821
822
  // Withdrawal Queue
@@ -836,8 +837,11 @@ var EXAGENT_VAULT_ABI = [
836
837
  ],
837
838
  stateMutability: "view"
838
839
  },
839
- // Emergency
840
- { type: "function", name: "emergencyWithdraw", inputs: [], outputs: [], stateMutability: "nonpayable" },
840
+ // V2: Safe "withdraw all"
841
+ { type: "function", name: "redeemMax", inputs: [{ name: "receiver", type: "address" }, { name: "owner", type: "address" }], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "nonpayable" },
842
+ { type: "function", name: "withdrawMax", inputs: [{ name: "receiver", type: "address" }, { name: "owner", type: "address" }], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "nonpayable" },
843
+ // V2: Emergency exit with penalty
844
+ { type: "function", name: "emergencyWithdraw", inputs: [], outputs: [{ name: "assets", type: "uint256" }], stateMutability: "nonpayable" },
841
845
  // Events
842
846
  { type: "event", name: "Deposit", inputs: [{ name: "sender", type: "address", indexed: true }, { name: "owner", type: "address", indexed: true }, { name: "assets", type: "uint256" }, { name: "shares", type: "uint256" }] },
843
847
  { type: "event", name: "Withdraw", inputs: [{ name: "sender", type: "address", indexed: true }, { name: "receiver", type: "address", indexed: true }, { name: "owner", type: "address", indexed: true }, { name: "assets", type: "uint256" }, { name: "shares", type: "uint256" }] },
@@ -930,14 +934,12 @@ var ExagentVault = class {
930
934
  shares,
931
935
  effectiveShares,
932
936
  pendingWithdrawals,
933
- userHighWaterMark,
934
- canWithdrawResult
937
+ userHighWaterMark
935
938
  ] = await Promise.all([
936
939
  this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "balanceOf", args: [user] }),
937
940
  this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "effectiveShares", args: [user] }),
938
941
  this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "pendingWithdrawals", args: [user] }),
939
- this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "userHighWaterMark", args: [user] }),
940
- this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "canWithdraw", args: [user] })
942
+ this.publicClient.readContract({ address: this.address, abi: EXAGENT_VAULT_ABI, functionName: "userHighWaterMark", args: [user] })
941
943
  ]);
942
944
  const assetsValue = await this.publicClient.readContract({
943
945
  address: this.address,
@@ -950,9 +952,7 @@ var ExagentVault = class {
950
952
  effectiveShares,
951
953
  pendingWithdrawals,
952
954
  assetsValue,
953
- userHighWaterMark,
954
- canWithdraw: canWithdrawResult[0],
955
- cooldownRemaining: canWithdrawResult[1]
955
+ userHighWaterMark
956
956
  };
957
957
  }
958
958
  /**
@@ -1108,6 +1108,51 @@ var ExagentVault = class {
1108
1108
  });
1109
1109
  return hash;
1110
1110
  }
1111
+ /**
1112
+ * Redeem all shares safely — charges performance fee first, then redeems remaining balance.
1113
+ * Use this instead of redeem(fullBalance) to avoid ERC4626ExceededMaxRedeem revert.
1114
+ * @param receiver Address to receive assets
1115
+ * @param owner Address whose shares to burn (defaults to caller)
1116
+ * @returns Transaction hash
1117
+ */
1118
+ async redeemMax(receiver, owner) {
1119
+ if (!this.walletClient || !this.account) {
1120
+ throw new Error("Wallet client required for write operations");
1121
+ }
1122
+ const to = receiver ?? this.account.address;
1123
+ const from = owner ?? this.account.address;
1124
+ const hash = await this.walletClient.writeContract({
1125
+ address: this.address,
1126
+ abi: EXAGENT_VAULT_ABI,
1127
+ functionName: "redeemMax",
1128
+ args: [to, from],
1129
+ account: this.account,
1130
+ chain: this.chain
1131
+ });
1132
+ return hash;
1133
+ }
1134
+ /**
1135
+ * Withdraw all assets safely — charges performance fee first, then withdraws remaining balance.
1136
+ * @param receiver Address to receive assets
1137
+ * @param owner Address whose shares to burn (defaults to caller)
1138
+ * @returns Transaction hash
1139
+ */
1140
+ async withdrawMax(receiver, owner) {
1141
+ if (!this.walletClient || !this.account) {
1142
+ throw new Error("Wallet client required for write operations");
1143
+ }
1144
+ const to = receiver ?? this.account.address;
1145
+ const from = owner ?? this.account.address;
1146
+ const hash = await this.walletClient.writeContract({
1147
+ address: this.address,
1148
+ abi: EXAGENT_VAULT_ABI,
1149
+ functionName: "withdrawMax",
1150
+ args: [to, from],
1151
+ account: this.account,
1152
+ chain: this.chain
1153
+ });
1154
+ return hash;
1155
+ }
1111
1156
  /**
1112
1157
  * Request a queued withdrawal (for large amounts)
1113
1158
  * @param shares Amount of shares to withdraw
@@ -1168,7 +1213,8 @@ var ExagentVault = class {
1168
1213
  return hash;
1169
1214
  }
1170
1215
  /**
1171
- * Emergency withdrawal (bypasses cooldown, forfeits pending rewards)
1216
+ * Emergency withdrawal with penalty (50% if vault < 7 days old, 20% otherwise).
1217
+ * Penalty stays in the vault for remaining backers.
1172
1218
  * @returns Transaction hash
1173
1219
  */
1174
1220
  async emergencyWithdraw() {
@@ -2041,7 +2087,7 @@ var CONTRACT_ADDRESSES = {
2041
2087
  exaToken: "0x13403Fb738C97cF7564F279288468c140AaEd05c",
2042
2088
  staking: "0xAF1729D1519A72f7d9b87aa23a305b775e2849DA",
2043
2089
  router: "0x1BCFa13f677fDCf697D8b7d5120f544817F1de1A",
2044
- vaultFactory: "0x1e72379F5B46b73df5EFaC610e0eEaE63d109a41",
2090
+ vaultFactory: "0x5b90C7F9F02F9130a92481360E9aa5Be4fcc9500",
2045
2091
  feeCollector: "0xe66328a964AF93bEF2eDB226D039C35aE6e66De1",
2046
2092
  buyback: "0x39967532b640B2f735548c7a5b46d8D890A0B2f2",
2047
2093
  serviceEscrow: "0x63A4d1dA774422EFC2cc57d71F948231BD812516"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exagent/sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "TypeScript SDK for Exagent",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",