View Source: contracts/examples/.router/NeptuneRouter.sol
↗ Extends: INeptuneRouterV1, Recoverable
NeptuneRouterV1
- constructor(IStore store)
- addCovers(struct ICover.AddCoverArgs[] args)
- addProducts(struct ICover.AddProductArgs[] args)
- _getFee(struct IPolicy.PurchaseCoverArgs[] args)
- purchaseCovers(struct IPolicy.PurchaseCoverArgs[] args)
- addLiquidities(struct IVault.AddLiquidityArgs[] args)
function (IStore store) public nonpayable Recoverable
Arguments
Name | Type | Description |
---|---|---|
store | IStore |
Source Code
constructor(IStore store) Recoverable(store) {}
function addCovers(struct ICover.AddCoverArgs[] args) external nonpayable
returns(vaults address[])
Arguments
Name | Type | Description |
---|---|---|
args | struct ICover.AddCoverArgs[] |
Source Code
function addCovers(ICover.AddCoverArgs[] calldata args) external override returns (address[] memory vaults) {
IERC20 npm = s.npmToken();
IERC20 stablecoin = IERC20(s.getStablecoin());
ICover cover = s.getCoverContract();
uint256 totalStakeWithFee;
uint256 totalReassurance;
for (uint256 i = 0; i < args.length; i++) {
totalStakeWithFee += args[i].stakeWithFee;
totalReassurance += args[i].initialReassuranceAmount;
}
npm.ensureTransferFrom(msg.sender, address(this), totalStakeWithFee);
npm.ensureApproval(address(cover), totalStakeWithFee);
if (totalReassurance > 0) {
stablecoin.ensureTransferFrom(msg.sender, address(this), totalReassurance);
stablecoin.ensureApproval(address(cover), totalReassurance);
}
vaults = new address[](args.length + 1);
for (uint256 i = 0; i < args.length; i++) {
vaults[i] = cover.addCover(args[i]);
}
}
function addProducts(struct ICover.AddProductArgs[] args) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
args | struct ICover.AddProductArgs[] |
Source Code
function addProducts(ICover.AddProductArgs[] calldata args) external override {
ICover cover = s.getCoverContract();
for (uint256 i = 0; i < args.length; i++) {
cover.addProduct(args[i]);
}
}
function _getFee(struct IPolicy.PurchaseCoverArgs[] args) private view
returns(total uint256)
Arguments
Name | Type | Description |
---|---|---|
args | struct IPolicy.PurchaseCoverArgs[] |
Source Code
function _getFee(IPolicy.PurchaseCoverArgs[] calldata args) private view returns (uint256 total) {
for (uint256 i = 0; i < args.length; i++) {
PolicyHelperV1.CalculatePolicyFeeArgs memory policyFeeArgs = PolicyHelperV1.CalculatePolicyFeeArgs({
coverKey: args[i].coverKey,
productKey: args[i].productKey,
coverDuration: args[i].coverDuration,
amountToCover: args[i].amountToCover
});
(uint256 fee, ) = s.getPolicyFeeInternal(policyFeeArgs);
total += fee;
}
}
function purchaseCovers(struct IPolicy.PurchaseCoverArgs[] args) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
args | struct IPolicy.PurchaseCoverArgs[] |
Source Code
function purchaseCovers(IPolicy.PurchaseCoverArgs[] calldata args) external override {
uint256 fee = _getFee(args);
IERC20 stablecoin = IERC20(s.getStablecoin());
IPolicy policy = s.getPolicyContract();
stablecoin.ensureTransferFrom(msg.sender, address(this), fee);
stablecoin.ensureApproval(address(policy), fee);
for (uint256 i = 0; i < args.length; i++) {
policy.purchaseCover(args[i]);
}
}
function addLiquidities(struct IVault.AddLiquidityArgs[] args) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
args | struct IVault.AddLiquidityArgs[] |
Source Code
function addLiquidities(IVault.AddLiquidityArgs[] calldata args) external override {
IERC20 stablecoin = IERC20(s.getStablecoin());
IERC20 npm = s.npmToken();
uint256 totalAmount;
uint256 totalNpm;
for (uint256 i = 0; i < args.length; i++) {
totalAmount += args[i].amount;
totalNpm += args[i].npmStakeToAdd;
}
stablecoin.ensureTransferFrom(msg.sender, address(this), totalAmount);
npm.ensureTransferFrom(msg.sender, address(this), totalNpm);
for (uint256 i = 0; i < args.length; i++) {
IVault vault = s.getVault(args[i].coverKey);
stablecoin.approve(address(vault), args[i].amount);
npm.approve(address(vault), args[i].npmStakeToAdd);
vault.addLiquidity(args[i]);
IERC20(vault).ensureTransfer(msg.sender, vault.balanceOf(address(this)));
}
}
- AaveStrategy
- AccessControl
- AccessControlLibV1
- Address
- BaseLibV1
- BokkyPooBahsDateTimeLibrary
- BondPool
- BondPoolBase
- BondPoolLibV1
- CompoundStrategy
- Context
- Cover
- CoverBase
- CoverLibV1
- CoverReassurance
- CoverStake
- CoverUtilV1
- cxToken
- cxTokenFactory
- cxTokenFactoryLibV1
- Delayable
- Destroyable
- ERC165
- ERC20
- FakeAaveLendingPool
- FakeCompoundDaiDelegator
- FakePriceOracle
- FakeRecoverable
- FakeStore
- FakeToken
- FakeUniswapPair
- FakeUniswapV2FactoryLike
- FakeUniswapV2PairLike
- FakeUniswapV2RouterLike
- FaultyAaveLendingPool
- FaultyCompoundDaiDelegator
- Finalization
- ForceEther
- Governance
- GovernanceUtilV1
- IAaveV2LendingPoolLike
- IAccessControl
- IBondPool
- IClaimsProcessor
- ICompoundERC20DelegatorLike
- ICover
- ICoverReassurance
- ICoverStake
- ICxToken
- ICxTokenFactory
- IERC165
- IERC20
- IERC20Detailed
- IERC20Metadata
- IERC3156FlashBorrower
- IERC3156FlashLender
- IFinalization
- IGovernance
- ILendingStrategy
- ILiquidityEngine
- IMember
- INeptuneRouterV1
- InvalidStrategy
- IPausable
- IPolicy
- IPolicyAdmin
- IPriceOracle
- IProtocol
- IRecoverable
- IReporter
- IResolution
- IResolvable
- IStakingPools
- IStore
- IStoreLike
- IUniswapV2FactoryLike
- IUniswapV2PairLike
- IUniswapV2RouterLike
- IUnstakable
- IVault
- IVaultDelegate
- IVaultFactory
- IWitness
- LiquidityEngine
- MaliciousToken
- MockAccessControlUser
- MockCoverUtilUser
- MockCxToken
- MockCxTokenPolicy
- MockCxTokenStore
- MockFlashBorrower
- MockLiquidityEngineUser
- MockProcessorStore
- MockProcessorStoreLib
- MockProtocol
- MockRegistryClient
- MockStore
- MockStoreKeyUtilUser
- MockValidationLibUser
- MockVault
- MockVaultLibUser
- NeptuneRouterV1
- NPM
- NpmDistributor
- NTransferUtilV2
- NTransferUtilV2Intermediate
- Ownable
- Pausable
- Policy
- PolicyAdmin
- PolicyHelperV1
- PoorMansERC20
- POT
- PriceLibV1
- Processor
- ProtoBase
- Protocol
- ProtoUtilV1
- Recoverable
- ReentrancyGuard
- RegistryLibV1
- Reporter
- Resolution
- Resolvable
- RoutineInvokerLibV1
- SafeERC20
- StakingPoolBase
- StakingPoolCoreLibV1
- StakingPoolInfo
- StakingPoolLibV1
- StakingPoolReward
- StakingPools
- Store
- StoreBase
- StoreKeyUtil
- StrategyLibV1
- Strings
- TimelockController
- Unstakable
- ValidationLibV1
- Vault
- VaultBase
- VaultDelegate
- VaultDelegateBase
- VaultDelegateWithFlashLoan
- VaultFactory
- VaultFactoryLibV1
- VaultLibV1
- VaultLiquidity
- VaultStrategy
- WithFlashLoan
- WithPausability
- WithRecovery
- Witness