@imtbl/sdk 0.8.0-alpha → 0.11.0-alpha
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/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +10576 -120
- package/dist/checkout_sdk.js +631 -296
- package/dist/checkout_widgets.d.ts +19837 -19837
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +632 -288
- package/dist/index.d.ts +159 -17
- package/dist/index.js +640 -296
- package/dist/orderbook.d.ts +11 -2
- package/dist/orderbook.js +78 -26
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2420,7 +2420,7 @@ class MultiRollupApiClients {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
|
|
2422
2422
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2423
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.
|
|
2423
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.11.0-alpha' };
|
|
2424
2424
|
const createConfig = ({ basePath, headers, }) => {
|
|
2425
2425
|
if (!basePath.trim()) {
|
|
2426
2426
|
throw Error('basePath can not be empty');
|
|
@@ -2480,7 +2480,7 @@ class APIError extends Error {
|
|
|
2480
2480
|
|
|
2481
2481
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2482
2482
|
const defaultHeaders = {
|
|
2483
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
2483
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.11.0-alpha',
|
|
2484
2484
|
};
|
|
2485
2485
|
/**
|
|
2486
2486
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -2752,7 +2752,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2752
2752
|
chainID,
|
|
2753
2753
|
coreContractAddress,
|
|
2754
2754
|
registrationContractAddress,
|
|
2755
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
2755
|
+
sdkVersion: 'ts-immutable-sdk-0.11.0-alpha',
|
|
2756
2756
|
});
|
|
2757
2757
|
/**
|
|
2758
2758
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9434,6 +9434,28 @@ class OrdersService {
|
|
|
9434
9434
|
},
|
|
9435
9435
|
});
|
|
9436
9436
|
}
|
|
9437
|
+
/**
|
|
9438
|
+
* Retrieve fulfillment data for orders
|
|
9439
|
+
* Retrieve signed fulfillment data based on the list of order IDs and corresponding fees.
|
|
9440
|
+
* @returns any Successful response
|
|
9441
|
+
* @throws ApiError
|
|
9442
|
+
*/
|
|
9443
|
+
fulfillmentData({ chainName, requestBody, }) {
|
|
9444
|
+
return this.httpRequest.request({
|
|
9445
|
+
method: 'POST',
|
|
9446
|
+
url: '/v1/chains/{chain_name}/orders/fulfillment-data',
|
|
9447
|
+
path: {
|
|
9448
|
+
'chain_name': chainName,
|
|
9449
|
+
},
|
|
9450
|
+
body: requestBody,
|
|
9451
|
+
mediaType: 'application/json',
|
|
9452
|
+
errors: {
|
|
9453
|
+
400: `Bad Request (400)`,
|
|
9454
|
+
404: `The specified resource was not found (404)`,
|
|
9455
|
+
500: `Internal Server Error (500)`,
|
|
9456
|
+
},
|
|
9457
|
+
});
|
|
9458
|
+
}
|
|
9437
9459
|
}
|
|
9438
9460
|
|
|
9439
9461
|
class OrderBookClient {
|
|
@@ -9441,7 +9463,7 @@ class OrderBookClient {
|
|
|
9441
9463
|
request;
|
|
9442
9464
|
constructor(config, HttpRequest = AxiosHttpRequest) {
|
|
9443
9465
|
this.request = new HttpRequest({
|
|
9444
|
-
BASE: config?.BASE ?? 'https://api.
|
|
9466
|
+
BASE: config?.BASE ?? 'https://api.sandbox.immutable.com',
|
|
9445
9467
|
VERSION: config?.VERSION ?? '1.0.0',
|
|
9446
9468
|
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
9447
9469
|
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
@@ -9510,7 +9532,7 @@ var ActionType;
|
|
|
9510
9532
|
// TODO: Resolve these from seaport-js.
|
|
9511
9533
|
// There is some bundling issue that is preventing this from working
|
|
9512
9534
|
const SEAPORT_CONTRACT_NAME = 'ImmutableSeaport';
|
|
9513
|
-
const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
|
|
9535
|
+
// export const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
|
|
9514
9536
|
const SEAPORT_CONTRACT_VERSION_V1_5 = '1.5';
|
|
9515
9537
|
const EIP_712_ORDER_TYPE = {
|
|
9516
9538
|
OrderComponents: [
|
|
@@ -9700,7 +9722,7 @@ class Seaport {
|
|
|
9700
9722
|
orderHash: this.getSeaportLib().getOrderHash(orderComponents),
|
|
9701
9723
|
};
|
|
9702
9724
|
}
|
|
9703
|
-
async fulfillOrder(order, account) {
|
|
9725
|
+
async fulfillOrder(order, account, extraData) {
|
|
9704
9726
|
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
9705
9727
|
const seaportLib = this.getSeaportLib(order);
|
|
9706
9728
|
const { actions: seaportActions } = await seaportLib.fulfillOrders({
|
|
@@ -9710,7 +9732,7 @@ class Seaport {
|
|
|
9710
9732
|
parameters: orderComponents,
|
|
9711
9733
|
signature: order.signature,
|
|
9712
9734
|
},
|
|
9713
|
-
extraData
|
|
9735
|
+
extraData,
|
|
9714
9736
|
}],
|
|
9715
9737
|
});
|
|
9716
9738
|
const fulfillmentActions = [];
|
|
@@ -9778,7 +9800,7 @@ class Seaport {
|
|
|
9778
9800
|
const { chainId } = await this.provider.getNetwork();
|
|
9779
9801
|
const domainData = {
|
|
9780
9802
|
name: SEAPORT_CONTRACT_NAME,
|
|
9781
|
-
version:
|
|
9803
|
+
version: SEAPORT_CONTRACT_VERSION_V1_5,
|
|
9782
9804
|
chainId,
|
|
9783
9805
|
verifyingContract: this.seaportContractAddress,
|
|
9784
9806
|
};
|
|
@@ -9790,10 +9812,10 @@ class Seaport {
|
|
|
9790
9812
|
}
|
|
9791
9813
|
getSeaportLib(order) {
|
|
9792
9814
|
const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
|
|
9793
|
-
|
|
9794
|
-
if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
|
|
9795
|
-
|
|
9796
|
-
}
|
|
9815
|
+
const seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
|
|
9816
|
+
// if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
|
|
9817
|
+
// seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
|
|
9818
|
+
// }
|
|
9797
9819
|
return this.seaportLibFactory.create(seaportVersion, seaportAddress);
|
|
9798
9820
|
}
|
|
9799
9821
|
}
|
|
@@ -9807,6 +9829,12 @@ class ImmutableApiClient {
|
|
|
9807
9829
|
this.chainName = chainName;
|
|
9808
9830
|
this.seaportAddress = seaportAddress;
|
|
9809
9831
|
}
|
|
9832
|
+
async fulfillmentData(requests) {
|
|
9833
|
+
return this.orderbookService.fulfillmentData({
|
|
9834
|
+
chainName: this.chainName,
|
|
9835
|
+
requestBody: requests,
|
|
9836
|
+
});
|
|
9837
|
+
}
|
|
9810
9838
|
async getListing(listingId) {
|
|
9811
9839
|
return this.orderbookService.getListing({
|
|
9812
9840
|
chainName: this.chainName,
|
|
@@ -9862,7 +9890,7 @@ class ImmutableApiClient {
|
|
|
9862
9890
|
order_type: CreateOrderProtocolData.order_type.FULL_RESTRICTED,
|
|
9863
9891
|
zone_address: orderComponents.zone,
|
|
9864
9892
|
seaport_address: this.seaportAddress,
|
|
9865
|
-
seaport_version:
|
|
9893
|
+
seaport_version: SEAPORT_CONTRACT_VERSION_V1_5,
|
|
9866
9894
|
counter: orderComponents.counter.toString(),
|
|
9867
9895
|
},
|
|
9868
9896
|
salt: orderComponents.salt,
|
|
@@ -9903,9 +9931,9 @@ function getOrderbookConfig(environment) {
|
|
|
9903
9931
|
switch (environment) {
|
|
9904
9932
|
case Environment$1.SANDBOX:
|
|
9905
9933
|
return {
|
|
9906
|
-
seaportContractAddress: '
|
|
9907
|
-
zoneContractAddress: '
|
|
9908
|
-
apiEndpoint: 'https://
|
|
9934
|
+
seaportContractAddress: '0x7Fb7Da6De152597830eD16361633e362A2F59410',
|
|
9935
|
+
zoneContractAddress: '0x63441cBfBd15Dd8f5E92598E535661Ac5aCB808E',
|
|
9936
|
+
apiEndpoint: 'https://api.sandbox.immutable.com',
|
|
9909
9937
|
chainName: TESTNET_CHAIN_NAME,
|
|
9910
9938
|
provider: new ethers.providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
|
|
9911
9939
|
};
|
|
@@ -10853,7 +10881,7 @@ class SeaportLibFactory {
|
|
|
10853
10881
|
this.provider = provider;
|
|
10854
10882
|
}
|
|
10855
10883
|
create(orderSeaportVersion, orderSeaportAddress) {
|
|
10856
|
-
const seaportVersion = orderSeaportVersion ??
|
|
10884
|
+
const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_5;
|
|
10857
10885
|
const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
|
|
10858
10886
|
return new seaportJs.Seaport(this.provider, {
|
|
10859
10887
|
seaportVersion,
|
|
@@ -10892,6 +10920,13 @@ class Orderbook {
|
|
|
10892
10920
|
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
10893
10921
|
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
10894
10922
|
}
|
|
10923
|
+
/**
|
|
10924
|
+
* Return the configuration for the orderbook module.
|
|
10925
|
+
* @return {OrderbookModuleConfiguration} The configuration for the orderbook module.
|
|
10926
|
+
*/
|
|
10927
|
+
config() {
|
|
10928
|
+
return this.orderbookConfig;
|
|
10929
|
+
}
|
|
10895
10930
|
/**
|
|
10896
10931
|
* Get an order by ID
|
|
10897
10932
|
* @param {string} listingId - The listingId to find.
|
|
@@ -10943,11 +10978,20 @@ class Orderbook {
|
|
|
10943
10978
|
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
10944
10979
|
*/
|
|
10945
10980
|
async fulfillOrder(listingId, takerAddress) {
|
|
10946
|
-
const
|
|
10947
|
-
|
|
10948
|
-
|
|
10981
|
+
const fulfillmentDataRes = await this.apiClient.fulfillmentData([{
|
|
10982
|
+
order_id: listingId,
|
|
10983
|
+
// fee: takerFee,
|
|
10984
|
+
fee: undefined,
|
|
10985
|
+
}]);
|
|
10986
|
+
if (fulfillmentDataRes.result.length !== 1) {
|
|
10987
|
+
throw new Error('unexpected fulfillment data result length');
|
|
10949
10988
|
}
|
|
10950
|
-
|
|
10989
|
+
const extraData = fulfillmentDataRes.result[0].extra_data;
|
|
10990
|
+
const orderResult = fulfillmentDataRes.result[0].order;
|
|
10991
|
+
if (orderResult.status !== OrderStatus.ACTIVE) {
|
|
10992
|
+
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.status}`);
|
|
10993
|
+
}
|
|
10994
|
+
return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
|
|
10951
10995
|
}
|
|
10952
10996
|
/**
|
|
10953
10997
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
@@ -10971,12 +11015,21 @@ class Orderbook {
|
|
|
10971
11015
|
}
|
|
10972
11016
|
}
|
|
10973
11017
|
|
|
11018
|
+
// Consumers might want an estimated gas limit for fulfilling an order
|
|
11019
|
+
// without calling the transaction builder. This is an estimate that
|
|
11020
|
+
// should work for all fulfillment scenarios.
|
|
11021
|
+
const ESTIMATED_FULFILLMENT_GAS_GWEI = 400000;
|
|
11022
|
+
const constants = {
|
|
11023
|
+
estimatedFulfillmentGasGwei: ESTIMATED_FULFILLMENT_GAS_GWEI,
|
|
11024
|
+
};
|
|
11025
|
+
|
|
10974
11026
|
var orderbook = /*#__PURE__*/Object.freeze({
|
|
10975
11027
|
__proto__: null,
|
|
10976
11028
|
get ActionType () { return ActionType; },
|
|
10977
11029
|
Orderbook: Orderbook,
|
|
10978
11030
|
get SignablePurpose () { return SignablePurpose; },
|
|
10979
|
-
get TransactionPurpose () { return TransactionPurpose; }
|
|
11031
|
+
get TransactionPurpose () { return TransactionPurpose; },
|
|
11032
|
+
constants: constants
|
|
10980
11033
|
});
|
|
10981
11034
|
|
|
10982
11035
|
function isChainValid(chainID, config) {
|
|
@@ -16067,10 +16120,10 @@ class BigNumber {
|
|
|
16067
16120
|
Object.freeze(this);
|
|
16068
16121
|
}
|
|
16069
16122
|
fromTwos(value) {
|
|
16070
|
-
return toBigNumber
|
|
16123
|
+
return toBigNumber(toBN(this).fromTwos(value));
|
|
16071
16124
|
}
|
|
16072
16125
|
toTwos(value) {
|
|
16073
|
-
return toBigNumber
|
|
16126
|
+
return toBigNumber(toBN(this).toTwos(value));
|
|
16074
16127
|
}
|
|
16075
16128
|
abs() {
|
|
16076
16129
|
if (this._hex[0] === "-") {
|
|
@@ -16079,73 +16132,73 @@ class BigNumber {
|
|
|
16079
16132
|
return this;
|
|
16080
16133
|
}
|
|
16081
16134
|
add(other) {
|
|
16082
|
-
return toBigNumber
|
|
16135
|
+
return toBigNumber(toBN(this).add(toBN(other)));
|
|
16083
16136
|
}
|
|
16084
16137
|
sub(other) {
|
|
16085
|
-
return toBigNumber
|
|
16138
|
+
return toBigNumber(toBN(this).sub(toBN(other)));
|
|
16086
16139
|
}
|
|
16087
16140
|
div(other) {
|
|
16088
16141
|
const o = BigNumber.from(other);
|
|
16089
16142
|
if (o.isZero()) {
|
|
16090
16143
|
throwFault("division-by-zero", "div");
|
|
16091
16144
|
}
|
|
16092
|
-
return toBigNumber
|
|
16145
|
+
return toBigNumber(toBN(this).div(toBN(other)));
|
|
16093
16146
|
}
|
|
16094
16147
|
mul(other) {
|
|
16095
|
-
return toBigNumber
|
|
16148
|
+
return toBigNumber(toBN(this).mul(toBN(other)));
|
|
16096
16149
|
}
|
|
16097
16150
|
mod(other) {
|
|
16098
16151
|
const value = toBN(other);
|
|
16099
16152
|
if (value.isNeg()) {
|
|
16100
16153
|
throwFault("division-by-zero", "mod");
|
|
16101
16154
|
}
|
|
16102
|
-
return toBigNumber
|
|
16155
|
+
return toBigNumber(toBN(this).umod(value));
|
|
16103
16156
|
}
|
|
16104
16157
|
pow(other) {
|
|
16105
16158
|
const value = toBN(other);
|
|
16106
16159
|
if (value.isNeg()) {
|
|
16107
16160
|
throwFault("negative-power", "pow");
|
|
16108
16161
|
}
|
|
16109
|
-
return toBigNumber
|
|
16162
|
+
return toBigNumber(toBN(this).pow(value));
|
|
16110
16163
|
}
|
|
16111
16164
|
and(other) {
|
|
16112
16165
|
const value = toBN(other);
|
|
16113
16166
|
if (this.isNegative() || value.isNeg()) {
|
|
16114
16167
|
throwFault("unbound-bitwise-result", "and");
|
|
16115
16168
|
}
|
|
16116
|
-
return toBigNumber
|
|
16169
|
+
return toBigNumber(toBN(this).and(value));
|
|
16117
16170
|
}
|
|
16118
16171
|
or(other) {
|
|
16119
16172
|
const value = toBN(other);
|
|
16120
16173
|
if (this.isNegative() || value.isNeg()) {
|
|
16121
16174
|
throwFault("unbound-bitwise-result", "or");
|
|
16122
16175
|
}
|
|
16123
|
-
return toBigNumber
|
|
16176
|
+
return toBigNumber(toBN(this).or(value));
|
|
16124
16177
|
}
|
|
16125
16178
|
xor(other) {
|
|
16126
16179
|
const value = toBN(other);
|
|
16127
16180
|
if (this.isNegative() || value.isNeg()) {
|
|
16128
16181
|
throwFault("unbound-bitwise-result", "xor");
|
|
16129
16182
|
}
|
|
16130
|
-
return toBigNumber
|
|
16183
|
+
return toBigNumber(toBN(this).xor(value));
|
|
16131
16184
|
}
|
|
16132
16185
|
mask(value) {
|
|
16133
16186
|
if (this.isNegative() || value < 0) {
|
|
16134
16187
|
throwFault("negative-width", "mask");
|
|
16135
16188
|
}
|
|
16136
|
-
return toBigNumber
|
|
16189
|
+
return toBigNumber(toBN(this).maskn(value));
|
|
16137
16190
|
}
|
|
16138
16191
|
shl(value) {
|
|
16139
16192
|
if (this.isNegative() || value < 0) {
|
|
16140
16193
|
throwFault("negative-width", "shl");
|
|
16141
16194
|
}
|
|
16142
|
-
return toBigNumber
|
|
16195
|
+
return toBigNumber(toBN(this).shln(value));
|
|
16143
16196
|
}
|
|
16144
16197
|
shr(value) {
|
|
16145
16198
|
if (this.isNegative() || value < 0) {
|
|
16146
16199
|
throwFault("negative-width", "shr");
|
|
16147
16200
|
}
|
|
16148
|
-
return toBigNumber
|
|
16201
|
+
return toBigNumber(toBN(this).shrn(value));
|
|
16149
16202
|
}
|
|
16150
16203
|
eq(other) {
|
|
16151
16204
|
return toBN(this).eq(toBN(other));
|
|
@@ -16308,7 +16361,7 @@ function toHex(value) {
|
|
|
16308
16361
|
}
|
|
16309
16362
|
return value;
|
|
16310
16363
|
}
|
|
16311
|
-
function toBigNumber
|
|
16364
|
+
function toBigNumber(value) {
|
|
16312
16365
|
return BigNumber.from(toHex(value));
|
|
16313
16366
|
}
|
|
16314
16367
|
function toBN(value) {
|
|
@@ -24881,70 +24934,6 @@ const getApproval = async (nativeToken, provider, ownerAddress, tokenAddress, pr
|
|
|
24881
24934
|
};
|
|
24882
24935
|
};
|
|
24883
24936
|
|
|
24884
|
-
const quoteReturnMapping = {
|
|
24885
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
24886
|
-
'0xcdca1753': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
|
|
24887
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
24888
|
-
'0xc6a5026a': ['uint256', 'uint160', 'uint32', 'uint256'],
|
|
24889
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
24890
|
-
'0x2f80bb1d': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
|
|
24891
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
24892
|
-
'0xbd21704a': ['uint256', 'uint160', 'uint32', 'uint256'],
|
|
24893
|
-
};
|
|
24894
|
-
/**
|
|
24895
|
-
* Returns true if poolA is equivalent to poolB
|
|
24896
|
-
* @param poolA one of the two pools
|
|
24897
|
-
* @param poolB the other pool
|
|
24898
|
-
*/
|
|
24899
|
-
function poolEquals(poolA, poolB) {
|
|
24900
|
-
return (poolA === poolB
|
|
24901
|
-
|| (poolA.token0.equals(poolB.token0)
|
|
24902
|
-
&& poolA.token1.equals(poolB.token1)
|
|
24903
|
-
&& poolA.fee === poolB.fee));
|
|
24904
|
-
}
|
|
24905
|
-
async function getERC20Decimals(tokenAddress, provider) {
|
|
24906
|
-
const decimalsFunctionSig = ethers.ethers.utils.id('decimals()').substring(0, 10);
|
|
24907
|
-
try {
|
|
24908
|
-
const decimalsResult = await provider.call({
|
|
24909
|
-
to: tokenAddress,
|
|
24910
|
-
data: decimalsFunctionSig,
|
|
24911
|
-
});
|
|
24912
|
-
return parseInt(decimalsResult, 16);
|
|
24913
|
-
}
|
|
24914
|
-
catch (e) {
|
|
24915
|
-
const message = e instanceof Error ? e.message : 'Unknown Error';
|
|
24916
|
-
throw new ProviderCallError(`failed to get ERC20 decimals: ${message}`);
|
|
24917
|
-
}
|
|
24918
|
-
}
|
|
24919
|
-
/**
|
|
24920
|
-
* Based on https://github.com/ethers-io/ethers.js/blob/main/src.ts/address/checks.ts#L51
|
|
24921
|
-
*/
|
|
24922
|
-
function isValidNonZeroAddress(address) {
|
|
24923
|
-
if (address === ethers.ethers.constants.AddressZero) {
|
|
24924
|
-
return false;
|
|
24925
|
-
}
|
|
24926
|
-
try {
|
|
24927
|
-
ethers.ethers.utils.getAddress(address);
|
|
24928
|
-
return true;
|
|
24929
|
-
}
|
|
24930
|
-
catch (error) {
|
|
24931
|
-
return false;
|
|
24932
|
-
}
|
|
24933
|
-
}
|
|
24934
|
-
const tokenInfoToUniswapToken = (tokenInfo) => new sdkCore.Token(tokenInfo.chainId, tokenInfo.address, tokenInfo.decimals, tokenInfo.symbol, tokenInfo.name);
|
|
24935
|
-
const uniswapTokenToTokenInfo = (token) => ({
|
|
24936
|
-
chainId: token.chainId,
|
|
24937
|
-
address: token.address,
|
|
24938
|
-
decimals: token.decimals,
|
|
24939
|
-
symbol: token.symbol,
|
|
24940
|
-
name: token.name,
|
|
24941
|
-
});
|
|
24942
|
-
const toBigNumber = (amount) => (ethers.ethers.BigNumber.from(amount.multiply(amount.decimalScale).toExact()));
|
|
24943
|
-
const newAmount = (amount, token) => ({
|
|
24944
|
-
value: amount,
|
|
24945
|
-
token,
|
|
24946
|
-
});
|
|
24947
|
-
|
|
24948
24937
|
// slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
|
|
24949
24938
|
// converts it to the Uniswap equivalent type
|
|
24950
24939
|
const slippageToFraction = (slippage) => {
|
|
@@ -24964,17 +24953,11 @@ const slippageToFraction = (slippage) => {
|
|
|
24964
24953
|
return new sdkCore.Percent(numerator, denominator);
|
|
24965
24954
|
};
|
|
24966
24955
|
|
|
24967
|
-
function getQuoteAmountFromTradeType(tradeInfo
|
|
24956
|
+
function getQuoteAmountFromTradeType(tradeInfo) {
|
|
24968
24957
|
if (tradeInfo.tradeType === sdkCore.TradeType.EXACT_INPUT) {
|
|
24969
|
-
return
|
|
24970
|
-
token: tokenInfo,
|
|
24971
|
-
value: tradeInfo.amountOut,
|
|
24972
|
-
};
|
|
24958
|
+
return tradeInfo.amountOut;
|
|
24973
24959
|
}
|
|
24974
|
-
return
|
|
24975
|
-
token: tokenInfo,
|
|
24976
|
-
value: tradeInfo.amountIn,
|
|
24977
|
-
};
|
|
24960
|
+
return tradeInfo.amountIn;
|
|
24978
24961
|
}
|
|
24979
24962
|
function applySlippage(tradeType, amount, slippage) {
|
|
24980
24963
|
const slippageTolerance = slippageToFraction(slippage);
|
|
@@ -24983,8 +24966,8 @@ function applySlippage(tradeType, amount, slippage) {
|
|
|
24983
24966
|
const amountWithSlippage = maybeInverted.multiply(amount.toString()).quotient;
|
|
24984
24967
|
return ethers.ethers.BigNumber.from(amountWithSlippage.toString());
|
|
24985
24968
|
}
|
|
24986
|
-
function prepareUserQuote(
|
|
24987
|
-
const resultToken =
|
|
24969
|
+
function prepareUserQuote(otherToken, tradeInfo, slippage, fees) {
|
|
24970
|
+
const resultToken = otherToken.wrapped;
|
|
24988
24971
|
const tokenInfo = {
|
|
24989
24972
|
chainId: resultToken.chainId,
|
|
24990
24973
|
address: resultToken.address,
|
|
@@ -24992,7 +24975,7 @@ function prepareUserQuote(otherCurrency, tradeInfo, slippage, fees) {
|
|
|
24992
24975
|
symbol: resultToken.symbol,
|
|
24993
24976
|
name: resultToken.name,
|
|
24994
24977
|
};
|
|
24995
|
-
const quote = getQuoteAmountFromTradeType(tradeInfo
|
|
24978
|
+
const quote = getQuoteAmountFromTradeType(tradeInfo);
|
|
24996
24979
|
const amountWithSlippage = applySlippage(tradeInfo.tradeType, quote.value, slippage);
|
|
24997
24980
|
return {
|
|
24998
24981
|
amount: quote,
|
|
@@ -25009,8 +24992,8 @@ function getOurQuoteReqAmount(amount, fees, tradeType) {
|
|
|
25009
24992
|
// For an exact output swap, we do not need to subtract fees from the given amount
|
|
25010
24993
|
return amount;
|
|
25011
24994
|
}
|
|
25012
|
-
fees.addAmount(
|
|
25013
|
-
return
|
|
24995
|
+
fees.addAmount(amount);
|
|
24996
|
+
return fees.amountLessFees();
|
|
25014
24997
|
}
|
|
25015
24998
|
|
|
25016
24999
|
// 0.1% default slippage
|
|
@@ -25162,6 +25145,11 @@ class Multicall__factory extends ethers.ContractFactory {
|
|
|
25162
25145
|
const _abi$1$1 = [
|
|
25163
25146
|
{
|
|
25164
25147
|
inputs: [
|
|
25148
|
+
{
|
|
25149
|
+
internalType: "address",
|
|
25150
|
+
name: "_admin",
|
|
25151
|
+
type: "address",
|
|
25152
|
+
},
|
|
25165
25153
|
{
|
|
25166
25154
|
internalType: "address",
|
|
25167
25155
|
name: "_uniRouter",
|
|
@@ -25202,36 +25190,92 @@ const _abi$1$1 = [
|
|
|
25202
25190
|
name: "FeeTaken",
|
|
25203
25191
|
type: "event",
|
|
25204
25192
|
},
|
|
25193
|
+
{
|
|
25194
|
+
anonymous: false,
|
|
25195
|
+
inputs: [
|
|
25196
|
+
{
|
|
25197
|
+
indexed: false,
|
|
25198
|
+
internalType: "address",
|
|
25199
|
+
name: "account",
|
|
25200
|
+
type: "address",
|
|
25201
|
+
},
|
|
25202
|
+
],
|
|
25203
|
+
name: "Paused",
|
|
25204
|
+
type: "event",
|
|
25205
|
+
},
|
|
25206
|
+
{
|
|
25207
|
+
anonymous: false,
|
|
25208
|
+
inputs: [
|
|
25209
|
+
{
|
|
25210
|
+
indexed: true,
|
|
25211
|
+
internalType: "bytes32",
|
|
25212
|
+
name: "role",
|
|
25213
|
+
type: "bytes32",
|
|
25214
|
+
},
|
|
25215
|
+
{
|
|
25216
|
+
indexed: true,
|
|
25217
|
+
internalType: "bytes32",
|
|
25218
|
+
name: "previousAdminRole",
|
|
25219
|
+
type: "bytes32",
|
|
25220
|
+
},
|
|
25221
|
+
{
|
|
25222
|
+
indexed: true,
|
|
25223
|
+
internalType: "bytes32",
|
|
25224
|
+
name: "newAdminRole",
|
|
25225
|
+
type: "bytes32",
|
|
25226
|
+
},
|
|
25227
|
+
],
|
|
25228
|
+
name: "RoleAdminChanged",
|
|
25229
|
+
type: "event",
|
|
25230
|
+
},
|
|
25205
25231
|
{
|
|
25206
25232
|
anonymous: false,
|
|
25207
25233
|
inputs: [
|
|
25234
|
+
{
|
|
25235
|
+
indexed: true,
|
|
25236
|
+
internalType: "bytes32",
|
|
25237
|
+
name: "role",
|
|
25238
|
+
type: "bytes32",
|
|
25239
|
+
},
|
|
25208
25240
|
{
|
|
25209
25241
|
indexed: true,
|
|
25210
25242
|
internalType: "address",
|
|
25211
|
-
name: "
|
|
25243
|
+
name: "account",
|
|
25212
25244
|
type: "address",
|
|
25213
25245
|
},
|
|
25214
25246
|
{
|
|
25215
25247
|
indexed: true,
|
|
25216
25248
|
internalType: "address",
|
|
25217
|
-
name: "
|
|
25249
|
+
name: "sender",
|
|
25218
25250
|
type: "address",
|
|
25219
25251
|
},
|
|
25220
25252
|
],
|
|
25221
|
-
name: "
|
|
25253
|
+
name: "RoleGranted",
|
|
25222
25254
|
type: "event",
|
|
25223
25255
|
},
|
|
25224
25256
|
{
|
|
25225
25257
|
anonymous: false,
|
|
25226
25258
|
inputs: [
|
|
25227
25259
|
{
|
|
25228
|
-
indexed:
|
|
25260
|
+
indexed: true,
|
|
25261
|
+
internalType: "bytes32",
|
|
25262
|
+
name: "role",
|
|
25263
|
+
type: "bytes32",
|
|
25264
|
+
},
|
|
25265
|
+
{
|
|
25266
|
+
indexed: true,
|
|
25229
25267
|
internalType: "address",
|
|
25230
25268
|
name: "account",
|
|
25231
25269
|
type: "address",
|
|
25232
25270
|
},
|
|
25271
|
+
{
|
|
25272
|
+
indexed: true,
|
|
25273
|
+
internalType: "address",
|
|
25274
|
+
name: "sender",
|
|
25275
|
+
type: "address",
|
|
25276
|
+
},
|
|
25233
25277
|
],
|
|
25234
|
-
name: "
|
|
25278
|
+
name: "RoleRevoked",
|
|
25235
25279
|
type: "event",
|
|
25236
25280
|
},
|
|
25237
25281
|
{
|
|
@@ -25252,9 +25296,9 @@ const _abi$1$1 = [
|
|
|
25252
25296
|
name: "BASIS_POINT_PRECISION",
|
|
25253
25297
|
outputs: [
|
|
25254
25298
|
{
|
|
25255
|
-
internalType: "
|
|
25299
|
+
internalType: "uint256",
|
|
25256
25300
|
name: "",
|
|
25257
|
-
type: "
|
|
25301
|
+
type: "uint256",
|
|
25258
25302
|
},
|
|
25259
25303
|
],
|
|
25260
25304
|
stateMutability: "view",
|
|
@@ -25262,7 +25306,20 @@ const _abi$1$1 = [
|
|
|
25262
25306
|
},
|
|
25263
25307
|
{
|
|
25264
25308
|
inputs: [],
|
|
25265
|
-
name: "
|
|
25309
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
25310
|
+
outputs: [
|
|
25311
|
+
{
|
|
25312
|
+
internalType: "bytes32",
|
|
25313
|
+
name: "",
|
|
25314
|
+
type: "bytes32",
|
|
25315
|
+
},
|
|
25316
|
+
],
|
|
25317
|
+
stateMutability: "view",
|
|
25318
|
+
type: "function",
|
|
25319
|
+
},
|
|
25320
|
+
{
|
|
25321
|
+
inputs: [],
|
|
25322
|
+
name: "FEE_BASIS_POINTS_MAXIMUM",
|
|
25266
25323
|
outputs: [
|
|
25267
25324
|
{
|
|
25268
25325
|
internalType: "uint16",
|
|
@@ -25273,6 +25330,45 @@ const _abi$1$1 = [
|
|
|
25273
25330
|
stateMutability: "view",
|
|
25274
25331
|
type: "function",
|
|
25275
25332
|
},
|
|
25333
|
+
{
|
|
25334
|
+
inputs: [],
|
|
25335
|
+
name: "PAUSE",
|
|
25336
|
+
outputs: [
|
|
25337
|
+
{
|
|
25338
|
+
internalType: "bytes32",
|
|
25339
|
+
name: "",
|
|
25340
|
+
type: "bytes32",
|
|
25341
|
+
},
|
|
25342
|
+
],
|
|
25343
|
+
stateMutability: "view",
|
|
25344
|
+
type: "function",
|
|
25345
|
+
},
|
|
25346
|
+
{
|
|
25347
|
+
inputs: [],
|
|
25348
|
+
name: "UNPAUSE",
|
|
25349
|
+
outputs: [
|
|
25350
|
+
{
|
|
25351
|
+
internalType: "bytes32",
|
|
25352
|
+
name: "",
|
|
25353
|
+
type: "bytes32",
|
|
25354
|
+
},
|
|
25355
|
+
],
|
|
25356
|
+
stateMutability: "view",
|
|
25357
|
+
type: "function",
|
|
25358
|
+
},
|
|
25359
|
+
{
|
|
25360
|
+
inputs: [],
|
|
25361
|
+
name: "WITHDRAW",
|
|
25362
|
+
outputs: [
|
|
25363
|
+
{
|
|
25364
|
+
internalType: "bytes32",
|
|
25365
|
+
name: "",
|
|
25366
|
+
type: "bytes32",
|
|
25367
|
+
},
|
|
25368
|
+
],
|
|
25369
|
+
stateMutability: "view",
|
|
25370
|
+
type: "function",
|
|
25371
|
+
},
|
|
25276
25372
|
{
|
|
25277
25373
|
inputs: [
|
|
25278
25374
|
{
|
|
@@ -25283,13 +25379,13 @@ const _abi$1$1 = [
|
|
|
25283
25379
|
type: "address",
|
|
25284
25380
|
},
|
|
25285
25381
|
{
|
|
25286
|
-
internalType: "
|
|
25287
|
-
name: "
|
|
25288
|
-
type: "
|
|
25382
|
+
internalType: "uint256",
|
|
25383
|
+
name: "feeBasisPoints",
|
|
25384
|
+
type: "uint256",
|
|
25289
25385
|
},
|
|
25290
25386
|
],
|
|
25291
|
-
internalType: "struct ISecondaryFee.
|
|
25292
|
-
name: "
|
|
25387
|
+
internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
|
|
25388
|
+
name: "secondaryFees",
|
|
25293
25389
|
type: "tuple[]",
|
|
25294
25390
|
},
|
|
25295
25391
|
{
|
|
@@ -25331,11 +25427,11 @@ const _abi$1$1 = [
|
|
|
25331
25427
|
},
|
|
25332
25428
|
],
|
|
25333
25429
|
internalType: "struct IV3SwapRouter.ExactInputSingleParams",
|
|
25334
|
-
name: "
|
|
25430
|
+
name: "swapParams",
|
|
25335
25431
|
type: "tuple",
|
|
25336
25432
|
},
|
|
25337
25433
|
],
|
|
25338
|
-
name: "
|
|
25434
|
+
name: "exactInputSingleWithSecondaryFee",
|
|
25339
25435
|
outputs: [
|
|
25340
25436
|
{
|
|
25341
25437
|
internalType: "uint256",
|
|
@@ -25356,13 +25452,13 @@ const _abi$1$1 = [
|
|
|
25356
25452
|
type: "address",
|
|
25357
25453
|
},
|
|
25358
25454
|
{
|
|
25359
|
-
internalType: "
|
|
25360
|
-
name: "
|
|
25361
|
-
type: "
|
|
25455
|
+
internalType: "uint256",
|
|
25456
|
+
name: "feeBasisPoints",
|
|
25457
|
+
type: "uint256",
|
|
25362
25458
|
},
|
|
25363
25459
|
],
|
|
25364
|
-
internalType: "struct ISecondaryFee.
|
|
25365
|
-
name: "
|
|
25460
|
+
internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
|
|
25461
|
+
name: "secondaryFees",
|
|
25366
25462
|
type: "tuple[]",
|
|
25367
25463
|
},
|
|
25368
25464
|
{
|
|
@@ -25389,11 +25485,11 @@ const _abi$1$1 = [
|
|
|
25389
25485
|
},
|
|
25390
25486
|
],
|
|
25391
25487
|
internalType: "struct IV3SwapRouter.ExactInputParams",
|
|
25392
|
-
name: "
|
|
25488
|
+
name: "swapParams",
|
|
25393
25489
|
type: "tuple",
|
|
25394
25490
|
},
|
|
25395
25491
|
],
|
|
25396
|
-
name: "
|
|
25492
|
+
name: "exactInputWithSecondaryFee",
|
|
25397
25493
|
outputs: [
|
|
25398
25494
|
{
|
|
25399
25495
|
internalType: "uint256",
|
|
@@ -25414,13 +25510,13 @@ const _abi$1$1 = [
|
|
|
25414
25510
|
type: "address",
|
|
25415
25511
|
},
|
|
25416
25512
|
{
|
|
25417
|
-
internalType: "
|
|
25418
|
-
name: "
|
|
25419
|
-
type: "
|
|
25513
|
+
internalType: "uint256",
|
|
25514
|
+
name: "feeBasisPoints",
|
|
25515
|
+
type: "uint256",
|
|
25420
25516
|
},
|
|
25421
25517
|
],
|
|
25422
|
-
internalType: "struct ISecondaryFee.
|
|
25423
|
-
name: "
|
|
25518
|
+
internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
|
|
25519
|
+
name: "secondaryFees",
|
|
25424
25520
|
type: "tuple[]",
|
|
25425
25521
|
},
|
|
25426
25522
|
{
|
|
@@ -25462,15 +25558,15 @@ const _abi$1$1 = [
|
|
|
25462
25558
|
},
|
|
25463
25559
|
],
|
|
25464
25560
|
internalType: "struct IV3SwapRouter.ExactOutputSingleParams",
|
|
25465
|
-
name: "
|
|
25561
|
+
name: "swapParams",
|
|
25466
25562
|
type: "tuple",
|
|
25467
25563
|
},
|
|
25468
25564
|
],
|
|
25469
|
-
name: "
|
|
25565
|
+
name: "exactOutputSingleWithSecondaryFee",
|
|
25470
25566
|
outputs: [
|
|
25471
25567
|
{
|
|
25472
25568
|
internalType: "uint256",
|
|
25473
|
-
name: "
|
|
25569
|
+
name: "",
|
|
25474
25570
|
type: "uint256",
|
|
25475
25571
|
},
|
|
25476
25572
|
],
|
|
@@ -25487,13 +25583,13 @@ const _abi$1$1 = [
|
|
|
25487
25583
|
type: "address",
|
|
25488
25584
|
},
|
|
25489
25585
|
{
|
|
25490
|
-
internalType: "
|
|
25491
|
-
name: "
|
|
25492
|
-
type: "
|
|
25586
|
+
internalType: "uint256",
|
|
25587
|
+
name: "feeBasisPoints",
|
|
25588
|
+
type: "uint256",
|
|
25493
25589
|
},
|
|
25494
25590
|
],
|
|
25495
|
-
internalType: "struct ISecondaryFee.
|
|
25496
|
-
name: "
|
|
25591
|
+
internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
|
|
25592
|
+
name: "secondaryFees",
|
|
25497
25593
|
type: "tuple[]",
|
|
25498
25594
|
},
|
|
25499
25595
|
{
|
|
@@ -25520,21 +25616,82 @@ const _abi$1$1 = [
|
|
|
25520
25616
|
},
|
|
25521
25617
|
],
|
|
25522
25618
|
internalType: "struct IV3SwapRouter.ExactOutputParams",
|
|
25523
|
-
name: "
|
|
25619
|
+
name: "swapParams",
|
|
25524
25620
|
type: "tuple",
|
|
25525
25621
|
},
|
|
25526
25622
|
],
|
|
25527
|
-
name: "
|
|
25623
|
+
name: "exactOutputWithSecondaryFee",
|
|
25528
25624
|
outputs: [
|
|
25529
25625
|
{
|
|
25530
25626
|
internalType: "uint256",
|
|
25531
|
-
name: "
|
|
25627
|
+
name: "",
|
|
25532
25628
|
type: "uint256",
|
|
25533
25629
|
},
|
|
25534
25630
|
],
|
|
25535
25631
|
stateMutability: "payable",
|
|
25536
25632
|
type: "function",
|
|
25537
25633
|
},
|
|
25634
|
+
{
|
|
25635
|
+
inputs: [
|
|
25636
|
+
{
|
|
25637
|
+
internalType: "bytes32",
|
|
25638
|
+
name: "role",
|
|
25639
|
+
type: "bytes32",
|
|
25640
|
+
},
|
|
25641
|
+
],
|
|
25642
|
+
name: "getRoleAdmin",
|
|
25643
|
+
outputs: [
|
|
25644
|
+
{
|
|
25645
|
+
internalType: "bytes32",
|
|
25646
|
+
name: "",
|
|
25647
|
+
type: "bytes32",
|
|
25648
|
+
},
|
|
25649
|
+
],
|
|
25650
|
+
stateMutability: "view",
|
|
25651
|
+
type: "function",
|
|
25652
|
+
},
|
|
25653
|
+
{
|
|
25654
|
+
inputs: [
|
|
25655
|
+
{
|
|
25656
|
+
internalType: "bytes32",
|
|
25657
|
+
name: "role",
|
|
25658
|
+
type: "bytes32",
|
|
25659
|
+
},
|
|
25660
|
+
{
|
|
25661
|
+
internalType: "address",
|
|
25662
|
+
name: "account",
|
|
25663
|
+
type: "address",
|
|
25664
|
+
},
|
|
25665
|
+
],
|
|
25666
|
+
name: "grantRole",
|
|
25667
|
+
outputs: [],
|
|
25668
|
+
stateMutability: "nonpayable",
|
|
25669
|
+
type: "function",
|
|
25670
|
+
},
|
|
25671
|
+
{
|
|
25672
|
+
inputs: [
|
|
25673
|
+
{
|
|
25674
|
+
internalType: "bytes32",
|
|
25675
|
+
name: "role",
|
|
25676
|
+
type: "bytes32",
|
|
25677
|
+
},
|
|
25678
|
+
{
|
|
25679
|
+
internalType: "address",
|
|
25680
|
+
name: "account",
|
|
25681
|
+
type: "address",
|
|
25682
|
+
},
|
|
25683
|
+
],
|
|
25684
|
+
name: "hasRole",
|
|
25685
|
+
outputs: [
|
|
25686
|
+
{
|
|
25687
|
+
internalType: "bool",
|
|
25688
|
+
name: "",
|
|
25689
|
+
type: "bool",
|
|
25690
|
+
},
|
|
25691
|
+
],
|
|
25692
|
+
stateMutability: "view",
|
|
25693
|
+
type: "function",
|
|
25694
|
+
},
|
|
25538
25695
|
{
|
|
25539
25696
|
inputs: [
|
|
25540
25697
|
{
|
|
@@ -25578,19 +25735,6 @@ const _abi$1$1 = [
|
|
|
25578
25735
|
stateMutability: "nonpayable",
|
|
25579
25736
|
type: "function",
|
|
25580
25737
|
},
|
|
25581
|
-
{
|
|
25582
|
-
inputs: [],
|
|
25583
|
-
name: "owner",
|
|
25584
|
-
outputs: [
|
|
25585
|
-
{
|
|
25586
|
-
internalType: "address",
|
|
25587
|
-
name: "",
|
|
25588
|
-
type: "address",
|
|
25589
|
-
},
|
|
25590
|
-
],
|
|
25591
|
-
stateMutability: "view",
|
|
25592
|
-
type: "function",
|
|
25593
|
-
},
|
|
25594
25738
|
{
|
|
25595
25739
|
inputs: [],
|
|
25596
25740
|
name: "pause",
|
|
@@ -25612,25 +25756,60 @@ const _abi$1$1 = [
|
|
|
25612
25756
|
type: "function",
|
|
25613
25757
|
},
|
|
25614
25758
|
{
|
|
25615
|
-
inputs: [
|
|
25616
|
-
|
|
25759
|
+
inputs: [
|
|
25760
|
+
{
|
|
25761
|
+
internalType: "bytes32",
|
|
25762
|
+
name: "role",
|
|
25763
|
+
type: "bytes32",
|
|
25764
|
+
},
|
|
25765
|
+
{
|
|
25766
|
+
internalType: "address",
|
|
25767
|
+
name: "account",
|
|
25768
|
+
type: "address",
|
|
25769
|
+
},
|
|
25770
|
+
],
|
|
25771
|
+
name: "renounceRole",
|
|
25617
25772
|
outputs: [],
|
|
25618
25773
|
stateMutability: "nonpayable",
|
|
25619
25774
|
type: "function",
|
|
25620
25775
|
},
|
|
25621
25776
|
{
|
|
25622
25777
|
inputs: [
|
|
25778
|
+
{
|
|
25779
|
+
internalType: "bytes32",
|
|
25780
|
+
name: "role",
|
|
25781
|
+
type: "bytes32",
|
|
25782
|
+
},
|
|
25623
25783
|
{
|
|
25624
25784
|
internalType: "address",
|
|
25625
|
-
name: "
|
|
25785
|
+
name: "account",
|
|
25626
25786
|
type: "address",
|
|
25627
25787
|
},
|
|
25628
25788
|
],
|
|
25629
|
-
name: "
|
|
25789
|
+
name: "revokeRole",
|
|
25630
25790
|
outputs: [],
|
|
25631
25791
|
stateMutability: "nonpayable",
|
|
25632
25792
|
type: "function",
|
|
25633
25793
|
},
|
|
25794
|
+
{
|
|
25795
|
+
inputs: [
|
|
25796
|
+
{
|
|
25797
|
+
internalType: "bytes4",
|
|
25798
|
+
name: "interfaceId",
|
|
25799
|
+
type: "bytes4",
|
|
25800
|
+
},
|
|
25801
|
+
],
|
|
25802
|
+
name: "supportsInterface",
|
|
25803
|
+
outputs: [
|
|
25804
|
+
{
|
|
25805
|
+
internalType: "bool",
|
|
25806
|
+
name: "",
|
|
25807
|
+
type: "bool",
|
|
25808
|
+
},
|
|
25809
|
+
],
|
|
25810
|
+
stateMutability: "view",
|
|
25811
|
+
type: "function",
|
|
25812
|
+
},
|
|
25634
25813
|
{
|
|
25635
25814
|
inputs: [],
|
|
25636
25815
|
name: "uniswapRouter",
|
|
@@ -25651,8 +25830,26 @@ const _abi$1$1 = [
|
|
|
25651
25830
|
stateMutability: "nonpayable",
|
|
25652
25831
|
type: "function",
|
|
25653
25832
|
},
|
|
25833
|
+
{
|
|
25834
|
+
inputs: [
|
|
25835
|
+
{
|
|
25836
|
+
internalType: "address",
|
|
25837
|
+
name: "to",
|
|
25838
|
+
type: "address",
|
|
25839
|
+
},
|
|
25840
|
+
{
|
|
25841
|
+
internalType: "address",
|
|
25842
|
+
name: "erc20",
|
|
25843
|
+
type: "address",
|
|
25844
|
+
},
|
|
25845
|
+
],
|
|
25846
|
+
name: "withdrawFunds",
|
|
25847
|
+
outputs: [],
|
|
25848
|
+
stateMutability: "nonpayable",
|
|
25849
|
+
type: "function",
|
|
25850
|
+
},
|
|
25654
25851
|
];
|
|
25655
|
-
const _bytecode$1$1 = "0x60806040523480156200001157600080fd5b5060405162002123380380620021238339810160408190526200003491620000c2565b6200003f3362000072565b6000805460ff60a01b19169055600180546001600160a01b0319166001600160a01b0392909216919091179055620000f4565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215620000d557600080fd5b81516001600160a01b0381168114620000ed57600080fd5b9392505050565b61201f80620001046000396000f3fe6080604052600436106100e85760003560e01c8063735de9f71161008a578063ac9650d811610059578063ac9650d814610243578063d9a6f70514610263578063ed921d3c14610279578063f2fde38b1461028c57600080fd5b8063735de9f7146101c5578063742ac944146101fd5780638456cb59146102105780638da5cb5b1461022557600080fd5b80633f4ba83a116100c65780633f4ba83a1461014f5780635ae401dc146101665780635c975abb14610186578063715018a6146101b057600080fd5b80631411734e146100ed57806314d90e1b146101135780631fd168ff1461013c575b600080fd5b6101006100fb366004611a14565b6102ac565b6040519081526020015b60405180910390f35b34801561011f57600080fd5b506101296103e881565b60405161ffff909116815260200161010a565b61010061014a366004611a14565b61040a565b34801561015b57600080fd5b5061016461057a565b005b610179610174366004611ac0565b61058c565b60405161010a9190611b5b565b34801561019257600080fd5b50600054600160a01b900460ff16604051901515815260200161010a565b3480156101bc57600080fd5b506101646105e2565b3480156101d157600080fd5b506001546101e5906001600160a01b031681565b6040516001600160a01b03909116815260200161010a565b61010061020b366004611c50565b6105f4565b34801561021c57600080fd5b50610164610731565b34801561023157600080fd5b506000546001600160a01b03166101e5565b34801561024f57600080fd5b5061017961025e366004611ca5565b610741565b34801561026f57600080fd5b5061012961271081565b610100610287366004611c50565b610836565b34801561029857600080fd5b506101646102a7366004611ce6565b61095e565b60208101516000906001600160a01b031633148015906102d9575060208201516001600160a01b03163014155b156102ff5760405162461bcd60e51b81526004016102f690611d03565b60405180910390fd5b600061030e83600001516109d7565b905060008061037983866040015187602001518a8a808060200260200160405190810160405280939291908181526020016000905b8282101561036f5761036060408302860136819003810190611d50565b81526020019060010190610343565b50505050506109e3565b60408088018390526001600160a01b0380831660208a0152600154915163b858183f60e01b8152939550919350169063b858183f906103bc908890600401611dfc565b6020604051808303816000875af11580156103db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ff9190611e0f565b979650505050505050565b6040810151815160009190829061042090610ac4565b9050600061043185600001516109d7565b90506000806000806104a4868a606001518b604001518c602001518f8f808060200260200160405190810160405280939291908181526020016000905b8282101561049a5761048b60408302860136819003810190611d50565b8152602001906001019061046e565b5050505050610af2565b9350935093509350838960400181815250508289602001906001600160a01b031690816001600160a01b031681525050600160009054906101000a90046001600160a01b03166001600160a01b03166309b813468a6040518263ffffffff1660e01b81526004016105159190611dfc565b6020604051808303816000875af1158015610534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105589190611e0f565b975061056c8787878c604001518587610bd3565b505050505050509392505050565b610582610e16565b61058a610e70565b565b6060834211156105d05760405162461bcd60e51b815260206004820152600f60248201526e111958591b1a5b99481c185cdcd959608a1b60448201526064016102f6565b6105da8383610741565b949350505050565b6105ea610e16565b61058a6000610ec5565b60608101516000906001600160a01b03163314801590610621575060608201516001600160a01b03163014155b1561063e5760405162461bcd60e51b81526004016102f690611d03565b6000806106a18460000151856080015186606001518989808060200260200160405190810160405280939291908181526020016000905b8282101561036f5761069260408302860136819003810190611d50565b81526020019060010190610675565b608086018290526001600160a01b0380821660608801526001546040516304e45aaf60e01b815293955091935016906304e45aaf906106e4908790600401611e28565b6020604051808303816000875af1158015610703573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107279190611e0f565b9695505050505050565b610739610e16565b61058a610f15565b6060816001600160401b0381111561075b5761075b61189c565b60405190808252806020026020018201604052801561078e57816020015b60608152602001906001900390816107795790505b50905060005b8281101561082e576107fe308585848181106107b2576107b2611e87565b90506020028101906107c49190611e9d565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f5892505050565b82828151811061081057610810611e87565b6020026020010181905250808061082690611ef9565b915050610794565b505b92915050565b600080826080015190506000806000806108ab87600001518860a0015189608001518a606001518d8d808060200260200160405190810160405280939291908181526020016000905b8282101561049a5761089c60408302860136819003810190611d50565b8152602001906001019061087f565b60808b018490526001600160a01b0380841660608d0152600154604051635023b4df60e01b815295995093975091955093501690635023b4df906108f3908a90600401611e28565b6020604051808303816000875af1158015610912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109369190611e0f565b955061095285886000015189602001518a608001518587610bd3565b50505050509392505050565b610966610e16565b6001600160a01b0381166109cb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102f6565b6109d481610ec5565b50565b60006108308282610f84565b600080548190600160a01b900460ff16610a2257600080610a048786610fe9565b9092509050610a138288611f12565b9650610a1f88826111c6565b50505b6040516323b872dd60e01b8152336004820152306024820152604481018690526001600160a01b038716906323b872dd906064016020604051808303816000875af1158015610a75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a999190611f25565b50610aa48686611341565b306001600160a01b03851603610ab8573393505b50929491935090915050565b60008060148351610ad59190611f12565b90506000610ae584836014611438565b90506105da816000610f84565b6000806060818082610b0e60005460ff600160a01b9091041690565b610b2e57610b1c8988610fe9565b9092509050610b2b828a611f47565b98505b6001600160a01b0388163014610b42573097505b610b4c8b8b611341565b6040516323b872dd60e01b8152336004820152306024820152604481018b90526001600160a01b038c16906323b872dd906064016020604051808303816000875af1158015610b9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc39190611f25565b50979a9699509697505050505050565b600054600160a01b900460ff16610bee57610bee8482611545565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015610c35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c599190611e0f565b9050610c658385611f12565b811015610cb45760405162461bcd60e51b815260206004820181905260248201527f696e636f72726563742066656520616d6f756e7420646973747269627574656460448201526064016102f6565b60405163a9059cbb60e01b8152336004820152602481018890526001600160a01b0386169063a9059cbb906044016020604051808303816000875af1158015610d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d259190611f25565b506040516370a0823160e01b81523060048201526000906001600160a01b038816906370a0823190602401602060405180830381865afa158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d919190611e0f565b90508015610e0c5760405163a9059cbb60e01b8152336004820152602481018290526001600160a01b0388169063a9059cbb906044016020604051808303816000875af1158015610de6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0a9190611f25565b505b5050505050505050565b6000546001600160a01b0316331461058a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102f6565b610e786116b4565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610f1d611704565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610ea83390565b6060610f7d8383604051806060016040528060278152602001611fc360279139611751565b9392505050565b6000610f91826014611f47565b83511015610fd95760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b60448201526064016102f6565b500160200151600160601b900490565b6000606081805b845181101561103a5784818151811061100b5761100b611e87565b60200260200101516020015161ffff16826110269190611f47565b91508061103281611ef9565b915050610ff0565b506103e881111561108d5760405162461bcd60e51b815260206004820152601d60248201527f5365727669636520666565203e204d41585f534552564943455f46454500000060448201526064016102f6565b60008085516001600160401b038111156110a9576110a961189c565b6040519080825280602002602001820160405280156110ee57816020015b60408051808201909152600080825260208201528152602001906001900390816110c75790505b50905060005b86518110156111b757600061271061ffff1688838151811061111857611118611e87565b60200260200101516020015161ffff168a6111339190611f5a565b61113d9190611f71565b9050604051806040016040528089848151811061115c5761115c611e87565b6020026020010151600001516001600160a01b031681526020018281525083838151811061118c5761118c611e87565b60209081029190910101526111a18185611f47565b93505080806111af90611ef9565b9150506110f4565b509093509150505b9250929050565b60005b815181101561133c57826001600160a01b03166323b872dd338484815181106111f4576111f4611e87565b60200260200101516000015185858151811061121257611212611e87565b60209081029190910181015101516040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611274573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112989190611f25565b508181815181106112ab576112ab611e87565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061130757611307611e87565b60200260200101516020015160405161132291815260200190565b60405180910390a48061133481611ef9565b9150506111c9565b505050565b600154604051636eb1769f60e11b81523060048201526001600160a01b039182166024820152829184169063dd62ed3e90604401602060405180830381865afa158015611392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b69190611e0f565b10156114345760015460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529083169063095ea7b3906044016020604051808303816000875af1158015611410573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133c9190611f25565b5050565b60608161144681601f611f47565b10156114855760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b60448201526064016102f6565b61148f8284611f47565b845110156114d35760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b60448201526064016102f6565b6060821580156114f2576040519150600082526020820160405261153c565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561152b578051835260209283019201611513565b5050858452601f01601f1916604052505b50949350505050565b60005b815181101561133c57826001600160a01b031663a9059cbb83838151811061157257611572611e87565b60200260200101516000015184848151811061159057611590611e87565b6020026020010151602001516040518363ffffffff1660e01b81526004016115cd9291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af11580156115ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116109190611f25565b5081818151811061162357611623611e87565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061167f5761167f611e87565b60200260200101516020015160405161169a91815260200190565b60405180910390a4806116ac81611ef9565b915050611548565b600054600160a01b900460ff1661058a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016102f6565b600054600160a01b900460ff161561058a5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016102f6565b6060600080856001600160a01b03168560405161176e9190611f93565b600060405180830381855af49150503d80600081146117a9576040519150601f19603f3d011682016040523d82523d6000602084013e6117ae565b606091505b50915091506107278683838760608315611829578251600003611822576001600160a01b0385163b6118225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102f6565b50816105da565b6105da838381511561183e5781518083602001fd5b8060405162461bcd60e51b81526004016102f69190611faf565b60008083601f84011261186a57600080fd5b5081356001600160401b0381111561188157600080fd5b6020830191508360208260061b85010111156111bf57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156118d4576118d461189c565b60405290565b60405160e081016001600160401b03811182821017156118d4576118d461189c565b604051601f8201601f191681016001600160401b03811182821017156119245761192461189c565b604052919050565b6001600160a01b03811681146109d457600080fd5b803561194c8161192c565b919050565b60006080828403121561196357600080fd5b61196b6118b2565b905081356001600160401b038082111561198457600080fd5b818401915084601f83011261199857600080fd5b81356020828211156119ac576119ac61189c565b6119be601f8301601f191682016118fc565b925081835286818386010111156119d457600080fd5b818185018285013760008183850101528285526119f2818701611941565b8186015250505050604082013560408201526060820135606082015292915050565b600080600060408486031215611a2957600080fd5b83356001600160401b0380821115611a4057600080fd5b611a4c87838801611858565b90955093506020860135915080821115611a6557600080fd5b50611a7286828701611951565b9150509250925092565b60008083601f840112611a8e57600080fd5b5081356001600160401b03811115611aa557600080fd5b6020830191508360208260051b85010111156111bf57600080fd5b600080600060408486031215611ad557600080fd5b8335925060208401356001600160401b03811115611af257600080fd5b611afe86828701611a7c565b9497909650939450505050565b60005b83811015611b26578181015183820152602001611b0e565b50506000910152565b60008151808452611b47816020860160208601611b0b565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015611bb057603f19888603018452611b9e858351611b2f565b94509285019290850190600101611b82565b5092979650505050505050565b600060e08284031215611bcf57600080fd5b611bd76118da565b90508135611be48161192c565b81526020820135611bf48161192c565b6020820152604082013562ffffff81168114611c0f57600080fd5b6040820152611c2060608301611941565b60608201526080820135608082015260a082013560a0820152611c4560c08301611941565b60c082015292915050565b60008060006101008486031215611c6657600080fd5b83356001600160401b03811115611c7c57600080fd5b611c8886828701611858565b9094509250611c9c90508560208601611bbd565b90509250925092565b60008060208385031215611cb857600080fd5b82356001600160401b03811115611cce57600080fd5b611cda85828601611a7c565b90969095509350505050565b600060208284031215611cf857600080fd5b8135610f7d8161192c565b6020808252602d908201527f726563697069656e74206d757374206265206d73672e73656e646572206f722060408201526c1d1a1a5cc818dbdb9d1c9858dd609a1b606082015260800190565b600060408284031215611d6257600080fd5b604051604081018181106001600160401b0382111715611d8457611d8461189c565b6040528235611d928161192c565b8152602083013561ffff81168114611da957600080fd5b60208201529392505050565b6000815160808452611dca6080850182611b2f565b6020848101516001600160a01b0316908601526040808501519086015260609384015193909401929092525090919050565b602081526000610f7d6020830184611db5565b600060208284031215611e2157600080fd5b5051919050565b60e08101610830828480516001600160a01b03908116835260208083015182169084015260408083015162ffffff16908401526060808301518216908401526080808301519084015260a0828101519084015260c09182015116910152565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611eb457600080fd5b8301803591506001600160401b03821115611ece57600080fd5b6020019150368190038213156111bf57600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611f0b57611f0b611ee3565b5060010190565b8181038181111561083057610830611ee3565b600060208284031215611f3757600080fd5b81518015158114610f7d57600080fd5b8082018082111561083057610830611ee3565b808202811582820484141761083057610830611ee3565b600082611f8e57634e487b7160e01b600052601260045260246000fd5b500490565b60008251611fa5818460208701611b0b565b9190910192915050565b602081526000610f7d6020830184611b2f56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203925f97cd63c2e61736a2a442ff1d4bf966f453350e9df354a849229f69092cf64736f6c63430008130033";
|
|
25852
|
+
const _bytecode$1$1 = "0x60806040523480156200001157600080fd5b506040516200278438038062002784833981016040819052620000349162000136565b6001805460ff191690556200004b60008362000078565b600180546001600160a01b0390921661010002610100600160a81b0319909216919091179055506200016e565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000115576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620000d43390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b80516001600160a01b03811681146200013157600080fd5b919050565b600080604083850312156200014a57600080fd5b620001558362000119565b9150620001656020840162000119565b90509250929050565b612606806200017e6000396000f3fe60806040526004361061013f5760003560e01c80635ae401dc116100b657806393751f631161006f57806393751f631461038c578063a217fddf146103b5578063ac9650d8146103ca578063d547741f146103ea578063d9a6f7051461040a578063e65fad971461042057600080fd5b80635ae401dc146102ae5780635c975abb146102ce578063735de9f7146102e65780638456cb59146103235780638f3914661461033857806391d148541461036c57600080fd5b80632f2ff15d116101085780632f2ff15d1461022057806336568abe14610240578063383ebb0b146102605780633f4ba83a146102735780635640f6591461028857806358e81a501461029b57600080fd5b80620fa9fb1461014457806301ffc9a714610166578063116944b21461019b57806316ba7197146101bc578063248a9ca3146101f0575b600080fd5b34801561015057600080fd5b5061016461015f366004611db4565b610454565b005b34801561017257600080fd5b50610186610181366004611ded565b61050d565b60405190151581526020015b60405180910390f35b6101ae6101a9366004611f85565b610544565b604051908152602001610192565b3480156101c857600080fd5b506101ae7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e98286981565b3480156101fc57600080fd5b506101ae61020b366004611fda565b60009081526020819052604090206001015490565b34801561022c57600080fd5b5061016461023b366004611ff3565b610634565b34801561024c57600080fd5b5061016461025b366004611ff3565b610659565b6101ae61026e3660046120db565b6106dc565b34801561027f57600080fd5b5061016461084c565b6101ae6102963660046120db565b610889565b6101ae6102a9366004611f85565b61097f565b6102c16102bc366004612187565b610ad0565b6040516101929190612222565b3480156102da57600080fd5b5060015460ff16610186565b3480156102f257600080fd5b5060015461030b9061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610192565b34801561032f57600080fd5b50610164610b1e565b34801561034457600080fd5b506101ae7fe7276a2a84d8de556657ec9cf93a55a7d66f096e529d0582ed08e9e2208b92b581565b34801561037857600080fd5b50610186610387366004611ff3565b610b59565b34801561039857600080fd5b506103a26103e881565b60405161ffff9091168152602001610192565b3480156103c157600080fd5b506101ae600081565b3480156103d657600080fd5b506102c16103e5366004612284565b610b82565b3480156103f657600080fd5b50610164610405366004611ff3565b610c76565b34801561041657600080fd5b506101ae61271081565b34801561042c57600080fd5b506101ae7ffcb9fcbfa83b897fb2d5cf4b58962164105c1e71489a37ef3ae0db3fdce576f681565b61047e7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e98286933610b59565b61048757600080fd5b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156104ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f291906122c5565b90506105086001600160a01b0383168483610c9b565b505050565b60006001600160e01b03198216637965db0b60e01b148061053e57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006105b08260000151836080015184606001518787808060200260200160405190810160405280939291908181526020016000905b828210156105a657610597604083028601368190038101906122de565b8152602001906001019061057a565b5050505050610cfe565b60808301526001546040516304e45aaf60e01b81526101009091046001600160a01b0316906304e45aaf906105e9908590600401612335565b6020604051808303816000875af1158015610608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062c91906122c5565b949350505050565b60008281526020819052604090206001015461064f81610dbf565b6105088383610dcc565b6001600160a01b03811633146106ce5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6106d88282610e50565b5050565b6000806106ec8360000151610eb5565b905060008061075783866060015187602001518a8a808060200260200160405190810160405280939291908181526020016000905b8282101561074d5761073e604083028601368190038101906122de565b81526020019060010190610721565b5050505050610ee3565b606087018190526001546040516304dc09a360e11b81529294509092506000916101009091046001600160a01b0316906309b813469061079b9089906004016123db565b6020604051808303816000875af11580156107ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107de91906122c5565b905061083e8482858b8b808060200260200160405190810160405280939291908181526020016000905b8282101561083457610825604083028601368190038101906122de565b81526020019060010190610808565b5050505050610f96565b9450505050505b9392505050565b6108767fe7276a2a84d8de556657ec9cf93a55a7d66f096e529d0582ed08e9e2208b92b533610b59565b61087f57600080fd5b610887610ff7565b565b6000806108998360000151611049565b90506108f781846040015185602001518888808060200260200160405190810160405280939291908181526020016000905b828210156105a6576108e8604083028601368190038101906122de565b815260200190600101906108cb565b604084810191909152600154905163b858183f60e01b81526101009091046001600160a01b03169063b858183f906109339086906004016123db565b6020604051808303816000875af1158015610952573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097691906122c5565b95945050505050565b60008060006109e484600001518560a0015186606001518989808060200260200160405190810160405280939291908181526020016000905b8282101561074d576109d5604083028601368190038101906122de565b815260200190600101906109b8565b60a08601819052600154604051635023b4df60e01b81529294509092506000916101009091046001600160a01b031690635023b4df90610a28908890600401612335565b6020604051808303816000875af1158015610a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6b91906122c5565b9050610ac5856000015182858a8a808060200260200160405190810160405280939291908181526020016000905b8282101561083457610ab6604083028601368190038101906122de565b81526020019060010190610a99565b979650505050505050565b606083421115610b145760405162461bcd60e51b815260206004820152600f60248201526e111958591b1a5b99481c185cdcd959608a1b60448201526064016106c5565b61062c8383610b82565b610b487ffcb9fcbfa83b897fb2d5cf4b58962164105c1e71489a37ef3ae0db3fdce576f633610b59565b610b5157600080fd5b610887611055565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060816001600160401b03811115610b9c57610b9c611e62565b604051908082528060200260200182016040528015610bcf57816020015b6060815260200190600190039081610bba5790505b50905060005b82811015610c6f57610c3f30858584818110610bf357610bf36123ee565b9050602002810190610c059190612404565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061109092505050565b828281518110610c5157610c516123ee565b60200260200101819052508080610c6790612460565b915050610bd5565b5092915050565b600082815260208190526040902060010154610c9181610dbf565b6105088383610e50565b6040516001600160a01b03831660248201526044810182905261050890849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526110b5565b60006001600160a01b0383163314610d585760405162461bcd60e51b815260206004820181905260248201527f73776170526563697069656e74206d757374206265206d73672e73656e64657260448201526064016106c5565b60015460ff16610d9757610d6b8261118a565b50600080610d79868561123d565b9092509050610d888287612479565b9550610d948782611366565b50505b610dac6001600160a01b03861633308761146f565b610db685856114ad565b50919392505050565b610dc981336115aa565b50565b610dd68282610b59565b6106d8576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610e0c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610e5a8282610b59565b156106d8576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008060148351610ec69190612479565b90506000610ed684836014611603565b905061062c816000611710565b6000806001600160a01b0384163314610f3e5760405162461bcd60e51b815260206004820181905260248201527f73776170526563697069656e74206d757374206265206d73672e73656e64657260448201526064016106c5565b6000610f498461118a565b90506000610f598261271061248c565b9050610f688761271083611775565b9250610f7488846114ad565b610f896001600160a01b03891633308a61146f565b5094969095509350505050565b6000806000610fa5868561123d565b91509150610fb560015460ff1690565b610fc357610fc387826117b5565b610fed3383610fd28989612479565b610fdc9190612479565b6001600160a01b038a169190610c9b565b610ac5828761248c565b610fff6118bc565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600061053e8282611710565b61105d611905565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583361102c565b606061084583836040518060600160405280602781526020016125aa6027913961194b565b600061110a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166119c39092919063ffffffff16565b905080516000148061112b57508080602001905181019061112b919061249f565b6105085760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106c5565b6000805b82518110156111d4578281815181106111a9576111a96123ee565b602002602001015160200151826111c0919061248c565b9150806111cc81612460565b91505061118e565b506103e88111156112385760405162461bcd60e51b815260206004820152602860248201527f5365636f6e6461727920666565203e204645455f42415349535f504f494e54536044820152675f4d4158494d554d60c01b60648201526084016106c5565b919050565b6000606082516001600160401b0381111561125a5761125a611e62565b60405190808252806020026020018201604052801561129f57816020015b60408051808201909152600080825260208201528152602001906001900390816112785790505b50905060005b835181101561135e5760006112e48583815181106112c5576112c56123ee565b602002602001015160200151612710886119d29092919063ffffffff16565b90506040518060400160405280868481518110611303576113036123ee565b6020026020010151600001516001600160a01b0316815260200182815250838381518110611333576113336123ee565b6020908102919091010152611348818561248c565b935050808061135690612460565b9150506112a5565b509250929050565b60005b8151811015610508576113cc33838381518110611388576113886123ee565b6020026020010151600001518484815181106113a6576113a66123ee565b602002602001015160200151866001600160a01b031661146f909392919063ffffffff16565b8181815181106113de576113de6123ee565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061143a5761143a6123ee565b60200260200101516020015160405161145591815260200190565b60405180910390a48061146781612460565b915050611369565b6040516001600160a01b03808516602483015283166044820152606481018290526114a79085906323b872dd60e01b90608401610cc7565b50505050565b600154604051636eb1769f60e11b81523060048201526001600160a01b0361010090920482166024820152829184169063dd62ed3e90604401602060405180830381865afa158015611503573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152791906122c5565b10156106d85760015460405163095ea7b360e01b81526101009091046001600160a01b039081166004830152600019602483015283169063095ea7b3906044016020604051808303816000875af1158015611586573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610508919061249f565b6115b48282610b59565b6106d8576115c181611a74565b6115cc836020611a86565b6040516020016115dd9291906124c1565b60408051601f198184030181529082905262461bcd60e51b82526106c591600401612536565b60608161161181601f61248c565b10156116505760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b60448201526064016106c5565b61165a828461248c565b8451101561169e5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b60448201526064016106c5565b6060821580156116bd5760405191506000825260208201604052611707565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156116f65780518352602092830192016116de565b5050858452601f01601f1916604052505b50949350505050565b600061171d82601461248c565b835110156117655760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b60448201526064016106c5565b500160200151600160601b900490565b60006117828484846119d2565b90506000828061179457611794612549565b84860911156108455760001981106117ab57600080fd5b6001019392505050565b60005b8151811015610508576118198282815181106117d6576117d66123ee565b6020026020010151600001518383815181106117f4576117f46123ee565b602002602001015160200151856001600160a01b0316610c9b9092919063ffffffff16565b81818151811061182b5761182b6123ee565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e858581518110611887576118876123ee565b6020026020010151602001516040516118a291815260200190565b60405180910390a4806118b481612460565b9150506117b8565b60015460ff166108875760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106c5565b60015460ff16156108875760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106c5565b6060600080856001600160a01b031685604051611968919061255f565b600060405180830381855af49150503d80600081146119a3576040519150601f19603f3d011682016040523d82523d6000602084013e6119a8565b606091505b50915091506119b986838387611c21565b9695505050505050565b606061062c8484600085611c9a565b600083830281600019858709828110838203039150508084116119f457600080fd5b80600003611a0757508290049050610845565b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b606061053e6001600160a01b03831660145b60606000611a9583600261257b565b611aa090600261248c565b6001600160401b03811115611ab757611ab7611e62565b6040519080825280601f01601f191660200182016040528015611ae1576020820181803683370190505b509050600360fc1b81600081518110611afc57611afc6123ee565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611b2b57611b2b6123ee565b60200101906001600160f81b031916908160001a9053506000611b4f84600261257b565b611b5a90600161248c565b90505b6001811115611bd2576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611b8e57611b8e6123ee565b1a60f81b828281518110611ba457611ba46123ee565b60200101906001600160f81b031916908160001a90535060049490941c93611bcb81612592565b9050611b5d565b5083156108455760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016106c5565b60608315611c90578251600003611c89576001600160a01b0385163b611c895760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106c5565b508161062c565b61062c8383611d6a565b606082471015611cfb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106c5565b600080866001600160a01b03168587604051611d17919061255f565b60006040518083038185875af1925050503d8060008114611d54576040519150601f19603f3d011682016040523d82523d6000602084013e611d59565b606091505b5091509150610ac587838387611c21565b815115611d7a5781518083602001fd5b8060405162461bcd60e51b81526004016106c59190612536565b6001600160a01b0381168114610dc957600080fd5b803561123881611d94565b60008060408385031215611dc757600080fd5b8235611dd281611d94565b91506020830135611de281611d94565b809150509250929050565b600060208284031215611dff57600080fd5b81356001600160e01b03198116811461084557600080fd5b60008083601f840112611e2957600080fd5b5081356001600160401b03811115611e4057600080fd5b6020830191508360208260061b8501011115611e5b57600080fd5b9250929050565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b0381118282101715611e9a57611e9a611e62565b60405290565b604051608081016001600160401b0381118282101715611e9a57611e9a611e62565b604051601f8201601f191681016001600160401b0381118282101715611eea57611eea611e62565b604052919050565b600060e08284031215611f0457600080fd5b611f0c611e78565b90508135611f1981611d94565b81526020820135611f2981611d94565b6020820152604082013562ffffff81168114611f4457600080fd5b6040820152611f5560608301611da9565b60608201526080820135608082015260a082013560a0820152611f7a60c08301611da9565b60c082015292915050565b60008060006101008486031215611f9b57600080fd5b83356001600160401b03811115611fb157600080fd5b611fbd86828701611e17565b9094509250611fd190508560208601611ef2565b90509250925092565b600060208284031215611fec57600080fd5b5035919050565b6000806040838503121561200657600080fd5b823591506020830135611de281611d94565b60006080828403121561202a57600080fd5b612032611ea0565b905081356001600160401b038082111561204b57600080fd5b818401915084601f83011261205f57600080fd5b813560208282111561207357612073611e62565b612085601f8301601f19168201611ec2565b9250818352868183860101111561209b57600080fd5b818185018285013760008183850101528285526120b9818701611da9565b8186015250505050604082013560408201526060820135606082015292915050565b6000806000604084860312156120f057600080fd5b83356001600160401b038082111561210757600080fd5b61211387838801611e17565b9095509350602086013591508082111561212c57600080fd5b5061213986828701612018565b9150509250925092565b60008083601f84011261215557600080fd5b5081356001600160401b0381111561216c57600080fd5b6020830191508360208260051b8501011115611e5b57600080fd5b60008060006040848603121561219c57600080fd5b8335925060208401356001600160401b038111156121b957600080fd5b6121c586828701612143565b9497909650939450505050565b60005b838110156121ed5781810151838201526020016121d5565b50506000910152565b6000815180845261220e8160208601602086016121d2565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561227757603f198886030184526122658583516121f6565b94509285019290850190600101612249565b5092979650505050505050565b6000806020838503121561229757600080fd5b82356001600160401b038111156122ad57600080fd5b6122b985828601612143565b90969095509350505050565b6000602082840312156122d757600080fd5b5051919050565b6000604082840312156122f057600080fd5b604051604081018181106001600160401b038211171561231257612312611e62565b604052823561232081611d94565b81526020928301359281019290925250919050565b60e0810161053e828480516001600160a01b03908116835260208083015182169084015260408083015162ffffff16908401526060808301518216908401526080808301519084015260a0828101519084015260c09182015116910152565b60008151608084526123a960808501826121f6565b6020848101516001600160a01b0316908601526040808501519086015260609384015193909401929092525090919050565b6020815260006108456020830184612394565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261241b57600080fd5b8301803591506001600160401b0382111561243557600080fd5b602001915036819003821315611e5b57600080fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016124725761247261244a565b5060010190565b8181038181111561053e5761053e61244a565b8082018082111561053e5761053e61244a565b6000602082840312156124b157600080fd5b8151801515811461084557600080fd5b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516124f98160178501602088016121d2565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161252a8160288401602088016121d2565b01602801949350505050565b60208152600061084560208301846121f6565b634e487b7160e01b600052601260045260246000fd5b600082516125718184602087016121d2565b9190910192915050565b808202811582820484141761053e5761053e61244a565b6000816125a1576125a161244a565b50600019019056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220c75a7db1b170ff1ce6888f2940825a25db3ebb624d8b84bd3f2372ebae2de1d464736f6c63430008130033";
|
|
25656
25853
|
const isSuperArgs$1$1 = (xs) => xs.length > 1;
|
|
25657
25854
|
class SecondaryFee__factory extends ethers.ContractFactory {
|
|
25658
25855
|
constructor(...args) {
|
|
@@ -25663,11 +25860,11 @@ class SecondaryFee__factory extends ethers.ContractFactory {
|
|
|
25663
25860
|
super(_abi$1$1, _bytecode$1$1, args[0]);
|
|
25664
25861
|
}
|
|
25665
25862
|
}
|
|
25666
|
-
deploy(_uniRouter, overrides) {
|
|
25667
|
-
return super.deploy(_uniRouter, overrides || {});
|
|
25863
|
+
deploy(_admin, _uniRouter, overrides) {
|
|
25864
|
+
return super.deploy(_admin, _uniRouter, overrides || {});
|
|
25668
25865
|
}
|
|
25669
|
-
getDeployTransaction(_uniRouter, overrides) {
|
|
25670
|
-
return super.getDeployTransaction(_uniRouter, overrides || {});
|
|
25866
|
+
getDeployTransaction(_admin, _uniRouter, overrides) {
|
|
25867
|
+
return super.getDeployTransaction(_admin, _uniRouter, overrides || {});
|
|
25671
25868
|
}
|
|
25672
25869
|
attach(address) {
|
|
25673
25870
|
return super.attach(address);
|
|
@@ -26753,10 +26950,87 @@ const getCallData = (methodName, contractInterface) => {
|
|
|
26753
26950
|
return fragment ? contractInterface?.encodeFunctionData(fragment) : undefined;
|
|
26754
26951
|
};
|
|
26755
26952
|
|
|
26953
|
+
const quoteReturnMapping = {
|
|
26954
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26955
|
+
'0xcdca1753': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
|
|
26956
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26957
|
+
'0xc6a5026a': ['uint256', 'uint160', 'uint32', 'uint256'],
|
|
26958
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26959
|
+
'0x2f80bb1d': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
|
|
26960
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26961
|
+
'0xbd21704a': ['uint256', 'uint160', 'uint32', 'uint256'],
|
|
26962
|
+
};
|
|
26963
|
+
/**
|
|
26964
|
+
* Returns true if poolA is equivalent to poolB
|
|
26965
|
+
* @param poolA one of the two pools
|
|
26966
|
+
* @param poolB the other pool
|
|
26967
|
+
*/
|
|
26968
|
+
function poolEquals(poolA, poolB) {
|
|
26969
|
+
return (poolA === poolB
|
|
26970
|
+
|| (poolA.token0.equals(poolB.token0)
|
|
26971
|
+
&& poolA.token1.equals(poolB.token1)
|
|
26972
|
+
&& poolA.fee === poolB.fee));
|
|
26973
|
+
}
|
|
26974
|
+
async function getERC20Decimals(tokenAddress, provider) {
|
|
26975
|
+
const decimalsFunctionSig = ethers.ethers.utils.id('decimals()').substring(0, 10);
|
|
26976
|
+
try {
|
|
26977
|
+
const decimalsResult = await provider.call({
|
|
26978
|
+
to: tokenAddress,
|
|
26979
|
+
data: decimalsFunctionSig,
|
|
26980
|
+
});
|
|
26981
|
+
return parseInt(decimalsResult, 16);
|
|
26982
|
+
}
|
|
26983
|
+
catch (e) {
|
|
26984
|
+
const message = e instanceof Error ? e.message : 'Unknown Error';
|
|
26985
|
+
throw new ProviderCallError(`failed to get ERC20 decimals: ${message}`);
|
|
26986
|
+
}
|
|
26987
|
+
}
|
|
26988
|
+
/**
|
|
26989
|
+
* Based on https://github.com/ethers-io/ethers.js/blob/main/src.ts/address/checks.ts#L51
|
|
26990
|
+
*/
|
|
26991
|
+
function isValidNonZeroAddress(address) {
|
|
26992
|
+
if (address === ethers.ethers.constants.AddressZero) {
|
|
26993
|
+
return false;
|
|
26994
|
+
}
|
|
26995
|
+
try {
|
|
26996
|
+
ethers.ethers.utils.getAddress(address);
|
|
26997
|
+
return true;
|
|
26998
|
+
}
|
|
26999
|
+
catch (error) {
|
|
27000
|
+
return false;
|
|
27001
|
+
}
|
|
27002
|
+
}
|
|
27003
|
+
const tokenInfoToUniswapToken = (tokenInfo) => new sdkCore.Token(tokenInfo.chainId, tokenInfo.address, tokenInfo.decimals, tokenInfo.symbol, tokenInfo.name);
|
|
27004
|
+
const uniswapTokenToTokenInfo = (token) => ({
|
|
27005
|
+
chainId: token.chainId,
|
|
27006
|
+
address: token.address,
|
|
27007
|
+
decimals: token.decimals,
|
|
27008
|
+
symbol: token.symbol,
|
|
27009
|
+
name: token.name,
|
|
27010
|
+
});
|
|
27011
|
+
const toCurrencyAmount = (amount) => {
|
|
27012
|
+
const token = tokenInfoToUniswapToken(amount.token);
|
|
27013
|
+
return sdkCore.CurrencyAmount.fromRawAmount(token, amount.value.toString());
|
|
27014
|
+
};
|
|
27015
|
+
const newAmount = (amount, token) => ({
|
|
27016
|
+
value: amount,
|
|
27017
|
+
token,
|
|
27018
|
+
});
|
|
27019
|
+
const addAmount = (a, b) => {
|
|
27020
|
+
if (a.token.address !== b.token.address)
|
|
27021
|
+
throw new Error('Token mismatch');
|
|
27022
|
+
return { value: a.value.add(b.value), token: a.token };
|
|
27023
|
+
};
|
|
27024
|
+
const subtractAmount = (a, b) => {
|
|
27025
|
+
if (a.token.address !== b.token.address)
|
|
27026
|
+
throw new Error('Token mismatch');
|
|
27027
|
+
return { value: a.value.sub(b.value), token: a.token };
|
|
27028
|
+
};
|
|
27029
|
+
|
|
26756
27030
|
const amountIndex = 0;
|
|
26757
27031
|
const gasEstimateIndex = 3;
|
|
26758
27032
|
async function getQuotesForRoutes(multicallContract, quoterContractAddress, routes, amountSpecified, tradeType) {
|
|
26759
|
-
const callData = routes.map((route) => v3Sdk.SwapQuoter.quoteCallParameters(route, amountSpecified, tradeType, {
|
|
27033
|
+
const callData = routes.map((route) => v3Sdk.SwapQuoter.quoteCallParameters(route, toCurrencyAmount(amountSpecified), tradeType, {
|
|
26760
27034
|
useQuoterV2: true,
|
|
26761
27035
|
}).calldata);
|
|
26762
27036
|
let quoteResults;
|
|
@@ -26782,27 +27056,26 @@ async function getQuotesForRoutes(multicallContract, quoterContractAddress, rout
|
|
|
26782
27056
|
// eslint-disable-next-line no-continue
|
|
26783
27057
|
continue;
|
|
26784
27058
|
}
|
|
26785
|
-
let decodedQuoteResult;
|
|
26786
27059
|
try {
|
|
26787
|
-
decodedQuoteResult = ethers.ethers.utils.defaultAbiCoder.decode(returnTypes, quoteResults.returnData[i].returnData);
|
|
27060
|
+
const decodedQuoteResult = ethers.ethers.utils.defaultAbiCoder.decode(returnTypes, quoteResults.returnData[i].returnData);
|
|
27061
|
+
if (decodedQuoteResult) {
|
|
27062
|
+
// The 0th element in each decoded data is going to be the amountOut or amountIn.
|
|
27063
|
+
const quoteAmount = decodedQuoteResult[amountIndex];
|
|
27064
|
+
if (!(quoteAmount instanceof ethers.BigNumber))
|
|
27065
|
+
throw new Error('Expected BigNumber');
|
|
27066
|
+
decodedQuoteResults.push({
|
|
27067
|
+
route: routes[i],
|
|
27068
|
+
amountIn: tradeType === sdkCore.TradeType.EXACT_INPUT ? amountSpecified : newAmount(quoteAmount, routes[i].input),
|
|
27069
|
+
amountOut: tradeType === sdkCore.TradeType.EXACT_INPUT ? newAmount(quoteAmount, routes[i].output) : amountSpecified,
|
|
27070
|
+
gasEstimate: ethers.ethers.BigNumber.from(decodedQuoteResult[gasEstimateIndex]),
|
|
27071
|
+
});
|
|
27072
|
+
}
|
|
26788
27073
|
}
|
|
26789
27074
|
catch {
|
|
26790
27075
|
// Failed to get the quote for this particular route
|
|
26791
27076
|
// Other quotes for routes may still succeed, so do nothing
|
|
26792
27077
|
// and continue processing
|
|
26793
27078
|
}
|
|
26794
|
-
// TODO: ideally this is already a big number as we don't need a CurrencyAmount at this level
|
|
26795
|
-
const amountSpecifiedBigNumber = toBigNumber(amountSpecified);
|
|
26796
|
-
if (decodedQuoteResult) {
|
|
26797
|
-
// The 0th element in each decoded data is going to be the amountOut or amountIn.
|
|
26798
|
-
const quoteAmount = decodedQuoteResult[amountIndex];
|
|
26799
|
-
decodedQuoteResults.push({
|
|
26800
|
-
route: routes[i],
|
|
26801
|
-
amountIn: tradeType === sdkCore.TradeType.EXACT_INPUT ? amountSpecifiedBigNumber : quoteAmount,
|
|
26802
|
-
amountOut: tradeType === sdkCore.TradeType.EXACT_INPUT ? quoteAmount : amountSpecifiedBigNumber,
|
|
26803
|
-
gasEstimate: ethers.ethers.BigNumber.from(decodedQuoteResult[gasEstimateIndex]),
|
|
26804
|
-
});
|
|
26805
|
-
}
|
|
26806
27079
|
}
|
|
26807
27080
|
return decodedQuoteResults;
|
|
26808
27081
|
}
|
|
@@ -26938,10 +27211,10 @@ class Router {
|
|
|
26938
27211
|
this.routingTokens = routingTokens;
|
|
26939
27212
|
this.routingContracts = routingContracts;
|
|
26940
27213
|
}
|
|
26941
|
-
async findOptimalRoute(amountSpecified,
|
|
26942
|
-
const [
|
|
27214
|
+
async findOptimalRoute(amountSpecified, otherToken, tradeType, maxHops = 2) {
|
|
27215
|
+
const [tokenIn, tokenOut] = this.determineERC20InAndERC20Out(tradeType, amountSpecified, otherToken);
|
|
26943
27216
|
const multicallContract = Multicall__factory.connect(this.routingContracts.multicallAddress, this.provider);
|
|
26944
|
-
const erc20Pair = [
|
|
27217
|
+
const erc20Pair = [tokenIn, tokenOut];
|
|
26945
27218
|
// Get all pools and use these to get all possible routes.
|
|
26946
27219
|
const pools = await fetchValidPools(multicallContract, erc20Pair, this.routingTokens, this.routingContracts.factoryAddress);
|
|
26947
27220
|
const noValidPools = pools.length === 0;
|
|
@@ -26951,7 +27224,7 @@ class Router {
|
|
|
26951
27224
|
// Get all the possible routes from the given pools
|
|
26952
27225
|
// TODO: Fix used before defined error
|
|
26953
27226
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
26954
|
-
const routes = generateAllAcyclicPaths(
|
|
27227
|
+
const routes = generateAllAcyclicPaths(tokenIn, tokenOut, pools, maxHops, [], [], tokenIn);
|
|
26955
27228
|
const noValidRoute = routes.length === 0;
|
|
26956
27229
|
if (noValidRoute) {
|
|
26957
27230
|
throw new NoRoutesAvailableError();
|
|
@@ -26961,9 +27234,7 @@ class Router {
|
|
|
26961
27234
|
return {
|
|
26962
27235
|
route,
|
|
26963
27236
|
amountIn,
|
|
26964
|
-
tokenIn: currencyIn,
|
|
26965
27237
|
amountOut,
|
|
26966
|
-
tokenOut: currencyOut,
|
|
26967
27238
|
tradeType,
|
|
26968
27239
|
gasEstimate,
|
|
26969
27240
|
};
|
|
@@ -26999,7 +27270,7 @@ class Router {
|
|
|
26999
27270
|
bestQuoteForAmountIn(quotes) {
|
|
27000
27271
|
let bestQuote = quotes[0];
|
|
27001
27272
|
for (let i = 1; i < quotes.length; i++) {
|
|
27002
|
-
if (quotes[i].amountOut.gt(bestQuote.amountOut)) {
|
|
27273
|
+
if (quotes[i].amountOut.value.gt(bestQuote.amountOut.value)) {
|
|
27003
27274
|
bestQuote = quotes[i];
|
|
27004
27275
|
}
|
|
27005
27276
|
}
|
|
@@ -27009,48 +27280,49 @@ class Router {
|
|
|
27009
27280
|
bestQuoteForAmountOut(quotes) {
|
|
27010
27281
|
let bestQuote = quotes[0];
|
|
27011
27282
|
for (let i = 1; i < quotes.length; i++) {
|
|
27012
|
-
if (quotes[i].amountIn.lt(bestQuote.amountIn)) {
|
|
27283
|
+
if (quotes[i].amountIn.value.lt(bestQuote.amountIn.value)) {
|
|
27013
27284
|
bestQuote = quotes[i];
|
|
27014
27285
|
}
|
|
27015
27286
|
}
|
|
27016
27287
|
return bestQuote;
|
|
27017
27288
|
}
|
|
27018
27289
|
// eslint-disable-next-line class-methods-use-this
|
|
27019
|
-
determineERC20InAndERC20Out(tradeType, amountSpecified,
|
|
27290
|
+
determineERC20InAndERC20Out(tradeType, amountSpecified, otherToken) {
|
|
27020
27291
|
// If the trade type is EXACT INPUT then we have specified the amount for the tokenIn
|
|
27021
27292
|
return tradeType === sdkCore.TradeType.EXACT_INPUT
|
|
27022
|
-
? [amountSpecified
|
|
27023
|
-
: [
|
|
27293
|
+
? [amountSpecified.token, otherToken]
|
|
27294
|
+
: [otherToken, amountSpecified.token];
|
|
27024
27295
|
}
|
|
27025
27296
|
}
|
|
27026
|
-
const generateAllAcyclicPaths = (
|
|
27027
|
-
|
|
27297
|
+
const generateAllAcyclicPaths = (tokenIn, // the currency we start with
|
|
27298
|
+
tokenOut, // the currency we want to end up with
|
|
27028
27299
|
pools, // list of all available pools
|
|
27029
27300
|
maxHops, // the maximum number of pools that can be traversed
|
|
27030
27301
|
currentRoute = [], // list of pools already traversed
|
|
27031
27302
|
routes = [], // list of all routes found so far
|
|
27032
|
-
|
|
27033
|
-
const
|
|
27034
|
-
const
|
|
27303
|
+
startTokenIn = tokenIn) => {
|
|
27304
|
+
const currencyIn = new sdkCore.Token(tokenIn.chainId, tokenIn.address, tokenIn.decimals);
|
|
27305
|
+
const currencyOut = new sdkCore.Token(tokenOut.chainId, tokenOut.address, tokenOut.decimals);
|
|
27306
|
+
const startCurrencyIn = new sdkCore.Token(startTokenIn.chainId, startTokenIn.address, startTokenIn.decimals);
|
|
27035
27307
|
for (const pool of pools) {
|
|
27036
27308
|
// if the pool doesn't have the tokenIn or if it has already been traversed,
|
|
27037
27309
|
// skip to the next pool
|
|
27038
|
-
const poolHasTokenIn = pool.involvesToken(
|
|
27310
|
+
const poolHasTokenIn = pool.involvesToken(currencyIn);
|
|
27039
27311
|
const poolHasCycle = currentRoute.find((pathPool) => poolEquals(pool, pathPool));
|
|
27040
27312
|
// eslint-disable-next-line no-continue
|
|
27041
27313
|
if (!poolHasTokenIn || poolHasCycle)
|
|
27042
27314
|
continue;
|
|
27043
27315
|
// get the output token of the pool
|
|
27044
|
-
const outputToken = pool.token0.equals(
|
|
27316
|
+
const outputToken = pool.token0.equals(currencyIn) ? pool.token1 : pool.token0;
|
|
27045
27317
|
// if we have found a route to the target currency, add it to the list of routes
|
|
27046
|
-
const routeFound = outputToken.equals(
|
|
27318
|
+
const routeFound = outputToken.equals(currencyOut);
|
|
27047
27319
|
if (routeFound) {
|
|
27048
27320
|
routes.push(new v3Sdk.Route([...currentRoute, pool], startCurrencyIn, currencyOut));
|
|
27049
27321
|
}
|
|
27050
27322
|
else if (maxHops > 1) {
|
|
27051
27323
|
// otherwise, if we haven't exceeded the maximum number of pools that can be traversed,
|
|
27052
27324
|
// recursively call this function with the output token as the new starting currency
|
|
27053
|
-
generateAllAcyclicPaths(outputToken,
|
|
27325
|
+
generateAllAcyclicPaths(outputToken, tokenOut, pools, maxHops - 1, [...currentRoute, pool], routes, startTokenIn);
|
|
27054
27326
|
}
|
|
27055
27327
|
}
|
|
27056
27328
|
return routes;
|
|
@@ -27058,39 +27330,38 @@ startCurrencyIn = currencyIn) => {
|
|
|
27058
27330
|
|
|
27059
27331
|
class Fees {
|
|
27060
27332
|
secondaryFees;
|
|
27061
|
-
|
|
27062
|
-
amount = ethers.ethers.BigNumber.from(0);
|
|
27333
|
+
amount;
|
|
27063
27334
|
constructor(secondaryFees, token) {
|
|
27064
27335
|
this.secondaryFees = secondaryFees;
|
|
27065
|
-
this.
|
|
27336
|
+
this.amount = { token, value: ethers.BigNumber.from(0) };
|
|
27066
27337
|
}
|
|
27067
27338
|
addAmount(amount) {
|
|
27068
|
-
this.amount = this.amount
|
|
27339
|
+
this.amount = addAmount(this.amount, amount);
|
|
27069
27340
|
}
|
|
27070
27341
|
amountWithFeesApplied() {
|
|
27071
|
-
return this.amount
|
|
27342
|
+
return addAmount(this.amount, this.total());
|
|
27072
27343
|
}
|
|
27073
27344
|
amountLessFees() {
|
|
27074
|
-
return this.amount
|
|
27345
|
+
return subtractAmount(this.amount, this.total());
|
|
27075
27346
|
}
|
|
27076
27347
|
withAmounts() {
|
|
27077
27348
|
return this.secondaryFees.map((fee) => {
|
|
27078
|
-
const feeAmount = this.amount
|
|
27079
|
-
.mul(fee.
|
|
27349
|
+
const feeAmount = this.amount.value
|
|
27350
|
+
.mul(fee.basisPoints)
|
|
27080
27351
|
.div(BASIS_POINT_PRECISION);
|
|
27081
27352
|
return {
|
|
27082
27353
|
...fee,
|
|
27083
|
-
amount: newAmount(feeAmount, this.token),
|
|
27354
|
+
amount: newAmount(feeAmount, this.amount.token),
|
|
27084
27355
|
};
|
|
27085
27356
|
});
|
|
27086
27357
|
}
|
|
27087
27358
|
total() {
|
|
27088
|
-
let totalFees = ethers.
|
|
27089
|
-
for (
|
|
27090
|
-
const feeAmount = this.amount
|
|
27091
|
-
.mul(
|
|
27359
|
+
let totalFees = newAmount(ethers.BigNumber.from(0), this.amount.token);
|
|
27360
|
+
for (const fee of this.secondaryFees) {
|
|
27361
|
+
const feeAmount = this.amount.value
|
|
27362
|
+
.mul(fee.basisPoints)
|
|
27092
27363
|
.div(BASIS_POINT_PRECISION);
|
|
27093
|
-
totalFees = totalFees
|
|
27364
|
+
totalFees = addAmount(totalFees, newAmount(feeAmount, this.amount.token));
|
|
27094
27365
|
}
|
|
27095
27366
|
return totalFees;
|
|
27096
27367
|
}
|
|
@@ -27114,11 +27385,11 @@ const zeroNativeCurrencyValue = '0x00';
|
|
|
27114
27385
|
const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
|
|
27115
27386
|
function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
|
|
27116
27387
|
const secondaryFeeValues = secondaryFees.map((fee) => ({
|
|
27117
|
-
|
|
27118
|
-
recipient: fee.
|
|
27388
|
+
feeBasisPoints: fee.basisPoints,
|
|
27389
|
+
recipient: fee.recipient,
|
|
27119
27390
|
}));
|
|
27120
27391
|
if (trade.tradeType === sdkCore.TradeType.EXACT_INPUT) {
|
|
27121
|
-
return secondaryFeeContract.encodeFunctionData('
|
|
27392
|
+
return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [secondaryFeeValues, {
|
|
27122
27393
|
tokenIn: route.tokenPath[0].address,
|
|
27123
27394
|
tokenOut: route.tokenPath[1].address,
|
|
27124
27395
|
fee: route.pools[0].fee,
|
|
@@ -27128,7 +27399,7 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
|
|
|
27128
27399
|
sqrtPriceLimitX96: 0,
|
|
27129
27400
|
}]);
|
|
27130
27401
|
}
|
|
27131
|
-
return secondaryFeeContract.encodeFunctionData('
|
|
27402
|
+
return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [secondaryFeeValues, {
|
|
27132
27403
|
tokenIn: route.tokenPath[0].address,
|
|
27133
27404
|
tokenOut: route.tokenPath[1].address,
|
|
27134
27405
|
fee: route.pools[0].fee,
|
|
@@ -27141,18 +27412,18 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
|
|
|
27141
27412
|
function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
|
|
27142
27413
|
const path = v3Sdk.encodeRouteToPath(route, trade.tradeType === sdkCore.TradeType.EXACT_OUTPUT);
|
|
27143
27414
|
const secondaryFeeValues = secondaryFees.map((fee) => ({
|
|
27144
|
-
|
|
27145
|
-
recipient: fee.
|
|
27415
|
+
feeBasisPoints: fee.basisPoints,
|
|
27416
|
+
recipient: fee.recipient,
|
|
27146
27417
|
}));
|
|
27147
27418
|
if (trade.tradeType === sdkCore.TradeType.EXACT_INPUT) {
|
|
27148
|
-
return secondaryFeeContract.encodeFunctionData('
|
|
27419
|
+
return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [secondaryFeeValues, {
|
|
27149
27420
|
path,
|
|
27150
27421
|
recipient: fromAddress,
|
|
27151
27422
|
amountIn,
|
|
27152
27423
|
amountOutMinimum: amountOut,
|
|
27153
27424
|
}]);
|
|
27154
27425
|
}
|
|
27155
|
-
return secondaryFeeContract.encodeFunctionData('
|
|
27426
|
+
return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [secondaryFeeValues, {
|
|
27156
27427
|
path,
|
|
27157
27428
|
recipient: fromAddress,
|
|
27158
27429
|
amountInMaximum: amountIn,
|
|
@@ -27188,8 +27459,8 @@ function createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, se
|
|
|
27188
27459
|
// Create an unchecked trade to be used in generating swap parameters.
|
|
27189
27460
|
const uncheckedTrade = v3Sdk.Trade.createUncheckedTrade({
|
|
27190
27461
|
route: adjustedQuote.route,
|
|
27191
|
-
inputAmount:
|
|
27192
|
-
outputAmount:
|
|
27462
|
+
inputAmount: toCurrencyAmount(adjustedQuote.amountIn),
|
|
27463
|
+
outputAmount: toCurrencyAmount(adjustedQuote.amountOut),
|
|
27193
27464
|
tradeType: adjustedQuote.tradeType,
|
|
27194
27465
|
});
|
|
27195
27466
|
const slippageTolerance = slippageToFraction(slippage);
|
|
@@ -27227,8 +27498,6 @@ function prepareSwap(ourQuote, amountSpecified, fees) {
|
|
|
27227
27498
|
return {
|
|
27228
27499
|
gasEstimate: ourQuote.gasEstimate,
|
|
27229
27500
|
route: ourQuote.route,
|
|
27230
|
-
tokenIn: ourQuote.tokenIn,
|
|
27231
|
-
tokenOut: ourQuote.tokenOut,
|
|
27232
27501
|
amountIn: fees.amountWithFeesApplied(),
|
|
27233
27502
|
amountOut: amountSpecified,
|
|
27234
27503
|
tradeType: ourQuote.tradeType,
|
|
@@ -27237,8 +27506,6 @@ function prepareSwap(ourQuote, amountSpecified, fees) {
|
|
|
27237
27506
|
return {
|
|
27238
27507
|
gasEstimate: ourQuote.gasEstimate,
|
|
27239
27508
|
route: ourQuote.route,
|
|
27240
|
-
tokenIn: ourQuote.tokenIn,
|
|
27241
|
-
tokenOut: ourQuote.tokenOut,
|
|
27242
27509
|
amountIn: amountSpecified,
|
|
27243
27510
|
amountOut: ourQuote.amountOut,
|
|
27244
27511
|
tradeType: ourQuote.tradeType,
|
|
@@ -27251,7 +27518,7 @@ const CONTRACTS_FOR_CHAIN_ID = {
|
|
|
27251
27518
|
coreFactory: '0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e',
|
|
27252
27519
|
quoterV2: '0x0Afe6F5f4DC34461A801420634239FFaD50A2e44',
|
|
27253
27520
|
peripheryRouter: '0x87854A7D4b9BaC3D37f4516A1Ac7F36fB5ad539f',
|
|
27254
|
-
secondaryFee: '
|
|
27521
|
+
secondaryFee: '0x5893A5c7bc615Dfd36D7383366d00FFFca5f7178',
|
|
27255
27522
|
},
|
|
27256
27523
|
};
|
|
27257
27524
|
const SUPPORTED_SANDBOX_CHAINS = {
|
|
@@ -27284,13 +27551,13 @@ function validateOverrides(overrides) {
|
|
|
27284
27551
|
function validateSecondaryFees(secondaryFees) {
|
|
27285
27552
|
let totalSecondaryFeeBasisPoints = 0;
|
|
27286
27553
|
for (const secondaryFee of secondaryFees) {
|
|
27287
|
-
if (!isValidNonZeroAddress(secondaryFee.
|
|
27288
|
-
throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.
|
|
27554
|
+
if (!isValidNonZeroAddress(secondaryFee.recipient)) {
|
|
27555
|
+
throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.recipient}`);
|
|
27289
27556
|
}
|
|
27290
|
-
if (secondaryFee.
|
|
27291
|
-
throw new InvalidConfigurationError(`Invalid secondary fee basis points: ${secondaryFee.
|
|
27557
|
+
if (secondaryFee.basisPoints < 0 || secondaryFee.basisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
|
|
27558
|
+
throw new InvalidConfigurationError(`Invalid secondary fee basis points: ${secondaryFee.basisPoints}`);
|
|
27292
27559
|
}
|
|
27293
|
-
totalSecondaryFeeBasisPoints += secondaryFee.
|
|
27560
|
+
totalSecondaryFeeBasisPoints += secondaryFee.basisPoints;
|
|
27294
27561
|
}
|
|
27295
27562
|
if (totalSecondaryFeeBasisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
|
|
27296
27563
|
throw new InvalidConfigurationError(`Invalid total secondary fee basis points: ${totalSecondaryFeeBasisPoints}`);
|
|
@@ -27360,12 +27627,24 @@ class Exchange {
|
|
|
27360
27627
|
assert(slippagePercent <= 50, new InvalidSlippageError('slippage percent must be less than or equal to 50'));
|
|
27361
27628
|
assert(slippagePercent >= 0, new InvalidSlippageError('slippage percent must be greater than or equal to 0'));
|
|
27362
27629
|
}
|
|
27630
|
+
async getSecondaryFees() {
|
|
27631
|
+
if (this.secondaryFees.length === 0) {
|
|
27632
|
+
return [];
|
|
27633
|
+
}
|
|
27634
|
+
const secondaryFeeContract = SecondaryFee__factory.connect(this.router.routingContracts.secondaryFeeAddress, this.provider);
|
|
27635
|
+
if (await secondaryFeeContract.paused()) {
|
|
27636
|
+
// Do not use secondary fees if the contract is paused
|
|
27637
|
+
return [];
|
|
27638
|
+
}
|
|
27639
|
+
return this.secondaryFees;
|
|
27640
|
+
}
|
|
27363
27641
|
async getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amount, slippagePercent, maxHops, deadline, tradeType) {
|
|
27364
27642
|
Exchange.validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress);
|
|
27365
27643
|
// get the decimals of the tokens that will be swapped
|
|
27366
|
-
const [tokenInDecimals, tokenOutDecimals] = await Promise.all([
|
|
27644
|
+
const [tokenInDecimals, tokenOutDecimals, secondaryFees] = await Promise.all([
|
|
27367
27645
|
getERC20Decimals(tokenInAddress, this.provider),
|
|
27368
27646
|
getERC20Decimals(tokenOutAddress, this.provider),
|
|
27647
|
+
this.getSecondaryFees(),
|
|
27369
27648
|
]);
|
|
27370
27649
|
const tokenIn = new sdkCore.Token(this.chainId, tokenInAddress, tokenInDecimals);
|
|
27371
27650
|
const tokenOut = new sdkCore.Token(this.chainId, tokenOutAddress, tokenOutDecimals);
|
|
@@ -27373,22 +27652,24 @@ class Exchange {
|
|
|
27373
27652
|
let amountSpecified;
|
|
27374
27653
|
let otherToken;
|
|
27375
27654
|
if (tradeType === sdkCore.TradeType.EXACT_INPUT) {
|
|
27376
|
-
amountSpecified =
|
|
27655
|
+
amountSpecified = newAmount(amount, tokenIn);
|
|
27377
27656
|
otherToken = tokenOut;
|
|
27378
27657
|
}
|
|
27379
27658
|
else {
|
|
27380
|
-
amountSpecified =
|
|
27659
|
+
amountSpecified = newAmount(amount, tokenOut);
|
|
27381
27660
|
otherToken = tokenIn;
|
|
27382
27661
|
}
|
|
27383
|
-
const fees = new Fees(
|
|
27662
|
+
const fees = new Fees(secondaryFees, uniswapTokenToTokenInfo(tokenIn));
|
|
27384
27663
|
const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType);
|
|
27385
|
-
|
|
27386
|
-
|
|
27387
|
-
|
|
27388
|
-
|
|
27389
|
-
|
|
27664
|
+
// get quote and gas details
|
|
27665
|
+
const [ourQuote, gasPrice] = await Promise.all([
|
|
27666
|
+
this.router.findOptimalRoute(ourQuoteReqAmount, otherToken, tradeType, maxHops),
|
|
27667
|
+
fetchGasPrice(this.provider),
|
|
27668
|
+
]);
|
|
27669
|
+
const adjustedQuote = prepareSwap(ourQuote, amountSpecified, fees);
|
|
27670
|
+
const swap = getSwap(this.nativeToken, adjustedQuote, fromAddress, slippagePercent, deadline, this.router.routingContracts.peripheryRouterAddress, this.router.routingContracts.secondaryFeeAddress, gasPrice, secondaryFees);
|
|
27390
27671
|
const userQuote = prepareUserQuote(otherToken, adjustedQuote, slippagePercent, fees);
|
|
27391
|
-
const preparedApproval = prepareApproval(tradeType, amount, userQuote.amountWithMaxSlippage.value, this.router.routingContracts,
|
|
27672
|
+
const preparedApproval = prepareApproval(tradeType, amount, userQuote.amountWithMaxSlippage.value, this.router.routingContracts, secondaryFees);
|
|
27392
27673
|
// we always use the tokenIn address because we are always selling the tokenIn
|
|
27393
27674
|
const approval = await getApproval(this.nativeToken, this.provider, fromAddress, tokenInAddress, preparedApproval, gasPrice);
|
|
27394
27675
|
return {
|
|
@@ -27494,17 +27775,6 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
|
27494
27775
|
];
|
|
27495
27776
|
|
|
27496
27777
|
|
|
27497
|
-
var $aa144554f9ef124b$export$1fc8f52ad1810e52;
|
|
27498
|
-
(function(ItemType) {
|
|
27499
|
-
ItemType["NATIVE"] = "NATIVE";
|
|
27500
|
-
ItemType["ERC20"] = "ERC20";
|
|
27501
|
-
ItemType["ERC721"] = "ERC721";
|
|
27502
|
-
})($aa144554f9ef124b$export$1fc8f52ad1810e52 || ($aa144554f9ef124b$export$1fc8f52ad1810e52 = {}));
|
|
27503
|
-
var $aa144554f9ef124b$export$537fa3efd10ed435;
|
|
27504
|
-
(function(GasTokenType) {
|
|
27505
|
-
GasTokenType["NATIVE"] = "NATIVE";
|
|
27506
|
-
GasTokenType["ERC20"] = "ERC20";
|
|
27507
|
-
})($aa144554f9ef124b$export$537fa3efd10ed435 || ($aa144554f9ef124b$export$537fa3efd10ed435 = {}));
|
|
27508
27778
|
|
|
27509
27779
|
|
|
27510
27780
|
/**
|
|
@@ -27588,8 +27858,8 @@ var $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
|
27588
27858
|
|
|
27589
27859
|
var $e768639828688ca3$export$2d7a51a18d87e21d;
|
|
27590
27860
|
(function(WalletProviderName) {
|
|
27591
|
-
WalletProviderName["METAMASK"] = "metamask";
|
|
27592
27861
|
WalletProviderName["PASSPORT"] = "passport";
|
|
27862
|
+
WalletProviderName["METAMASK"] = "metamask";
|
|
27593
27863
|
})($e768639828688ca3$export$2d7a51a18d87e21d || ($e768639828688ca3$export$2d7a51a18d87e21d = {}));
|
|
27594
27864
|
const $e768639828688ca3$export$44dde05038008549 = {
|
|
27595
27865
|
allowMistmatchedChainId: false,
|
|
@@ -27712,6 +27982,31 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
|
|
|
27712
27982
|
]);
|
|
27713
27983
|
|
|
27714
27984
|
|
|
27985
|
+
var $4b58188d47aafe8d$export$1fc8f52ad1810e52;
|
|
27986
|
+
(function(ItemType) {
|
|
27987
|
+
ItemType["NATIVE"] = "NATIVE";
|
|
27988
|
+
ItemType["ERC20"] = "ERC20";
|
|
27989
|
+
ItemType["ERC721"] = "ERC721";
|
|
27990
|
+
})($4b58188d47aafe8d$export$1fc8f52ad1810e52 || ($4b58188d47aafe8d$export$1fc8f52ad1810e52 = {}));
|
|
27991
|
+
var $4b58188d47aafe8d$export$65c64e46348ee3c1;
|
|
27992
|
+
(function(TransactionOrGasType) {
|
|
27993
|
+
TransactionOrGasType["TRANSACTION"] = "TRANSACTION";
|
|
27994
|
+
TransactionOrGasType["GAS"] = "GAS";
|
|
27995
|
+
})($4b58188d47aafe8d$export$65c64e46348ee3c1 || ($4b58188d47aafe8d$export$65c64e46348ee3c1 = {}));
|
|
27996
|
+
var $4b58188d47aafe8d$export$537fa3efd10ed435;
|
|
27997
|
+
(function(GasTokenType) {
|
|
27998
|
+
GasTokenType["NATIVE"] = "NATIVE";
|
|
27999
|
+
GasTokenType["ERC20"] = "ERC20";
|
|
28000
|
+
})($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
|
|
28001
|
+
var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
28002
|
+
(function(TransactionRequirementType) {
|
|
28003
|
+
TransactionRequirementType["GAS"] = "GAS";
|
|
28004
|
+
TransactionRequirementType["NATIVE"] = "NATIVE";
|
|
28005
|
+
TransactionRequirementType["ERC20"] = "ERC20";
|
|
28006
|
+
TransactionRequirementType["ERC721"] = "ERC721";
|
|
28007
|
+
})($4b58188d47aafe8d$export$5d3b0ad129b9b98e || ($4b58188d47aafe8d$export$5d3b0ad129b9b98e = {}));
|
|
28008
|
+
|
|
28009
|
+
|
|
27715
28010
|
|
|
27716
28011
|
|
|
27717
28012
|
/**
|
|
@@ -28046,9 +28341,13 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
|
|
|
28046
28341
|
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
28047
28342
|
return new (providers.Web3Provider)(provider);
|
|
28048
28343
|
}
|
|
28049
|
-
async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
|
|
28344
|
+
async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName, passport) {
|
|
28050
28345
|
let provider = null;
|
|
28051
28346
|
switch(walletProviderName){
|
|
28347
|
+
case ($e768639828688ca3$export$2d7a51a18d87e21d).PASSPORT:
|
|
28348
|
+
if (passport) provider = new (providers.Web3Provider)(passport.connectEvm());
|
|
28349
|
+
else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Passport not provided", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).DEFAULT_PROVIDER_ERROR);
|
|
28350
|
+
break;
|
|
28052
28351
|
case ($e768639828688ca3$export$2d7a51a18d87e21d).METAMASK:
|
|
28053
28352
|
provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
|
|
28054
28353
|
break;
|
|
@@ -28428,20 +28727,19 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
28428
28727
|
|
|
28429
28728
|
const $c147333b1f360629$export$92589613aaa38e1f = 300000;
|
|
28430
28729
|
const $c147333b1f360629$export$dea9ce0e9bb2441c = "0x474989C4D25DD41B0B9b1ECb4643B9Fe25f83B19";
|
|
28431
|
-
const $c147333b1f360629$export$
|
|
28730
|
+
const $c147333b1f360629$export$4249179755829904 = (type, contractAddress, amount)=>{
|
|
28432
28731
|
switch(type){
|
|
28433
|
-
case ($
|
|
28434
|
-
case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721:
|
|
28732
|
+
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
|
|
28435
28733
|
return {
|
|
28436
28734
|
type: type,
|
|
28437
28735
|
amount: amount,
|
|
28438
28736
|
contractAddress: contractAddress,
|
|
28439
|
-
|
|
28737
|
+
spenderAddress: $c147333b1f360629$export$dea9ce0e9bb2441c
|
|
28440
28738
|
};
|
|
28441
|
-
case ($
|
|
28739
|
+
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE:
|
|
28442
28740
|
default:
|
|
28443
28741
|
return {
|
|
28444
|
-
type: ($
|
|
28742
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
28445
28743
|
amount: amount
|
|
28446
28744
|
};
|
|
28447
28745
|
}
|
|
@@ -28458,19 +28756,15 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
28458
28756
|
});
|
|
28459
28757
|
}
|
|
28460
28758
|
let amount = (ethers.BigNumber).from("0");
|
|
28461
|
-
let type = ($
|
|
28759
|
+
let type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
|
|
28462
28760
|
let contractAddress = "";
|
|
28463
28761
|
const buyArray = order.result.buy;
|
|
28464
28762
|
if (buyArray.length > 0) switch(buyArray[0].item_type){
|
|
28465
28763
|
case "NATIVE":
|
|
28466
|
-
type = ($
|
|
28764
|
+
type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
|
|
28467
28765
|
break;
|
|
28468
28766
|
case "ERC20":
|
|
28469
|
-
type = ($
|
|
28470
|
-
contractAddress = buyArray[0].contract_address;
|
|
28471
|
-
break;
|
|
28472
|
-
case "ERC721":
|
|
28473
|
-
type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721;
|
|
28767
|
+
type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20;
|
|
28474
28768
|
contractAddress = buyArray[0].contract_address;
|
|
28475
28769
|
break;
|
|
28476
28770
|
default:
|
|
@@ -28479,19 +28773,19 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
28479
28773
|
});
|
|
28480
28774
|
}
|
|
28481
28775
|
buyArray.forEach((item)=>{
|
|
28482
|
-
amount = amount.add((ethers.BigNumber).from(item.start_amount));
|
|
28776
|
+
if (item.item_type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) amount = amount.add((ethers.BigNumber).from(item.start_amount));
|
|
28483
28777
|
});
|
|
28484
28778
|
const feeArray = order.result.fees;
|
|
28485
28779
|
feeArray.forEach((item)=>{
|
|
28486
28780
|
amount = amount.add((ethers.BigNumber).from(item.amount));
|
|
28487
28781
|
});
|
|
28488
|
-
const
|
|
28489
|
-
$c147333b1f360629$export$
|
|
28782
|
+
const itemRequirements = [
|
|
28783
|
+
$c147333b1f360629$export$4249179755829904(type, contractAddress, amount)
|
|
28490
28784
|
];
|
|
28491
28785
|
return {
|
|
28492
|
-
|
|
28493
|
-
|
|
28494
|
-
type: ($
|
|
28786
|
+
itemRequirements: itemRequirements,
|
|
28787
|
+
gasToken: {
|
|
28788
|
+
type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
|
|
28495
28789
|
limit: (ethers.BigNumber).from($c147333b1f360629$export$92589613aaa38e1f)
|
|
28496
28790
|
}
|
|
28497
28791
|
};
|
|
@@ -28502,6 +28796,45 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
28502
28796
|
|
|
28503
28797
|
|
|
28504
28798
|
|
|
28799
|
+
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
|
|
28800
|
+
// eslint-disable-next-line no-console
|
|
28801
|
+
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
28802
|
+
return {
|
|
28803
|
+
sufficient: true,
|
|
28804
|
+
transactionRequirements: [
|
|
28805
|
+
{
|
|
28806
|
+
type: ($4b58188d47aafe8d$export$5d3b0ad129b9b98e).GAS,
|
|
28807
|
+
sufficient: true,
|
|
28808
|
+
required: {
|
|
28809
|
+
balance: (ethers.BigNumber).from(0),
|
|
28810
|
+
formattedBalance: "0",
|
|
28811
|
+
token: {
|
|
28812
|
+
name: "IMX",
|
|
28813
|
+
symbol: "IMX",
|
|
28814
|
+
address: "0x0",
|
|
28815
|
+
decimals: 18
|
|
28816
|
+
}
|
|
28817
|
+
},
|
|
28818
|
+
current: {
|
|
28819
|
+
balance: (ethers.BigNumber).from(1),
|
|
28820
|
+
formattedBalance: "1",
|
|
28821
|
+
token: {
|
|
28822
|
+
name: "IMX",
|
|
28823
|
+
symbol: "IMX",
|
|
28824
|
+
address: "0x0",
|
|
28825
|
+
decimals: 18
|
|
28826
|
+
}
|
|
28827
|
+
}
|
|
28828
|
+
}
|
|
28829
|
+
]
|
|
28830
|
+
};
|
|
28831
|
+
};
|
|
28832
|
+
|
|
28833
|
+
|
|
28834
|
+
|
|
28835
|
+
|
|
28836
|
+
|
|
28837
|
+
|
|
28505
28838
|
|
|
28506
28839
|
|
|
28507
28840
|
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
@@ -28540,7 +28873,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28540
28873
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
|
28541
28874
|
* @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
|
|
28542
28875
|
*/ async createProvider(params) {
|
|
28543
|
-
return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
|
|
28876
|
+
return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider, params.passport);
|
|
28544
28877
|
}
|
|
28545
28878
|
/**
|
|
28546
28879
|
* Checks if a wallet is connected to the specified provider.
|
|
@@ -28641,12 +28974,23 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28641
28974
|
* Determines the requirements for performing a buy.
|
|
28642
28975
|
* @param {BuyParams} params - The parameters for the buy.
|
|
28643
28976
|
*/ async buy(params) {
|
|
28977
|
+
if (this.config.isProduction) throw new Error("This endpoint is not currently available.");
|
|
28644
28978
|
// eslint-disable-next-line no-console
|
|
28645
28979
|
console.warn("This endpoint is currently under construction.");
|
|
28646
28980
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
28647
28981
|
await $c147333b1f360629$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orderId);
|
|
28648
28982
|
}
|
|
28649
28983
|
/**
|
|
28984
|
+
* Determines the transaction requirements to complete a purchase.
|
|
28985
|
+
* @params {SmartCheckoutParams} params - The parameters for smart checkout.
|
|
28986
|
+
*/ async smartCheckout(params) {
|
|
28987
|
+
if (this.config.isProduction) throw new Error("This endpoint is not currently available.");
|
|
28988
|
+
// eslint-disable-next-line no-console
|
|
28989
|
+
console.warn("This endpoint is currently under construction.");
|
|
28990
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
28991
|
+
await $0e7419077c373b24$export$9e073f9ada8c81e6(web3Provider, params.itemRequirements, params.transactionOrGasAmount);
|
|
28992
|
+
}
|
|
28993
|
+
/**
|
|
28650
28994
|
* Checks if the given object is a Web3 provider.
|
|
28651
28995
|
* @param {Web3Provider} web3Provider - The object to check.
|
|
28652
28996
|
* @returns {boolean} - True if the object is a Web3 provider, false otherwise.
|
|
@@ -28680,7 +29024,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
28680
29024
|
function $parcel$export(e, n, v, s) {
|
|
28681
29025
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28682
29026
|
}
|
|
28683
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.
|
|
29027
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.11.0-alpha";
|
|
28684
29028
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28685
29029
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28686
29030
|
|