Skip to content

Commit

Permalink
address part 5
Browse files Browse the repository at this point in the history
  • Loading branch information
m30m committed Mar 12, 2024
1 parent ac3bab9 commit eac07a8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion auction-server/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct TokenAmount {
/// Opportunity parameters needed for on-chain execution
/// If a searcher signs the opportunity and have approved enough tokens to liquidation adapter,
/// by calling this contract with the given calldata and structures, they will receive the tokens specified
/// in the receipt_tokens field, and will send the tokens specified in the repay_tokens field.
/// in the buy_tokens field, and will send the tokens specified in the sell_tokens field.
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq)]
pub struct OpportunityParamsV1 {
/// The permission key required for succesful execution of the liquidation.
Expand Down
10 changes: 5 additions & 5 deletions per_multicall/src/OpportunityAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ contract OpportunityAdapter is SigVerify {
);

address weth = getWeth();
// transfer repay tokens to this contract
// transfer sell tokens to this contract
for (uint i = 0; i < params.sellTokens.length; i++) {
IERC20 token = IERC20(params.sellTokens[i].token);

Expand All @@ -98,7 +98,7 @@ contract OpportunityAdapter is SigVerify {
params.sellTokens[i].amount
);

// approve contract to spend repay tokens
// approve contract to spend sell tokens
uint256 approveAmount = params.sellTokens[i].amount;
if (params.sellTokens[i].token == weth) {
if (approveAmount >= params.value) {
Expand All @@ -112,7 +112,7 @@ contract OpportunityAdapter is SigVerify {
token.approve(params.target, approveAmount);
}

// get balances of receipt tokens before call
// get balances of buy tokens before call
for (uint i = 0; i < params.buyTokens.length; i++) {
IERC20 token = IERC20(params.buyTokens[i].token);
uint256 amount = params.buyTokens[i].amount;
Expand All @@ -136,7 +136,7 @@ contract OpportunityAdapter is SigVerify {
revert FulfillFailed(revertData);
}

// check balances of receipt tokens after call and transfer to opportunity adapter
// check balances of buy tokens after call and transfer to opportunity adapter
for (uint i = 0; i < params.buyTokens.length; i++) {
IERC20 token = IERC20(params.buyTokens[i].token);
uint256 amount = params.buyTokens[i].amount;
Expand All @@ -146,7 +146,7 @@ contract OpportunityAdapter is SigVerify {
revert InsufficientTokenReceived();
}

// transfer receipt tokens to the fulfiller
// transfer buy tokens to the fulfiller
token.transfer(params.executor, amount);
}

Expand Down
8 changes: 4 additions & 4 deletions per_multicall/test/PERIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ contract PERIntegrationTest is
tokenExpo
);

TokenAmount[] memory repayTokens = new TokenAmount[](1);
repayTokens[0] = TokenAmount(
TokenAmount[] memory sellTokens = new TokenAmount[](1);
sellTokens[0] = TokenAmount(
tokensDebt[vaultNumber],
amountsDebt[vaultNumber]
);
Expand All @@ -526,7 +526,7 @@ contract PERIntegrationTest is
for (uint i = 0; i < bidInfos.length; i++) {
// create liquidation call params struct
bytes memory signatureLiquidator = createLiquidationSignature(
repayTokens,
sellTokens,
expectedReceiptTokens,
contractAddress,
calldataVault,
Expand All @@ -536,7 +536,7 @@ contract PERIntegrationTest is
bidInfos[i].liquidatorSk
);
ExecutionParams memory liquidationCallParams = ExecutionParams(
repayTokens,
sellTokens,
expectedReceiptTokens,
bidInfos[i].liquidator,
contractAddress,
Expand Down
8 changes: 4 additions & 4 deletions per_multicall/test/helpers/Signatures.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ contract Signatures is Test, SigVerify {
}

function createLiquidationSignature(
TokenAmount[] memory repayTokens,
TokenAmount[] memory expectedReceiptTokens,
TokenAmount[] memory sellTokens,
TokenAmount[] memory buyTokens,
address contractAddress,
bytes memory data,
uint256 value,
Expand All @@ -36,8 +36,8 @@ contract Signatures is Test, SigVerify {
) public pure returns (bytes memory) {
bytes32 calldataDigestLiquidator = keccak256(
abi.encode(
repayTokens,
expectedReceiptTokens,
sellTokens,
buyTokens,
contractAddress,
data,
value,
Expand Down
12 changes: 6 additions & 6 deletions per_sdk/searcher/searcher_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class BidInfo(TypedDict):


def construct_signature_liquidator(
repay_tokens: list[(str, int)],
receipt_tokens: list[(str, int)],
sell_tokens: list[(str, int)],
buy_tokens: list[(str, int)],
address: str,
liq_calldata: bytes,
value: int,
Expand All @@ -24,8 +24,8 @@ def construct_signature_liquidator(
Constructs a signature for a liquidator's bid to submit to the liquidation server.
Args:
repay_tokens: A list of tuples (token address, amount) representing the tokens to repay.
receipt_tokens: A list of tuples (token address, amount) representing the tokens to receive.
sell_tokens: A list of tuples (token address, amount) representing the tokens to repay.
buy_tokens: A list of tuples (token address, amount) representing the tokens to receive.
address: The address of the protocol contract for the liquidation.
liq_calldata: The calldata for the liquidation method call.
value: The value for the liquidation method call.
Expand All @@ -47,8 +47,8 @@ def construct_signature_liquidator(
"uint256",
],
[
repay_tokens,
receipt_tokens,
sell_tokens,
buy_tokens,
address,
liq_calldata,
value,
Expand Down
14 changes: 7 additions & 7 deletions per_sdk/utils/types_liquidation_adapter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import TypedDict


class TokenQty(TypedDict):
class TokenAmount(TypedDict):
contract: str
amount: str

Expand All @@ -19,17 +19,17 @@ class LiquidationOpportunity(TypedDict):
value: str
# The permission key necessary to call the liquidation method
permission_key: str
# A list of tokens that can be used to repay this account's debt. Each entry in the list is a tuple (token address, hex string of repay amount)
repay_tokens: list[TokenQty]
# A list of tokens that ought to be received by the liquidator in exchange for the repay tokens. Each entry in the list is a tuple (token address, hex string of receipt amount)
receipt_tokens: list[TokenQty]
# A list of tokens that can be used to repay this account's debt.
sell_tokens: list[TokenAmount]
# A list of tokens that ought to be received by the liquidator in exchange for the sell tokens.
buy_tokens: list[TokenAmount]
# Opportunity format version, used to determine how to interpret the opportunity data
version: str


class LiquidationAdapterCalldata(TypedDict):
repay_tokens: list[(str, int)]
expected_receipt_tokens: list[(str, int)]
sell_tokens: list[(str, int)]
buy_tokens: list[(str, int)]
liquidator: str
contract: str
data: bytes
Expand Down

0 comments on commit eac07a8

Please sign in to comment.