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

AB#3227: Add Symbiotic pufETH (pufETHs) #57

Merged
merged 2 commits into from
Feb 4, 2025
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
25 changes: 0 additions & 25 deletions lib/contracts/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Chain } from '../chains/constants';
import { UnifiToken } from './tokens';

// Source of truth:
// https://github.com/PufferFinance/Deployments-and-ACL/tree/main/docs/deployments
Expand Down Expand Up @@ -28,27 +27,3 @@ export const CONTRACT_ADDRESSES = {
L2RewardManager: '0xF9Dd335bF363b2E4ecFe3c94A86EBD7Dd3Dcf0e7',
},
};

export const NUCLEUS_CONTRACT_ADDRESSES = {
[UnifiToken.unifiETH]: {
[Chain.Mainnet]: {
NucleusBoringVault: '0x196ead472583bc1e9af7a05f860d9857e1bd3dcc',
NucleusAccountant: '0xa9fb7e2922216debe3fd5e1bbe7591ee446dc21c',
NucleusTeller: '0x08eb2eccdf6ebd7aba601791f23ec5b5f68a1d53',
},
},
[UnifiToken.unifiUSD]: {
[Chain.Mainnet]: {
NucleusBoringVault: '0x82c40e07277eBb92935f79cE92268F80dDc7caB4',
NucleusAccountant: '0xe0bDb7b9225A2CeB42998dc2E51D4D3CDeb7e3Be',
NucleusTeller: '0x5d3Fb47FE7f3F4Ce8fe55518f7E4F7D6061B54DD',
},
},
[UnifiToken.unifiBTC]: {
[Chain.Mainnet]: {
NucleusBoringVault: '0x170d847a8320f3b6a77ee15b0cae430e3ec933a0',
NucleusAccountant: '0x2afb28b0561d99b5e00829ec2ef54946a00a35f7',
NucleusTeller: '0x0743647a607822781f9d0a639454e76289182f0b',
},
},
};
8 changes: 3 additions & 5 deletions lib/contracts/handlers/nucleus-accountant-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { mockAccount, testingUtils } from '../../../test/setup-tests';
import { generateAddress } from '../../../test/mocks/address';
import { Address } from 'viem';
import { UnifiToken } from '../tokens';
import { NUCLEUS_CONTRACT_ADDRESSES } from '../addresses';
import { VAULTS_ADDRESSES } from '../vaults-addresses';

describe('NucleusAccountantHandler', () => {
const contractTestingUtils = testingUtils.generateContractUtils(
Expand Down Expand Up @@ -80,16 +80,14 @@ describe('NucleusAccountantHandler', () => {
.withToken(UnifiToken.unifiBTC)
.getContract();
expect(unifiBTCAccountant.address).toEqual(
NUCLEUS_CONTRACT_ADDRESSES[UnifiToken.unifiBTC][Chain.Mainnet]
.NucleusAccountant,
VAULTS_ADDRESSES[UnifiToken.unifiBTC][Chain.Mainnet].NucleusAccountant,
);

const unifiUSDAcountant = handler
.withToken(UnifiToken.unifiUSD)
.getContract();
expect(unifiUSDAcountant.address).toEqual(
NUCLEUS_CONTRACT_ADDRESSES[UnifiToken.unifiUSD][Chain.Mainnet]
.NucleusAccountant,
VAULTS_ADDRESSES[UnifiToken.unifiUSD][Chain.Mainnet].NucleusAccountant,
);
});
});
4 changes: 2 additions & 2 deletions lib/contracts/handlers/nucleus-accountant-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GetContractReturnType,
} from 'viem';
import { Chain } from '../../chains/constants';
import { NUCLEUS_CONTRACT_ADDRESSES } from '../addresses';
import { VAULTS_ADDRESSES } from '../vaults-addresses';
import { NUCLEUS_ACCOUNTANT_ABIS } from '../abis/nucleus-accountant-abis';
import { UnifiToken } from '../tokens';

Expand Down Expand Up @@ -54,7 +54,7 @@ export class NucleusAccountantHandler {
* @returns The viem contract.
*/
public getContract() {
const address = NUCLEUS_CONTRACT_ADDRESSES[this.token][this.chain]
const address = VAULTS_ADDRESSES[this.token][this.chain]
.NucleusAccountant as Address;
const abi = NUCLEUS_ACCOUNTANT_ABIS[this.chain].Accountant;
const client = { public: this.publicClient, wallet: this.walletClient };
Expand Down
8 changes: 3 additions & 5 deletions lib/contracts/handlers/nucleus-boring-vault-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { mockAccount, testingUtils } from '../../../test/setup-tests';
import { NucleusBoringVaultHandler } from './nucleus-boring-vault-handler';
import { NUCLEUS_BORING_VAULT_ABIS } from '../abis/nucleus-boring-vault-abis';
import { generateAddress } from '../../../test/mocks/address';
import { NUCLEUS_CONTRACT_ADDRESSES } from '../addresses';
import { VAULTS_ADDRESSES } from '../vaults-addresses';
import { UnifiToken } from '../tokens';

describe('NucleusBoringVaultHandler', () => {
Expand Down Expand Up @@ -113,16 +113,14 @@ describe('NucleusBoringVaultHandler', () => {
.withToken(UnifiToken.unifiBTC)
.getContract();
expect(unifiBTCBoringVault.address).toEqual(
NUCLEUS_CONTRACT_ADDRESSES[UnifiToken.unifiBTC][Chain.Mainnet]
.NucleusBoringVault,
VAULTS_ADDRESSES[UnifiToken.unifiBTC][Chain.Mainnet].NucleusBoringVault,
);

const unifiUSDBoringVault = handler
.withToken(UnifiToken.unifiUSD)
.getContract();
expect(unifiUSDBoringVault.address).toEqual(
NUCLEUS_CONTRACT_ADDRESSES[UnifiToken.unifiUSD][Chain.Mainnet]
.NucleusBoringVault,
VAULTS_ADDRESSES[UnifiToken.unifiUSD][Chain.Mainnet].NucleusBoringVault,
);
});
});
4 changes: 2 additions & 2 deletions lib/contracts/handlers/nucleus-boring-vault-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'viem';
import { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';
import { NUCLEUS_BORING_VAULT_ABIS } from '../abis/nucleus-boring-vault-abis';
import { NUCLEUS_CONTRACT_ADDRESSES } from '../addresses';
import { VAULTS_ADDRESSES } from '../vaults-addresses';
import { UnifiToken } from '../tokens';

export type PermitParams = {
Expand Down Expand Up @@ -68,7 +68,7 @@ export class NucleusBoringVaultHandler {
* @returns The viem contract.
*/
public getContract() {
const address = NUCLEUS_CONTRACT_ADDRESSES[this.token][this.chain]
const address = VAULTS_ADDRESSES[this.token][this.chain]
.NucleusBoringVault as Address;
const abi = NUCLEUS_BORING_VAULT_ABIS[this.chain].BoringVault;
const client = { public: this.publicClient, wallet: this.walletClient };
Expand Down
8 changes: 3 additions & 5 deletions lib/contracts/handlers/nucleus-teller-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { generateAddress } from '../../../test/mocks/address';
import { Token, TOKENS_ADDRESSES, UnifiToken } from '../tokens';
import { isHash } from 'viem';
import { mockPermitSignature } from '../../../test/mocks/permit-signature';
import { NUCLEUS_CONTRACT_ADDRESSES } from '../addresses';
import { VAULTS_ADDRESSES } from '../vaults-addresses';

describe('NucleusBoringVaultHandler', () => {
const contractTestingUtils = testingUtils.generateContractUtils(
Expand Down Expand Up @@ -114,14 +114,12 @@ describe('NucleusBoringVaultHandler', () => {
it('should use the given token to call contract functions', async () => {
const unifiBTCTeller = handler.withToken(UnifiToken.unifiBTC).getContract();
expect(unifiBTCTeller.address).toEqual(
NUCLEUS_CONTRACT_ADDRESSES[UnifiToken.unifiBTC][Chain.Mainnet]
.NucleusTeller,
VAULTS_ADDRESSES[UnifiToken.unifiBTC][Chain.Mainnet].NucleusTeller,
);

const unifiUSDTeller = handler.withToken(UnifiToken.unifiUSD).getContract();
expect(unifiUSDTeller.address).toEqual(
NUCLEUS_CONTRACT_ADDRESSES[UnifiToken.unifiUSD][Chain.Mainnet]
.NucleusTeller,
VAULTS_ADDRESSES[UnifiToken.unifiUSD][Chain.Mainnet].NucleusTeller,
);
});
});
4 changes: 2 additions & 2 deletions lib/contracts/handlers/nucleus-teller-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
GetContractReturnType,
} from 'viem';
import { Chain, VIEM_CHAINS, ViemChain } from '../../chains/constants';
import { NUCLEUS_CONTRACT_ADDRESSES } from '../addresses';
import { VAULTS_ADDRESSES } from '../vaults-addresses';
import { NUCLEUS_TELLER_ABIS } from '../abis/nucleus-teller-abis';
import { Token, TOKENS_ADDRESSES, UnifiToken } from '../tokens';
import { ERC20PermitHandler } from './erc20-permit-handler';
Expand Down Expand Up @@ -81,7 +81,7 @@ export class NucleusTellerHandler {
* @returns The viem contract.
*/
public getContract() {
const address = NUCLEUS_CONTRACT_ADDRESSES[this.token][this.chain]
const address = VAULTS_ADDRESSES[this.token][this.chain]
.NucleusTeller as Address;
const abi = NUCLEUS_TELLER_ABIS[this.chain].Teller;
const client = { public: this.publicClient, wallet: this.walletClient };
Expand Down
27 changes: 21 additions & 6 deletions lib/contracts/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export enum Token {
WETH = 'WETH',
stETH = 'stETH',
wstETH = 'wstETH',
ALT = 'ALT',
eETH = 'eETH',
cbETH = 'cbETH',
ALT = 'ALT',
pufETHwstE = 'pufETHwstE',
pufETH = 'pufETH',
WBTC = 'WBTC',
Expand All @@ -28,6 +29,8 @@ export enum UnifiToken {
unifiETH = 'unifiETH',
unifiUSD = 'unifiUSD',
unifiBTC = 'unifiBTC',
// Symbiotic pufETH.
pufETHs = 'pufETHs',
}

export type AnyToken = Token | UnifiToken;
Expand Down Expand Up @@ -59,14 +62,18 @@ export const TOKENS_ADDRESSES: {
[Chain.Mainnet]: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
[Chain.Holesky]: '0x8d09a4502Cc8Cf1547aD300E066060D043f6982D',
},
[Token.ALT]: {
[Chain.Mainnet]: '0x8457ca5040ad67fdebbcc8edce889a335bc0fbfb',
[Chain.Holesky]: '0xaf5588a571b42c7e50bd440d80f9bf94a4db94ee',
},
[Token.eETH]: {
[Chain.Mainnet]: '0x35fa164735182de50811e8e2e824cfb9b6118ac2',
[Chain.Holesky]: '0x7ba2ee123b5977e3da040e1eacb3a61c82c17876',
},
[Token.cbETH]: {
[Chain.Mainnet]: '0xbe9895146f7af43049ca1c1ae358b0541ea49704',
[Chain.Holesky]: '0x0000000000000000000000000000000000000000',
},
[Token.ALT]: {
[Chain.Mainnet]: '0x8457ca5040ad67fdebbcc8edce889a335bc0fbfb',
[Chain.Holesky]: '0xaf5588a571b42c7e50bd440d80f9bf94a4db94ee',
},
[Token.pufETHwstE]: {
[Chain.Mainnet]: '0xeeda34a377dd0ca676b9511ee1324974fa8d980d',
[Chain.Holesky]: '0x0000000000000000000000000000000000000000',
Expand Down Expand Up @@ -129,6 +136,10 @@ export const TOKENS_ADDRESSES: {
[Chain.Mainnet]: '0x170d847a8320f3b6a77ee15b0cae430e3ec933a0',
[Chain.Holesky]: '0x0000000000000000000000000000000000000000',
},
[UnifiToken.pufETHs]: {
[Chain.Mainnet]: '0x62a4ce0722ee65635c0f8339dd814d549b6f6735',
[Chain.Holesky]: '0x0000000000000000000000000000000000000000',
},
};

export const TOKENS_PERMIT_VERSION: { [key in AnyToken]: string } = {
Expand All @@ -142,9 +153,11 @@ export const TOKENS_PERMIT_VERSION: { [key in AnyToken]: string } = {
[Token.stETH]: '2',
// Puffer Quest v1 uses version 1 for wstETH.
[Token.wstETH]: '1',
[Token.ALT]: '1',
// https://github.com/etherfi-protocol/smart-contracts/blob/7c66e571df4fe7ec502a3c325b623bc52349ef9d/src/EETH.sol#L55
[Token.eETH]: '1',
// https://etherscan.io/token/0xbe9895146f7af43049ca1c1ae358b0541ea49704#readProxyContract#F26
[Token.cbETH]: '2',
[Token.ALT]: '1',
[Token.pufETHwstE]: 'v7.0.0',
[Token.pufETH]: '1',
[Token.WBTC]: '',
Expand All @@ -165,6 +178,8 @@ export const TOKENS_PERMIT_VERSION: { [key in AnyToken]: string } = {
[UnifiToken.unifiUSD]: '1',
// https://etherscan.io/address/0x170d847a8320f3b6a77ee15b0cae430e3ec933a0#code#F7#L172
[UnifiToken.unifiBTC]: '1',
// https://etherscan.io/address/0x62a4ce0722ee65635c0f8339dd814d549b6f6735#code#F7#L172
[UnifiToken.pufETHs]: '1',
};

export const TOKENS_SALT: Partial<{
Expand Down
33 changes: 33 additions & 0 deletions lib/contracts/vaults-addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Chain } from '../chains/constants';
import { UnifiToken } from './tokens';

export const VAULTS_ADDRESSES = {
[UnifiToken.unifiETH]: {
[Chain.Mainnet]: {
NucleusBoringVault: '0x196ead472583bc1e9af7a05f860d9857e1bd3dcc',
NucleusAccountant: '0xa9fb7e2922216debe3fd5e1bbe7591ee446dc21c',
NucleusTeller: '0x08eb2eccdf6ebd7aba601791f23ec5b5f68a1d53',
},
},
[UnifiToken.unifiUSD]: {
[Chain.Mainnet]: {
NucleusBoringVault: '0x82c40e07277eBb92935f79cE92268F80dDc7caB4',
NucleusAccountant: '0xe0bDb7b9225A2CeB42998dc2E51D4D3CDeb7e3Be',
NucleusTeller: '0x5d3Fb47FE7f3F4Ce8fe55518f7E4F7D6061B54DD',
},
},
[UnifiToken.unifiBTC]: {
[Chain.Mainnet]: {
NucleusBoringVault: '0x170d847a8320f3b6a77ee15b0cae430e3ec933a0',
NucleusAccountant: '0x2afb28b0561d99b5e00829ec2ef54946a00a35f7',
NucleusTeller: '0x0743647a607822781f9d0a639454e76289182f0b',
},
},
[UnifiToken.pufETHs]: {
[Chain.Mainnet]: {
NucleusBoringVault: '0x62a4ce0722ee65635c0f8339dd814d549b6f6735',
NucleusAccountant: '0xd049ebeaa59b75ba8ee38f9f6830db7293320236',
NucleusTeller: '0xa99a92c505ff92c543d9d48295f1f31024afb31f',
},
},
};