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

Blur Integration #371

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
fff4a04
chore: base implementation for blur integration
zhoujia6139 Apr 15, 2023
307ef77
chore: merge main
zhoujia6139 Apr 15, 2023
946ce7a
chore: add comment
zhoujia6139 Apr 17, 2023
72fd6ec
chore: add pool extended logic to reduce contract size
zhoujia6139 Apr 17, 2023
dd1c390
chore: add more test case
zhoujia6139 Apr 17, 2023
33edf3b
chore: merge main
zhoujia6139 Apr 17, 2023
db7cd30
chore: fix typechain issue
zhoujia6139 Apr 18, 2023
ef0f608
chore: mint debt token before transfer asset
zhoujia6139 Apr 18, 2023
fdfa6be
chore: only support ETH listing order and user can only pay cash with…
zhoujia6139 Apr 18, 2023
0476e82
chore: Set limit count for ongoing request
zhoujia6139 Apr 18, 2023
d03a5a7
chore: add charge fee logic
zhoujia6139 Apr 18, 2023
16d7fc3
chore: separate role for enable and disable BLUR exchange
zhoujia6139 Apr 18, 2023
ac1b6b3
chore: remove Fulfilled and Rejected status
zhoujia6139 Apr 18, 2023
ecc0a8a
chore: small fix
zhoujia6139 Apr 18, 2023
2dc2418
chore: move BLUR integration to PoolExtendedLogic
zhoujia6139 Apr 18, 2023
dd8e4f3
chore: merge main
zhoujia6139 Apr 21, 2023
3ebbf0e
chore: add comment
zhoujia6139 Apr 21, 2023
5c6b0a0
chore: upgrade script
zhoujia6139 Apr 24, 2023
1fd580a
chore: add query request status interface
zhoujia6139 Apr 24, 2023
bac5df1
chore: end auction before burn user's nToken
zhoujia6139 Apr 25, 2023
76ad323
chore: should use trait boosted price to calculate listing price calc…
zhoujia6139 Apr 25, 2023
f6886b7
chore: ensureOwnsUnderlying when borrowApeAndStake
zhoujia6139 Apr 26, 2023
cfd575c
chore: check liquidation threshold when initiate request
zhoujia6139 Apr 27, 2023
17a1ed3
chore: declare event in interface file
zhoujia6139 Apr 27, 2023
3334212
Merge branch 'main' into blur_integration
zhoujia6139 Apr 27, 2023
404a425
chore: fix lint
zhoujia6139 Apr 27, 2023
b57a085
chore: support batch call
zhoujia6139 May 5, 2023
e783529
Merge branch 'main' into blur_integration
zhoujia6139 May 5, 2023
11518a1
chore: add comment
zhoujia6139 May 5, 2023
c8fc6c1
chore: update comment and testcase
zhoujia6139 May 6, 2023
0bc4f6b
chore: update listing price limit and add test case
zhoujia6139 May 6, 2023
981725d
chore: rename test case file
zhoujia6139 May 8, 2023
5b6c97e
chore: add-para-proxy-interfaces
zhoujia6139 May 12, 2023
eaf867c
Merge branch 'main' into blur_integration
zhoujia6139 May 12, 2023
c2a33bc
Merge branch 'main' into blur_integration
zhoujia6139 May 22, 2023
bbb3453
chore: merge main
zhoujia6139 Oct 10, 2023
db11144
chore: fix deploy script
zhoujia6139 Oct 10, 2023
43cb9a8
Accept underlying bids from Blur (#390)
zhoujia6139 Oct 10, 2023
de597f3
chore: add izumi check in case got forgotten
zhoujia6139 Oct 10, 2023
88741a0
chore: some optimization
zhoujia6139 Oct 11, 2023
877e67f
chore: fix typo and test case(break since market config change)
zhoujia6139 Oct 12, 2023
1d71b6f
chore: some small optimization
zhoujia6139 Oct 17, 2023
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
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,22 @@ set-reserve-pause:
set-cAPE-pause:
make TASK_NAME=set-cAPE-pause run-task

.PHONY: set-blur-integration-enable
set-blur-integration-enable:
make TASK_NAME=set-blur-integration-enable run-task

.PHONY: set-blur-ongoing-request-limit
set-blur-ongoing-request-limit:
make TASK_NAME=set-blur-ongoing-request-limit run-task

.PHONY: set-blur-request-fee-rate
set-blur-request-fee-rate:
make TASK_NAME=set-blur-request-fee-rate run-task

.PHONY: set-blur-exchange-keeper
set-blur-exchange-keeper:
make TASK_NAME=set-blur-exchange-keeper run-task

.PHONY: list-facets
list-facets:
make TASK_NAME=list-facets run-task
Expand Down Expand Up @@ -620,6 +636,10 @@ upgrade:
upgrade-pool:
make TASK_NAME=upgrade:pool run-task

.PHONY: add-para-proxy-interfaces
add-para-proxy-interfaces:
make TASK_NAME=upgrade:add-para-proxy-interfaces run-task

.PHONY: upgrade-pool-core
upgrade-pool-core:
make TASK_NAME=upgrade:pool-core run-task
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {IParaProxyInterfaces} from "./IParaProxyInterfaces.sol";
import {IPoolPositionMover} from "./IPoolPositionMover.sol";
import "./IPoolApeStaking.sol";
import "./IPoolBorrowAndStake.sol";
import "./IPoolBlurIntegration.sol";

/**
* @title IPool
Expand All @@ -21,6 +22,7 @@ interface IPool is
IPoolApeStaking,
IParaProxyInterfaces,
IPoolPositionMover,
IPoolBlurIntegration,
IPoolBorrowAndStake
{

Expand Down
194 changes: 194 additions & 0 deletions contracts/interfaces/IPoolBlurIntegration.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IPoolAddressesProvider} from "./IPoolAddressesProvider.sol";
import {DataTypes} from "../protocol/libraries/types/DataTypes.sol";

/**
* @title IPoolBlurIntegration
*
* @notice Defines the basic interface for an ParaSpace Pool.
**/
interface IPoolBlurIntegration {
/**
* @dev Emitted on initiateBlurExchangeRequest()
* @param initiator The address of initiator of the request
* @param paymentToken The address of paymentToken of the request
* @param listingPrice The listing price of the request
* @param borrowAmount The borrow amount for the request
* @param collection the collection address of the erc721
* @param tokenId the tokenId address of the erc721
**/
event BlurExchangeRequestInitiated(
address indexed initiator,
address paymentToken,
uint256 listingPrice,
uint256 borrowAmount,
address collection,
uint256 tokenId
);

/**
* @dev Emitted on fulfillBlurExchangeRequest()
* @param initiator The address of initiator of the request
* @param paymentToken The address of paymentToken of the request
* @param listingPrice The listing price of the request
* @param borrowAmount The borrow amount for the request
* @param collection the collection address of the erc721
* @param tokenId the tokenId address of the erc721
**/
event BlurExchangeRequestFulfilled(
address indexed initiator,
address paymentToken,
uint256 listingPrice,
uint256 borrowAmount,
address collection,
uint256 tokenId
);

/**
* @dev Emitted on rejectBlurExchangeRequest()
* @param initiator The address of initiator of the request
* @param paymentToken The address of paymentToken of the request
* @param listingPrice The listing price of the request
* @param borrowAmount The borrow amount for the request
* @param collection the collection address of the erc721
* @param tokenId the tokenId address of the erc721
**/
event BlurExchangeRequestRejected(
address indexed initiator,
address paymentToken,
uint256 listingPrice,
uint256 borrowAmount,
address collection,
uint256 tokenId
);

/**
* @dev Emitted on initiateAcceptBlurBidsRequest()
* @param initiator The address of initiator of the request
* @param paymentToken The address of paymentToken of the request
* @param bidingPrice The listing price of the request
* @param marketPlaceFee The market place fee taken from bidingPrice
* @param collection the collection address of the erc721
* @param tokenId the tokenId address of the erc721
* @param bidOrderHash the biding order hash
**/
event AcceptBlurBidsRequestInitiated(
address indexed initiator,
address paymentToken,
uint256 bidingPrice,
uint256 marketPlaceFee,
address collection,
uint256 tokenId,
bytes32 bidOrderHash
);

/**
* @dev Emitted on fulfillAcceptBlurBidsRequest()
* @param initiator The address of initiator of the request
* @param paymentToken The address of paymentToken of the request
* @param bidingPrice The listing price of the request
* @param marketPlaceFee The market place fee taken from bidingPrice
* @param collection the collection address of the erc721
* @param tokenId the tokenId address of the erc721
* @param bidOrderHash the biding order hash
**/
event AcceptBlurBidsRequestFulfilled(
address indexed initiator,
address paymentToken,
uint256 bidingPrice,
uint256 marketPlaceFee,
address collection,
uint256 tokenId,
bytes32 bidOrderHash
);

/**
* @dev Emitted on rejectAcceptBlurBidsRequest()
* @param initiator The address of initiator of the request
* @param paymentToken The address of paymentToken of the request
* @param bidingPrice The listing price of the request
* @param marketPlaceFee The market place fee taken from bidingPrice
* @param collection the collection address of the erc721
* @param tokenId the tokenId address of the erc721
* @param bidOrderHash the biding order hash
**/
event AcceptBlurBidsRequestRejected(
address indexed initiator,
address paymentToken,
uint256 bidingPrice,
uint256 marketPlaceFee,
address collection,
uint256 tokenId,
bytes32 bidOrderHash
);

/**
* @notice Initiate a buyWithCredit request for Blur exchange listing order.
* @dev Only the request initiator can call this function
* @param requests The request array
*/
function initiateBlurExchangeRequest(
DataTypes.BlurBuyWithCreditRequest[] calldata requests
) external payable;

/**
* @notice Fulfill a buyWithCredit request for Blur exchange listing order if the blur transaction is successes.
* @dev Only keeper can call this function
* @param requests The request array
*/
function fulfillBlurExchangeRequest(
DataTypes.BlurBuyWithCreditRequest[] calldata requests
) external;

/**
* @notice Reject a buyWithCredit request for Blur exchange listing order if the blur transaction is failed.
* @dev Only keeper can call this function
* @param requests The request array
*/
function rejectBlurExchangeRequest(
DataTypes.BlurBuyWithCreditRequest[] calldata requests
) external payable;

/**
* @notice Get a buyWithCredit request status for Blur exchange listing order.
*/
function getBlurExchangeRequestStatus(
DataTypes.BlurBuyWithCreditRequest calldata request
) external view returns (DataTypes.BlurBuyWithCreditRequestStatus);

/**
* @notice Initiate accept blur bids for underlying request.
* @dev Only the request initiator can call this function
* @param requests The request array
*/
function initiateAcceptBlurBidsRequest(
DataTypes.AcceptBlurBidsRequest[] calldata requests
) external payable;

/**
* @notice Fulfill accept blur bids for underlying request if the blur selling transaction is successes.
* @dev Only keeper can call this function
* @param requests The request array
*/
function fulfillAcceptBlurBidsRequest(
DataTypes.AcceptBlurBidsRequest[] calldata requests
) external payable;

/**
* @notice Reject accept blur bids for underlying request if the blur selling transaction is failed.
* @dev Only keeper can call this function
* @param requests The request array
*/
function rejectAcceptBlurBidsRequest(
DataTypes.AcceptBlurBidsRequest[] calldata requests
) external;

/**
* @notice Get a accept blur bids for underlying request status.
*/
function getAcceptBlurBidsRequestStatus(
DataTypes.AcceptBlurBidsRequest calldata request
) external view returns (DataTypes.AcceptBlurBidsRequestStatus);
}
2 changes: 1 addition & 1 deletion contracts/interfaces/IPoolMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {IPoolAddressesProvider} from "./IPoolAddressesProvider.sol";
import {DataTypes} from "../protocol/libraries/types/DataTypes.sol";

/**
* @title IPool
* @title IPoolMarketplace
*
* @notice Defines the basic interface for an ParaSpace Pool.
**/
Expand Down
101 changes: 101 additions & 0 deletions contracts/interfaces/IPoolParameters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,51 @@ interface IPoolParameters {
**/
event ClaimApeForYieldIncentiveUpdated(uint256 oldValue, uint256 newValue);

/**
* @dev Emitted when the status of blur exchange enable status update
**/
event BlurExchangeEnableStatusUpdated(bool isEnable);

/**
* @dev Emitted when the limit amount of blur ongoing request update
**/
event BlurOngoingRequestLimitUpdated(uint256 oldValue, uint256 newValue);

/**
* @dev Emitted when the fee rate of blur exchange request update
**/
event BlurExchangeRequestFeeRateUpdated(uint256 oldValue, uint256 newValue);

/**
* @dev Emitted when the blur exchange keeper address update
**/
event BlurExchangeKeeperUpdated(address keeper);
/**
* @dev Emitted when the status of accept blur bids enable status update
**/
event AcceptBlurBidsEnableStatusUpdated(bool isEnable);

/**
* @dev Emitted when the limit amount of accept blur bids ongoing request update
**/
event AcceptBlurBidsOngoingRequestLimitUpdated(
uint256 oldValue,
uint256 newValue
);

/**
* @dev Emitted when the fee rate of accept blur bids request update
**/
event AcceptBlurBidsRequestFeeRateUpdated(
uint256 oldValue,
uint256 newValue
);

/**
* @dev Emitted when the accept blur bids keeper address update
**/
event AcceptBlurBidsKeeperUpdated(address keeper);

/**
* @notice Initializes a reserve, activating it, assigning an xToken and debt tokens and an
* interest rate strategy
Expand Down Expand Up @@ -200,4 +245,60 @@ interface IPoolParameters {
address asset,
uint256 tokenId
) external view returns (uint256 ltv, uint256 lt);

/**
* @notice enable blur exchange request, only pool admin call this function
**/
function enableBlurExchange() external;

/**
* @notice disable blur exchange request, only pool admin or emergency admin call this function
**/
function disableBlurExchange() external;

/**
* @notice update blur ongoing request limit amount
* @param limit The new limit amount
**/
function setBlurOngoingRequestLimit(uint8 limit) external;

/**
* @notice update blur exchange request fee rate
* @param feeRate The new fee rate
**/
function setBlurExchangeRequestFeeRate(uint16 feeRate) external;

/**
* @notice update blur exchange keeper, only pool admin call this function
* @param keeper The new keeper address
**/
function setBlurExchangeKeeper(address keeper) external;

/**
* @notice enable accept blur bids request, only pool admin call this function
**/
function enableAcceptBlurBids() external;

/**
* @notice disable accept blur bids request, only pool admin or emergency admin call this function
**/
function disableAcceptBlurBids() external;

/**
* @notice update accept blur bids ongoing request limit amount
* @param limit The new limit amount
**/
function setAcceptBlurBidsOngoingRequestLimit(uint8 limit) external;

/**
* @notice update accept blur bids request fee rate
* @param feeRate The new fee rate
**/
function setAcceptBlurBidsRequestFeeRate(uint16 feeRate) external;

/**
* @notice update accept blur bids keeper, only pool admin call this function
* @param keeper The new keeper address
**/
function setAcceptBlurBidsKeeper(address keeper) external;
}
2 changes: 1 addition & 1 deletion contracts/interfaces/IXTokenType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum XTokenType {
NTokenOtherdeed,
NTokenStakefish,
NTokenChromieSquiggle,
PhantomData1,
NTokenIZUMILp,
PhantomData2,
PhantomData3,
PhantomData4,
Expand Down
13 changes: 13 additions & 0 deletions contracts/protocol/libraries/helpers/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ library Errors {
string public constant CALLER_NOT_OPERATOR = "138"; // The caller of the function is not operator
string public constant INVALID_FEE_VALUE = "139"; // invalid fee rate value
string public constant TOKEN_NOT_ALLOW_RESCUE = "140"; // token is not allow rescue
string public constant CALLER_NOT_INITIATOR = "141"; //The caller of the function is not the request initiator
string public constant INVALID_KEEPER_ADDRESS = "142"; //invalid keeper address to receive money
string public constant ONGOING_REQUEST_AMOUNT_EXCEEDED = "143"; //ongoing request amount exceeds limit
string public constant REQUEST_DISABLED = "144"; //blur exchange request disabled
string public constant INVALID_ASSET = "145"; // invalid asset.
string public constant INVALID_ETH_VALUE = "146"; //the eth value with the transaction is invalid
string public constant INVALID_REQUEST_STATUS = "147"; //The status of the request is invalid for this function
string public constant INVALID_PAYMENT_TOKEN = "148"; //the invalid payment token for blur exchange request
string public constant INVALID_REQUEST_PRICE = "149"; //the listing price for blur exchange request is invalid
string public constant CALLER_NOT_KEEPER = "150"; //The caller of the function is not keeper
string public constant NTOKEN_NOT_OWNS_UNDERLYING = "151"; //The ntoken does not owns the underlying nft
string public constant EXISTING_APE_STAKING = "152"; // Ape coin staking position existed
string public constant NOT_SAME_NTOKEN_OWNER = "153"; // ntoken have different owner

string public constant INVALID_PARAMETER = "170"; //invalid parameter
}
Loading
Loading