Skip to content

Commit

Permalink
Add more ServiceConfiguration setters and tasks (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
bricestacey authored Nov 30, 2022
1 parent 0c5c508 commit 7b9100d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 13 deletions.
13 changes: 2 additions & 11 deletions contracts/ServiceConfiguration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract ServiceConfiguration is AccessControl, IServiceConfiguration {

mapping(address => bool) public isLiquidityAsset;

mapping(address => uint256) private _firstLossMinimum;
mapping(address => uint256) public firstLossMinimum;

uint256 public firstLossFeeBps = 500;

Expand Down Expand Up @@ -144,19 +144,10 @@ contract ServiceConfiguration is AccessControl, IServiceConfiguration {
override
onlyOperator
{
_firstLossMinimum[addr] = value;
firstLossMinimum[addr] = value;
emit FirstLossMinimumSet(addr, value);
}

function firstLossMinimum(address addr)
external
view
override
returns (uint256)
{
return _firstLossMinimum[addr];
}

/**
* @inheritdoc IServiceConfiguration
*/
Expand Down
57 changes: 55 additions & 2 deletions tasks/serviceConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ task(
"serviceConfigurationView",
"Get public properties of the service configuration"
)
.addParam("address", "Address of the service configuration contract")
.addParam("contract", "Address of the service configuration contract")
.setAction(async (taskArgs, hre) => {
const ServiceConfiguration: ContractFactory =
await hre.ethers.getContractFactory("ServiceConfiguration");
const serviceConfiguration = ServiceConfiguration.attach(taskArgs.address);
const serviceConfiguration = ServiceConfiguration.attach(taskArgs.contract);
console.log("paused: ", await serviceConfiguration.paused());
console.log(
"firstLossFeeBps: ",
Expand Down Expand Up @@ -130,3 +130,56 @@ task("serviceConfigurationSetToSAcceptanceRegistry", "Set a ToS registry")
const receipt = await tx.wait();
console.log("Transaction hash:", receipt.transactionHash);
});

task(
"serviceConfigurationFirstLossMinimum",
"Gets the first loss minimum for the given token"
)
.addParam("contract", "Address of the service configuration contract")
.addParam("token", "Address of the token contract")
.setAction(async (taskArgs, hre) => {
const ServiceConfiguration: ContractFactory =
await hre.ethers.getContractFactory("ServiceConfiguration");
const serviceConfiguration = ServiceConfiguration.attach(taskArgs.contract);
console.log(
"First Loss Minimum: ",
await serviceConfiguration.firstLossMinimum(taskArgs.token)
);
});

task(
"serviceConfigurationSetFirstLossMinimum",
"Sets the first loss minimum for the given token"
)
.addParam("contract", "Address of the service configuration contract")
.addParam("token", "Address of the token contract")
.addParam(
"value",
"The minimum tokens required to be deposited by pool admins"
)
.setAction(async (taskArgs, hre) => {
const ServiceConfiguration: ContractFactory =
await hre.ethers.getContractFactory("ServiceConfiguration");
const serviceConfiguration = ServiceConfiguration.attach(taskArgs.contract);
const tx = await serviceConfiguration.setFirstLossMinimum(
taskArgs.token,
taskArgs.value
);
const receipt = await tx.wait();
console.log("Transaction hash:", receipt.transactionHash);
});

task(
"serviceConfigurationSetFirstLossFeeBps",
"Sets the first loss fee in basis points (100 = 1%)"
)
.addParam("contract", "Address of the service configuration contract")
.addParam("value", "The first loss fee in basis points (100 = 1%)")
.setAction(async (taskArgs, hre) => {
const ServiceConfiguration: ContractFactory =
await hre.ethers.getContractFactory("ServiceConfiguration");
const serviceConfiguration = ServiceConfiguration.attach(taskArgs.contract);
const tx = await serviceConfiguration.setFirstLossFeeBps(taskArgs.value);
const receipt = await tx.wait();
console.log("Transaction hash:", receipt.transactionHash);
});

0 comments on commit 7b9100d

Please sign in to comment.