@etherisc/gif-next 0.0.2-d64ea51-772 → 0.0.2-d8b116d-201
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +43 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +2 -2
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +2 -2
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +16 -11
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +13 -8
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +750 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +20 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +52 -32
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +38 -28
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +2 -2
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +2 -2
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +272 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +2 -2
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +2 -2
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +2 -2
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +21 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +59 -14
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +20 -8
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +24 -24
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +13 -13
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/IPoolComponent.sol +1 -1
- package/contracts/components/Pool.sol +7 -6
- package/contracts/components/Product.sol +1 -0
- package/contracts/instance/BundleManager.sol +143 -0
- package/contracts/instance/Cloneable.sol +47 -0
- package/contracts/instance/InstanceService.sol +3 -0
- package/contracts/instance/ObjectManager.sol +95 -0
- package/contracts/instance/module/ISetup.sol +2 -1
- package/contracts/instance/service/IPoolService.sol +2 -0
- package/contracts/instance/service/PoolService.sol +15 -12
- package/contracts/instance/service/ProductService.sol +2 -4
- package/contracts/types/NftIdSet.sol +26 -24
- package/package.json +1 -1
@@ -5,7 +5,6 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
|
|
5
5
|
|
6
6
|
import {Fee} from "../../types/Fee.sol";
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
|
-
import {LibNftIdSet} from "../../types/NftIdSet.sol";
|
9
8
|
import {UFixed} from "../../types/UFixed.sol";
|
10
9
|
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
11
10
|
|
@@ -21,6 +20,7 @@ interface ISetup {
|
|
21
20
|
Fee poolFee; // pool fee on net premium
|
22
21
|
Fee stakingFee; // pool fee on staked capital from investor
|
23
22
|
Fee performanceFee; // pool fee on profits from capital investors
|
23
|
+
bool isIntercepting; // intercepts nft transfers (for products)
|
24
24
|
address wallet;
|
25
25
|
}
|
26
26
|
|
@@ -40,6 +40,7 @@ interface ISetup {
|
|
40
40
|
Fee stakingFee; // pool fee on staked capital from investor
|
41
41
|
Fee performanceFee; // pool fee on profits from capital investors
|
42
42
|
bool isIntercepting; // intercepts nft transfers (for bundles)
|
43
|
+
bool isConfirmingApplication; // confirms applications before they are underwritten
|
43
44
|
address wallet;
|
44
45
|
}
|
45
46
|
}
|
@@ -8,6 +8,8 @@ import {IService} from "../../shared/IService.sol";
|
|
8
8
|
import {IBundle} from "../module/IBundle.sol";
|
9
9
|
|
10
10
|
interface IPoolService is IService {
|
11
|
+
error ErrorIPoolServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
12
|
+
|
11
13
|
function setFees(
|
12
14
|
Fee memory poolFee,
|
13
15
|
Fee memory stakingFee,
|
@@ -28,7 +28,6 @@ import {IRegistryService} from "../../registry/IRegistryService.sol";
|
|
28
28
|
import {InstanceService} from "../InstanceService.sol";
|
29
29
|
import {InstanceReader} from "../InstanceReader.sol";
|
30
30
|
|
31
|
-
|
32
31
|
string constant POOL_SERVICE_NAME = "PoolService";
|
33
32
|
|
34
33
|
contract PoolService is
|
@@ -136,13 +135,11 @@ contract PoolService is
|
|
136
135
|
|
137
136
|
// TODO add bundle to pool in instance
|
138
137
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
// bundleNftId,
|
145
|
-
// stakingAmount);
|
138
|
+
_processStakingByTreasury(
|
139
|
+
instanceReader,
|
140
|
+
poolNftId,
|
141
|
+
bundleNftId,
|
142
|
+
stakingAmount);
|
146
143
|
|
147
144
|
// TODO add logging
|
148
145
|
}
|
@@ -178,7 +175,6 @@ contract PoolService is
|
|
178
175
|
|
179
176
|
function _processStakingByTreasury(
|
180
177
|
InstanceReader instanceReader,
|
181
|
-
NftId productNftId,
|
182
178
|
NftId poolNftId,
|
183
179
|
NftId bundleNftId,
|
184
180
|
uint256 stakingAmount
|
@@ -187,15 +183,22 @@ contract PoolService is
|
|
187
183
|
{
|
188
184
|
// process token transfer(s)
|
189
185
|
if(stakingAmount > 0) {
|
190
|
-
TokenHandler tokenHandler = TokenHandler(instanceReader.getTokenHandler(productNftId));
|
191
|
-
address bundleOwner = getRegistry().ownerOf(bundleNftId);
|
192
186
|
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
193
|
-
|
187
|
+
TokenHandler tokenHandler = poolInfo.tokenHandler;
|
188
|
+
address bundleOwner = getRegistry().ownerOf(bundleNftId);
|
189
|
+
Fee memory stakingFee = poolInfo.stakingFee;
|
190
|
+
|
194
191
|
tokenHandler.transfer(
|
195
192
|
bundleOwner,
|
196
193
|
poolInfo.wallet,
|
197
194
|
stakingAmount
|
198
195
|
);
|
196
|
+
|
197
|
+
|
198
|
+
if (! FeeLib.feeIsZero(stakingFee)) {
|
199
|
+
(uint256 stakingFeeAmount, uint256 netAmount) = FeeLib.calculateFee(stakingFee, stakingAmount);
|
200
|
+
// TODO: track staking fees in pool's state (issue #177)
|
201
|
+
}
|
199
202
|
}
|
200
203
|
}
|
201
204
|
}
|
@@ -323,8 +323,7 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
323
323
|
returns (IBundle.BundleInfo memory)
|
324
324
|
{
|
325
325
|
bundleInfo.lockedAmount += collateralAmount;
|
326
|
-
//
|
327
|
-
// instance.collateralizePolicy(bundleNftId, policyNftId, collateralAmount);
|
326
|
+
// TODO: track policy associated to bundle in bundlemanager (tbd) and how much is locked for it
|
328
327
|
return bundleInfo;
|
329
328
|
}
|
330
329
|
|
@@ -432,8 +431,7 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
432
431
|
NftId poolNftId = bundleInfo.poolNftId;
|
433
432
|
ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
|
434
433
|
|
435
|
-
|
436
|
-
if(poolInfo.isIntercepting) {
|
434
|
+
if(poolInfo.isConfirmingApplication) {
|
437
435
|
_underwriteByPool(
|
438
436
|
poolNftId,
|
439
437
|
policyNftId,
|
@@ -11,35 +11,37 @@ library LibNftIdSet {
|
|
11
11
|
mapping(NftId nftid => uint256 index) at;
|
12
12
|
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
error ErrorNftIdSetAlreadyAdded(NftId nftId);
|
15
|
+
error ErrorNftIdSetNotInSet(NftId nftId);
|
16
|
+
|
17
|
+
|
18
|
+
function add(Set storage set, NftId nftId) external {
|
19
|
+
if (set.at[nftId] > 0) {
|
20
|
+
revert ErrorNftIdSetAlreadyAdded(nftId);
|
21
21
|
}
|
22
|
+
|
23
|
+
set.ids.push(nftId);
|
24
|
+
set.at[nftId] = set.ids.length;
|
22
25
|
}
|
23
26
|
|
24
|
-
function remove(Set storage set, NftId nftId) external
|
27
|
+
function remove(Set storage set, NftId nftId) external {
|
25
28
|
uint256 nftIdIndex = set.at[nftId];
|
26
29
|
|
27
|
-
if (nftIdIndex
|
28
|
-
|
29
|
-
uint256 lastIndex = set.ids.length - 1;
|
30
|
-
|
31
|
-
if (lastIndex != toDeleteIndex) {
|
32
|
-
NftId lastId = set.ids[lastIndex];
|
33
|
-
set.ids[toDeleteIndex] = lastId;
|
34
|
-
set.at[lastId] = nftIdIndex; // Replace lastValue's index to valueIndex
|
35
|
-
}
|
36
|
-
|
37
|
-
set.ids.pop();
|
38
|
-
delete set.at[nftId];
|
39
|
-
return true;
|
40
|
-
} else {
|
41
|
-
return false;
|
30
|
+
if (nftIdIndex == 0) {
|
31
|
+
revert ErrorNftIdSetNotInSet(nftId);
|
42
32
|
}
|
33
|
+
|
34
|
+
uint256 toDeleteIndex = nftIdIndex - 1;
|
35
|
+
uint256 lastIndex = set.ids.length - 1;
|
36
|
+
|
37
|
+
if (lastIndex != toDeleteIndex) {
|
38
|
+
NftId lastId = set.ids[lastIndex];
|
39
|
+
set.ids[toDeleteIndex] = lastId;
|
40
|
+
set.at[lastId] = nftIdIndex; // Replace lastValue's index to valueIndex
|
41
|
+
}
|
42
|
+
|
43
|
+
set.ids.pop();
|
44
|
+
delete set.at[nftId];
|
43
45
|
}
|
44
46
|
|
45
47
|
function isEmpty(Set storage set) external view returns(bool empty) {
|
@@ -50,7 +52,7 @@ library LibNftIdSet {
|
|
50
52
|
return set.at[nftId] > 0;
|
51
53
|
}
|
52
54
|
|
53
|
-
function
|
55
|
+
function size(Set storage set) external view returns(uint256 length) {
|
54
56
|
return set.ids.length;
|
55
57
|
}
|
56
58
|
|
package/package.json
CHANGED