-
Notifications
You must be signed in to change notification settings - Fork 102
KNC Migration Adapter #86
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8e58b78
Add Kyber migration adapter contract
0xSachinK 0233abb
Add tests
0xSachinK e8c0179
Add @openzeppelin/[email protected] as dependency
0xSachinK f3b339f
Add external contract KyberNetworkTokenV2
0xSachinK 6504823
Updated KyberNetworkTokenV2 abi
0xSachinK 622f754
Add missing test and remove proxy from contract
0xSachinK 39e9c43
Remove external dependency openzeppelin/contracts-upgradeable
0xSachinK 4258f5e
Fix variable names and bump package
0xSachinK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
contracts/protocol/integration/wrap/KyberMigrationAdapter.sol
This file contains hidden or 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,107 @@ | ||
/* | ||
Copyright 2021 Set Labs Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
SPDX-License-Identifier: Apache License, Version 2.0 | ||
*/ | ||
|
||
pragma solidity 0.6.10; | ||
|
||
/** | ||
* @title KyberMigrationAdapter | ||
* @author Set Protocol | ||
* | ||
* Wrap adapter for one time token migration that returns data for wrapping KNC Legacy into KNC. | ||
* Note: KNC can not be unwrapped into KNC Legacy, because migration can not be reversed. | ||
*/ | ||
contract KyberMigrationWrapAdapter { | ||
|
||
/* ============ State Variables ============ */ | ||
|
||
address public immutable kncLegacyToken; | ||
address public immutable kncToken; | ||
|
||
/* ============ Constructor ============ */ | ||
|
||
/** | ||
* Set state variables | ||
* | ||
* @param _kncLegacyToken Address of KNC Legacy token | ||
* @param _kncToken Address of KNC token | ||
*/ | ||
constructor( | ||
address _kncLegacyToken, | ||
address _kncToken | ||
) | ||
public | ||
{ | ||
kncLegacyToken = _kncLegacyToken; | ||
kncToken = _kncToken; | ||
} | ||
|
||
/* ============ External Getter Functions ============ */ | ||
|
||
/** | ||
* Generates the calldata to migrate KNC Legacy to KNC. | ||
* | ||
* @param _underlyingToken Address of the component to be wrapped | ||
* @param _wrappedToken Address of the wrapped component | ||
* @param _underlyingUnits Total quantity of underlying units to wrap | ||
* | ||
* @return address Target contract address | ||
* @return uint256 Total quantity of underlying units (if underlying is ETH) | ||
* @return bytes Wrap calldata | ||
*/ | ||
function getWrapCallData( | ||
address _underlyingToken, | ||
address _wrappedToken, | ||
uint256 _underlyingUnits | ||
) | ||
external | ||
view | ||
returns (address, uint256, bytes memory) | ||
{ | ||
require(_underlyingToken == kncLegacyToken, "Must be KNC Legacy token"); | ||
require(_wrappedToken == kncToken, "Must be KNC token"); | ||
|
||
// mintWithOldKnc(uint256 amount) | ||
bytes memory callData = abi.encodeWithSignature("mintWithOldKnc(uint256)", _underlyingUnits); | ||
|
||
return (kncToken, 0, callData); | ||
} | ||
|
||
/** | ||
* This function will revert, since migration cannot be reversed. | ||
*/ | ||
function getUnwrapCallData( | ||
address /* _underlyingToken */, | ||
address /* _wrappedToken */, | ||
uint256 /* _wrappedTokenUnits */ | ||
) | ||
external | ||
pure | ||
returns (address, uint256, bytes memory) | ||
{ | ||
revert("KNC migration cannot be reversed"); | ||
} | ||
|
||
/** | ||
* Returns the address to approve source tokens for wrapping. | ||
* | ||
* @return address Address of the contract to approve tokens to | ||
*/ | ||
function getSpenderAddress(address /* _underlyingToken */, address /* _wrappedToken */) external view returns(address) { | ||
return kncToken; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.