@seal-protocol/backendjs 0.0.79 → 0.0.80
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/lib/codegen/api/seal-client.d.ts +10 -2
- package/lib/codegen/api/seal-client.js +10 -5
- package/lib/codegen/model/seal-order-activity.d.ts +3 -2
- package/lib/codegen/model/seal-order.d.ts +6 -0
- package/lib/utils/calculate-liquidity.js +4 -5
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +3 -1
- package/lib/utils/numbers.d.ts +2 -0
- package/lib/utils/numbers.js +7 -0
- package/package.json +1 -1
|
@@ -134,6 +134,7 @@ export declare const SealClientAxiosParamCreator: (configuration?: Configuration
|
|
|
134
134
|
* @param {boolean} [expiredValue]
|
|
135
135
|
* @param {string} [reserver]
|
|
136
136
|
* @param {string} [orderIdHash]
|
|
137
|
+
* @param {string} [orderId] this would be ignore if order_id_hash is provided
|
|
137
138
|
* @param {GetOrderReservationsOrderByPropertyEnum} [orderByProperty]
|
|
138
139
|
* @param {boolean} [orderByDescending]
|
|
139
140
|
* @param {string} [paginationKey]
|
|
@@ -142,7 +143,7 @@ export declare const SealClientAxiosParamCreator: (configuration?: Configuration
|
|
|
142
143
|
* @param {*} [options] Override http request option.
|
|
143
144
|
* @throws {RequiredError}
|
|
144
145
|
*/
|
|
145
|
-
getOrderReservations: (chainId?: string, liveValue?: boolean, expiredValue?: boolean, reserver?: string, orderIdHash?: string, orderByProperty?: GetOrderReservationsOrderByPropertyEnum, orderByDescending?: boolean, paginationKey?: string, paginationLimit?: number, paginationCountTotal?: boolean, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
146
|
+
getOrderReservations: (chainId?: string, liveValue?: boolean, expiredValue?: boolean, reserver?: string, orderIdHash?: string, orderId?: string, orderByProperty?: GetOrderReservationsOrderByPropertyEnum, orderByDescending?: boolean, paginationKey?: string, paginationLimit?: number, paginationCountTotal?: boolean, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
146
147
|
/**
|
|
147
148
|
*
|
|
148
149
|
* @param {string} [chainId] uint256
|
|
@@ -352,6 +353,7 @@ export declare const SealClientFp: (configuration?: Configuration) => {
|
|
|
352
353
|
* @param {boolean} [expiredValue]
|
|
353
354
|
* @param {string} [reserver]
|
|
354
355
|
* @param {string} [orderIdHash]
|
|
356
|
+
* @param {string} [orderId] this would be ignore if order_id_hash is provided
|
|
355
357
|
* @param {GetOrderReservationsOrderByPropertyEnum} [orderByProperty]
|
|
356
358
|
* @param {boolean} [orderByDescending]
|
|
357
359
|
* @param {string} [paginationKey]
|
|
@@ -360,7 +362,7 @@ export declare const SealClientFp: (configuration?: Configuration) => {
|
|
|
360
362
|
* @param {*} [options] Override http request option.
|
|
361
363
|
* @throws {RequiredError}
|
|
362
364
|
*/
|
|
363
|
-
getOrderReservations(chainId?: string, liveValue?: boolean, expiredValue?: boolean, reserver?: string, orderIdHash?: string, orderByProperty?: GetOrderReservationsOrderByPropertyEnum, orderByDescending?: boolean, paginationKey?: string, paginationLimit?: number, paginationCountTotal?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SealGetOrderReservationsResponse>>;
|
|
365
|
+
getOrderReservations(chainId?: string, liveValue?: boolean, expiredValue?: boolean, reserver?: string, orderIdHash?: string, orderId?: string, orderByProperty?: GetOrderReservationsOrderByPropertyEnum, orderByDescending?: boolean, paginationKey?: string, paginationLimit?: number, paginationCountTotal?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SealGetOrderReservationsResponse>>;
|
|
364
366
|
/**
|
|
365
367
|
*
|
|
366
368
|
* @param {string} [chainId] uint256
|
|
@@ -880,6 +882,12 @@ export interface SealClientGetOrderReservationsRequest {
|
|
|
880
882
|
* @memberof SealClientGetOrderReservations
|
|
881
883
|
*/
|
|
882
884
|
readonly orderIdHash?: string;
|
|
885
|
+
/**
|
|
886
|
+
* this would be ignore if order_id_hash is provided
|
|
887
|
+
* @type {string}
|
|
888
|
+
* @memberof SealClientGetOrderReservations
|
|
889
|
+
*/
|
|
890
|
+
readonly orderId?: string;
|
|
883
891
|
/**
|
|
884
892
|
*
|
|
885
893
|
* @type {'OrderReservationsOrderByProperty_UNSPECIFIED' | 'OrderReservationsOrderByProperty_ORDER_ID_HASH' | 'OrderReservationsOrderByProperty_RESERVATION_ID_HASH' | 'OrderReservationsOrderByProperty_TOTAL_AMOUNT' | 'OrderReservationsOrderByProperty_REMAINING_AMOUNT' | 'OrderReservationsOrderByProperty_TOTAL_DEPOSIT_AMOUNT' | 'OrderReservationsOrderByProperty_REMAINING_DEPOSIT_AMOUNT' | 'OrderReservationsOrderByProperty_CHAIN_ID' | 'OrderReservationsOrderByProperty_CREATED_AT_BLOCK_NUMBER'}
|
|
@@ -407,6 +407,7 @@ const SealClientAxiosParamCreator = function (configuration) {
|
|
|
407
407
|
* @param {boolean} [expiredValue]
|
|
408
408
|
* @param {string} [reserver]
|
|
409
409
|
* @param {string} [orderIdHash]
|
|
410
|
+
* @param {string} [orderId] this would be ignore if order_id_hash is provided
|
|
410
411
|
* @param {GetOrderReservationsOrderByPropertyEnum} [orderByProperty]
|
|
411
412
|
* @param {boolean} [orderByDescending]
|
|
412
413
|
* @param {string} [paginationKey]
|
|
@@ -415,7 +416,7 @@ const SealClientAxiosParamCreator = function (configuration) {
|
|
|
415
416
|
* @param {*} [options] Override http request option.
|
|
416
417
|
* @throws {RequiredError}
|
|
417
418
|
*/
|
|
418
|
-
getOrderReservations: async (chainId, liveValue, expiredValue, reserver, orderIdHash, orderByProperty, orderByDescending, paginationKey, paginationLimit, paginationCountTotal, options = {}) => {
|
|
419
|
+
getOrderReservations: async (chainId, liveValue, expiredValue, reserver, orderIdHash, orderId, orderByProperty, orderByDescending, paginationKey, paginationLimit, paginationCountTotal, options = {}) => {
|
|
419
420
|
const localVarPath = `/seal/order_reservations`;
|
|
420
421
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
421
422
|
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
@@ -441,6 +442,9 @@ const SealClientAxiosParamCreator = function (configuration) {
|
|
|
441
442
|
if (orderIdHash !== undefined) {
|
|
442
443
|
localVarQueryParameter['orderIdHash'] = orderIdHash;
|
|
443
444
|
}
|
|
445
|
+
if (orderId !== undefined) {
|
|
446
|
+
localVarQueryParameter['orderId'] = orderId;
|
|
447
|
+
}
|
|
444
448
|
if (orderByProperty !== undefined) {
|
|
445
449
|
localVarQueryParameter['orderBy.property'] = orderByProperty;
|
|
446
450
|
}
|
|
@@ -1053,6 +1057,7 @@ const SealClientFp = function (configuration) {
|
|
|
1053
1057
|
* @param {boolean} [expiredValue]
|
|
1054
1058
|
* @param {string} [reserver]
|
|
1055
1059
|
* @param {string} [orderIdHash]
|
|
1060
|
+
* @param {string} [orderId] this would be ignore if order_id_hash is provided
|
|
1056
1061
|
* @param {GetOrderReservationsOrderByPropertyEnum} [orderByProperty]
|
|
1057
1062
|
* @param {boolean} [orderByDescending]
|
|
1058
1063
|
* @param {string} [paginationKey]
|
|
@@ -1061,8 +1066,8 @@ const SealClientFp = function (configuration) {
|
|
|
1061
1066
|
* @param {*} [options] Override http request option.
|
|
1062
1067
|
* @throws {RequiredError}
|
|
1063
1068
|
*/
|
|
1064
|
-
async getOrderReservations(chainId, liveValue, expiredValue, reserver, orderIdHash, orderByProperty, orderByDescending, paginationKey, paginationLimit, paginationCountTotal, options) {
|
|
1065
|
-
const localVarAxiosArgs = await localVarAxiosParamCreator.getOrderReservations(chainId, liveValue, expiredValue, reserver, orderIdHash, orderByProperty, orderByDescending, paginationKey, paginationLimit, paginationCountTotal, options);
|
|
1069
|
+
async getOrderReservations(chainId, liveValue, expiredValue, reserver, orderIdHash, orderId, orderByProperty, orderByDescending, paginationKey, paginationLimit, paginationCountTotal, options) {
|
|
1070
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getOrderReservations(chainId, liveValue, expiredValue, reserver, orderIdHash, orderId, orderByProperty, orderByDescending, paginationKey, paginationLimit, paginationCountTotal, options);
|
|
1066
1071
|
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
1067
1072
|
const localVarOperationServerBasePath = base_1.operationServerMap['SealClient.getOrderReservations']?.[localVarOperationServerIndex]?.url;
|
|
1068
1073
|
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
@@ -1326,7 +1331,7 @@ const SealClientFactory = function (configuration, basePath, axios) {
|
|
|
1326
1331
|
* @throws {RequiredError}
|
|
1327
1332
|
*/
|
|
1328
1333
|
getOrderReservations(requestParameters = {}, options) {
|
|
1329
|
-
return localVarFp.getOrderReservations(requestParameters.chainId, requestParameters.liveValue, requestParameters.expiredValue, requestParameters.reserver, requestParameters.orderIdHash, requestParameters.orderByProperty, requestParameters.orderByDescending, requestParameters.paginationKey, requestParameters.paginationLimit, requestParameters.paginationCountTotal, options).then((request) => request(axios, basePath));
|
|
1334
|
+
return localVarFp.getOrderReservations(requestParameters.chainId, requestParameters.liveValue, requestParameters.expiredValue, requestParameters.reserver, requestParameters.orderIdHash, requestParameters.orderId, requestParameters.orderByProperty, requestParameters.orderByDescending, requestParameters.paginationKey, requestParameters.paginationLimit, requestParameters.paginationCountTotal, options).then((request) => request(axios, basePath));
|
|
1330
1335
|
},
|
|
1331
1336
|
/**
|
|
1332
1337
|
*
|
|
@@ -1524,7 +1529,7 @@ class SealClient extends base_1.BaseAPI {
|
|
|
1524
1529
|
* @memberof SealClient
|
|
1525
1530
|
*/
|
|
1526
1531
|
getOrderReservations(requestParameters = {}, options) {
|
|
1527
|
-
return (0, exports.SealClientFp)(this.configuration).getOrderReservations(requestParameters.chainId, requestParameters.liveValue, requestParameters.expiredValue, requestParameters.reserver, requestParameters.orderIdHash, requestParameters.orderByProperty, requestParameters.orderByDescending, requestParameters.paginationKey, requestParameters.paginationLimit, requestParameters.paginationCountTotal, options).then((request) => request(this.axios, this.basePath));
|
|
1532
|
+
return (0, exports.SealClientFp)(this.configuration).getOrderReservations(requestParameters.chainId, requestParameters.liveValue, requestParameters.expiredValue, requestParameters.reserver, requestParameters.orderIdHash, requestParameters.orderId, requestParameters.orderByProperty, requestParameters.orderByDescending, requestParameters.paginationKey, requestParameters.paginationLimit, requestParameters.paginationCountTotal, options).then((request) => request(this.axios, this.basePath));
|
|
1528
1533
|
}
|
|
1529
1534
|
/**
|
|
1530
1535
|
*
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { SealOrder } from './seal-order';
|
|
13
13
|
import type { TypesOrderActivityType } from './types-order-activity-type';
|
|
14
|
+
import type { TypesTimestamp } from './types-timestamp';
|
|
14
15
|
/**
|
|
15
16
|
*
|
|
16
17
|
* @export
|
|
@@ -55,10 +56,10 @@ export interface SealOrderActivity {
|
|
|
55
56
|
'txHash'?: string;
|
|
56
57
|
/**
|
|
57
58
|
*
|
|
58
|
-
* @type {
|
|
59
|
+
* @type {TypesTimestamp}
|
|
59
60
|
* @memberof SealOrderActivity
|
|
60
61
|
*/
|
|
61
|
-
'time'?:
|
|
62
|
+
'time'?: TypesTimestamp;
|
|
62
63
|
/**
|
|
63
64
|
*
|
|
64
65
|
* @type {string}
|
|
@@ -80,12 +80,11 @@ async function calculateLiquidity(params) {
|
|
|
80
80
|
const balance = await erc20Contract.balanceOf(owner);
|
|
81
81
|
// 2) On-chain ERC20 allowance to spender
|
|
82
82
|
const onChainAllowance = await erc20Contract.allowance(owner, spender);
|
|
83
|
-
let maxAllowed = onChainAllowance;
|
|
84
83
|
// 3) ERC20 allowance to Permit2 contract (if zero, Permit2 approvals are not usable)
|
|
85
|
-
const
|
|
84
|
+
const onChainAllowanceToPermit2Contract = await erc20Contract.allowance(owner, permit2);
|
|
86
85
|
// 4) On-chain Permit2 allowance amount (subject to expiry), only if token->Permit2 allowance > 0
|
|
87
86
|
let onChainPermit2 = 0n;
|
|
88
|
-
if (
|
|
87
|
+
if (onChainAllowanceToPermit2Contract > 0n) {
|
|
89
88
|
const result = await permit2Contract.allowance(owner, token, spender);
|
|
90
89
|
// tuple: [amount, expiration, nonce]
|
|
91
90
|
const amount = result[0];
|
|
@@ -97,7 +96,7 @@ async function calculateLiquidity(params) {
|
|
|
97
96
|
onChainPermit2 = amount;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
|
-
maxAllowed = maxBigInt(
|
|
99
|
+
let maxAllowed = maxBigInt(onChainAllowance, onChainPermit2);
|
|
101
100
|
let permission = {};
|
|
102
101
|
// 5) Validate optional off-chain permission against on-chain state and expiry windows
|
|
103
102
|
if (backendPermission) {
|
|
@@ -110,7 +109,7 @@ async function calculateLiquidity(params) {
|
|
|
110
109
|
// - close to expiry (either approval expiration or sig deadline)
|
|
111
110
|
let exp = BigInt(backendPermission.allowanceExpiration?.seconds ?? 0n);
|
|
112
111
|
const drop = (amt <= onChainPermit2)
|
|
113
|
-
|| (
|
|
112
|
+
|| (onChainAllowanceToPermit2Contract === 0n)
|
|
114
113
|
|| isCloseToExpiry(exp, minPermissionDurationMs)
|
|
115
114
|
|| isCloseToExpiry(sigDeadline, minPermissionDurationMs);
|
|
116
115
|
if (!drop)
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateLiquidity = exports.LiquidityBreakdown = void 0;
|
|
3
|
+
exports.truncateFixedNumberToBigInt = exports.calculateLiquidity = exports.LiquidityBreakdown = void 0;
|
|
4
4
|
var calculate_liquidity_1 = require("./calculate-liquidity");
|
|
5
5
|
Object.defineProperty(exports, "LiquidityBreakdown", { enumerable: true, get: function () { return calculate_liquidity_1.LiquidityBreakdown; } });
|
|
6
6
|
Object.defineProperty(exports, "calculateLiquidity", { enumerable: true, get: function () { return calculate_liquidity_1.calculateLiquidity; } });
|
|
7
|
+
var numbers_1 = require("./numbers");
|
|
8
|
+
Object.defineProperty(exports, "truncateFixedNumberToBigInt", { enumerable: true, get: function () { return numbers_1.truncateFixedNumberToBigInt; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.truncateFixedNumberToBigInt = truncateFixedNumberToBigInt;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
function truncateFixedNumberToBigInt(f) {
|
|
6
|
+
return f.value / ethers_1.ethers.parseUnits("1", f.decimals);
|
|
7
|
+
}
|
package/package.json
CHANGED