Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
dd9f1ca
feat: support non-listed nft
0x8f701 Apr 12, 2023
9fdcc53
feat: remove collateral swap approve process & add eth support & calc…
0x8f701 Apr 12, 2023
3d77ba1
fix: seperate listingPrice & supplyAmount
0x8f701 Apr 13, 2023
e68ccf1
chore: add more comments
0x8f701 Apr 13, 2023
c1a2738
feat: add missing supplyAmount check
0x8f701 Apr 13, 2023
b0f62df
fix: looksrare & blur adapter recipient
0x8f701 Apr 13, 2023
6332ca3
fix: collateral swap test cases
0x8f701 Apr 13, 2023
89f5bce
chore: use safeTransfer instead
0x8f701 Apr 13, 2023
d77d03a
feat: add missing tests
0x8f701 Apr 14, 2023
f974534
fix: lint
0x8f701 Apr 14, 2023
555f4c0
Merge branch 'main' into feat/collateral-swap-2
0x8f701 Apr 18, 2023
3d4243e
Merge remote-tracking branch 'origin/main' into feat/collateral-swap-2
0x8f701 Apr 20, 2023
7f6f5a6
Feat/collateral swap 2 - borrow any (#373)
0x8f701 Apr 21, 2023
a6e6a8d
Feat/collateral swap 2 - ptoken (#380)
0x8f701 Apr 21, 2023
3a44155
Merge branch 'main' into feat/collateral-swap-2
0x8f701 Apr 21, 2023
5feb7ba
feat: make collateralswap only works with ptoken
0x8f701 Apr 21, 2023
18dd06e
chore: add seaport v14 config
0x8f701 Apr 21, 2023
250a773
feat: consistent naming
0x8f701 Apr 21, 2023
0526092
feat: better naming
0x8f701 Apr 21, 2023
3567955
fix: ptoken tests
0x8f701 Apr 22, 2023
0fe791a
fix: ptoken tests
0x8f701 Apr 22, 2023
2d02b7b
fix: bid ptoken tests
0x8f701 Apr 23, 2023
cdcf693
fix: bid ptoken tests
0x8f701 Apr 23, 2023
7063359
feat: remove duplicated timelock code
0x8f701 Apr 23, 2023
6f6b4b7
chore: update ci to use make
0x8f701 Apr 23, 2023
3c259e1
feat: no need to check isListingPToken when supplyAmount != 0
0x8f701 Apr 23, 2023
ecd78bd
chore: fix warnings & use another error
0x8f701 Apr 23, 2023
6857436
Update ci.yml
woshihahaha Apr 23, 2023
4f476de
Update ci.yml
woshihahaha Apr 23, 2023
d2c494a
Update ci.yml
woshihahaha Apr 23, 2023
718a36e
fix: unreachable branch
0x8f701 Apr 24, 2023
7770e40
Merge branch 'feat/collateral-swap-2' of ssh://github.com/para-space/…
0x8f701 Apr 24, 2023
9b77634
fix: restrict dstToken for marketplace
0x8f701 Apr 24, 2023
075654c
fix: revert when amount out bigger than price
0x8f701 Apr 24, 2023
d9dd713
fix: leave extra swapped assets in ptoken for rescue
0x8f701 Apr 24, 2023
d349c10
fix: add missing verify
0x8f701 Apr 27, 2023
edb5841
Merge remote-tracking branch 'origin/main' into feat/collateral-swap-2
0x8f701 May 16, 2023
faf3272
feat: add support for swap with exactOutput
0x8f701 May 16, 2023
f31c459
Feat/ptoken debt swap (#388)
0x8f701 May 22, 2023
f447e71
feat: reset allowance at the end of swap tx
0x8f701 May 22, 2023
95aa30b
fix: mint debt after validateBorrow
0x8f701 May 22, 2023
0286f9d
fix: build
0x8f701 May 22, 2023
8ffb1bd
chore: revert yarn.lock
0x8f701 May 22, 2023
4ccbf08
feat: gas optimize
0x8f701 May 23, 2023
ee48439
feat: remove unnecessary decode
0x8f701 May 23, 2023
5e071a1
feat: limit debtToSwap to userTotalDebt
0x8f701 May 23, 2023
ee93c6a
Feat/private listing sell to opensea (#392)
0x8f701 Jun 8, 2023
a4da24f
chore: cleanup
0x8f701 Jun 9, 2023
39d8185
fix: remove redundant check
0x8f701 Jun 9, 2023
6632c66
fix: finding
0x8f701 Jun 12, 2023
68e6b11
refactor: logic
0x8f701 Jun 12, 2023
8e5d95a
chore: cleanup
0x8f701 Jun 14, 2023
5058014
feat: remove unused orderInfo.id in buyWithCredit
0x8f701 Jun 14, 2023
e68b743
feat: apply optimizatiom
0x8f701 Jun 14, 2023
7c52239
Merge remote-tracking branch 'origin/main' into feat/collateral-swap-2
0x8f701 Jul 6, 2023
4c2f46f
chore: format
0x8f701 Jul 6, 2023
9d14490
feat: dont verify credit if creditAmount == 0
0x8f701 Jul 6, 2023
daf1755
feat: remove extra logic branches
0x8f701 Jul 6, 2023
e399c19
chore: add more comments
0x8f701 Jul 6, 2023
7d4c681
feat: remove ethLeft from vars
0x8f701 Jul 6, 2023
7705a25
feat: remove duplicated code
0x8f701 Jul 6, 2023
d145853
feat: remove duplicated code
0x8f701 Jul 6, 2023
5a41a31
feat: remove msg.value check
0x8f701 Jul 7, 2023
635eac6
feat: remove redundant check
0x8f701 Jul 7, 2023
d4c99c1
fix: tests
0x8f701 Jul 7, 2023
86de1ec
feat: limit marketplace offer to be same collection
0x8f701 Jul 7, 2023
f3c9768
fix: typo
0x8f701 Jul 9, 2023
83db9a9
feat: remove one if else
0x8f701 Jul 9, 2023
81cf9e5
feat: batch supply
0x8f701 Jul 9, 2023
9b07cd5
fix: typo
0x8f701 Jul 10, 2023
d4c6c6c
feat: simplify
0x8f701 Jul 10, 2023
2adfe1c
feat: resolve comments
0x8f701 Jul 10, 2023
71e189b
feat: add batchAcceptOpenseaBid
0x8f701 Jul 11, 2023
d78fa85
feat: cache requiredItemType
0x8f701 Jul 11, 2023
f35ec00
feat: batch collateralize
0x8f701 Jul 11, 2023
1d3cbbe
feat: improve gas
0x8f701 Jul 11, 2023
65c800b
feat: improve gas
0x8f701 Jul 11, 2023
fe27530
fix: typo
0x8f701 Jul 11, 2023
238acdb
chore: update lockfile
0x8f701 Jul 18, 2023
c7cfb0f
fix: unused lib
0x8f701 Jul 18, 2023
92bb4d6
fix: remove redundant check
0x8f701 Jul 18, 2023
9506a4e
fix: remove transferToken
0x8f701 Jul 18, 2023
33766a0
chore: revert husky
0x8f701 Jul 18, 2023
f7adee4
fix: remove 1 mstore
0x8f701 Jul 18, 2023
153652c
fix: remove typos
0x8f701 Jul 18, 2023
add9a62
Merge branch 'main' into feat/collateral-swap-2
0x8f701 Sep 12, 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
25 changes: 11 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ jobs:

- name: Run lint
run: |
yarn cache clean --all
YARN_CHECKSUM_BEHAVIOR=update yarn
touch .env
yarn
yarn build
yarn doc
yarn lint
yarn size
make build
make doc
make lint
make size

tests:
name: Unit Tests
Expand Down Expand Up @@ -65,11 +64,10 @@ jobs:

- name: Run unit tests
run: |
yarn cache clean --all
YARN_CHECKSUM_BEHAVIOR=update yarn
touch .env
yarn
yarn build
yarn test
make build
make test

coverage:
name: Coverage Check
Expand All @@ -95,11 +93,10 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: |
yarn cache clean --all
YARN_CHECKSUM_BEHAVIOR=update yarn
touch .env
yarn
yarn build
yarn coverage
make build
make coverage
env:
NODE_OPTIONS: --max_old_space_size=8192
- name: Publish coverage
Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ doc:

.PHONY: lint
lint:
typos
yarn lint

.PHONY: coverage
Expand Down Expand Up @@ -104,6 +103,18 @@ test-erc20-liquidation:
test-erc20-borrow:
make TEST_TARGET=_pool_core_erc20_borrow.spec.ts test

.PHONY: test-erc20-borrow-swap
test-erc20-borrow-swap:
make TEST_TARGET=_pool_core_erc20_borrow_swap.spec.ts test

.PHONY: test-erc20-ptoken-swap
test-erc20-ptoken-swap:
make TEST_TARGET=_pool_core_erc20_ptoken_swap.spec.ts test

.PHONY: test-erc20-debt-swap
test-erc20-debt-swap:
make TEST_TARGET=_pool_core_erc20_debt_swap.spec.ts test

.PHONY: test-erc20-supply
test-erc20-supply:
make TEST_TARGET=_pool_core_erc20_supply.spec.ts test
Expand Down Expand Up @@ -172,6 +183,10 @@ test-moonbirds:
test-marketplace-buy:
make TEST_TARGET=_pool_marketplace_buy_with_credit.spec.ts test

.PHONY: test-marketplace-buy-any
test-marketplace-buy-any:
make TEST_TARGET=_pool_marketplace_buy_any_with_credit.spec.ts test

.PHONY: test-marketplace-accept-bid
test-marketplace-accept-bid:
make TEST_TARGET=_pool_marketplace_accept_bid_with_credit.spec.ts test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

/* solhint-disable avoid-low-level-calls */
/* solhint-disable no-empty-blocks */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

import {UserOperation} from "../utils/UserOperation.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

import {UserOperation} from "../utils/UserOperation.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** Only one instance required on each chain.
**/
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

/* solhint-disable avoid-low-level-calls */
/* solhint-disable no-inline-assembly */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

interface INonceManager {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

import {UserOperation} from "../utils/UserOperation.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

/**
* manage deposits and stakes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
pragma solidity ^0.8.0;

/**
* User Operation struct
Expand Down
101 changes: 101 additions & 0 deletions contracts/dependencies/uniswapv3-core/libraries/BytesLib.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* @title Solidity Bytes Arrays Utils
* @author Gonçalo Sá <goncalo.sa@consensys.net>
*
* @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
* The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
*/
pragma solidity ^0.8.0;

library BytesLib {
function slice(
bytes memory _bytes,
uint256 _start,
uint256 _length
) internal pure returns (bytes memory) {
require(_length + 31 >= _length, 'slice_overflow');
require(_start + _length >= _start, 'slice_overflow');
require(_bytes.length >= _start + _length, 'slice_outOfBounds');

bytes memory tempBytes;

assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)

// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)

// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)

for {
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}

mstore(tempBytes, _length)

//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
default {
tempBytes := mload(0x40)
//zero out the 32 bytes slice we are about to return
//we need to do it because Solidity does not garbage collect
mstore(tempBytes, 0)

mstore(0x40, add(tempBytes, 0x20))
}
}

return tempBytes;
}

function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
require(_start + 20 >= _start, 'toAddress_overflow');
require(_bytes.length >= _start + 20, 'toAddress_outOfBounds');
address tempAddress;

assembly {
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
}

return tempAddress;
}

function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) {
require(_start + 3 >= _start, 'toUint24_overflow');
require(_bytes.length >= _start + 3, 'toUint24_outOfBounds');
uint24 tempUint;

assembly {
tempUint := mload(add(add(_bytes, 0x3), _start))
}

return tempUint;
}
}
69 changes: 69 additions & 0 deletions contracts/dependencies/uniswapv3-core/libraries/Path.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {BytesLib} from './BytesLib.sol';

/// @title Functions for manipulating path data for multihop swaps
library Path {
using BytesLib for bytes;

/// @dev The length of the bytes encoded address
uint256 private constant ADDR_SIZE = 20;
/// @dev The length of the bytes encoded fee
uint256 private constant FEE_SIZE = 3;

/// @dev The offset of a single token address and pool fee
uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE;
/// @dev The offset of an encoded pool key
uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE;
/// @dev The minimum length of an encoding that contains 2 or more pools
uint256 private constant MULTIPLE_POOLS_MIN_LENGTH = POP_OFFSET + NEXT_OFFSET;

/// @notice Returns true iff the path contains two or more pools
/// @param path The encoded swap path
/// @return True if path contains two or more pools, otherwise false
function hasMultiplePools(bytes memory path) internal pure returns (bool) {
return path.length >= MULTIPLE_POOLS_MIN_LENGTH;
}

/// @notice Returns the number of pools in the path
/// @param path The encoded swap path
/// @return The number of pools in the path
function numPools(bytes memory path) internal pure returns (uint256) {
// Ignore the first token address. From then on every fee and token offset indicates a pool.
return ((path.length - ADDR_SIZE) / NEXT_OFFSET);
}

/// @notice Decodes the first pool in path
/// @param path The bytes encoded swap path
/// @return tokenA The first token of the given pool
/// @return tokenB The second token of the given pool
/// @return fee The fee level of the pool
function decodeFirstPool(bytes memory path)
internal
pure
returns (
address tokenA,
address tokenB,
uint24 fee
)
{
tokenA = path.toAddress(0);
fee = path.toUint24(ADDR_SIZE);
tokenB = path.toAddress(NEXT_OFFSET);
}

/// @notice Gets the segment corresponding to the first pool in the path
/// @param path The bytes encoded swap path
/// @return The segment containing all data necessary to target the first pool in the path
function getFirstPool(bytes memory path) internal pure returns (bytes memory) {
return path.slice(0, POP_OFFSET);
}

/// @notice Skips a token + fee element from the buffer and returns the remainder
/// @param path The swap path
/// @return The remaining token + fee elements in the path
function skipToken(bytes memory path) internal pure returns (bytes memory) {
return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET);
}
}
26 changes: 26 additions & 0 deletions contracts/interfaces/IOneInch.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

interface IAggregationExecutor {
/// @notice propagates information about original msg.sender and executes arbitrary data
function execute(address msgSender) external payable; // 0x4b64e492
}

interface IOneInch {
struct SwapDescription {
address srcToken;
address dstToken;
address payable srcReceiver;
address payable dstReceiver;
uint256 amount;
uint256 minReturnAmount;
uint256 flags;
}

function swap(
IAggregationExecutor executor,
SwapDescription calldata desc,
bytes calldata permit,
bytes calldata data
) external payable returns (uint256 returnAmount, uint256 spentAmount);
}
Loading