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

STP-14: Incentivize USDC LP on Base Andromeda #159

Merged
merged 5 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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