[rfq-api] feat: Add acceptedTypes query param to tx-relay (#230)

This commit is contained in:
Vic
2023-03-20 14:21:31 -07:00
committed by GitHub
parent 843e7b19aa
commit e85031be32
7 changed files with 164 additions and 12 deletions

View File

@@ -29,6 +29,9 @@
"priceImpactProtectionPercentage": {
"$ref": "/numberSchema"
},
"acceptedTypes": {
"type": "string"
},
"feeType": {
"type": "string",
"enum": ["volume"]

View File

@@ -25,6 +25,9 @@
"priceImpactProtectionPercentage": {
"$ref": "/numberSchema"
},
"acceptedTypes": {
"type": "string"
},
"feeType": {
"type": "string",
"enum": ["volume"]

View File

@@ -76,8 +76,8 @@ export class GaslessSwapHandlers {
* Handler for the /price endpoint
*/
public async getPriceAsync(req: express.Request, res: express.Response): Promise<void> {
const metaTransactionType = getGaslessSwapServiceType(req.baseUrl);
const { chainId, params } = await this._parsePriceParamsAsync(req);
const serviceType = getGaslessSwapServiceType(req.baseUrl);
const { chainId, params } = await this._parsePriceParamsAsync(req, serviceType);
// Consistent with `rfqm_handlers`: not all requests are emitted if they fail parsing
ZEROG_GASLESS_SWAP_REQUEST.inc({
chainId,
@@ -87,7 +87,7 @@ export class GaslessSwapHandlers {
let price;
try {
price = await this._getServiceForChain(chainId).fetchPriceAsync(params, metaTransactionType);
price = await this._getServiceForChain(chainId).fetchPriceAsync(params, serviceType);
} catch (err) {
ZEROG_GASLESS_SWAP_REQUEST_ERROR.inc({
chainId,
@@ -108,9 +108,9 @@ export class GaslessSwapHandlers {
* Handler for the /quote endpoint
*/
public async getQuoteAsync(req: express.Request, res: express.Response): Promise<void> {
const metaTransactionType = getGaslessSwapServiceType(req.baseUrl);
const serviceType = getGaslessSwapServiceType(req.baseUrl);
// Parse request
const { chainId, params } = await this._parseFetchFirmQuoteParamsAsync(req);
const { chainId, params } = await this._parseFetchFirmQuoteParamsAsync(req, serviceType);
// Consistent with `rfqm_handlers`: not all requests are emitted if they fail parsing
ZEROG_GASLESS_SWAP_REQUEST.inc({
chainId,
@@ -120,7 +120,7 @@ export class GaslessSwapHandlers {
let quote;
try {
quote = await this._getServiceForChain(chainId).fetchQuoteAsync(params, metaTransactionType);
quote = await this._getServiceForChain(chainId).fetchQuoteAsync(params, serviceType);
} catch (err) {
ZEROG_GASLESS_SWAP_REQUEST_ERROR.inc({
chainId,
@@ -207,13 +207,14 @@ export class GaslessSwapHandlers {
private async _parseFetchFirmQuoteParamsAsync(
req: express.Request,
serviceType: GaslessSwapServiceTypes,
): Promise<{ chainId: number; params: FetchFirmQuoteParams }> {
// $eslint-fix-me https://github.com/rhinodavid/eslint-fix-me
// eslint-disable-next-line @typescript-eslint/no-explicit-any
schemaUtils.validateSchema(req.query, schemas.firmQuoteRequestSchema as any);
const takerAddress = req.query.takerAddress;
const shouldCheckApproval = req.query.checkApproval === 'true' ? true : false;
const { chainId, params } = await this._parseIndicativeAndFirmQuoteSharedParamsAsync(req);
const { chainId, params } = await this._parseIndicativeAndFirmQuoteSharedParamsAsync(req, serviceType);
if (!addressUtils.isAddress(takerAddress as string)) {
throw new ValidationError([
{
@@ -267,12 +268,13 @@ export class GaslessSwapHandlers {
private async _parsePriceParamsAsync(
req: express.Request,
serviceType: GaslessSwapServiceTypes,
): Promise<{ chainId: number; params: FetchIndicativeQuoteParams }> {
// $eslint-fix-me https://github.com/rhinodavid/eslint-fix-me
// eslint-disable-next-line @typescript-eslint/no-explicit-any
schemaUtils.validateSchema(req.query, schemas.indicativeQuoteRequestSchema as any);
const { takerAddress } = req.query;
const { chainId, params } = await this._parseIndicativeAndFirmQuoteSharedParamsAsync(req);
const { chainId, params } = await this._parseIndicativeAndFirmQuoteSharedParamsAsync(req, serviceType);
return {
chainId,
@@ -288,6 +290,7 @@ export class GaslessSwapHandlers {
*/
private async _parseIndicativeAndFirmQuoteSharedParamsAsync(
req: express.Request,
serviceType: GaslessSwapServiceTypes,
): Promise<{ chainId: number; params: FetchQuoteParamsBase }> {
const chainId = extractChainId(req, this._gaslessSwapServices);
const { integrator } = this._validateApiKey(req.header('0x-api-key'), chainId);
@@ -370,6 +373,38 @@ export class GaslessSwapHandlers {
]);
}
let acceptedTypes: GaslessTypes[] = [];
if (serviceType === GaslessSwapServiceTypes.TxRelay) {
if (req.query.acceptedTypes) {
const rawAcceptedTypes = (req.query.acceptedTypes as string).split(',');
acceptedTypes = rawAcceptedTypes.map((rawAcceptedType) => {
// TODO: Uncomment when tx-relay supports all order types in `GaslessTypes`
// if (Object.values(GaslessTypes).includes(rawAcceptedType as GaslessTypes)) {
// return rawAcceptedType as GaslessTypes;
// }
// Currently tx-relay only supports meta-transaction
if ((rawAcceptedType as GaslessTypes) === GaslessTypes.MetaTransaction) {
return rawAcceptedType as GaslessTypes;
}
throw new ValidationError([
{
field: 'acceptedTypes',
code: ValidationErrorCodes.IncorrectFormat,
reason: `acceptedTypes ${req.query.acceptedTypes} is of wrong format. ${rawAcceptedType} is not supported yet`,
},
]);
});
} else {
// Caller does not pass in `acceptedTypes` which means the caller is fine with any order type
// TODO: Add GaslessTypes.OtcOrder and GaslessTypes.MetaTransactionV2 when tx-relay supports them
acceptedTypes = [GaslessTypes.MetaTransaction];
}
} else {
// `acceptedTypes` does not apply to zero/g
acceptedTypes = [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder];
}
if (req.query.feeType) {
if (req.query.feeType !== 'volume') {
throw new ValidationError([
@@ -427,6 +462,7 @@ export class GaslessSwapHandlers {
affiliateAddress: affiliateAddress as string,
slippagePercentage,
priceImpactProtectionPercentage,
acceptedTypes,
feeType,
feeSellTokenPercentage,
feeRecipient,

View File

@@ -309,6 +309,42 @@ describe('GaslessSwapHandlers', () => {
expect(response.statusCode).toEqual(HttpStatus.BAD_REQUEST);
});
it('throws if the `acceptedTypes` is invalid for /price', async () => {
const response = await supertest(app)
.get(`${TX_RELAY_V1_PATH}/price`)
.set('Content-type', 'application/json')
.set('0x-api-key', 'integrator-api-key')
.set('0x-chain-id', '1337') // tslint:disable-line: custom-no-magic-numbers
.query({
buyToken: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
sellToken: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
buyAmount: 1000,
takerAddress,
acceptedTypes: 'metatransaction,random',
});
expect(response.body.validationErrors[0].code).toEqual(ValidationErrorCodes.IncorrectFormat);
expect(response.statusCode).toEqual(HttpStatus.BAD_REQUEST);
});
it('throws if the `acceptedTypes` is invalid for /quote', async () => {
const response = await supertest(app)
.get(`${TX_RELAY_V1_PATH}/quote`)
.set('Content-type', 'application/json')
.set('0x-api-key', 'integrator-api-key')
.set('0x-chain-id', '1337') // tslint:disable-line: custom-no-magic-numbers
.query({
buyToken: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
sellToken: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
buyAmount: 1000,
takerAddress,
acceptedTypes: 'metatransaction,random',
});
expect(response.body.validationErrors[0].code).toEqual(ValidationErrorCodes.IncorrectFormat);
expect(response.statusCode).toEqual(HttpStatus.BAD_REQUEST);
});
it('throws if the `feeType` is invalid for /quote', async () => {
const response = await supertest(app)
.get(`${TX_RELAY_V1_PATH}/quote`)
@@ -456,6 +492,10 @@ describe('GaslessSwapHandlers', () => {
expect(mockGaslessSwapService.fetchPriceAsync.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"acceptedTypes": [
"metatransaction",
"otc",
],
"affiliateAddress": undefined,
"buyAmount": "1000",
"buyToken": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
@@ -577,6 +617,9 @@ describe('GaslessSwapHandlers', () => {
expect(mockGaslessSwapService.fetchPriceAsync.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"acceptedTypes": [
"metatransaction",
],
"affiliateAddress": undefined,
"buyAmount": "1000",
"buyToken": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
@@ -695,6 +738,10 @@ describe('GaslessSwapHandlers', () => {
expect(mockGaslessSwapService.fetchQuoteAsync.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"acceptedTypes": [
"metatransaction",
"otc",
],
"affiliateAddress": undefined,
"buyAmount": "1000",
"buyToken": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
@@ -840,6 +887,7 @@ describe('GaslessSwapHandlers', () => {
buyAmount: 1000,
takerAddress,
priceImpactProtectionPercentage: 0.2,
acceptedTypes: 'metatransaction',
feeType: 'volume',
feeSellTokenPercentage: 0.1,
feeRecipient,
@@ -848,6 +896,9 @@ describe('GaslessSwapHandlers', () => {
expect(mockGaslessSwapService.fetchQuoteAsync.mock.calls[0]).toMatchInlineSnapshot(`
[
{
"acceptedTypes": [
"metatransaction",
],
"affiliateAddress": undefined,
"buyAmount": "1000",
"buyToken": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",

View File

@@ -192,6 +192,15 @@ export class GaslessSwapService {
feeConfigs = this._getFeeConfigs(params, 'on-chain'); // integrator billing type would always be on-chain for now
}
const acceptedTypes = params.acceptedTypes ?? [];
let metaTransactionVersion: 'v1' | 'v2' | undefined;
// Always prefer meta-transaction v2 over meta-transaction
if (acceptedTypes.includes(GaslessTypes.MetaTransactionV2)) {
metaTransactionVersion = 'v2';
} else if (acceptedTypes.includes(GaslessTypes.MetaTransaction)) {
metaTransactionVersion = 'v1';
}
const metaTransactionRequestParams = {
...params,
chainId: this._chainId,
@@ -199,7 +208,7 @@ export class GaslessSwapService {
// Can use the null address here since we won't be returning
// the actual metatransaction
takerAddress: params.takerAddress ?? NULL_ADDRESS,
metaTransactionVersion: 'v1' as 'v1' | 'v2',
metaTransactionVersion,
feeConfigs,
};
@@ -318,6 +327,15 @@ export class GaslessSwapService {
feeConfigs = this._getFeeConfigs(params, 'on-chain'); // integrator billing type would always be on-chain for now
}
const acceptedTypes = params.acceptedTypes ?? [];
let metaTransactionVersion: 'v1' | 'v2' | undefined;
// Always prefer meta-transaction v2 over meta-transaction
if (acceptedTypes.includes(GaslessTypes.MetaTransactionV2)) {
metaTransactionVersion = 'v2';
} else if (acceptedTypes.includes(GaslessTypes.MetaTransaction)) {
metaTransactionVersion = 'v1';
}
const metaTransactionRequestParams = {
...params,
chainId: this._chainId,
@@ -325,7 +343,7 @@ export class GaslessSwapService {
integratorId: params.integrator.integratorId,
quoteUniqueId:
serviceType === GaslessSwapServiceTypes.ZeroG ? rfqQuoteReportId ?? undefined : undefined,
metaTransactionVersion: 'v1' as 'v1' | 'v2',
metaTransactionVersion,
feeConfigs,
};

View File

@@ -30,6 +30,7 @@ export interface FetchQuoteParamsBase {
// fields specific to gasless endpoints
slippagePercentage?: BigNumber;
priceImpactProtectionPercentage?: BigNumber;
acceptedTypes?: GaslessTypes[];
feeType?: 'volume';
feeSellTokenPercentage?: BigNumber;
feeRecipient?: string;

View File

@@ -296,6 +296,7 @@ describe('GaslessSwapService', () => {
integrator: {} as Integrator,
sellToken: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
sellTokenDecimals: 18,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
)) as FetchIndicativeQuoteResponse & { liquiditySource: 'rfq' | 'amm' };
@@ -335,6 +336,7 @@ describe('GaslessSwapService', () => {
integrator: {} as Integrator,
sellToken: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
sellTokenDecimals: 18,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
)) as FetchIndicativeQuoteResponse & { liquiditySource: 'rfq' | 'amm' };
@@ -375,6 +377,7 @@ describe('GaslessSwapService', () => {
integrator: {} as Integrator,
sellToken: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
sellTokenDecimals: 18,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
)) as FetchIndicativeQuoteResponse & { liquiditySource: 'rfq' | 'amm' };
@@ -406,6 +409,7 @@ describe('GaslessSwapService', () => {
integrator: {} as Integrator,
sellToken: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
sellTokenDecimals: 18,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
);
@@ -430,6 +434,7 @@ describe('GaslessSwapService', () => {
integrator: {} as Integrator,
sellToken: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
sellTokenDecimals: 18,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
),
@@ -458,6 +463,7 @@ describe('GaslessSwapService', () => {
sellToken: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
sellTokenDecimals: 18,
takerAddress: '0xtaker',
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
),
@@ -490,10 +496,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
)) as FetchIndicativeQuoteResponse & { sources: LiquiditySource[]; fees?: Fees };
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v1');
expect(result).toMatchInlineSnapshot(`
{
"allowanceTarget": "0x12345",
@@ -562,10 +570,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.MetaTransactionV2],
},
GaslessSwapServiceTypes.TxRelay,
)) as FetchIndicativeQuoteResponse & { sources: LiquiditySource[]; fees?: Fees };
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v2');
expect(result).toMatchInlineSnapshot(`
{
"allowanceTarget": "0x12345",
@@ -624,10 +634,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
);
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v1');
expect(result).toBeNull();
});
@@ -648,6 +660,7 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransactionV2],
},
GaslessSwapServiceTypes.TxRelay,
),
@@ -678,6 +691,7 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
),
@@ -701,6 +715,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
)) as OtcOrderRfqmQuoteResponse & { liquiditySource: 'rfq' | 'amm' };
@@ -760,6 +775,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
)) as MetaTransactionV1QuoteResponse & { liquiditySource: 'rfq' | 'amm' };
@@ -825,6 +841,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
),
@@ -852,6 +869,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
);
@@ -882,6 +900,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
);
@@ -904,6 +923,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
);
@@ -930,6 +950,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
),
@@ -957,6 +978,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: false,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
);
@@ -994,6 +1016,7 @@ describe('GaslessSwapService', () => {
sellTokenDecimals: 18,
takerAddress: '0xtaker',
checkApproval: true,
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.OtcOrder],
},
GaslessSwapServiceTypes.ZeroG,
);
@@ -1031,10 +1054,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
)) as MetaTransactionV2QuoteResponse;
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v1');
expect(result).not.toBeNull();
expect(result?.trade.type).toEqual(GaslessTypes.MetaTransaction);
expect(result?.trade.hash).toEqual(metaTransactionV1.getHash());
@@ -1198,10 +1223,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.MetaTransactionV2],
},
GaslessSwapServiceTypes.TxRelay,
)) as MetaTransactionV2QuoteResponse;
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v2');
expect(result).not.toBeNull();
expect(result?.trade.type).toEqual(GaslessTypes.MetaTransactionV2);
expect(result?.trade.hash).toEqual(metaTransactionV2.getHash());
@@ -1366,6 +1393,7 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
),
@@ -1400,10 +1428,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
);
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][/* params */ 2]['affiliateAddress']).toEqual(
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v1');
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][/* params */ 2].affiliateAddress).toEqual(
'0xaffiliateAddress',
);
});
@@ -1437,10 +1467,13 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
);
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][/* params */ 2]['affiliateAddress']).toEqual(
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v1');
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][/* params */ 2].affiliateAddress).toEqual(
'0xaffiliateAddressShouldUse',
);
});
@@ -1461,10 +1494,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction, GaslessTypes.MetaTransactionV2],
},
GaslessSwapServiceTypes.TxRelay,
);
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v2');
expect(result).toBeNull();
});
@@ -1487,6 +1522,7 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
),
@@ -1521,10 +1557,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransaction],
},
GaslessSwapServiceTypes.TxRelay,
);
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v1');
expect(mockRedis.set).toBeCalledWith(
`metaTransactionHash.${metaTransactionV1.getHash()}`,
0,
@@ -1565,10 +1603,12 @@ describe('GaslessSwapService', () => {
feeType: 'volume',
feeRecipient: integratorAddress,
feeSellTokenPercentage: new BigNumber(0.1),
acceptedTypes: [GaslessTypes.MetaTransactionV2],
},
GaslessSwapServiceTypes.TxRelay,
);
expect(getMetaTransactionV2QuoteAsyncMock.mock.calls[0][2].metaTransactionVersion).toEqual('v2');
expect(result?.approval).not.toBeUndefined();
});
});