Compare commits

...

4 Commits

Author SHA1 Message Date
Github Actions
f8dd7168ee Publish
- @0x/contracts-treasury@1.4.46
 - @0x/contracts-zero-ex@0.42.1
 - @0x/contract-artifacts@3.19.0
 - @0x/contract-wrappers@13.23.0
 - @0x/protocol-utils@11.22.0
2023-04-24 11:12:31 +00:00
Github Actions
527ccf2ae5 Updated CHANGELOGS & MD docs 2023-04-24 11:12:28 +00:00
Andy
a7acf2951d MetaTransaction V2 Utility Packages (#714)
* add utility class for MetaTransactionsV2, update artifacts, update wrappers

* fix exports

* update artifacts, update wrappers

* update changelogs
2023-04-24 06:03:23 -04:00
wonge97
e57fc60a76 add new audits to documentation. fix broken link (#715) 2023-04-20 18:30:29 -05:00
22 changed files with 1883 additions and 264 deletions

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1682334742,
"version": "1.4.46",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1681969282,
"version": "1.4.45",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.4.46 - _April 24, 2023_
* Dependencies updated
## v1.4.45 - _April 20, 2023_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-treasury",
"version": "1.4.45",
"version": "1.4.46",
"engines": {
"node": ">=6.12"
},
@@ -73,7 +73,7 @@
},
"dependencies": {
"@0x/base-contract": "^7.0.0",
"@0x/protocol-utils": "^11.21.0",
"@0x/protocol-utils": "^11.22.0",
"@0x/subproviders": "^8.0.1",
"@0x/types": "^3.3.7",
"@0x/typescript-typings": "^5.3.1",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1682334742,
"version": "0.42.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "0.42.0",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.42.1 - _April 24, 2023_
* Dependencies updated
## v0.42.0 - _April 20, 2023_
* Add Trader Joe V2 support on Avalanche

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-zero-ex",
"version": "0.42.0",
"version": "0.42.1",
"engines": {
"node": ">=6.12"
},
@@ -80,7 +80,7 @@
},
"dependencies": {
"@0x/base-contract": "^7.0.0",
"@0x/protocol-utils": "^11.21.0",
"@0x/protocol-utils": "^11.22.0",
"@0x/subproviders": "^8.0.1",
"@0x/types": "^3.3.7",
"@0x/typescript-typings": "^5.3.1",

View File

@@ -4,28 +4,34 @@ Audits
Below are links to our third-party audit reports.
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| **Release** | **Reports** |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| ERC721OrdersFeature | * `ABDK Consulting <https://s3.us-east-2.amazonaws.com/zeips.0x.org/audits/abdk-consulting/ABDK_0x_Solidity_v_1_0.pdf>`__ |
| | |
| | |
| ERC1155OrdersFeature | |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| Exchange V4 | * `Consensys Diligence (December 2020) <https://consensys.net/diligence/audits/2020/12/0x-exchange-v4/>`__ |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| Exchange V3 | * `Trail of Bits <http://zeips.0x.org.s3-website.us-east-2.amazonaws.com/audits/56/trail-of-bits/audit.pdf>`__ |
| | * `Consensys Diligence (Exchange) <https://diligence.consensys.net/audits/2019/09/0x-v3-exchange/>`__ |
| | * `Consensys Diligence (Staking) <https://diligence.consensys.net/audits/2019/10/0x-v3-staking/>`__ |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| Exchange V2.1 | * `First <https://docs.google.com/document/d/1jYv6V21MfCSwCS5fxD6ZyaLWGzkpRSUO0lZpST94XsA/edit>`_ |
| | * `Consensys Diligence <https://github.com/ConsenSys/0x_audit_report_2018-07-23>`_ |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| MultiAssetProxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2018-12>`__ |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| ERC1155Proxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2019-05>`__ |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| StaticCallProxy | * No third-party audit. |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
| ERC20BridgeProxy | * No third-party audit. |
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| **Release** | **Reports** |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Governance | * `Ourovoros <https://github.com/0xProject/protocol/blob/development/contracts/governance/audits/0xProtocol-06-04-2023-Final.pdf>`__ |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| MultiplexFeature | * `ABDK Consulting <https://github.com/0xProject/ZEIPs/blob/master/zeip96_images/ABDK_0x_MetaTransaction_v_1_0.pdf>`__ |
| | |
| MetaTransactions | |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| ERC721OrdersFeature | * `ABDK Consulting <https://s3.us-east-2.amazonaws.com/zeips.0x.org/audits/abdk-consulting/ABDK_0x_Solidity_v_1_0.pdf>`__ |
| | |
| | |
| ERC1155OrdersFeature | |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Exchange V4 | * `Consensys Diligence (December 2020) <https://consensys.net/diligence/audits/2020/12/0x-exchange-v4/>`__ |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Exchange V3 | * `Trail of Bits <http://zeips.0x.org.s3-website.us-east-2.amazonaws.com/audits/56/trail-of-bits/audit.pdf>`__ |
| | * `Consensys Diligence (Exchange) <https://diligence.consensys.net/audits/2019/09/0x-v3-exchange/>`__ |
| | * `Consensys Diligence (Staking) <https://diligence.consensys.net/audits/2019/10/0x-v3-staking/>`__ |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Exchange V2.1 | * `First <https://docs.google.com/document/d/1jYv6V21MfCSwCS5fxD6ZyaLWGzkpRSUO0lZpST94XsA/edit>`_ |
| | * `Consensys Diligence <https://github.com/ConsenSys/0x_audit_report_2018-07-23>`_ |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| MultiAssetProxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2018-12>`__ |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| ERC1155Proxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2019-05>`__ |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| StaticCallProxy | * No third-party audit. |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| ERC20BridgeProxy | * No third-party audit. |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------+

View File

@@ -9,7 +9,7 @@ This documentation is aimed to serve as the canonical technical documentation fo
- Subsections will provide a deep dive into each contracts
- Tutorial and tools to get started building with/on top of 0x Protocol
To learn more about why 0x Protocol was created, read the whitepaper `here <https://github.com/0xProject/whitepaper/blob/master/0x_white_paper.pdf>`_ and at `0xProtocol.org <httpsL//0xProtocol.org>`_.
To learn more about why 0x Protocol was created, read the whitepaper `here <https://github.com/0xProject/whitepaper/blob/master/0x_white_paper.pdf>`_ and at `0xProtocol.org <https://0xProtocol.org>`_.
All code is open sourced on `GitHub <https://github.com/0xProject/protocol>`_.

View File

@@ -1,4 +1,13 @@
[
{
"version": "3.19.0",
"changes": [
{
"note": "Regenerate IZeroEx artifact"
}
],
"timestamp": 1682334742
},
{
"timestamp": 1674517560,
"version": "3.18.3",

View File

@@ -6,6 +6,9 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.19.0 - _April 24, 2023_
* Regenerate IZeroEx artifact
## v3.18.3 - _January 23, 2023_
* Dependencies updated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contract-artifacts",
"version": "3.18.3",
"version": "3.19.0",
"engines": {
"node": ">=6.12"
},

View File

@@ -1,4 +1,13 @@
[
{
"version": "13.23.0",
"changes": [
{
"note": "Regenerate IZeroEx wrapper"
}
],
"timestamp": 1682334742
},
{
"timestamp": 1681969282,
"version": "13.22.21",

View File

@@ -6,6 +6,9 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v13.23.0 - _April 24, 2023_
* Regenerate IZeroEx wrapper
## v13.22.21 - _April 20, 2023_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contract-wrappers",
"version": "13.22.21",
"version": "13.23.0",
"engines": {
"node": ">=6.12"
},

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,13 @@
[
{
"version": "11.22.0",
"changes": [
{
"note": "Add MetaTransactionV2 utilities"
}
],
"timestamp": 1682334742
},
{
"version": "11.21.0",
"changes": [

View File

@@ -6,6 +6,9 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v11.22.0 - _April 24, 2023_
* Add MetaTransactionV2 utilities
## v11.21.0 - _April 20, 2023_
* Add Trader Joe V2 support on Avalanche

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/protocol-utils",
"version": "11.21.0",
"version": "11.22.0",
"engines": {
"node": ">=6.12"
},
@@ -63,7 +63,7 @@
"dependencies": {
"@0x/assert": "^3.0.36",
"@0x/contract-addresses": "^8.5.0",
"@0x/contract-wrappers": "^13.22.21",
"@0x/contract-wrappers": "^13.23.0",
"@0x/json-schemas": "^6.4.4",
"@0x/subproviders": "^8.0.1",
"@0x/utils": "^7.0.0",

View File

@@ -12,6 +12,7 @@ export const NFTOrder = {
export * from './eip712_utils';
export * from './orders';
export * from './meta_transactions';
export * from './meta_transactions_v2';
export * from './signature_utils';
export * from './transformer_utils';
export * from './constants';

View File

@@ -0,0 +1,143 @@
import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { EIP712TypedData } from '@0x/types';
import { BigNumber, hexUtils, NULL_ADDRESS } from '@0x/utils';
import { ZERO } from './constants';
import {
createExchangeProxyEIP712Domain,
EIP712_DOMAIN_PARAMETERS,
getExchangeProxyEIP712Hash,
getTypeHash,
} from './eip712_utils';
export interface MetaTransactionV2Fee {
recipient: string,
amount: BigNumber,
}
const MTX_DEFAULT_VALUES = {
signer: NULL_ADDRESS,
sender: NULL_ADDRESS,
expirationTimeSeconds: ZERO,
salt: ZERO,
callData: hexUtils.leftPad(0),
feeToken: NULL_ADDRESS,
fees: [] as MetaTransactionV2Fee[],
chainId: 1,
verifyingContract: getContractAddressesForChainOrThrow(1).exchangeProxy,
};
export type MetaTransactionV2Fields = typeof MTX_DEFAULT_VALUES;
export class MetaTransactionV2 {
public static readonly FEE_STRUCT_NAME = 'MetaTransactionFeeData';
public static readonly FEE_STRUCT_ABI = [
{ type: 'address', name: 'recipient' },
{ type: 'uint256', name: 'amount' },
];
public static readonly FEE_TYPE_HASH = getTypeHash(MetaTransactionV2.FEE_STRUCT_NAME, MetaTransactionV2.FEE_STRUCT_ABI);
public static readonly MTX_STRUCT_NAME = 'MetaTransactionDataV2';
public static readonly MTX_STRUCT_ABI = [
{ type: 'address', name: 'signer' },
{ type: 'address', name: 'sender' },
{ type: 'uint256', name: 'expirationTimeSeconds' },
{ type: 'uint256', name: 'salt' },
{ type: 'bytes', name: 'callData' },
{ type: 'address', name: 'feeToken' },
{ type: `${MetaTransactionV2.FEE_STRUCT_NAME}[]`, name: 'fees' },
];
public static readonly MTX_TYPE_HASH = getTypeHash(
MetaTransactionV2.MTX_STRUCT_NAME,
MetaTransactionV2.MTX_STRUCT_ABI,
{ [MetaTransactionV2.FEE_STRUCT_NAME]: MetaTransactionV2.FEE_STRUCT_ABI }
);
public signer: string;
public sender: string;
public expirationTimeSeconds: BigNumber;
public salt: BigNumber;
public callData: string;
public feeToken: string;
public fees: MetaTransactionV2Fee[];
public chainId: number;
public verifyingContract: string;
public constructor(fields: Partial<MetaTransactionV2Fields> = {}) {
const _fields = { ...MTX_DEFAULT_VALUES, ...fields };
this.signer = _fields.signer;
this.sender = _fields.sender;
this.expirationTimeSeconds = _fields.expirationTimeSeconds;
this.salt = _fields.salt;
this.callData = _fields.callData;
this.feeToken = _fields.feeToken;
this.fees = _fields.fees;
this.chainId = _fields.chainId;
this.verifyingContract = _fields.verifyingContract;
}
public clone(fields: Partial<MetaTransactionV2Fields> = {}): MetaTransactionV2 {
return new MetaTransactionV2({
signer: this.signer,
sender: this.sender,
expirationTimeSeconds: this.expirationTimeSeconds,
salt: this.salt,
callData: this.callData,
feeToken: this.feeToken,
fees: this.fees,
chainId: this.chainId,
verifyingContract: this.verifyingContract,
...fields,
});
}
public getStructHash(): string {
const feesHash = hexUtils.hash(hexUtils.concat(
...this.fees.map((fee) => hexUtils.hash(hexUtils.concat(
hexUtils.leftPad(MetaTransactionV2.FEE_TYPE_HASH),
hexUtils.leftPad(fee.recipient),
hexUtils.leftPad(fee.amount),
)))
));
return hexUtils.hash(
hexUtils.concat(
hexUtils.leftPad(MetaTransactionV2.MTX_TYPE_HASH),
hexUtils.leftPad(this.signer),
hexUtils.leftPad(this.sender),
hexUtils.leftPad(this.expirationTimeSeconds),
hexUtils.leftPad(this.salt),
hexUtils.hash(this.callData),
hexUtils.leftPad(this.feeToken),
hexUtils.leftPad(feesHash),
),
);
}
public getEIP712TypedData(): EIP712TypedData {
return {
types: {
EIP712Domain: EIP712_DOMAIN_PARAMETERS,
[MetaTransactionV2.MTX_STRUCT_NAME]: MetaTransactionV2.MTX_STRUCT_ABI,
[MetaTransactionV2.FEE_STRUCT_NAME]: MetaTransactionV2.FEE_STRUCT_ABI,
},
domain: createExchangeProxyEIP712Domain(this.chainId, this.verifyingContract) as any,
primaryType: MetaTransactionV2.MTX_STRUCT_NAME,
message: {
signer: this.signer,
sender: this.sender,
expirationTimeSeconds: this.expirationTimeSeconds.toString(10),
salt: this.salt.toString(10),
callData: this.callData,
feeToken: this.feeToken,
fees: this.fees.map(({recipient, amount}) => ({
recipient,
amount: amount.toString(10),
})) as any,
},
};
}
public getHash(): string {
return getExchangeProxyEIP712Hash(this.getStructHash(), this.chainId, this.verifyingContract);
}
}

View File

@@ -0,0 +1,66 @@
import { chaiSetup, } from '@0x/dev-utils';
import { BigNumber } from '@0x/utils';
import { expect } from 'chai';
import { MetaTransactionV2 } from '../src/meta_transactions_v2';
chaiSetup.configure();
describe('mtxs v2', () => {
describe('MetaTransactionV2 (no fees)', () => {
const mtx = new MetaTransactionV2({
signer: '0x349e8d89e8b37214d9ce3949fc5754152c525bc3',
sender: '0x83c62b2e67dea0df2a27be0def7a22bd7102642c',
expirationTimeSeconds: new BigNumber(9101112),
salt: new BigNumber(2001),
callData: '0x12345678',
feeToken: '0xcc3c7ea403427154ec908203ba6c418bd699f7ce',
fees: [] as any,
chainId: 8008,
verifyingContract: '0x6701704d2421c64ee9aa93ec7f96ede81c4be77d',
});
it('can get the struct hash', () => {
const actual = mtx.getStructHash();
const expected = '0x57db4055edfed82a6d86103197c21390bf29412fb4585e08c708454e03d92516';
expect(actual).to.eq(expected);
});
it('can get the EIP712 hash', () => {
const actual = mtx.getHash();
const expected = '0x05fc975cb9f37cc442a2975bc479502ce33d2d068fe8a1d6f50dbb11c1499137';
expect(actual).to.eq(expected);
});
});
describe('MetaTransactionV2 (two fees)', () => {
const mtx = new MetaTransactionV2({
signer: '0x349e8d89e8b37214d9ce3949fc5754152c525bc3',
sender: '0x83c62b2e67dea0df2a27be0def7a22bd7102642c',
expirationTimeSeconds: new BigNumber(9101112),
salt: new BigNumber(2001),
callData: '0x12345678',
feeToken: '0xcc3c7ea403427154ec908203ba6c418bd699f7ce',
fees: [{
recipient: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
amount: new BigNumber(1000000),
}, {
recipient: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
amount: new BigNumber(1000),
}] as any,
chainId: 8008,
verifyingContract: '0x6701704d2421c64ee9aa93ec7f96ede81c4be77d',
});
it('can get the struct hash', () => {
const actual = mtx.getStructHash();
const expected = '0x441c8b8a8f25c1716f2880326d008d07d0b8eb9606623c0a81dd5d9fa14dd12e';
expect(actual).to.eq(expected);
});
it('can get the EIP712 hash', () => {
const actual = mtx.getHash();
const expected = '0xfc85ef2149bd49fcc8fee2571ed8f0ecd671dec03845637ab1ded3d891ac3386';
expect(actual).to.eq(expected);
});
});
});