Skip to content

Commit

Permalink
STP-14: Incentivize USDC LP on Base Andromeda (#159)
Browse files Browse the repository at this point in the history
* Deploy Spartan Council pool Rewards Distributor to Base Mainnet Andromeda

* E2E test for SNX Rewards Distributor on Base Mainnet

* Bump version

* Rename deployment steps

* Switch public RPC -> Infura
  • Loading branch information
noisekit authored Mar 26, 2024
1 parent 008bd99 commit 6d08122
Show file tree
Hide file tree
Showing 7 changed files with 444 additions and 63 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,15 +597,15 @@ workflows:
package: "synthetix-omnibus:latest"
preset: "andromeda"
chain-id: 84532
provider-url: https://sepolia.base.org
provider-url: https://base-sepolia.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: base-mainnet-andromeda
toml: omnibus-base-mainnet-andromeda.toml
package: "synthetix-omnibus:latest"
preset: "andromeda"
chain-id: 8453
provider-url: https://mainnet.base.org
provider-url: https://base-mainnet.infura.io/v3/$INFURA_API_KEY

- fork-test:
name: mainnet
Expand Down Expand Up @@ -669,14 +669,14 @@ workflows:
package: "synthetix-omnibus:latest"
preset: "andromeda"
chain-id: 84532
provider-url: https://sepolia.base.org
provider-url: https://base-sepolia.infura.io/v3/$INFURA_API_KEY

- deployment-info:
name: docs-base-mainnet-andromeda
package: "synthetix-omnibus:latest"
preset: "andromeda"
chain-id: 8453
provider-url: https://mainnet.base.org
provider-url: https://base-mainnet.infura.io/v3/$INFURA_API_KEY

- deployment-info:
name: docs-mainnet
Expand Down Expand Up @@ -782,12 +782,12 @@ workflows:
package: "synthetix-omnibus:latest"
preset: "andromeda"
chain-id: 8453
provider-url: https://mainnet.base.org
provider-url: https://base-mainnet.infura.io/v3/$INFURA_API_KEY

- preview:
name: preview-base-sepolia-andromeda
toml: omnibus-base-sepolia-andromeda.toml
package: "synthetix-omnibus:latest"
preset: "andromeda"
chain-id: 84532
provider-url: https://sepolia.base.org
provider-url: https://base-sepolia.infura.io/v3/$INFURA_API_KEY
2 changes: 2 additions & 0 deletions e2e/generateDeployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ async function run() {
}

const snxRewards =
deployments?.state?.[`provision.stp_14_spartan_council_pool_snx_rewards`]?.artifacts?.imports
?.stp_14_spartan_council_pool_snx_rewards ??
deployments?.state?.[`provision.spartan_council_pool_rewards`]?.artifacts?.imports
?.spartan_council_pool_rewards;
if (snxRewards) {
Expand Down
63 changes: 63 additions & 0 deletions e2e/tasks/setMainnetTokenBalance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node

const { ethers } = require('ethers');
const { setEthBalance } = require('./setEthBalance');
const { parseError } = require('../parseError');
const { gasLog } = require('../gasLog');

const log = require('debug')(`e2e:${require('path').basename(__filename, '.js')}`);

async function setMainnetTokenBalance({ wallet, balance, tokenAddress, friendlyWhale }) {
const Token = new ethers.Contract(
tokenAddress,
[
'function symbol() view returns (string)',
'function decimals() view returns (uint8)',
'function balanceOf(address account) view returns (uint256)',
'function transfer(address to, uint256 value) returns (bool)',
],
wallet
);
const decimals = await Token.decimals();
const symbol = await Token.symbol();

const oldBalance = parseFloat(
ethers.utils.formatUnits(await Token.balanceOf(wallet.address), decimals)
);
log({ symbol, tokenAddress, oldBalance });
if (oldBalance > balance) {
log({ result: 'SKIP' });
return;
}

// Mainnet only!
const whaleBalance = parseFloat(
ethers.utils.formatUnits(await Token.balanceOf(friendlyWhale), decimals)
);
log({ friendlyWhale, whaleBalance });

await setEthBalance({ address: friendlyWhale, balance: 1000 });

await wallet.provider.send('anvil_impersonateAccount', [friendlyWhale]);
const signer = wallet.provider.getSigner(friendlyWhale);
const tx = await Token.connect(signer).transfer(
wallet.address,
ethers.utils.parseUnits(`${balance - oldBalance}`, decimals)
);
await tx
.wait()
.then((txn) => log(txn.events) || txn, parseError)
.then(gasLog({ action: 'Token.transfer', log }));
await wallet.provider.send('anvil_stopImpersonatingAccount', [friendlyWhale]);

const newBalance = parseFloat(
ethers.utils.formatUnits(await Token.balanceOf(wallet.address), decimals)
);
log({ symbol, tokenAddress: tokenAddress, newBalance });

return null;
}

module.exports = {
setMainnetTokenBalance,
};
59 changes: 4 additions & 55 deletions e2e/tasks/setUSDCTokenBalance.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,13 @@
#!/usr/bin/env node

const { ethers } = require('ethers');
const { getCollateralConfig } = require('./getCollateralConfig');
const { setEthBalance } = require('./setEthBalance');
const { parseError } = require('../parseError');
const { gasLog } = require('../gasLog');

const log = require('debug')(`e2e:${require('path').basename(__filename, '.js')}`);
const { setMainnetTokenBalance } = require('./setMainnetTokenBalance');

async function setUSDCTokenBalance({ wallet, balance }) {
const config = await getCollateralConfig('USDC');
const Token = new ethers.Contract(
config.tokenAddress,
[
'function symbol() view returns (string)',
'function decimals() view returns (uint8)',
'function balanceOf(address account) view returns (uint256)',
'function transfer(address to, uint256 value) returns (bool)',
],
wallet
);
const decimals = await Token.decimals();
const symbol = await Token.symbol();

const oldBalance = parseFloat(
ethers.utils.formatUnits(await Token.balanceOf(wallet.address), decimals)
);
log({ symbol, tokenAddress: config.tokenAddress, oldBalance });
if (oldBalance > balance) {
log({ result: 'SKIP' });
return;
}

// Mainnet only!
const { tokenAddress } = await getCollateralConfig('USDC');
// BASE Mainnet only!
const friendlyWhale = '0xcdac0d6c6c59727a65f871236188350531885c43';
const whaleBalance = parseFloat(
ethers.utils.formatUnits(await Token.balanceOf(friendlyWhale), decimals)
);
log({ friendlyWhale, whaleBalance });

await setEthBalance({ address: friendlyWhale, balance: 1000 });

await wallet.provider.send('anvil_impersonateAccount', [friendlyWhale]);
const signer = wallet.provider.getSigner(friendlyWhale);
const tx = await Token.connect(signer).transfer(
wallet.address,
ethers.utils.parseUnits(`${balance - oldBalance}`, decimals)
);
await tx
.wait()
.then((txn) => log(txn.events) || txn, parseError)
.then(gasLog({ action: 'Token.transfer', log }));
await wallet.provider.send('anvil_stopImpersonatingAccount', [friendlyWhale]);

const newBalance = parseFloat(
ethers.utils.formatUnits(await Token.balanceOf(wallet.address), decimals)
);
log({ symbol, tokenAddress: config.tokenAddress, newBalance });

return null;
return setMainnetTokenBalance({ wallet, balance, tokenAddress, friendlyWhale });
}

module.exports = {
Expand Down
Loading

0 comments on commit 6d08122

Please sign in to comment.