From 7bf3b70f28b29bdf481a00f4472c19e23b7d011a Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 23 Aug 2024 11:38:36 +0200 Subject: [PATCH] feat: add uniform programs --- package.json | 4 +- src/index.ts | 23 ++++ src/uniform-programs.ts | 239 ++++++++++++++++++++++++++++++++++++++++ yarn.lock | 8 +- 4 files changed, 268 insertions(+), 6 deletions(-) create mode 100644 src/uniform-programs.ts diff --git a/package.json b/package.json index ea9eca2..397465c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@morpho-org/blue-reward-programs", - "version": "1.4.12", + "version": "1.4.19-beta.0", "author": "Morpho Association ", "license": "MIT", "main": "lib/index.js", @@ -33,7 +33,7 @@ "typescript": "^5.4.5" }, "dependencies": { - "@morpho-org/blue-rewards-core-sdk": "0.0.9", + "@morpho-org/blue-rewards-core-sdk": "0.0.11", "@morpho-org/morpho-ts": "^1.4.5", "viem": "^2.9.31" }, diff --git a/src/index.ts b/src/index.ts index df145fc..add065a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,10 +6,12 @@ import { VaultRewardProgram, AirdropRewardProgram, RewardProgram, + UniformRateProgram, } from "@morpho-org/blue-rewards-core-sdk"; import { AirdropRewardProgramArgs, airdropPrograms } from "./airdrop-programs"; import { MarketRewardProgramArgs, marketPrograms } from "./market-programs"; +import { UniformRewardProgramArgs, uniformPrograms } from "./uniform-programs"; import { VaultRewardProgramArgs, vaultPrograms } from "./vault-programs"; export const OffchainPrograms = { @@ -22,6 +24,9 @@ export const OffchainPrograms = { getAirdropPrograms(): AirdropRewardProgram[] { return airdropPrograms.map((programArgs) => toAirdropRewardProgram(programArgs)); }, + getUniformRatePrograms(): UniformRateProgram[] { + return uniformPrograms.map((programArgs) => toUniformRateProgram(programArgs)); + }, getPrograms(): RewardProgram[] { return [...this.getMarketPrograms(), ...this.getVaultPrograms(), ...this.getAirdropPrograms()]; }, @@ -115,3 +120,21 @@ function toAirdropRewardProgram(args: AirdropRewardProgramArgs): AirdropRewardPr cidV0: args.cidV0, }); } + +function toUniformRateProgram(args: UniformRewardProgramArgs): UniformRateProgram { + return new UniformRateProgram({ + createdAt: args.start, + start: args.start, + creator: args.fundsSender, + asset: new OnchainAsset({ + address: args.tokenAddress, + chainId: args.chainId, + }), + distributor: new UniversalRewardDistributor({ + address: args.urdAddress, + chainId: args.chainId, + }), + chainId: args.chainId, + config: args.config, + }); +} diff --git a/src/uniform-programs.ts b/src/uniform-programs.ts new file mode 100644 index 0000000..bad5a43 --- /dev/null +++ b/src/uniform-programs.ts @@ -0,0 +1,239 @@ +import { parseUnits } from "viem"; + +import { Address, ChainId, ConfigEvent, SubsetStrategy } from "@morpho-org/blue-rewards-core-sdk"; + +export type UniformRewardProgramArgs = { + fundsSender: Address; + start: bigint; + config: ConfigEvent[]; + urdAddress: Address; + tokenAddress: Address; + chainId: ChainId; +}; + +/** + * List of Uniform programs + * @example + * [ + * { + * start: 1717149233n, + * fundsSender: "0xF057afeEc22E220f47AD4220871364e9E828b2e9", + * urdAddress: "0x330eefa8a787552dc5cad3c3ca644844b1e61ddb", + * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + * config: [ + * timestamp: 1718272800n, + * rateParams: { + * sLim: 500_000_000, + * r0: parseUnits('0.000145', // 1.45E-4 MORPHO per dollar supplied per day) + * }, + * market: { + * supply: { + * subset: SubsetStrategy.CuratedMarket + * } + * } + * ], + * chainId: ChainId.MAINNET + * } + * ] + */ +export const uniformPrograms: UniformRewardProgramArgs[] = [ + { + fundsSender: "0xF057afeEc22E220f47AD4220871364e9E828b2e9", + start: 1718272800n, + urdAddress: "0x330eefa8a787552dc5cad3c3ca644844b1e61ddb", + tokenAddress: "0x9994E35Db50125E0DF82e4c2dde62496CE330999", + chainId: ChainId.MAINNET, + config: [ + { + // Thursday, June 13, 2024 10:00:00 AM + timestamp: 1718272800n, + rateParams: { + sLim: 500_000_000n, + r0: parseUnits( + "0.000145", // 1.45E-4 MORPHO per dollar supplied per day + 18 + ), + }, + market: { + supply: { + subset: SubsetStrategy.CuratedMarket, + }, + borrow: { + subset: SubsetStrategy.CuratedMarket, + whitelistedTokens: [ + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH + "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC + "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT + "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8", // PYUSD + ], + rateDivisorByToken: { + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": 10n, // WETH + "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": 10n, // USDC + "0xdAC17F958D2ee523a2206206994597C13D831ec7": 10n, // USDT + "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8": 10n, // PYUSD + }, + }, + }, + }, + { + // Monday, July 8, 2024 2:00:00 PM GMT + // additional borrow tokens (USDA, USDM, wUSDM) + timestamp: 1720447200n, + rateParams: { + sLim: 500_000_000n, + r0: parseUnits( + "0.000145", // 1.45E-4 MORPHO per dollar supplied per day + 18 + ), + }, + market: { + supply: { + subset: SubsetStrategy.CuratedMarket, + }, + borrow: { + subset: SubsetStrategy.CuratedMarket, + whitelistedTokens: [ + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH + "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC + "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT + "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8", // PYUSD + "0x0000206329b97DB379d5E1Bf586BbDB969C63274", // USDA + "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C", // USDM + "0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812", // wUSDM + ], + rateDivisorByToken: { + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": 10n, // WETH + "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": 10n, // USDC + "0xdAC17F958D2ee523a2206206994597C13D831ec7": 10n, // USDT + "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8": 10n, // PYUSD + "0x0000206329b97DB379d5E1Bf586BbDB969C63274": 10n, // USDA + "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C": 10n, // USDM + "0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812": 10n, // wUSDM + }, + }, + }, + }, + ], + }, + { + fundsSender: "0xF057afeEc22E220f47AD4220871364e9E828b2e9", + start: 1718719200n, + urdAddress: "0x5400dBb270c956E8985184335A1C62AcA6Ce1333", + // Update MORPHO token address on BASE + tokenAddress: "0x9994E35Db50125E0DF82e4c2dde62496CE330999", + chainId: ChainId.BASE, + config: [ + { + // Tuesday, June 18, 2024 2:00:00 PM GMT + timestamp: 1718719200n, + rateParams: { + sLim: 10_000_000n, + r0: parseUnits( + "0.000545", // 5.45E-4 MORPHO per dollar supplied per day + 18 + ), + }, + market: { + supply: { + subset: SubsetStrategy.CuratedMarket, + }, + }, + }, + { + // Thursday, July 4, 2024 2:00:00 PM GMT + timestamp: 1720101600n, + rateParams: { + sLim: 50_000_000n, + r0: parseUnits( + "0.000220", // 2.20E-4 MORPHO per dollar supplied per day + 18 + ), + }, + market: { + supply: { + subset: SubsetStrategy.CuratedMarket, + }, + borrow: { + subset: SubsetStrategy.CuratedMarket, + whitelistedTokens: [ + "0x4200000000000000000000000000000000000006", // WETH + "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC + ], + rateDivisorByToken: { + "0x4200000000000000000000000000000000000006": 3n, // WETH + "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": 3n, // USDC + }, + }, + }, + }, + { + // Monday, July 8, 2024 2:00:00 PM GMT + // additional borrow tokens (USDA, USDM, wUSDM) + timestamp: 1720447200n, + rateParams: { + sLim: 50_000_000n, + r0: parseUnits( + "0.000220", // 2.20E-4 MORPHO per dollar supplied per day + 18 + ), + }, + market: { + supply: { + subset: SubsetStrategy.CuratedMarket, + }, + borrow: { + subset: SubsetStrategy.CuratedMarket, + whitelistedTokens: [ + "0x4200000000000000000000000000000000000006", // WETH + "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC + "0x0000206329b97DB379d5E1Bf586BbDB969C63274", // USDA + "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C", // USDM + "0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812", // wUSDM + ], + rateDivisorByToken: { + "0x4200000000000000000000000000000000000006": 3n, // WETH + "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": 3n, // USDC + "0x0000206329b97DB379d5E1Bf586BbDB969C63274": 3n, // USDA + "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C": 3n, // USDM + "0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812": 3n, // wUSDM + }, + }, + }, + }, + { + // Thursday, August 1, 2024 2:00:00 PM GMT + // lower weth borrow rate + timestamp: 1722520800n, + rateParams: { + sLim: 50_000_000n, + r0: parseUnits( + "0.000220", // 2.20E-4 MORPHO per dollar supplied per day + 18 + ), + }, + market: { + supply: { + subset: SubsetStrategy.CuratedMarket, + }, + borrow: { + subset: SubsetStrategy.CuratedMarket, + whitelistedTokens: [ + "0x4200000000000000000000000000000000000006", // WETH + "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC + "0x0000206329b97DB379d5E1Bf586BbDB969C63274", // USDA + "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C", // USDM + "0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812", // wUSDM + ], + rateDivisorByToken: { + "0x4200000000000000000000000000000000000006": 10n, // WETH + "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": 3n, // USDC + "0x0000206329b97DB379d5E1Bf586BbDB969C63274": 3n, // USDA + "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C": 3n, // USDM + "0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812": 3n, // wUSDM + }, + }, + }, + }, + ], + }, +]; diff --git a/yarn.lock b/yarn.lock index bdf8929..2ccb972 100644 --- a/yarn.lock +++ b/yarn.lock @@ -594,10 +594,10 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@morpho-org/blue-rewards-core-sdk@0.0.9": - version "0.0.9" - resolved "https://registry.yarnpkg.com/@morpho-org/blue-rewards-core-sdk/-/blue-rewards-core-sdk-0.0.9.tgz#4613f434715bbec177b35925504d5870a6cdff72" - integrity sha512-jXncQHWipkHo47PCJSgcx3n21HtjcZawNKkqOwWhhBPP/E/2APEguELBWQv9qhHcgPn+/HJ2gtiKdJrUwPxuHw== +"@morpho-org/blue-rewards-core-sdk@0.0.11": + version "0.0.11" + resolved "https://registry.yarnpkg.com/@morpho-org/blue-rewards-core-sdk/-/blue-rewards-core-sdk-0.0.11.tgz#8da3acfe8080ab79efc2c317da6ebdf53db54a51" + integrity sha512-8+8IzHxj83cRgGIPhkRF7Ei5hdzuZZSMrsZSQik27W4tYOpZL8EJbanmSHlHfmnnVqYqlqIG7jczGb0zj2tmqQ== dependencies: "@morpho-org/blue-sdk" "^1.0.6" "@morpho-org/morpho-ts" "^1.4.4"