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

feat: Add option for governance to borrow from dex #464

Merged
merged 1 commit into from
Nov 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,19 @@ public void govWithdraw(int id, Address token, BigInteger value) {
Context.call(token, "transfer", getDaofund(), value);
}

@External
public void governanceBorrow(Address token, BigInteger amount, Address recipient) {
onlyGovernance();
BigInteger currentDebt = governanceDebt.getOrDefault(token, BigInteger.ZERO);
governanceDebt.set(token, currentDebt.add(amount));
Context.call(token, "transfer", recipient, amount);
}

@External(readonly=true)
public BigInteger getGovernanceDebt(Address token) {
return governanceDebt.getOrDefault(token, BigInteger.ZERO);
}

@External
public void govSetPoolTotal(int pid, BigInteger total) {
onlyGovernance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class DexDBVariables {
private static final String TOKEN_PRECISIONS = "token_precisions";
public static final String VERSION = "version";
public static final String ORACLE_PROTECTION = "oracle_protection";
public static final String GOV_DEBT = "governance_debt";


final static VarDB<Address> governance = Context.newVarDB(GOVERNANCE_ADDRESS, Address.class);
Expand Down Expand Up @@ -137,4 +138,8 @@ public class DexDBVariables {

//Map: pid -> percentage
public final static DictDB<BigInteger, BigInteger> oracleProtection = Context.newDictDB(ORACLE_PROTECTION, BigInteger.class);

//Map: token -> amount
final static DictDB<Address, BigInteger> governanceDebt = Context.newDictDB(GOV_DEBT, BigInteger.class);

}
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,10 @@ void xAdd(String from, String _baseToken, String _quoteToken, BigInteger _baseVa
@External
void addLpAddresses(BigInteger _poolId, Address[] _addresses);

@External
void governanceBorrow(Address token, BigInteger amount, Address recipient);

@External(readonly=true)
BigInteger getGovernanceDebt(Address token);
}

Loading