Skip to content
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

feat(smart-contarcts): add support for swap and purchase when a discount hook is activated #13456

Closed
wants to merge 13 commits into from

Conversation

clemsos
Copy link
Member

@clemsos clemsos commented Mar 12, 2024

Description

NB: This is WIP

This can be tested with

RUN_FORK=1 yarn hardhat test test/UnlockSwapPurchaser/usePurchaseHook.mainnet.js

Issues

Fixes #
Refs #

Checklist:

  • 1 PR, 1 purpose: my Pull Request applies to a single purpose
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the docs to reflect my changes if applicable
  • I have added tests (and stories for frontend components) that prove my fix is effective or that my feature works
  • I have performed a self-review of my own code
  • If my code involves visual changes, I am adding applicable screenshots to this thread

Release Note Draft Snippet

@clemsos clemsos requested a review from julien51 March 12, 2024 16:53
@cla-bot cla-bot bot added the cla-signed label Mar 12, 2024
Renaming for clarity!
@@ -77,6 +77,29 @@ contract UnlockSwapPurchaser {
: IMintableERC20(token).balanceOf(address(this));
}

function getKeyPrice(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment that this does it only for the the first recipient.

console.log(srcToken);
console.log(msg.sender);
console.log(address(this));
console.log(amountInMax);
TransferHelper.safeTransferFrom(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this fails. But I am not sure why :/

)

// WHY DOES THIS FAIL?
await tokenContract
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails, even though the approval above is correct so I am really confused.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    Error: VM Exception while processing transaction: reverted with reason string 'ERC20: transfer amount exceeds allowance'

@@ -20,14 +20,14 @@
"@nomiclabs/hardhat-ethers": "2.2.3",
"@nomiclabs/hardhat-waffle": "2.0.6",
"@uniswap/permit2-sdk": "1.2.0",
"@uniswap/sdk-core": "4.0.9",
"@uniswap/smart-order-router": "3.19.2",
"@uniswap/v3-sdk": "3.10.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as this was not used. This seems to help remove errors!

"@unlock-protocol/contracts": "workspace:^",
"@unlock-protocol/networks": "workspace:^",
"@unlock-protocol/tsconfig": "workspace:^",
"@unlock-protocol/types": "workspace:^",
"ethers": "6.10.0",
"ethersv5": "npm:ethers@^5.7.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added because the alphe router needs it!

@@ -84,6 +84,7 @@ export const sepolia: NetworkConfig = {
networkName: 'sepolia',
studioName: 'unlock-protocol-sepolia',
},
swapPurchaser: '0x580A4a5a9612371e3832c4559026B9Ee3b23Cc11',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deplpyed on Sepolia but can't test because we're getting 404 on

failed to resolve /ipns/api.uniswap.org/v1/pools/v3/sepolia.json: no link named "sepolia.json" under QmaimGCW33MN3uCAZYQmckXLCFQCgt82bypYt4tWqpiU32

@julien51
Copy link
Member

I think we can close that one unless there are things we need to keep?

@clemsos
Copy link
Member Author

clemsos commented Mar 13, 2024

I think we can close that one unless there are things we need to keep?

yes lets close it. Still annoys me to not know why that transferFrom was failing haha

@clemsos clemsos closed this Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants