Skip to content

Commit

Permalink
Feat: FlashmintNAV (#186)
Browse files Browse the repository at this point in the history
* start FlashMintNav

* minimal compile

* minimal compile

* wip add deploy funcs for nav issuance module

* add nav issuance abi for typechain

* remove alt name nav issuance module

* consistent filename casing

* consistent filename casing

* fix deps

* test setup

* first test run

* use correct version of DIM from fixture

* check for reserve asset

* issue functions & tests

* redeem for ETH

* add redeem for erc20 function

* cleanup unused functions

* function to validate reserve asset

* wip getter functions

* debugging static call in test

* fix callStatic

* use callStatic

* tests for output estimation

* cleanup

* add description

* cleanup issue from eth test

* issue tests cont

* add tests for dai and usdt

* wip refactor redeem tests

* redemption tests

* update desc and wip refactor tests

* refactor redeem tests

* remove unused import

* reorg immutable vars

* format withdrawTokens

---------

Co-authored-by: Pranav Bhardwaj <[email protected]>
  • Loading branch information
edkim and pblivin0x authored Oct 3, 2024
1 parent 509df42 commit bcec4c1
Show file tree
Hide file tree
Showing 10 changed files with 1,105 additions and 2 deletions.
412 changes: 412 additions & 0 deletions contracts/exchangeIssuance/FlashMintNAV.sol

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions contracts/interfaces/INAVIssuanceHook.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2020 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;

import { ISetToken } from "./ISetToken.sol";

interface INAVIssuanceHook {
function invokePreIssueHook(
ISetToken _setToken,
address _reserveAsset,
uint256 _reserveAssetQuantity,
address _sender,
address _to
)
external;

function invokePreRedeemHook(
ISetToken _setToken,
uint256 _redeemQuantity,
address _sender,
address _to
)
external;
}
57 changes: 57 additions & 0 deletions contracts/interfaces/INAVIssuanceModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2024 Index Coop
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;

import { ISetToken } from "./ISetToken.sol";

interface INAVIssuanceModule {
function issue(
ISetToken _setToken,
address _reserveAsset,
uint256 _reserveAssetQuantity,
uint256 _minSetTokenReceiveQuantity,
address _to
) external;

function redeem(
ISetToken _setToken,
address _reserveAsset,
uint256 _setTokenQuantity,
uint256 _minReserveReceiveQuantity,
address _to
) external;

function isReserveAsset(
ISetToken _setToken,
address _asset
) external view returns(bool);

function getReserveAssets(address _setToken) external view returns (address[] memory);

function getExpectedSetTokenIssueQuantity(
ISetToken _setToken,
address _reserveAsset,
uint256 _reserveAssetQuantity
) external view returns (uint256);

function getExpectedReserveRedeemQuantity(
ISetToken _setToken,
address _reserveAsset,
uint256 _setTokenQuantity
) external view returns (uint256);
}
2 changes: 1 addition & 1 deletion test/integration/arbitrum/withdrawTokens.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { impersonateAccount, setBlockNumber } from "@utils/test/testingUtils";
import { WithdrawTokens__factory } from "../../../typechain";

if (process.env.INTEGRATIONTEST) {
describe.only("WithdrawTokens", function () {
describe("WithdrawTokens", function () {
const deployerAddress = "0x37e6365d4f6aE378467b0e24c9065Ce5f06D70bF";
let deployerSigner: Signer;

Expand Down
1 change: 1 addition & 0 deletions test/integration/ethereum/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const PRODUCTION_ADDRESSES = {
osEth: "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38",
comp: "0xc00e94Cb662C3520282E6f5717214004A7f26888",
dpi: "0x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b",
usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
},
whales: {
stEth: "0xdc24316b9ae028f1497c275eb9192a3ea0f67022",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/ethereum/flashMintDex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const swapDataWethToUsdc = {
};

if (process.env.INTEGRATIONTEST) {
describe.only("FlashMintDex - Integration Test", async () => {
describe("FlashMintDex - Integration Test", async () => {
let owner: Account;
let deployer: DeployHelper;
let legacySetTokenCreator: SetTokenCreator;
Expand Down
Loading

0 comments on commit bcec4c1

Please sign in to comment.