Skip to content

Commit

Permalink
gyro protocol fees
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco committed Oct 10, 2023
1 parent 54325b1 commit e4181bb
Show file tree
Hide file tree
Showing 7 changed files with 402 additions and 5 deletions.
3 changes: 3 additions & 0 deletions modules/network/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export const mainnetNetworkData: NetworkData = {
},
gaugeControllerAddress: '0xc128468b7ce63ea702c1f104d55a2566b13d3abd',
gaugeControllerHelperAddress: '0x8e5698dc4897dc12243c8642e77b4f21349db97c',
gyro: {
config: '0xac89cc9d78bbad7eb3a02601b4d65daa1f908aa6'
},
balancer: {
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
tokenAdmin: '0xf302f9f50958c5593770fdf4d4812309ff77414f',
Expand Down
3 changes: 3 additions & 0 deletions modules/network/network-config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export interface NetworkData {
};
gaugeControllerAddress?: string;
gaugeControllerHelperAddress?: string;
gyro?: {
config: string;
};
balancer: {
vault: string;
tokenAdmin?: string;
Expand Down
3 changes: 3 additions & 0 deletions modules/network/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ const optimismNetworkData: NetworkData = {
address: '0xc128a9954e6c874ea3d62ce62b468ba073093f25',
delegationProxy: '0x9da18982a33fd0c7051b19f0d7c76f2d5e7e017c',
},
gyro: {
config: '0x32acb44fc929339b9f16f0449525cc590d2a23f3'
},
balancer: {
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
composableStablePoolFactories: [
Expand Down
3 changes: 3 additions & 0 deletions modules/network/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const polygonNetworkData: NetworkData = {
address: '0xc128a9954e6c874ea3d62ce62b468ba073093f25',
delegationProxy: '0x0f08eef2c785aa5e7539684af04755dec1347b7c',
},
gyro: {
config: '0xfdc2e9e03f515804744a40d0f8d25c16e93fbe67'
},
balancer: {
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
composableStablePoolFactories: [
Expand Down
324 changes: 324 additions & 0 deletions modules/pool/abi/GyroConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "previousValue",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newValue",
"type": "uint256"
}
],
"name": "ConfigChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "ConfigFrozen",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "ConfigUnset",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "newGovernor",
"type": "address"
}
],
"name": "GovernorChangeRequested",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "oldGovernor",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "newGovernor",
"type": "address"
}
],
"name": "GovernorChanged",
"type": "event"
},
{
"inputs": [],
"name": "acceptGovernance",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newGovernor",
"type": "address"
}
],
"name": "changeGovernor",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "freeze",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
},
{
"internalType": "address",
"name": "defaultValue",
"type": "address"
}
],
"name": "getAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "getAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "getConfigMeta",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
},
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "getUint",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "governor",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "hasKey",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_governor",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "listKeys",
"outputs": [
{
"internalType": "bytes32[]",
"name": "",
"type": "bytes32[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "pendingGovernor",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
},
{
"internalType": "address",
"name": "newValue",
"type": "address"
}
],
"name": "setAddress",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "newValue",
"type": "uint256"
}
],
"name": "setUint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "unset",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
11 changes: 8 additions & 3 deletions modules/pool/lib/apr-data-sources/swap-fee-apr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ export class SwapFeeAprService implements PoolAprService {
? (pool.dynamicData.fees24h * 365) / pool.dynamicData.totalLiquidity
: 0;

let userApr = apr * (1 - this.swapProtocolFeePercentage);

let protocolFee = this.swapProtocolFeePercentage;
if (pool.type === 'GYROE') {
// Gyro has custom protocol fee structure
protocolFee = parseFloat(pool.dynamicData.protocolYieldFee || '0');
}
if (pool.dynamicData.isInRecoveryMode || pool.type === 'LIQUIDITY_BOOTSTRAPPING') {
// pool does not collect any protocol fees
userApr = apr;
protocolFee = 0;
}

let userApr = apr * (1 - protocolFee);

// TODO: clean this up
if (userApr > MAX_DB_INT) {
userApr = 0;
Expand Down
Loading

0 comments on commit e4181bb

Please sign in to comment.