diff --git a/.vscode/settings.json b/.vscode/settings.json index a2f9328f..744ac11d 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,5 +12,6 @@ ], "editor.codeActionsOnSave": { "source.fixAll.eslint": true - } + }, + "solidity.compileUsingRemoteVersion": "v0.8.9+commit.e5eed63a" } diff --git a/contracts/interface/ILockup.sol b/contracts/interface/ILockup.sol index 08854749..c50ff23e 100644 --- a/contracts/interface/ILockup.sol +++ b/contracts/interface/ILockup.sol @@ -35,6 +35,13 @@ interface ILockup { external returns (uint256); + function depositToProperty( + address _property, + uint256 _amount, + address _gatewayAddress, + uint256 _gatewayFee + ) external returns (uint256); + function depositToPosition(uint256 _tokenId, uint256 _amount) external returns (bool); @@ -46,6 +53,13 @@ interface ILockup { function update() external; + function withdrawByPosition( + uint256 _tokenId, + uint256 _amount, + address _gatewayAddress, + uint256 _gatewayBasisFee + ) external returns (bool); + function withdrawByPosition(uint256 _tokenId, uint256 _amount) external returns (bool); diff --git a/contracts/src/lockup/Lockup.sol b/contracts/src/lockup/Lockup.sol index 8b31875d..917c6ec3 100644 --- a/contracts/src/lockup/Lockup.sol +++ b/contracts/src/lockup/Lockup.sol @@ -99,21 +99,12 @@ contract Lockup is ILockup, InitializableUsingRegistry { } /** - * @dev deposit dev token to dev protocol and generate s-token - * @param _property target property address - * @param _amount staking value - * @return tokenId The ID of the created new staking position + * */ - function depositToProperty(address _property, uint256 _amount) - external - override - onlyAuthenticatedProperty(_property) + function _depositToProperty(address _property, uint256 _amount) + private returns (uint256) { - /** - * Validates _amount is not 0. - */ - require(_amount != 0, "illegal deposit amount"); /** * Gets the latest cumulative sum of the interest price. */ @@ -163,6 +154,63 @@ contract Lockup is ILockup, InitializableUsingRegistry { return tokenId; } + /** + * @dev overloaded depositToProperty with gateway fee params + * @param _property target property address + * @param _amount staking value + * @param _gatewayAddress is the address to which the liquidity provider fee will be directed + * @param _gatewayFee is the basis points to pass. For example 10000 is 100% + * @return tokenId The ID of the created new staking position + */ + function depositToProperty( + address _property, + uint256 _amount, + address _gatewayAddress, + uint256 _gatewayFee + ) external override onlyAuthenticatedProperty(_property) returns (uint256) { + /** + * Validates _amount is not 0. + */ + require(_amount != 0, "illegal deposit amount"); + require(_gatewayFee <= 10000, "must be below 10000"); + + uint256 feeAmount = (_amount * _gatewayFee) / 10000; + + /** + * transfer feeAmount to _gatewayAddress + */ + require( + IERC20(registry().registries("Dev")).transferFrom( + msg.sender, + _gatewayAddress, + feeAmount + ), + "dev transfer failed" + ); + + return _depositToProperty(_property, _amount - feeAmount); + } + + /** + * @dev deposit dev token to dev protocol and generate s-token + * @param _property target property address + * @param _amount staking value + * @return tokenId The ID of the created new staking position + */ + function depositToProperty(address _property, uint256 _amount) + external + override + onlyAuthenticatedProperty(_property) + returns (uint256) + { + /** + * Validates _amount is not 0. + */ + require(_amount != 0, "illegal deposit amount"); + + return _depositToProperty(_property, _amount); + } + /** * @dev deposit dev token to dev protocol and update s-token status * @param _tokenId s-token id @@ -228,15 +276,20 @@ contract Lockup is ILockup, InitializableUsingRegistry { } /** - * Withdraw staking.(NFT) + * @dev Withdraw staking.(NFT) * Releases staking, withdraw rewards, and transfer the staked and withdraw rewards amount to the sender. + * @param _tokenId s-token id + * @param _amount staking value + * @param _gatewayAddress optional gateway fee address - set address(0) for no fee + * @param _gatewayBasisFee is the basis points fee. For example 10000 is a 100% fee + * @return bool On success, true will be returned */ - function withdrawByPosition(uint256 _tokenId, uint256 _amount) - external - override - onlyPositionOwner(_tokenId) - returns (bool) - { + function _withdrawByPosition( + uint256 _tokenId, + uint256 _amount, + address _gatewayAddress, + uint256 _gatewayBasisFee + ) private returns (bool) { ISTokensManager sTokenManager = ISTokensManager( registry().registries("STokensManager") ); @@ -253,7 +306,9 @@ contract Lockup is ILockup, InitializableUsingRegistry { * Withdraws the staking reward */ (uint256 value, RewardPrices memory prices) = _withdrawInterest( - positions + positions, + _gatewayAddress, + _gatewayBasisFee ); /** * Transfer the staked amount to the sender. @@ -265,7 +320,6 @@ contract Lockup is ILockup, InitializableUsingRegistry { * Saves variables that should change due to the canceling staking.. */ updateValues(false, positions.property, _amount, prices); - uint256 cumulative = positions.cumulativeReward + value; /** * update position information @@ -274,7 +328,7 @@ contract Lockup is ILockup, InitializableUsingRegistry { _tokenId, positions.amount - _amount, prices.interest, - cumulative, + positions.cumulativeReward + value, 0 ); if (totalLockedForProperty[positions.property] == 0) { @@ -288,6 +342,45 @@ contract Lockup is ILockup, InitializableUsingRegistry { return result; } + /** + * @dev Withdraw staking.(NFT) + * Releases staking, withdraw rewards, and transfer the staked and withdraw rewards amount to the sender. + * @param _tokenId s-token id + * @param _amount staking value + * @return bool On success, true will be returned + */ + function withdrawByPosition(uint256 _tokenId, uint256 _amount) + external + override + onlyPositionOwner(_tokenId) + returns (bool) + { + return _withdrawByPosition(_tokenId, _amount, address(0), 0); + } + + /** + * @dev withdrawByPosition overloaded with _gatewayAddress and _gatewayBasisFee + * @param _tokenId s-token id + * @param _amount staking value + * @param _gatewayAddress optional gateway fee address - set address(0) for no fee + * @param _gatewayBasisFee is the basis points fee. For example 10000 is a 100% fee + * @return bool On success, true will be returned + */ + function withdrawByPosition( + uint256 _tokenId, + uint256 _amount, + address _gatewayAddress, + uint256 _gatewayBasisFee + ) external override onlyPositionOwner(_tokenId) returns (bool) { + return + _withdrawByPosition( + _tokenId, + _amount, + _gatewayAddress, + _gatewayBasisFee + ); + } + /** * get lockup info */ @@ -658,7 +751,9 @@ contract Lockup is ILockup, InitializableUsingRegistry { * Withdraws staking reward as an interest. */ function _withdrawInterest( - ISTokensManager.StakingPositions memory positions + ISTokensManager.StakingPositions memory positions, + address _gatewayAddress, + uint256 _gatewayBasisFee ) private returns (uint256 value_, RewardPrices memory prices_) { /** * Gets the withdrawable amount. @@ -668,16 +763,32 @@ contract Lockup is ILockup, InitializableUsingRegistry { RewardPrices memory prices ) = _calculateWithdrawableInterestAmount(positions); + IDevBridge devBridge = IDevBridge(registry().registries("DevBridge")); + /** - * Mints the reward. + * Gateway Fee exists + * send fee to gateway address and the remainder to msg.sender */ - require( - IDevBridge(registry().registries("DevBridge")).mint( - msg.sender, - value - ), - "dev mint failed" - ); + if (_gatewayAddress != address(0) && _gatewayBasisFee > 0) { + uint256 feeValue = (value * _gatewayBasisFee) / 10000; + + require( + devBridge.mint(msg.sender, value - feeValue), + "dev mint failed" + ); + + require( + devBridge.mint(_gatewayAddress, feeValue), + "fee dev mint failed" + ); + } + /** + * No gateway fee + * send the entirety to msg.sender + */ + else { + require(devBridge.mint(msg.sender, value), "dev mint failed"); + } /** * Since the total supply of tokens has changed, updates the latest maximum mint amount. diff --git a/package.json b/package.json index b5a9b57a..54ec962c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devprotocol/protocol-v2", - "version": "0.5.0", + "version": "0.5.1", "description": "Securitize for Internet assets", "scripts": { "test": "truffle test --config truffle-config.js", @@ -42,6 +42,7 @@ "eslint-config-xo": "0.41.0", "eslint-config-xo-typescript": "0.51.1", "husky": "7.0.4", + "js-base64": "3.7.2", "p-queue": "7.2.0", "prettier": "2.7.1", "prettier-plugin-solidity": "1.0.0-beta.19", diff --git a/test/lockup/lockup-s-token-common.ts b/test/lockup/lockup-s-token-common.ts index 4ec2fdf2..d507ad01 100644 --- a/test/lockup/lockup-s-token-common.ts +++ b/test/lockup/lockup-s-token-common.ts @@ -55,7 +55,14 @@ export const init2 = async ( ): Promise<[DevProtocolInstance, PropertyInstance, number]> => { const [dev, property] = await init(deployer, user) await dev.dev.approve(dev.lockup.address, 600) - await dev.lockup.depositToProperty(property.address, 100) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + const tokenIds = await dev.sTokensManager.positionsOfOwner(deployer) return [dev, property, tokenIds[0].toNumber()] diff --git a/test/lockup/lockup-s-token-scenario.ts b/test/lockup/lockup-s-token-scenario.ts index d5a117f7..885ba5d9 100644 --- a/test/lockup/lockup-s-token-scenario.ts +++ b/test/lockup/lockup-s-token-scenario.ts @@ -64,9 +64,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { * And stakers share is 10% */ it('Alice has a 100% of interests', async () => { - await dev.lockup.depositToProperty(property.address, 1000000000000, { - from: alice, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 1000000000000, + { + from: alice, + } + ) + const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) @@ -101,9 +108,15 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { expect(result.toFixed()).to.be.equal(calculated) }) it('Alice has a 50% of interests', async () => { - await dev.lockup.depositToProperty(property.address, 1000000000000, { - from: bob, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 1000000000000, + { + from: bob, + } + ) timestamps.set('a1', await getBlockTimestamp()) await dev.lockup.withdrawByPosition(aliceFirstTokenId, 0, { from: alice, @@ -237,9 +250,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { bobPosition.amount.toString(), { from: bob } ) - await dev.lockup.depositToProperty(property.address, 1000000000000, { - from: alice, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 1000000000000, + { + from: alice, + } + ) + const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) const result = await dev.lockup @@ -258,9 +278,17 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { await dev.lockup.depositToPosition(aliceSecoundTokenId, 1000000000000, { from: alice, }) - await dev.lockup.depositToProperty(property.address, 1000000000000, { - from: bob, - }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 1000000000000, + { + from: bob, + } + ) + await forwardBlockTimestamp(2) const alicePosition = await dev.sTokensManager.positions( aliceSecoundTokenId @@ -311,14 +339,29 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { const bobBalance = toBigNumber(10000000).times(1e18) await dev.dev.mint(bob, bobBalance) - await dev.lockup.depositToProperty(property.address, bobBalance, { - from: bob, - }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + bobBalance, + { + from: bob, + } + ) + await forwardBlockTimestamp(10) - await dev.lockup.depositToProperty(property2.address, 10000000, { - from: alice, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property2.address, + 10000000, + { + from: alice, + } + ) + const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) const result = await dev.lockup @@ -344,9 +387,17 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { propertyAddress, 1 ) - await dev.lockup.depositToProperty(propertyAddress, 1000000000000, { - from: alice, - }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + propertyAddress, + 1000000000000, + { + from: alice, + } + ) + await forwardBlockTimestamp(1) await dev.lockup.depositToPosition(aliceFourthTokenId, 1000000000000, { from: alice, @@ -380,9 +431,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { const aliceBalance = await dev.dev.balanceOf(alice).then(toBigNumber) await dev.dev.mint(bob, aliceBalance) await dev.dev.approve(dev.lockup.address, aliceBalance, { from: alice }) - await dev.lockup.depositToProperty(property.address, 10000, { - from: alice, - }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 10000, + { + from: alice, + } + ) lastTimestamp = await getBlockTimestamp() }) @@ -495,9 +553,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { const aliceBalance = await dev.dev.balanceOf(alice).then(toBigNumber) await dev.dev.mint(bob, aliceBalance) await dev.dev.approve(dev.lockup.address, aliceBalance, { from: alice }) - await dev.lockup.depositToProperty(property.address, 10000, { - from: alice, - }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 10000, + { + from: alice, + } + ) lastTimestamp = await getBlockTimestamp() }) @@ -616,9 +681,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { await dev.dev.mint(bob, aliceBalance) await dev.dev.approve(dev.lockup.address, aliceBalance, { from: alice }) await dev.dev.approve(dev.lockup.address, aliceBalance, { from: bob }) - await dev.lockup.depositToProperty(property.address, 10000, { - from: alice, - }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 10000, + { + from: alice, + } + ) }) describe('before second run', () => { @@ -631,9 +703,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { expect(aliceBalance.toFixed()).to.be.equal(total.toFixed()) }) it(`Bob does staking 25% of the Property's total lockups, Alice's share become 80%`, async () => { - await dev.lockup.depositToProperty(property.address, 10000 * 0.25, { - from: bob, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 10000 * 0.25, + { + from: bob, + } + ) + const total = await dev.lockup .totalLockedForProperty(property.address) .then(toBigNumber) @@ -845,9 +924,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { 1 ) - await dev.lockup.depositToProperty(property1.address, 10000, { - from: alice, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property1.address, + 10000, + { + from: alice, + } + ) + await forwardBlockTimestamp(3) }) @@ -861,9 +947,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { expect(aliceBalance.toFixed()).to.be.equal(total.toFixed()) }) it(`Bob does staking 100% of the Property2 total lockups, Property2 is 20% of the total rewards`, async () => { - await dev.lockup.depositToProperty(property2.address, 2500, { - from: bob, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property2.address, + 2500, + { + from: bob, + } + ) + const total = await dev.lockup.totalLocked().then(toBigNumber) const p1 = await dev.lockup .totalLockedForProperty(property1.address) @@ -973,9 +1066,16 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { }) describe('additional staking', () => { before(async () => { - await dev.lockup.depositToProperty(property3.address, 16250 * 0.6, { - from: alice, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property3.address, + 16250 * 0.6, + { + from: alice, + } + ) + await forwardBlockTimestamp(3) }) it(`Alice does staking 60% of the all Property's total lockups, Alice's share become ${ @@ -1116,6 +1216,149 @@ contract('LockupTest', ([deployer, user1, user2, user3]) => { expect(bobAmount.toFixed()).to.be.equal(expected) }) }) + + describe('scenario; single lockup with gateway fee', () => { + let dev: DevProtocolInstance + let property: PropertyInstance + let lastTimestamp: number + + const alice = deployer + const bob = user1 + + const aliceFirstTokenId = 1 + + before(async () => { + ;[dev, property] = await init(deployer, user2) + const aliceBalance = await dev.dev.balanceOf(alice).then(toBigNumber) + await dev.dev.approve(dev.lockup.address, aliceBalance, { + from: alice, + }) + + lastTimestamp = await getBlockTimestamp() + }) + + /* + * PolicyTestBase returns 100 as rewards + * And stakers share is 10% + */ + + it(`Alice should deposit to property and send Bob a gateway fee`, async () => { + const basisPoints = 300 // 3% + const depositAmount = 10000 + const gatewayAddress = bob + + await dev.lockup.depositToProperty( + property.address, + depositAmount, + gatewayAddress, + basisPoints, + { + from: alice, + } + ) + + const bobBalance = await dev.dev.balanceOf(bob).then(toBigNumber) + const feeAmount = (depositAmount * basisPoints) / 10000 + + /** + * Bob should get his gateway fee + */ + expect(bobBalance.toNumber()).to.be.equal(feeAmount) + + /** + * Alice should have (amount - fee) locked up + */ + const propertyPosition = await dev.sTokensManager.positions( + aliceFirstTokenId + ) + const propertyBalance = toBigNumber(propertyPosition.amount) + expect(propertyBalance.toNumber()).to.eq( + new BigNumber(depositAmount).minus(feeAmount).toNumber() + ) + }) + }) + + describe('scenario; gateway fees withdraw', () => { + let dev: DevProtocolInstance + let property: PropertyInstance + let lastTimestamp: number + + const alice = deployer + const bob = user1 + const depositAmount = 10000 + + const aliceFirstTokenId = 1 + + before(async () => { + ;[dev, property] = await init(deployer, user2) + const aliceBalance = await dev.dev.balanceOf(alice).then(toBigNumber) + await dev.dev.mint(bob, aliceBalance) + await dev.dev.approve(dev.lockup.address, aliceBalance, { + from: alice, + }) + // Await dev.lockup.depositToProperty(property.address, depositAmount, { + // from: alice, + // }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + depositAmount, + { + from: alice, + } + ) + + lastTimestamp = await getBlockTimestamp() + }) + + it(`Alice's withdrawable interest is 100% of the Property's interest`, async () => { + await forwardBlockTimestamp(9) + + const beforeAliceBalance = await dev.dev + .balanceOf(alice) + .then(toBigNumber) + + const beforeBobBalance = await dev.dev + .balanceOf(bob) + .then(toBigNumber) + + const t1 = await getBlockTimestamp() + const gatewayBasisFee = 300 // 3% + const expected = toBigNumber(10) // In PolicyTestBase, the max staker reward per block is 10. + .times(1e18) + .times(t1 - lastTimestamp) + + const feeAmount = (expected.toNumber() * gatewayBasisFee) / 10000 + + const expectedMinusFee = expected.minus(feeAmount) + const position = await dev.sTokensManager.positions(aliceFirstTokenId) + const aliceLocked = toBigNumber(position.amount) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods[ + 'withdrawByPosition(uint256,uint256,address,uint256)' + ](aliceFirstTokenId, aliceLocked, bob, gatewayBasisFee, { + from: alice, + }) + + const afterAliceBalance = await dev.dev + .balanceOf(alice) + .then(toBigNumber) + + const afterBobBalance = await dev.dev.balanceOf(bob).then(toBigNumber) + + expect(afterAliceBalance.toNumber()).to.eq( + beforeAliceBalance.plus(expectedMinusFee).toNumber() + ) + expect(afterBobBalance.toNumber()).to.eq( + beforeBobBalance.plus(feeAmount).toNumber() + ) + }) + }) + // TODO - ensure passing 0 gateway fee and 0 address don't charge anything }) }) }) diff --git a/test/lockup/lockup-s-token.ts b/test/lockup/lockup-s-token.ts index c367632d..e2f8d16e 100644 --- a/test/lockup/lockup-s-token.ts +++ b/test/lockup/lockup-s-token.ts @@ -38,7 +38,14 @@ contract('LockupTest', ([deployer, , user2, user3]) => { describe('success', () => { it('get nft token.', async () => { await dev.dev.approve(dev.lockup.address, 100) - await dev.lockup.depositToProperty(property.address, 100) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + const owner = await dev.sTokensManager.ownerOf(1) expect(owner).to.be.equal(deployer) const position = await dev.sTokensManager.positions(1) @@ -50,11 +57,25 @@ contract('LockupTest', ([deployer, , user2, user3]) => { }) it('get 2 nft token.', async () => { await dev.dev.approve(dev.lockup.address, 100) - await dev.lockup.depositToProperty(property.address, 100) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) await dev.dev.approve(dev.lockup.address, 200) - await dev.lockup.depositToProperty(property.address, 200) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 200 + ) + const t2 = await getBlockTimestamp() const owner = await dev.sTokensManager.ownerOf(2) expect(owner).to.be.equal(deployer) @@ -73,7 +94,14 @@ contract('LockupTest', ([deployer, , user2, user3]) => { let info = await dev.lockup.getLockedupProperties() expect(info.length).to.be.equal(0) await dev.dev.approve(dev.lockup.address, 100) - await dev.lockup.depositToProperty(property.address, 100) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + info = await dev.lockup.getLockedupProperties() expect(info.length).to.be.equal(1) expect(info[0].property).to.be.equal(property.address) @@ -81,8 +109,20 @@ contract('LockupTest', ([deployer, , user2, user3]) => { }) it('get lockup info plus value.', async () => { await dev.dev.approve(dev.lockup.address, 300) - await dev.lockup.depositToProperty(property.address, 100) - await dev.lockup.depositToProperty(property.address, 200) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 200 + ) + const info = await dev.lockup.getLockedupProperties() expect(info.length).to.be.equal(1) expect(info[0].property).to.be.equal(property.address) @@ -100,8 +140,21 @@ contract('LockupTest', ([deployer, , user2, user3]) => { ).address ) await dev.dev.approve(dev.lockup.address, 300) - await dev.lockup.depositToProperty(property.address, 100) - await dev.lockup.depositToProperty(propertyAddress, 200) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + propertyAddress, + 200 + ) + const info = await dev.lockup.getLockedupProperties() expect(info.length).to.be.equal(2) for (const lockupInfo of info) { @@ -114,7 +167,14 @@ contract('LockupTest', ([deployer, , user2, user3]) => { }) it('generate event.', async () => { await dev.dev.approve(dev.lockup.address, 100) - dev.lockup.depositToProperty(property.address, 100) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + const [_from, _property, _value, _tokenId] = await Promise.all([ getEventValue(dev.lockup)('Lockedup', '_from'), getEventValue(dev.lockup)('Lockedup', '_property'), @@ -128,7 +188,14 @@ contract('LockupTest', ([deployer, , user2, user3]) => { }) it('set storage value.', async () => { await dev.dev.approve(dev.lockup.address, 100) - await dev.lockup.depositToProperty(property.address, 100) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + const allValue = await dev.lockup.totalLocked() expect(allValue.toString()).to.be.equal('100') const propertyValue = await dev.lockup.totalLockedForProperty( @@ -144,7 +211,14 @@ contract('LockupTest', ([deployer, , user2, user3]) => { const beforePropertyBalance = await dev.dev.balanceOf(property.address) expect(beforeBalance.toString()).to.be.equal(deployerBalance.toString()) expect(beforePropertyBalance.toString()).to.be.equal('0') - await dev.lockup.depositToProperty(property.address, 100) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + 100 + ) + const afterBalance = await dev.dev.balanceOf(deployer).then(toBigNumber) const afterPropertyBalance = await dev.dev.balanceOf(property.address) expect(afterBalance.toString()).to.be.equal( @@ -160,21 +234,31 @@ contract('LockupTest', ([deployer, , user2, user3]) => { from: user2, }) ) - const res = await dev.lockup - .depositToProperty(propertyAddress, 100) - .catch(err) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + const res = await dev.lockup.methods[ + 'depositToProperty(address,uint256)' + ](propertyAddress, 100).catch(err) + validateErrorMessage(res, 'unable to stake to unauthenticated property') }) it('0 dev staking is not possible.', async () => { - const res = await dev.lockup - .depositToProperty(property.address, 0) - .catch(err) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + const res = await dev.lockup.methods[ + 'depositToProperty(address,uint256)' + ](property.address, 0).catch(err) + validateErrorMessage(res, 'illegal deposit amount') }) it('user is not holding dev.', async () => { - const res = await dev.lockup - .depositToProperty(property.address, 100, { from: user3 }) - .catch(err) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + const res = await dev.lockup.methods[ + 'depositToProperty(address,uint256)' + ](property.address, 100, { from: user3 }).catch(err) + validateErrorMessage(res, 'ERC20: transfer amount exceeds balance') }) }) @@ -286,7 +370,14 @@ contract('LockupTest', ([deployer, , user2, user3]) => { await dev.createMetrics(deployer, propertyAddress) ).address ) - await dev.lockup.depositToProperty(propertyAddress, 200) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + propertyAddress, + 200 + ) + const info = await dev.lockup.getLockedupProperties() expect(info.length).to.be.equal(2) for (const lockupInfo of info) { @@ -442,7 +533,14 @@ contract('LockupTest', ([deployer, , user2, user3]) => { await dev.createMetrics(deployer, propertyAddress) ).address ) - await dev.lockup.depositToProperty(propertyAddress, 200) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + propertyAddress, + 200 + ) + await dev.lockup.withdrawByPosition(tokenId, 100) const info = await dev.lockup.getLockedupProperties() expect(info.length).to.be.equal(1) diff --git a/test/lockup/lockup.ts b/test/lockup/lockup.ts index cb2a9786..9d555bc9 100644 --- a/test/lockup/lockup.ts +++ b/test/lockup/lockup.ts @@ -125,10 +125,14 @@ contract('LockupTest', ([deployer, user1, user2]) => { it('The reward is calculated and comes back to you.', async () => { await dev.dev.approve(dev.lockup.address, '10000000000000000000000') - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000' ) + await dev.updateCap() const [reword, cap] = await calculate(dev, property) const result = await dev.lockup.calculateRewardAmount(property.address) diff --git a/test/market/market.ts b/test/market/market.ts index ee54661b..af9c290e 100755 --- a/test/market/market.ts +++ b/test/market/market.ts @@ -219,9 +219,15 @@ contract( }) }) it('Proxy to mapped Behavior Contract.', async () => { - await dev.lockup.depositToProperty(propertyAddress, 100000, { - from: propertyAuther, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + propertyAddress, + 100000, + { + from: propertyAuther, + } + ) const marketInstance = await marketContract.at(marketAddress1) marketInstance @@ -412,9 +418,15 @@ contract( }) }) it('Proxy to mapped Behavior Contract.', async () => { - await dev.lockup.depositToProperty(propertyAddress, 100000, { - from: propertyAuther, - }) + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + propertyAddress, + 100000, + { + from: propertyAuther, + } + ) const marketInstance = await marketContract.at(marketAddress1) void marketInstance.authenticateFromPropertyFactory( diff --git a/test/s-token/s-token-manager.ts b/test/s-token/s-token-manager.ts index 1653ab64..6ca88958 100644 --- a/test/s-token/s-token-manager.ts +++ b/test/s-token/s-token-manager.ts @@ -170,12 +170,24 @@ contract('STokensManager', ([deployer, user]) => { describe('tokenURI', () => { describe('success', () => { it('get token uri', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + const uri = await dev.sTokensManager.tokenURI(1) checkTokenUri(uri, property.address, 10000, 0) }) it('get custom token uri', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.setTokenURIImage(1, 'ipfs://IPFS-CID', { from: user, }) @@ -183,7 +195,12 @@ contract('STokensManager', ([deployer, user]) => { checkTokenUri(uri, property.address, 10000, 0, 'ipfs://IPFS-CID') }) it('get descriptor token uri', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) await dev.sTokensManager.setTokenURIDescriptor( property.address, descriptor.address, @@ -205,7 +222,12 @@ contract('STokensManager', ([deployer, user]) => { describe('mint', () => { describe('success', () => { it('mint nft', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const tokenId = await dev.sTokensManager.balanceOf(deployer) expect(tokenId.toString()).to.equal('1') const owner = await dev.sTokensManager.ownerOf(1) @@ -214,7 +236,12 @@ contract('STokensManager', ([deployer, user]) => { it('generate minted event', async () => { const [devLocal, propertyLocal] = await init() - devLocal.lockup.depositToProperty(propertyLocal.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + devLocal.lockup.methods['depositToProperty(address,uint256)']( + propertyLocal.address, + '10000' + ) const [_tokenId, _owner, _property, _amount, _price] = await Promise.all([ getEventValue(devLocal.sTokensManager)('Minted', 'tokenId'), @@ -230,7 +257,13 @@ contract('STokensManager', ([deployer, user]) => { expect(_price).to.equal('0') }) it('generate event', async () => { - dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + const [from, to, tokenId] = await Promise.all([ getEventValue(dev.sTokensManager)('Transfer', 'from'), getEventValue(dev.sTokensManager)('Transfer', 'to'), @@ -242,12 +275,24 @@ contract('STokensManager', ([deployer, user]) => { }) it('The counter will be incremented.', async () => { const [devLocal, propertyLocal] = await init() - devLocal.lockup.depositToProperty(propertyLocal.address, '10000') + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + devLocal.lockup.methods['depositToProperty(address,uint256)']( + propertyLocal.address, + '10000' + ) + const [_tokenId] = await Promise.all([ getEventValue(devLocal.sTokensManager)('Minted', 'tokenId'), ]) expect(_tokenId).to.equal('1') - devLocal.lockup.depositToProperty(propertyLocal.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + devLocal.lockup.methods['depositToProperty(address,uint256)']( + propertyLocal.address, + '10000' + ) const [_tokenId2] = await Promise.all([ getEventValue(devLocal.sTokensManager)('Minted', 'tokenId'), ]) @@ -266,7 +311,12 @@ contract('STokensManager', ([deployer, user]) => { describe('update', () => { describe('success', () => { it('update data', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const t1 = await getBlockTimestamp() await forwardBlockTimestamp(2) const latestTokenId = 1 @@ -301,7 +351,12 @@ contract('STokensManager', ([deployer, user]) => { }) it('generate updated event data', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const t1 = await getBlockTimestamp() await forwardBlockTimestamp(2) const latestTokenId = 1 @@ -347,7 +402,12 @@ contract('STokensManager', ([deployer, user]) => { describe('setTokenURIImage', () => { describe('success', () => { it('get data', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) await dev.sTokensManager.setTokenURIImage(1, 'ipfs://IPFS-CID', { from: user, }) @@ -355,7 +415,13 @@ contract('STokensManager', ([deployer, user]) => { checkTokenUri(tokenUri, property.address, 10000, 0, 'ipfs://IPFS-CID') }) it('get overwritten data', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.setTokenURIImage(1, 'ipfs://IPFS-CID', { from: user, }) @@ -368,14 +434,26 @@ contract('STokensManager', ([deployer, user]) => { }) describe('fail', () => { it('not author.', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + const res = await dev.sTokensManager .setTokenURIImage(1, '') .catch((err: Error) => err) validateErrorMessage(res, 'illegal access') }) it('was freezed', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.setTokenURIImage(1, 'http://dummy', { from: user, }) @@ -391,7 +469,13 @@ contract('STokensManager', ([deployer, user]) => { describe('freezeTokenURI', () => { describe('success', () => { it('data freezed', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.setTokenURIImage(1, 'http://dummy', { from: user, }) @@ -406,7 +490,13 @@ contract('STokensManager', ([deployer, user]) => { validateErrorMessage(res, 'freezed') }) it('generated event', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.setTokenURIImage(1, 'http://dummy', { from: user, }) @@ -421,7 +511,13 @@ contract('STokensManager', ([deployer, user]) => { }) describe('fail', () => { it('not author.', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.setTokenURIImage(1, 'http://dummy', { from: user, }) @@ -431,14 +527,24 @@ contract('STokensManager', ([deployer, user]) => { validateErrorMessage(res, 'illegal access') }) it('no uri data.', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const res = await dev.sTokensManager .freezeTokenURI(1, { from: user }) .catch((err: Error) => err) validateErrorMessage(res, 'no data') }) it('already freezed.', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) await dev.sTokensManager.setTokenURIImage(1, 'http://dummy', { from: user, }) @@ -454,7 +560,12 @@ contract('STokensManager', ([deployer, user]) => { describe('position', () => { describe('success', () => { it('get data', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const position = await dev.sTokensManager.positions(1) expect(position.property).to.equal(property.address) expect(toBigNumber(position.amount).toNumber()).to.equal(10000) @@ -476,7 +587,12 @@ contract('STokensManager', ([deployer, user]) => { describe('rewards', () => { describe('success', () => { it('get reward', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) const position = await dev.sTokensManager.rewards(1) @@ -494,7 +610,12 @@ contract('STokensManager', ([deployer, user]) => { ) }) it('get updated reward', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) const t2 = await getBlockTimestamp() @@ -530,7 +651,12 @@ contract('STokensManager', ([deployer, user]) => { describe('positionsOfProperty', () => { describe('success', () => { it('get token id', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const tokenIds = await dev.sTokensManager.positionsOfProperty( property.address ) @@ -538,7 +664,13 @@ contract('STokensManager', ([deployer, user]) => { expect(tokenIds[0].toNumber()).to.equal(1) }) it('get token by property', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + const propertyAddress = getPropertyAddress( await dev.propertyFactory.create('test', 'TEST', user, { from: user, @@ -550,7 +682,13 @@ contract('STokensManager', ([deployer, user]) => { ).address ) - await dev.lockup.depositToProperty(propertyAddress, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + propertyAddress, + '10000' + ) + const tokenIds = await dev.sTokensManager.positionsOfProperty( property.address ) @@ -563,8 +701,18 @@ contract('STokensManager', ([deployer, user]) => { expect(tokenIds2[0].toNumber()).to.equal(2) }) it('get token list', async () => { - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) const tokenIds = await dev.sTokensManager.positionsOfProperty( property.address @@ -584,7 +732,13 @@ contract('STokensManager', ([deployer, user]) => { describe('positionsOfOwner', () => { describe('success', () => { it('get token id', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + const tokenIds = await dev.sTokensManager.positionsOfOwner(deployer) expect(tokenIds.length).to.equal(1) expect(tokenIds[0].toNumber()).to.equal(1) @@ -592,10 +746,23 @@ contract('STokensManager', ([deployer, user]) => { it('get token by owners', async () => { await dev.dev.mint(user, deployerBalance) await dev.dev.approve(dev.lockup.address, '100000', { from: user }) - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000', { - from: user, - }) + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000', + { + from: user, + } + ) + const tokenIds = await dev.sTokensManager.positionsOfOwner(deployer) expect(tokenIds.length).to.equal(1) expect(tokenIds[0].toNumber()).to.equal(1) @@ -604,8 +771,19 @@ contract('STokensManager', ([deployer, user]) => { expect(tokenIds2[0].toNumber()).to.equal(2) }) it('get token list', async () => { - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + const tokenIds = await dev.sTokensManager.positionsOfOwner(deployer) expect(tokenIds.length).to.equal(2) expect(tokenIds[0].toNumber()).to.equal(1) @@ -618,9 +796,24 @@ contract('STokensManager', ([deployer, user]) => { expect(tokenIds.length).to.equal(0) }) it('transfer token(index0)', async () => { - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) await dev.sTokensManager.transferFrom(deployer, user, 1) const tokenIds = await dev.sTokensManager.positionsOfOwner(deployer) expect(tokenIds.length).to.equal(2) @@ -633,9 +826,25 @@ contract('STokensManager', ([deployer, user]) => { expect(tokenIdsUser[0].toNumber()).to.equal(1) }) it('transfer token(index1)', async () => { - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.transferFrom(deployer, user, 2) const tokenIds = await dev.sTokensManager.positionsOfOwner(deployer) expect(tokenIds.length).to.equal(2) @@ -648,9 +857,25 @@ contract('STokensManager', ([deployer, user]) => { expect(tokenIdsUser[0].toNumber()).to.equal(2) }) it('transfer token(index2)', async () => { - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + + // @ts-expect-error overloading functions aren't working + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.transferFrom(deployer, user, 3) const tokenIds = await dev.sTokensManager.positionsOfOwner(deployer) expect(tokenIds.length).to.equal(2) @@ -694,7 +919,13 @@ contract('STokensManager', ([deployer, user]) => { expect(tmp.toString()).to.equal('0') }) it('get currentIndex token id number', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + const tmp = await dev.sTokensManager.currentIndex() expect(tmp.toString()).to.equal('1') }) @@ -734,7 +965,13 @@ contract('STokensManager', ([deployer, user]) => { ) }) it('set token uri image', async () => { - await dev.lockup.depositToProperty(property.address, '10000') + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( + property.address, + '10000' + ) + await dev.sTokensManager.setTokenURIImage(1, 'ipfs://IPFS-CID', { from: user, }) diff --git a/test/withdraw/withdraw-scenario.ts b/test/withdraw/withdraw-scenario.ts index 82e3e104..62cf1978 100644 --- a/test/withdraw/withdraw-scenario.ts +++ b/test/withdraw/withdraw-scenario.ts @@ -29,7 +29,9 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { await dev.dev.approve(dev.lockup.address, '10000000000000000000000', { from: alis, }) - await dev.lockup.depositToProperty( + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000', { @@ -101,13 +103,17 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { await dev.dev.approve(dev.lockup.address, '10000000000000000000000', { from: user3, }) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000', { from: user3, } ) + timestamp = await getBlockTimestamp() }) @@ -230,13 +236,17 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { await dev.dev.approve(dev.lockup.address, '10000000000000000000000', { from: user3, }) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000', { from: user3, } ) + timestamps.set('a1', await getBlockTimestamp()) }) @@ -497,7 +507,10 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { property2.address, 1 ) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property2.address, toBigNumber(10000).times(1e18), { from: bob } @@ -557,21 +570,29 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { property.address, 1 ) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, toBigNumber(10000).times(1e18), { from: bob, } ) + await forwardBlockTimestamp(1) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, toBigNumber(10000).times(1e18), { from: bob, } ) + await forwardBlockTimestamp(1) await dev.metricsFactory.__setMetricsCountPerProperty( property.address, @@ -604,7 +625,10 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { { from: carol } ) await dev.dev.mint(carol, aliceBalance) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, toBigNumber(10000).times(1e18), { from: carol } @@ -744,15 +768,22 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { await dev.dev.approve(dev.lockup.address, '20000000000000000000000', { from: carol, }) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000', { from: bob, } ) + timestamp = await getBlockTimestamp() - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, toBigNumber('10000000000000000000000').times('0.25'), { @@ -947,13 +978,16 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { await dev.dev.approve(dev.lockup.address, '50000000000000000000000', { from: dave, }) - await dev.lockup.depositToProperty( + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property1.address, '10000000000000000000000', { from: dave, } ) + await forwardBlockTimestamp(3) }) @@ -1000,13 +1034,16 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { ) }) it(`Alice does staking 2500 to Property2, Property2 is 20% of the total rewards`, async () => { - await dev.lockup.depositToProperty( + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property2.address, '2500000000000000000000', { from: dave, } ) + const total = await dev.lockup.totalLocked().then(toBigNumber) const p1 = await dev.lockup .totalLockedForProperty(property1.address) @@ -1022,13 +1059,16 @@ contract('WithdrawTest', ([deployer, user1, user2, user3, user4]) => { }% of the total rewards, Property2 is ${ 250000 / 16250 }% of the total rewards`, async () => { - await dev.lockup.depositToProperty( + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property3.address, '3750000000000000000000', { from: dave, } ) + const total = await dev.lockup.totalLocked().then(toBigNumber) const p1 = await dev.lockup .totalLockedForProperty(property1.address) diff --git a/test/withdraw/withdraw.ts b/test/withdraw/withdraw.ts index 011b6941..ce59aa70 100644 --- a/test/withdraw/withdraw.ts +++ b/test/withdraw/withdraw.ts @@ -60,13 +60,17 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => { await dev.dev.approve(dev.lockup.address, '10000000000000000000000', { from: alis, }) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000', { from: alis, } ) + await forwardBlockTimestamp(1) const prev = await dev.dev.totalSupply().then(toBigNumber) const balance = await dev.dev.balanceOf(deployer).then(toBigNumber) @@ -88,13 +92,17 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => { await dev.dev.approve(dev.lockup.address, '10000000000000000000000', { from: user3, }) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000', { from: user3, } ) + const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) const totalSupply = await property.totalSupply().then(toBigNumber) @@ -142,13 +150,17 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => { await dev.dev.approve(dev.lockup.address, '10000000000000000000000', { from: user3, }) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property.address, '10000000000000000000000', { from: user3, } ) + const t1 = await getBlockTimestamp() await forwardBlockTimestamp(1) @@ -299,21 +311,30 @@ contract('WithdrawTest', ([deployer, user1, , user3]) => { it(`cap`, async () => { const [dev, [property1, property2, property3]] = await prepare() - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property1.address, toBigNumber(1000000000), { from: alis, } ) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property2.address, toBigNumber(2000000000), { from: alis, } ) - await dev.lockup.depositToProperty( + + // @ts-expect-error overloading functions aren't working + // pulled from https://github.com/trufflesuite/truffle/issues/3506 + await dev.lockup.methods['depositToProperty(address,uint256)']( property3.address, toBigNumber(3000000000), {