-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
822 additions
and
795 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
protocol/synthetix/test/integration/modules/core/PoolModuleFundAdmin.createPool.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import assert from 'node:assert'; | ||
import { ethers } from 'ethers'; | ||
import { bootstrapWithMockMarketAndPool } from '../../bootstrap'; | ||
|
||
describe('PoolModule Admin createPool()', function () { | ||
const { signers, systems, restore } = bootstrapWithMockMarketAndPool(); | ||
|
||
let owner: ethers.Signer, user1: ethers.Signer; | ||
|
||
const secondPoolId = 3384692; | ||
|
||
before('identify signers', async () => { | ||
[owner, user1] = signers(); | ||
}); | ||
|
||
before(restore); | ||
|
||
it('fails when pool already exists', async () => {}); | ||
|
||
before('give user1 permission to create pool', async () => { | ||
await systems() | ||
.Core.connect(owner) | ||
.addToFeatureFlagAllowlist( | ||
ethers.utils.formatBytes32String('createPool'), | ||
await user1.getAddress() | ||
); | ||
}); | ||
|
||
before('create a pool', async () => { | ||
await ( | ||
await systems() | ||
.Core.connect(user1) | ||
.createPool(secondPoolId, await user1.getAddress()) | ||
).wait(); | ||
}); | ||
|
||
it('pool is created', async () => { | ||
assert.equal(await systems().Core.getPoolOwner(secondPoolId), await user1.getAddress()); | ||
}); | ||
}); |
86 changes: 86 additions & 0 deletions
86
...ocol/synthetix/test/integration/modules/core/PoolModuleFundAdmin.setIssuanceRatio.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import assert from 'node:assert'; | ||
import assertBn from '@synthetixio/core-utils/utils/assertions/assert-bignumber'; | ||
import assertRevert from '@synthetixio/core-utils/utils/assertions/assert-revert'; | ||
import { ethers } from 'ethers'; | ||
import { bn, bootstrapWithMockMarketAndPool } from '../../bootstrap'; | ||
|
||
describe('PoolModule Admin set pool collateral issuance ratio', function () { | ||
const { signers, systems, collateralAddress, restore } = bootstrapWithMockMarketAndPool(); | ||
|
||
let owner: ethers.Signer, user1: ethers.Signer, user2: ethers.Signer; | ||
|
||
const thirdPoolId = 3384633; | ||
|
||
before('identify signers', async () => { | ||
[owner, user1, user2] = signers(); | ||
}); | ||
|
||
before(restore); | ||
|
||
before('give user1 permission to create pool', async () => { | ||
await systems() | ||
.Core.connect(owner) | ||
.addToFeatureFlagAllowlist( | ||
ethers.utils.formatBytes32String('createPool'), | ||
await user1.getAddress() | ||
); | ||
}); | ||
|
||
before('create a pool', async () => { | ||
await ( | ||
await systems() | ||
.Core.connect(user1) | ||
.createPool(thirdPoolId, await user1.getAddress()) | ||
).wait(); | ||
}); | ||
|
||
it('only works for owner', async () => { | ||
await assertRevert( | ||
systems() | ||
.Core.connect(user2) | ||
.setPoolCollateralConfiguration(thirdPoolId, collateralAddress(), { | ||
collateralLimitD18: bn(10), | ||
issuanceRatioD18: bn(2), | ||
}), | ||
`Unauthorized("${await user2.getAddress()}")`, | ||
systems().Core | ||
); | ||
}); | ||
|
||
it('min collateral ratio is set to zero for the pool by default', async () => { | ||
assert.equal( | ||
await systems().Core.getPoolCollateralIssuanceRatio(thirdPoolId, collateralAddress()), | ||
0 | ||
); | ||
}); | ||
|
||
it('set the pool collateal issuance ratio to 200%', async () => { | ||
await systems() | ||
.Core.connect(user1) | ||
.setPoolCollateralConfiguration(thirdPoolId, collateralAddress(), { | ||
collateralLimitD18: bn(10), | ||
issuanceRatioD18: bn(2), | ||
}); | ||
|
||
assertBn.equal( | ||
await systems().Core.getPoolCollateralIssuanceRatio(thirdPoolId, collateralAddress()), | ||
bn(2) | ||
); | ||
}); | ||
|
||
it('can get pool collateral configuration', async () => { | ||
await systems() | ||
.Core.connect(user1) | ||
.setPoolCollateralConfiguration(thirdPoolId, collateralAddress(), { | ||
collateralLimitD18: bn(123), | ||
issuanceRatioD18: bn(345), | ||
}); | ||
|
||
const { collateralLimitD18, issuanceRatioD18 } = | ||
await systems().Core.getPoolCollateralConfiguration(thirdPoolId, collateralAddress()); | ||
assert.deepEqual( | ||
{ collateralLimitD18, issuanceRatioD18 }, | ||
{ collateralLimitD18: bn(123), issuanceRatioD18: bn(345) } | ||
); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
.../synthetix/test/integration/modules/core/PoolModuleFundAdmin.setMinLiquidityRatio.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import assertBn from '@synthetixio/core-utils/utils/assertions/assert-bignumber'; | ||
import assertRevert from '@synthetixio/core-utils/utils/assertions/assert-revert'; | ||
import { ethers } from 'ethers'; | ||
import { bootstrapWithMockMarketAndPool } from '../../bootstrap'; | ||
|
||
describe('PoolModule Admin setMinLiquidityRatio(uint256)', function () { | ||
const { signers, systems, restore } = bootstrapWithMockMarketAndPool(); | ||
|
||
let owner: ethers.Signer, user1: ethers.Signer; | ||
|
||
before('identify signers', async () => { | ||
[owner, user1] = signers(); | ||
}); | ||
|
||
before(restore); | ||
|
||
it('only works for owner', async () => { | ||
await assertRevert( | ||
systems().Core.connect(user1)['setMinLiquidityRatio(uint256)'](ethers.utils.parseEther('2')), | ||
`Unauthorized("${await user1.getAddress()}")`, | ||
systems().Core | ||
); | ||
}); | ||
|
||
it('is set when invoked successfully', async () => { | ||
const value = ethers.utils.parseEther('2'); | ||
await systems().Core.connect(owner)['setMinLiquidityRatio(uint256)'](value); | ||
assertBn.equal(await systems().Core['getMinLiquidityRatio()'](), value); | ||
}); | ||
}); |
Oops, something went wrong.