-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(permit): add support for usdc mainnet #3231
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested the full scenario, but USDC is detected as permittable
'USD//C' | ||
'USD Coin' | ||
) | ||
export const USDC_GOERLI = new Token( | ||
SupportedChainId.GOERLI, | ||
'0x07865c6e87b9f70255377e024ace6630c1eaa37f', | ||
6, | ||
'USDC', | ||
'USD//C' | ||
'USD Coin' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved hackishly by mapping token name USD//C
to USD Coin
😬
fdcbd42
to
c010aba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
// For now, this is a problem for favourite tokens cached locally with the hardcoded name for USDC token | ||
// Using the wrong name breaks the signature. | ||
const [permitParams, chainId, _tokenName, ...rest] = callDataParams | ||
const tokenName = _tokenName === 'USD//C' ? 'USD Coin' : _tokenName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅
@@ -19,6 +26,7 @@ export async function buildDaiLikePermitCallData({ | |||
callDataParams, | |||
}: BuildDaiLikePermitCallDataParams): Promise<string> { | |||
const callData = await eip2162Utils.buildDaiLikePermitCallData(...callDataParams) | |||
console.log(`[buildDaiLikePermitCallData]`, callDataParams, callData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, don't forget to remove console.log
@@ -31,3 +32,10 @@ export const ORDER_TYPE_SUPPORTS_PERMIT: Record<TradeType, boolean> = { | |||
} | |||
|
|||
export const PENDING_ORDER_PERMIT_CHECK_INTERVAL = ms`1min` | |||
|
|||
// DAI's mainnet contract (https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#readContract) returns | |||
// `1` for the version, while when calling the contract method returns `2`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't get the problem. I see DAI contract returns version=1, where do we get version=2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know where it comes from!
But that's what we get when calling the version
method 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch("https://rpc.ankr.com/eth", {
"headers": {
"accept": "*/*",
"content-type": "application/json",
},
"referrer": "http://localhost:3000/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": "{\"method\":\"eth_call\",\"params\":[{\"to\":\"0x6b175474e89094c44da98b954eedeac495271d0f\",\"data\":\"0x54fd4d50\"},\"latest\"],\"id\":49,\"jsonrpc\":\"2.0\"}",
"method": "POST",
"mode": "cors",
"credentials": "omit"
}).then(res => res.json()).then(console.log)
It's very odd. I really see that version=2 in the JSON rpc response
48a13c9
to
86e48b3
Compare
Summary
Fixes #3148
Make USDC on mainnet permittable \o/
(And any other token that has a different
version
)TODODONEThere are 3 pending issues:
USDC not permittable when loadingFIXEDUSD//C
, different from contract'sUSD Coin
DAI no longer permittableFIXEDThe
version
fetched is2
While the value when looking at etherescan is
1
Not sure this issue is only for DAI or for any DAI like token
Not able to place order due to low feeFIXEDEstimated fee for the quote is much lower than what is calculated for the real user account.
This was an expected edge case which should have been addressed with increased defaults.
See this thread for more context
It was an issue with the local cache. Succeeded now: https://dev.explorer.cow.fi/orders/0xf087fab4df05bb0f6bb1e96d1915106312248cf900d410a2465d231b5d63ad2a5b0abe214ab7875562adee331deff0fe1912fe42652e9ae9?tab=overview
To Test
permittableTokens:v1
0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
) should contain: