-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from consenlabs/support_ammv2
Support AMMV2 protocol
- Loading branch information
Showing
12 changed files
with
139 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export const version = (ctx) => { | ||
ctx.body = { | ||
result: true, | ||
version: '5.2.0-alpha.1', | ||
version: '5.2.0-alpha.2', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// sign order from custom quoter no need to put it in MMSK | ||
import { assetDataUtils, generatePseudoRandomSalt } from '0x-v2-order-utils' | ||
import * as cryptoRandomString from 'crypto-random-string' | ||
import { orderBNToString } from '../utils' | ||
import { NULL_ADDRESS } from '../constants' | ||
|
||
export const buildSignedOrder = (order, payload, makerAddress, wethAddress): any => { | ||
const makerAssetAddress = order.makerAssetAddress.toLowerCase() | ||
const takerAssetAddress = order.takerAssetAddress.toLowerCase() | ||
// = Rewrite order fields | ||
// 1. change maker address to LP pool address | ||
order.makerAddress = makerAddress | ||
// 2. convert weth to eth | ||
if (makerAssetAddress === wethAddress.toLowerCase()) { | ||
order.makerAssetAddress = NULL_ADDRESS | ||
order.makerAssetData = assetDataUtils.encodeERC20AssetData(NULL_ADDRESS) | ||
} | ||
|
||
if (takerAssetAddress === wethAddress.toLowerCase()) { | ||
order.takerAssetAddress = NULL_ADDRESS | ||
order.takerAssetData = assetDataUtils.encodeERC20AssetData(NULL_ADDRESS) | ||
} | ||
// NOTE: for AMM order we don't do signing here | ||
const signedOrder = { | ||
...order, | ||
payload: payload, | ||
salt: generatePseudoRandomSalt(), | ||
makerWalletSignature: cryptoRandomString({ length: 40 }), | ||
} | ||
return orderBNToString(signedOrder) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters