four-flap-meme-sdk 1.5.11 → 1.5.13
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/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +5 -2
- package/dist/utils/erc20.js +17 -5
- package/dist/utils/quote-helpers.d.ts +1 -1
- package/dist/utils/quote-helpers.js +2 -0
- package/dist/xlayer/constants.d.ts +2 -0
- package/dist/xlayer/constants.js +2 -0
- package/package.json +1 -1
|
@@ -89,6 +89,7 @@ export declare const ADDRESSES: {
|
|
|
89
89
|
readonly PotatoSwapV3Factory: "0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5";
|
|
90
90
|
readonly USDT: "0x1e4a5963abfd975d8c9021ce480b42188849d41d";
|
|
91
91
|
readonly USDC: "0x74b7f16337b8972027f6196a17a631ac6de26d22";
|
|
92
|
+
readonly USDT0: "0x779ded0c9e1022225f8e0630b35a9b54be713736";
|
|
92
93
|
};
|
|
93
94
|
readonly MORPH: {
|
|
94
95
|
readonly FlapPortal: "0x6aB823408672c0Db1DE1a18F1750d62E5F995A58";
|
package/dist/utils/constants.js
CHANGED
|
@@ -94,8 +94,11 @@ export const ADDRESSES = {
|
|
|
94
94
|
PotatoSwapV3Router: '0xBB069e9465BcabC4F488d21e793BDEf0F2d41D41', // V3 Router
|
|
95
95
|
PotatoSwapV3Factory: '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5', // V3 Factory
|
|
96
96
|
// 稳定币
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
// 注意:Flap xLayer 发币/内盘计价支持的是 USD₮0(USDT0),不是原生桥接 USDT/USDC
|
|
98
|
+
USDT: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', // 6位精度(不一定被 Flap 内盘支持)
|
|
99
|
+
USDC: '0x74b7f16337b8972027f6196a17a631ac6de26d22', // 6位精度(不一定被 Flap 内盘支持)
|
|
100
|
+
USDT0: '0x779ded0c9e1022225f8e0630b35a9b54be713736', // 6位精度(USD₮0)
|
|
101
|
+
// ✅ USD₮0(Tether USD0)
|
|
99
102
|
},
|
|
100
103
|
MORPH: {
|
|
101
104
|
// Flap Portal
|
package/dist/utils/erc20.js
CHANGED
|
@@ -2,6 +2,11 @@ import { Contract, Wallet, JsonRpcProvider, Interface, parseUnits } from 'ethers
|
|
|
2
2
|
import { ADDRESSES, ZERO_ADDRESS } from './constants.js';
|
|
3
3
|
import { NonceManager } from './bundle-helpers.js';
|
|
4
4
|
import { ERC20_ABI, MULTICALL3_ABI } from '../abis/common.js';
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// ✅ Max approval(与 BSC 策略一致:阈值判断,避免频繁重复授权)
|
|
7
|
+
// ============================================================================
|
|
8
|
+
const MAX_UINT256 = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
|
|
9
|
+
const MAX_APPROVAL_THRESHOLD = MAX_UINT256 / 2n;
|
|
5
10
|
/**
|
|
6
11
|
* 验证合约地址是否有效(是否部署了代码)
|
|
7
12
|
*/
|
|
@@ -408,7 +413,8 @@ export async function approveTokenRaw(rpcUrl, privateKey, tokenAddress, spenderA
|
|
|
408
413
|
await validateContractAddress(provider, normalizedToken, 'Token');
|
|
409
414
|
await validateContractAddress(provider, normalizedSpender, 'Spender');
|
|
410
415
|
const erc20 = new Contract(normalizedToken, ERC20_ABI, signer);
|
|
411
|
-
const
|
|
416
|
+
const isMax = amount === 'max';
|
|
417
|
+
const requiredAmount = isMax ? MAX_UINT256 : amount;
|
|
412
418
|
// 检查当前授权额度
|
|
413
419
|
let currentAllowance;
|
|
414
420
|
try {
|
|
@@ -418,7 +424,8 @@ export async function approveTokenRaw(rpcUrl, privateKey, tokenAddress, spenderA
|
|
|
418
424
|
throw new Error(`❌ 查询授权额度失败: ${error.message}`);
|
|
419
425
|
}
|
|
420
426
|
// 如果已经授权足够,直接返回
|
|
421
|
-
|
|
427
|
+
// ✅ max 授权:使用阈值判断,避免每次消耗一点 allowance 都重新授权
|
|
428
|
+
if (isMax ? (currentAllowance >= MAX_APPROVAL_THRESHOLD) : (currentAllowance >= requiredAmount)) {
|
|
422
429
|
return {
|
|
423
430
|
alreadyApproved: true,
|
|
424
431
|
currentAllowance,
|
|
@@ -495,8 +502,9 @@ export async function approveTokenBatchRaw(params) {
|
|
|
495
502
|
// ✅ 优化:批量创建钱包和合约实例
|
|
496
503
|
const wallets = privateKeys.map(key => new Wallet(key, provider));
|
|
497
504
|
const ownerAddresses = wallets.map(w => w.address);
|
|
505
|
+
const isMaxApprovals = amounts.map(a => a === 'max');
|
|
498
506
|
const requiredAmounts = amounts.map(amount => amount === 'max'
|
|
499
|
-
?
|
|
507
|
+
? MAX_UINT256
|
|
500
508
|
: amount);
|
|
501
509
|
// ==================== signOnly=true:只签名不提交 ====================
|
|
502
510
|
if (signOnly) {
|
|
@@ -517,8 +525,10 @@ export async function approveTokenBatchRaw(params) {
|
|
|
517
525
|
const ownerAddress = ownerAddresses[i];
|
|
518
526
|
const currentAllowance = currentAllowances[i];
|
|
519
527
|
const requiredAmount = requiredAmounts[i];
|
|
528
|
+
const isMax = isMaxApprovals[i];
|
|
520
529
|
// 如果已经授权足够,跳过
|
|
521
|
-
|
|
530
|
+
// ✅ max 授权:使用阈值判断(与 BSC 一致)
|
|
531
|
+
if (isMax ? (currentAllowance >= MAX_APPROVAL_THRESHOLD) : (currentAllowance >= requiredAmount)) {
|
|
522
532
|
return {
|
|
523
533
|
owner: ownerAddress,
|
|
524
534
|
alreadyApproved: true,
|
|
@@ -568,9 +578,11 @@ export async function approveTokenBatchRaw(params) {
|
|
|
568
578
|
const ownerAddress = ownerAddresses[i];
|
|
569
579
|
const currentAllowance = currentAllowances[i];
|
|
570
580
|
const requiredAmount = requiredAmounts[i];
|
|
581
|
+
const isMax = isMaxApprovals[i];
|
|
571
582
|
try {
|
|
572
583
|
// 如果已经授权足够,跳过
|
|
573
|
-
|
|
584
|
+
// ✅ max 授权:使用阈值判断(与 BSC 一致)
|
|
585
|
+
if (isMax ? (currentAllowance >= MAX_APPROVAL_THRESHOLD) : (currentAllowance >= requiredAmount)) {
|
|
574
586
|
return {
|
|
575
587
|
owner: ownerAddress,
|
|
576
588
|
alreadyApproved: true,
|
|
@@ -27,7 +27,7 @@ export declare const QUOTE_CONFIG: {
|
|
|
27
27
|
readonly v2Router: "0x881fb2f98c13d521009464e7d1cbf16e1b394e8e";
|
|
28
28
|
readonly v3Quoter: "";
|
|
29
29
|
readonly wrappedNative: "0xe538905cf8410324e03a5a23c1c177a474d59b2b";
|
|
30
|
-
readonly stableCoins: readonly ["0x1E4a5963aBFD975d8c9021ce480b42188849D41d"];
|
|
30
|
+
readonly stableCoins: readonly ["0x1E4a5963aBFD975d8c9021ce480b42188849D41d", "0x74b7f16337b8972027f6196a17a631ac6de26d22", "0x779ded0c9e1022225f8e0630b35a9b54be713736"];
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
export type SupportedChain = keyof typeof QUOTE_CONFIG;
|
|
@@ -39,6 +39,8 @@ export const QUOTE_CONFIG = {
|
|
|
39
39
|
wrappedNative: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', // WOKB
|
|
40
40
|
stableCoins: [
|
|
41
41
|
'0x1E4a5963aBFD975d8c9021ce480b42188849D41d', // USDT
|
|
42
|
+
'0x74b7f16337b8972027f6196a17a631ac6de26d22', // USDC
|
|
43
|
+
'0x779ded0c9e1022225f8e0630b35a9b54be713736', // USD₮0
|
|
42
44
|
],
|
|
43
45
|
},
|
|
44
46
|
};
|
|
@@ -38,6 +38,8 @@ export declare const POTATOSWAP_V3_FACTORY = "0xa1415fAe79c4B196d087F02b8aD5a622
|
|
|
38
38
|
export declare const USDT = "0x1e4a5963abfd975d8c9021ce480b42188849d41d";
|
|
39
39
|
/** USDC (6位精度) */
|
|
40
40
|
export declare const USDC = "0x74b7f16337b8972027f6196a17a631ac6de26d22";
|
|
41
|
+
/** USD₮0 / USDT0 (6位精度) - Flap xLayer 支持的稳定币计价 */
|
|
42
|
+
export declare const USDT0 = "0x779ded0c9e1022225f8e0630b35a9b54be713736";
|
|
41
43
|
/** 零地址(表示原生代币 OKB) */
|
|
42
44
|
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
43
45
|
/** 默认 Gas Price 兜底值(0.1 gwei) */
|
package/dist/xlayer/constants.js
CHANGED
|
@@ -53,6 +53,8 @@ export const POTATOSWAP_V3_FACTORY = '0xa1415fAe79c4B196d087F02b8aD5a622B8A827E5
|
|
|
53
53
|
export const USDT = '0x1e4a5963abfd975d8c9021ce480b42188849d41d';
|
|
54
54
|
/** USDC (6位精度) */
|
|
55
55
|
export const USDC = '0x74b7f16337b8972027f6196a17a631ac6de26d22';
|
|
56
|
+
/** USD₮0 / USDT0 (6位精度) - Flap xLayer 支持的稳定币计价 */
|
|
57
|
+
export const USDT0 = '0x779ded0c9e1022225f8e0630b35a9b54be713736';
|
|
56
58
|
// ============================================================================
|
|
57
59
|
// 零地址
|
|
58
60
|
// ============================================================================
|