Skip to content

feat: add celo, ink and linea chains support #36

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

Merged
merged 1 commit into from
Apr 24, 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
10 changes: 10 additions & 0 deletions packages/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
"sdk-core"
],
"targets": {
"type-check": {
"executor": "@nx/js:tsc",
"options": {
"main": "packages/core/src/index.ts",
"tsConfig": "packages/core/tsconfig.lib.json",
"outputPath": "packages/core/dist",
"clean": true,
"noEmit": true
}
},
"biome-lint": {
"executor": "@gitopslovers/nx-biome:biome-lint",
"outputs": [
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/addresses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ describe("Addresses", () => {
[SupportedChain.World, "0xc0aCA216Aa936511b24Ff238F610B02bE54e10AD"],
[SupportedChain.Bsc, "0x4A75a527E97d853109aA6998a2B9E45a87A31e9f"],
[SupportedChain.Cronos, "0x973E09e96E64E4bf17e383a8A497Fb566284c707"],
[SupportedChain.Ink, "0x490040E1A2df842Cab527146a20534e23DcC46FF"],
[SupportedChain.Linea, "0xbe13866797bbdE2646FFBb58F102FcA91EFC88F1"],
[SupportedChain.Celo, "0xf2e389cEbA01db96e9bd63B5a9Fa47422dAeEb40"],
[SupportedChain.Sepolia, "0x448E3D0a4BAa00FE511a03E7B27177AeDE6d9636"],
[SupportedChain.Unichain, "0x354869495Fd916ADAFc0626C3d60115240dc06f1"],
[SupportedChain.UnichainSepolia, "0x1381F509f56f2aaA0faBD3012455901eA53F0BbD"],
// note: no starknet version of tokenBundlerContract
])("should resolve correct bundler address for %s", (chain, expected) => {
expect(
CHAIN_TO_ADDRESSES_MAP[chain as V1_3_SUPPORTED_CHAINS]
Expand Down
26 changes: 25 additions & 1 deletion packages/core/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const UNICHAIN_CONSTANTS: V1_3_Contracts = {
// Sepolia contracts
const SEPOLIA_CONTRACTS: V1_3_Contracts = {
...PWN_V1_3_CONTRACTS,
tokenBundlerContract: "0x448E3D0a4BAa0A0FE511a03E7B27177AeDE6d9636",
tokenBundlerContract: "0x448E3D0a4BAa00FE511a03E7B27177AeDE6d9636",
pwnSimpleLoanElasticChainlinkProposal: "0xC46170F43b97faE1A8B507d6fdDaFfBb7527D61B",
};

Expand All @@ -150,6 +150,27 @@ const UNICHAIN_SEPOLIA_CONTRACTS: V1_3_Contracts = {
pwnSimpleLoanElasticChainlinkProposal: ZERO_ADDRESS, // not deployed
};

// Ink contracts
const INK_CONTRACTS: V1_3_Contracts = {
...PWN_V1_3_CONTRACTS,
tokenBundlerContract: "0x490040E1A2df842Cab527146a20534e23DcC46FF",
pwnSimpleLoanElasticChainlinkProposal: ZERO_ADDRESS, // not deployed
};

// Linea contracts
const LINEA_CONTRACTS: V1_3_Contracts = {
...PWN_V1_3_CONTRACTS,
tokenBundlerContract: "0xbe13866797bbdE2646FFBb58F102FcA91EFC88F1",
pwnSimpleLoanElasticChainlinkProposal: "0x8E9955B34606f601491c14d5cc8247F5E0477ff1",
};

// Celo contracts
const CELO_CONTRACTS: V1_3_Contracts = {
...PWN_V1_3_CONTRACTS,
tokenBundlerContract: "0xf2e389cEbA01db96e9bd63B5a9Fa47422dAeEb40",
pwnSimpleLoanElasticChainlinkProposal: "0x53fb85416cAeEE7f4d142F88685e2094f6E9E985",
};

const STARKNET_CONTRACTS: V1_2_StarknetContracts = {
...PWN_V1_2_STARKNET_CONTRACTS,
};
Expand All @@ -176,6 +197,9 @@ export const V1_3_CHAIN_TO_ADDRESSES_MAP: Record<
[SupportedChain.World]: WORLDCHAIN_CONTRACTS,
[SupportedChain.Bsc]: BSC_CONTRACTS,
[SupportedChain.Cronos]: CRONOS_CONTRACTS,
[SupportedChain.Celo]: CELO_CONTRACTS,
[SupportedChain.Linea]: LINEA_CONTRACTS,
[SupportedChain.Ink]: INK_CONTRACTS,

[SupportedChain.Sepolia]: SEPOLIA_CONTRACTS,
[SupportedChain.UnichainSepolia]: UNICHAIN_SEPOLIA_CONTRACTS,
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export enum SupportedChain {
StarknetSepolia = 11155112,
StarknetMainnet = 112211,
World = 480,
Linea = 59144,
Celo = 42220,
Ink = 57073,
}

export const ALL_SUPPORTED_CHAINS = Object.values(SupportedChain).filter(
Expand Down
6 changes: 6 additions & 0 deletions packages/v1-core/src/actions/make-proposal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe("Test make proposal", () => {
getCollateralAmount: vi.fn().mockImplementation(() => 0n),
createOnChainProposal: vi.fn().mockImplementation((p) => p),
getProposalHash: vi.fn().mockImplementation(() => "0x123"),
createMultiProposal: vi.fn().mockImplementation((p) => p),
};

const loanContractMock = {
Expand Down Expand Up @@ -89,6 +90,7 @@ describe("Test make proposal", () => {
minCreditAmountPercentage: 3,
relatedStrategyId: "1",
isOffer: true,
sourceOfFunds: user_address,
},
{
api: {
Expand Down Expand Up @@ -146,6 +148,7 @@ describe("Test make proposal", () => {
getCollateralAmount: vi.fn().mockImplementation(() => 0n),
createOnChainProposal: vi.fn().mockImplementation((p) => p),
getProposalHash: vi.fn().mockImplementation(() => "0x123"),
createMultiProposal: vi.fn().mockImplementation((p) => p),
};

const loanContractMock = {
Expand Down Expand Up @@ -186,6 +189,7 @@ describe("Test make proposal", () => {
minCreditAmountPercentage: 3,
relatedStrategyId: "1",
isOffer: true,
sourceOfFunds: user_address,
},
{
api: {
Expand Down Expand Up @@ -262,6 +266,7 @@ describe("Test make proposal", () => {
getCollateralAmount: vi.fn().mockImplementation(() => 0n),
createOnChainProposal: vi.fn().mockImplementation((p) => p),
getProposalHash: vi.fn().mockImplementation(() => "0x123"),
createMultiProposal: vi.fn().mockImplementation((p) => p),
};

const poolTokenAddress = generateAddress();
Expand Down Expand Up @@ -311,6 +316,7 @@ describe("Test make proposal", () => {
minCreditAmountPercentage: 3,
relatedStrategyId: "1",
isOffer: true,
sourceOfFunds: user_address,
},
{
api: {
Expand Down
24 changes: 16 additions & 8 deletions packages/v1-core/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,23 @@ export const ezETH = defineAddresses({
[SupportedChain.Ethereum]: "0xbf5495efe5db9ce00f80364c8b423567e58d2110",
[SupportedChain.Base]: "0x2416092f143378750bb29b79ed961ab195cceea5",
[SupportedChain.Arbitrum]: "0x2416092f143378750bb29b79eD961ab195CcEea5",
[SupportedChain.Bsc]: "0x2416092f143378750bb29b79ed961ab195cceea5"
[SupportedChain.Bsc]: "0x2416092f143378750bb29b79ed961ab195cceea5",
[SupportedChain.Linea]: "0x2416092f143378750bb29b79eD961ab195CcEea5"
})

export const rsETH = defineAddresses({
[SupportedChain.Ethereum]: "0xa1290d69c65a6fe4df752f95823fae25cb99e5a7",
[SupportedChain.Optimism]: "0x4186BFC76E2E237523CBC30FD220FE055156b41F",
[SupportedChain.Arbitrum]: "0x4186BFC76E2E237523CBC30FD220FE055156b41F"
[SupportedChain.Arbitrum]: "0x4186BFC76E2E237523CBC30FD220FE055156b41F",
[SupportedChain.Linea]: "0x4186bfc76e2e237523cbc30fd220fe055156b41f"
})

export const weETH = defineAddresses({
[SupportedChain.Ethereum]: "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee",
[SupportedChain.Base]: "0x04c0599ae5a44757c0af6f9ec3b93da8976c150a",
[SupportedChain.Optimism]: "0x5A7fACB970D094B6C7FF1df0eA68D99E6e73CBFF",
[SupportedChain.Arbitrum]: "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe"
[SupportedChain.Arbitrum]: "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe",
[SupportedChain.Linea]: "0x1Bf74C010E6320bab11e2e5A532b5AC15e0b8aA6"
})

export const DAI = defineAddresses({
Expand All @@ -82,7 +85,8 @@ export const DAI = defineAddresses({
[SupportedChain.Optimism]: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
[SupportedChain.Arbitrum]: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
[SupportedChain.Polygon]: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
[SupportedChain.Bsc]: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3"
[SupportedChain.Bsc]: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3",
[SupportedChain.Linea]: "0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5"
})

export const TUSD = defineAddresses({
Expand All @@ -101,7 +105,8 @@ export const USDC = defineAddresses({
[SupportedChain.Optimism]: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
[SupportedChain.Arbitrum]: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
[SupportedChain.Polygon]: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
[SupportedChain.Bsc]: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d"
[SupportedChain.Bsc]: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
[SupportedChain.Linea]: "0x176211869cA2b568f2A7D4EE941E073a821EE1ff"
})

export const USDT = defineAddresses({
Expand All @@ -111,7 +116,8 @@ export const USDT = defineAddresses({
[SupportedChain.Optimism]: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",
[SupportedChain.Arbitrum]: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
[SupportedChain.Polygon]: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
[SupportedChain.Bsc]: "0x524bc91dc82d6b90ef29f76a3ecaabafffd490bc"
[SupportedChain.Bsc]: "0x524bc91dc82d6b90ef29f76a3ecaabafffd490bc",
[SupportedChain.Linea]: "0xA219439258ca9da29E9Cc4cE5596924745e12B93"
})

export const tBTC = defineAddresses({
Expand All @@ -127,7 +133,8 @@ export const wstETH = defineAddresses({
[SupportedChain.Optimism]: "0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb",
[SupportedChain.Arbitrum]: "0x5979D7b546E38E414F7E9822514be443A4800529",
[SupportedChain.Polygon]: "0x03b54a6e9a984069379fae1a4fc4dbae93b3bccd",
[SupportedChain.Bsc]: "0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C"
[SupportedChain.Bsc]: "0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C",
[SupportedChain.Linea]: "0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F"
})

export const USD0 = defineAddresses({
Expand All @@ -150,7 +157,8 @@ export const WETH = defineAddresses({
[SupportedChain.Optimism]: "0x4200000000000000000000000000000000000006",
[SupportedChain.Arbitrum]: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
[SupportedChain.Polygon]: "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
[SupportedChain.Bsc]: "0x4db5a66e937a9f4473fa95b1caf1d1e1d62e29ea"
[SupportedChain.Bsc]: "0x4db5a66e937a9f4473fa95b1caf1d1e1d62e29ea",
[SupportedChain.Linea]: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f"
})

export const sUSDe = defineAddresses({
Expand Down
17 changes: 16 additions & 1 deletion packages/v1-core/src/utils/chainlink-feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const NATIVE_PAIRS = {
[SupportedChain.Arbitrum]: ["BTC/ETH", "BTC/USD", "ETH/USD"],
[SupportedChain.Polygon]: ["BTC/ETH", "BTC/USD", "ETH/USD"],
[SupportedChain.Bsc]: ["BTC/ETH", "BTC/USD", "ETH/USD"],
[SupportedChain.Linea]: ["BTC/USD", "ETH/USD"],
} as const;

export const CHAINS_WITH_CHAINLINK_FEED_SUPPORT =
Expand Down Expand Up @@ -73,7 +74,9 @@ export type AllowedQuotes<T extends ChainsWithChainLinkFeedSupport> =
? "ETH" | "USD"
: T extends SupportedChain.Bsc
? "BTC" | "ETH" | "USD"
: never;
: T extends SupportedChain.Linea
? "BTC" | "ETH" | "USD"
: never;

// Define a type for the native pairs
type NativePair = `${NativeAssetName}/${NativeAssetName}`;
Expand Down Expand Up @@ -275,6 +278,18 @@ export const FEED_REGISTRY = {
// as for ETH in NATIVE_PAIRS
[WETH[SupportedChain.Sepolia]]: ["ETH", "USD"],
},
[SupportedChain.Linea]: {
[rsETH[SupportedChain.Linea]]: ["ETH"],
[ezETH[SupportedChain.Linea]]: ["ETH"],
[weETH[SupportedChain.Linea]]: ["ETH"],
[wstETH[SupportedChain.Linea]]: ["USD"],
[DAI[SupportedChain.Linea]]: ["USD"],
[USDC[SupportedChain.Linea]]: ["USD"],
[USDT[SupportedChain.Linea]]: ["USD"],
// note: slight hack as WETH == ETH, so these are the same feeds
// as for ETH in NATIVE_PAIRS
[WETH[SupportedChain.Linea]]: ["ETH", "USD"],
},
} as const satisfies CompleteFeedRegistry;

export const convertNameIntoDenominator = <
Expand Down
Loading