Skip to content

Commit

Permalink
Merge pull request #1213 from airswap/develop
Browse files Browse the repository at this point in the history
Deploy Latest to NPM
  • Loading branch information
dmosites authored Oct 10, 2023
2 parents d9a18a2 + a57fb87 commit c1b1133
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 50 deletions.
14 changes: 9 additions & 5 deletions source/swap-erc20/contracts/SwapERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,15 @@ contract SwapERC20 is ISwapERC20, Ownable, EIP712 {
) internal {
// Transfer fee from signer to feeWallet
uint256 feeAmount = (amount * protocolFee) / FEE_DIVISOR;
if (stakingToken != address(0) && feeAmount > 0) {
uint256 discountAmount = calculateDiscount(
IERC20(stakingToken).balanceOf(msg.sender),
feeAmount
);
if (feeAmount > 0) {
uint256 discountAmount = 0;
if (stakingToken != address(0)) {
// Only check discount if staking is set
discountAmount = calculateDiscount(
IERC20(stakingToken).balanceOf(msg.sender),
feeAmount
);
}
if (discountAmount > 0) {
// Transfer fee from signer to sender
IERC20(sourceToken).safeTransferFrom(
Expand Down
32 changes: 16 additions & 16 deletions source/swap-erc20/deploys-blocks.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module.exports = {
1: 18313788,
5: 9836907,
30: 5709868,
31: 4368360,
56: 32456402,
97: 34057585,
137: 48518111,
8453: 5043516,
42161: 139083040,
43113: 26625815,
43114: 36240432,
59140: 1688890,
59144: 596970,
80001: 41015710,
84531: 10838615,
421613: 46573263,
1: 18319195,
5: 9841536,
30: 5711587,
31: 4370691,
56: 32477948,
97: 34077869,
137: 48547131,
8453: 5071323,
42161: 139313165,
43113: 26648854,
43114: 36269658,
59140: 1694102,
59144: 602164,
80001: 41044777,
84531: 10869146,
421613: 46764380,
}
32 changes: 16 additions & 16 deletions source/swap-erc20/deploys.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module.exports = {
1: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
5: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
30: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
31: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
56: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
97: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
137: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
8453: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
42161: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
43113: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
43114: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
59140: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
59144: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
80001: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
84531: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
421613: '0xE2d2e134d61Cd1e7338ea184FB5c1224a23F5A56',
1: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
5: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
30: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
31: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
56: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
97: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
137: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
8453: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
42161: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
43113: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
43114: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
59140: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
59144: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
80001: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
84531: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
421613: '0x0C9b31Dc37718417608CE22bb1ba940f702BF90B',
}
2 changes: 1 addition & 1 deletion source/swap-erc20/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/swap-erc20",
"version": "4.1.3",
"version": "4.1.4",
"description": "AirSwap: Atomic ERC20 Token Swap",
"license": "MIT",
"repository": {
Expand Down
27 changes: 21 additions & 6 deletions source/swap-erc20/test/SwapERC20Integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,41 @@ describe('SwapERC20 Integration', () => {
})

describe('Test token holder discounts', async () => {
it('test swap without discount', async () => {
it('test swap without staking', async () => {
const order = await createSignedOrder({}, signer)

await expect(swap.connect(deployer).setStaking(staking.address)).to.emit(
await expect(swap.connect(sender).swap(sender.address, ...order)).to.emit(
swap,
'SetStaking'
'SwapERC20'
)

// Expect full 30 to be taken from signer
expect(await signerToken.balanceOf(signer.address)).to.equal('989970')

// Expect full amount to have been sent to sender
expect(await signerToken.balanceOf(sender.address)).to.equal('10000')

// Expect full fee to have been sent to fee wallet
expect(await signerToken.balanceOf(protocolFeeWallet.address)).to.equal(
'30'
)
})

it('test swap without discount', async () => {
const order = await createSignedOrder({}, signer)

await expect(swap.connect(sender).swap(sender.address, ...order)).to.emit(
swap,
'SwapERC20'
)

// Expect full 30 to be taken from signer
// Expect full fee to be taken from signer
expect(await signerToken.balanceOf(signer.address)).to.equal('989970')

// Expect full fee to have been sent to sender
// Expect full amount to have been sent to sender
expect(await signerToken.balanceOf(sender.address)).to.equal('10000')

// Expect no fee to have been sent to fee wallet
// Expect full fee to have been sent to fee wallet
expect(await signerToken.balanceOf(protocolFeeWallet.address)).to.equal(
'30'
)
Expand Down
4 changes: 2 additions & 2 deletions source/wrapper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/wrapper",
"version": "4.1.2",
"version": "4.1.3",
"description": "AirSwap: Wrap and Unwrap Native Tokens",
"license": "MIT",
"repository": {
Expand All @@ -27,7 +27,7 @@
"verify": "hardhat run ./scripts/verify.js"
},
"dependencies": {
"@airswap/swap-erc20": "4.1.3",
"@airswap/swap-erc20": "4.1.4",
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions tools/libraries/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/libraries",
"version": "4.1.6",
"version": "4.1.7",
"description": "AirSwap: Libraries for Developers",
"repository": {
"type": "git",
Expand Down Expand Up @@ -34,10 +34,10 @@
"@airswap/pool": "4.1.1",
"@airswap/staking": "4.0.3",
"@airswap/swap": "4.1.0",
"@airswap/swap-erc20": "4.1.3",
"@airswap/swap-erc20": "4.1.4",
"@airswap/types": "^4.1.1",
"@airswap/utils": "^4.1.4",
"@airswap/wrapper": "4.1.2",
"@airswap/wrapper": "4.1.3",
"browser-or-node": "^2.1.1",
"ethers": "^5.6.9",
"jayson": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion tools/metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@airswap/constants": "^4.1.1",
"@airswap/types": "^4.1.1",
"@airswap/wrapper": "4.1.2",
"@airswap/wrapper": "4.1.3",
"@openzeppelin/contracts": "^4.8.3",
"@uniswap/token-lists": "^1.0.0-beta.24",
"axios": "^0.21.4",
Expand Down

0 comments on commit c1b1133

Please sign in to comment.