Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more ServiceConfiguration setters and tasks #109

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});