@pafi-dev/trading 0.12.0 → 0.13.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.cjs CHANGED
@@ -1186,6 +1186,80 @@ var TradingHandlers = class {
1186
1186
  };
1187
1187
  }
1188
1188
  // =========================================================================
1189
+ // POST /aster-deposit — Aster perp deposit (same-chain on Arbitrum)
1190
+ // =========================================================================
1191
+ /**
1192
+ * Build a sponsored Aster deposit UserOp pair (sponsored + fallback).
1193
+ *
1194
+ * Aster is same-chain (Arbitrum), so — unlike Orderly — there is NO Relay,
1195
+ * Vault, broker-hash, or LayerZero msg.value. The user's own delegated
1196
+ * account deposits USDT straight into the Aster Deposit Bridge:
1197
+ * sponsored: `[USDT.transfer(PAFI, fee), USDT.approve(bridge, amount), Bridge.deposit(token, amount, broker)]`
1198
+ * fallback: `[ USDT.approve(bridge, amount), Bridge.deposit(token, amount, broker)]`
1199
+ *
1200
+ * ⚠️ Built against an ASSUMED Aster Deposit Bridge ABI (`ASTER_DEPOSIT_ABI`
1201
+ * in @pafi-dev/core) — Aster has not published it. Confirm the deposit
1202
+ * signature + PAFI's `broker` id before mainnet.
1203
+ */
1204
+ async handleAsterDeposit(authenticatedAddress, request) {
1205
+ const userAddress = (0, import_viem4.getAddress)(request.userAddress);
1206
+ if ((0, import_viem4.getAddress)(authenticatedAddress) !== userAddress) {
1207
+ throw new import_core9.ValidationError(
1208
+ "ADDRESS_MISMATCH",
1209
+ `handleAsterDeposit: authenticatedAddress (${authenticatedAddress}) does not match request.userAddress (${request.userAddress})`
1210
+ );
1211
+ }
1212
+ if (request.chainId !== this.chainId) {
1213
+ throw new import_core9.ValidationError(
1214
+ "CHAIN_MISMATCH",
1215
+ `handleAsterDeposit: unsupported chainId ${request.chainId}`
1216
+ );
1217
+ }
1218
+ if (request.amount <= 0n) {
1219
+ throw new import_core9.ValidationError(
1220
+ "INVALID_AMOUNT",
1221
+ "handleAsterDeposit: amount must be positive"
1222
+ );
1223
+ }
1224
+ const { asterDepositBridge, usdt, pafiFeeRecipient } = (0, import_core9.getContractAddresses)(
1225
+ request.chainId
1226
+ );
1227
+ if (!asterDepositBridge) {
1228
+ throw new import_core9.ValidationError(
1229
+ "ASTER_NOT_AVAILABLE",
1230
+ `handleAsterDeposit: Aster is not deployed on chainId ${request.chainId} (no Deposit Bridge)`
1231
+ );
1232
+ }
1233
+ const broker = (0, import_core9.getAsterBrokerId)(request.chainId);
1234
+ const gasFee = request.gasFee !== void 0 ? request.gasFee : await (0, import_core9.quoteOperatorFeeUsdt)({
1235
+ provider: this.provider,
1236
+ chainId: request.chainId
1237
+ }).catch(() => 0n);
1238
+ const common = {
1239
+ userAddress,
1240
+ aaNonce: request.aaNonce,
1241
+ bridgeAddress: asterDepositBridge,
1242
+ token: usdt,
1243
+ amount: request.amount,
1244
+ broker
1245
+ };
1246
+ const userOp = (0, import_core9.buildAsterDeposit)({
1247
+ ...common,
1248
+ gasFee: gasFee > 0n ? gasFee : void 0,
1249
+ gasFeeRecipient: gasFee > 0n ? pafiFeeRecipient : void 0
1250
+ });
1251
+ const userOpFallback = gasFee > 0n ? (0, import_core9.buildAsterDeposit)(common) : void 0;
1252
+ return {
1253
+ userOp,
1254
+ userOpFallback,
1255
+ feeAmount: gasFee > 0n ? gasFee : 0n,
1256
+ feeRecipient: pafiFeeRecipient,
1257
+ bridgeAddress: asterDepositBridge,
1258
+ token: usdt,
1259
+ broker
1260
+ };
1261
+ }
1262
+ // =========================================================================
1189
1263
  // POST /erc20-transfer — gasless ERC-20 send (USDC/USDT/active-PT)
1190
1264
  // =========================================================================
1191
1265
  /**